Back to index

lightning-sunbird  0.9+nobinonly
probslet.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the Netscape Portable Runtime (NSPR).
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998-2000
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*
00039 ** A collection of things thought to be obsolete
00040 */
00041 
00042 #if defined(PROBSLET_H)
00043 #else
00044 #define PROBSLET_H
00045 
00046 #include "prio.h"
00047 
00048 PR_BEGIN_EXTERN_C
00049 
00050 /*
00051 ** Yield the current thread.  The proper function to use in place of
00052 ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
00053 */
00054 NSPR_API(PRStatus) PR_Yield(void);
00055 
00056 /************************************************************************/
00057 /************* The following definitions are for select *****************/
00058 /************************************************************************/
00059 
00060 /*
00061 ** The following is obsolete and will be deleted in the next release!
00062 ** These are provided for compatibility, but are GUARANTEED to be slow.
00063 **
00064 ** Override PR_MAX_SELECT_DESC if you need more space in the select set.
00065 */
00066 #ifndef PR_MAX_SELECT_DESC
00067 #define PR_MAX_SELECT_DESC 1024
00068 #endif
00069 typedef struct PR_fd_set {
00070     PRUint32      hsize;
00071     PRFileDesc   *harray[PR_MAX_SELECT_DESC];
00072     PRUint32      nsize;
00073     PRInt32       narray[PR_MAX_SELECT_DESC];
00074 } PR_fd_set;
00075 
00076 /*
00077 *************************************************************************
00078 ** FUNCTION:    PR_Select
00079 ** DESCRIPTION:
00080 **
00081 ** The call returns as soon as I/O is ready on one or more of the underlying
00082 ** file/socket descriptors or an exceptional condition is pending. A count of the 
00083 ** number of ready descriptors is returned unless a timeout occurs in which case 
00084 ** zero is returned.  On return, PR_Select replaces the given descriptor sets with 
00085 ** subsets consisting of those descriptors that are ready for the requested condition.
00086 ** The total number of ready descriptors in all the sets is the return value.
00087 **
00088 ** INPUTS:
00089 **   PRInt32 num             
00090 **       This argument is unused but is provided for select(unix) interface
00091 **       compatability.  All input PR_fd_set arguments are self-describing
00092 **       with its own maximum number of elements in the set.
00093 **                               
00094 **   PR_fd_set *readfds
00095 **       A set describing the io descriptors for which ready for reading
00096 **       condition is of interest.  
00097 **                               
00098 **   PR_fd_set *writefds
00099 **       A set describing the io descriptors for which ready for writing
00100 **       condition is of interest.  
00101 **                               
00102 **   PR_fd_set *exceptfds
00103 **       A set describing the io descriptors for which exception pending
00104 **       condition is of interest.  
00105 **
00106 **   Any of the above readfds, writefds or exceptfds may be given as NULL 
00107 **   pointers if no descriptors are of interest for that particular condition.                          
00108 **   
00109 **   PRIntervalTime timeout  
00110 **       Amount of time the call will block waiting for I/O to become ready. 
00111 **       If this time expires without any I/O becoming ready, the result will
00112 **       be zero.
00113 **
00114 ** OUTPUTS:    
00115 **   PR_fd_set *readfds
00116 **       A set describing the io descriptors which are ready for reading.
00117 **                               
00118 **   PR_fd_set *writefds
00119 **       A set describing the io descriptors which are ready for writing.
00120 **                               
00121 **   PR_fd_set *exceptfds
00122 **       A set describing the io descriptors which have pending exception.
00123 **
00124 ** RETURN:PRInt32
00125 **   Number of io descriptors with asked for conditions or zero if the function
00126 **   timed out or -1 on failure.  The reason for the failure is obtained by 
00127 **   calling PR_GetError().
00128 ** XXX can we implement this on windoze and mac?
00129 **************************************************************************
00130 */
00131 NSPR_API(PRInt32) PR_Select(
00132     PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
00133     PR_fd_set *exceptfds, PRIntervalTime timeout);
00134 
00135 /* 
00136 ** The following are not thread safe for two threads operating on them at the
00137 ** same time.
00138 **
00139 ** The following routines are provided for manipulating io descriptor sets.
00140 ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
00141 ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
00142 ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.  
00143 ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of 
00144 ** fdset, zero otherwise.
00145 **
00146 ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
00147 ** in fdset.
00148 ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.  
00149 ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of 
00150 ** fdset, zero otherwise.
00151 */
00152 
00153 NSPR_API(void)        PR_FD_ZERO(PR_fd_set *set);
00154 NSPR_API(void)        PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
00155 NSPR_API(void)        PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
00156 NSPR_API(PRInt32)     PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
00157 NSPR_API(void)        PR_FD_NSET(PRInt32 osfd, PR_fd_set *set);
00158 NSPR_API(void)        PR_FD_NCLR(PRInt32 osfd, PR_fd_set *set);
00159 NSPR_API(PRInt32)     PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set);
00160 
00161 /*
00162 ** The next two entry points should not be in the API, but they are
00163 ** declared here for historical reasons.
00164 */
00165 
00166 NSPR_API(PRInt32) PR_GetSysfdTableMax(void);
00167 
00168 NSPR_API(PRInt32) PR_SetSysfdTableSize(PRIntn table_size);
00169 
00170 #ifndef NO_NSPR_10_SUPPORT
00171 #ifdef XP_MAC
00172 #include <stat.h>
00173 #else
00174 #include <sys/stat.h>
00175 #endif
00176 
00177 NSPR_API(PRInt32) PR_Stat(const char *path, struct stat *buf);
00178 #endif /* NO_NSPR_10_SUPPORT */
00179 
00180 PR_END_EXTERN_C
00181 
00182 #endif /* defined(PROBSLET_H) */
00183 
00184 /* probslet.h */