home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nspr30-v.zip / nspr30-v / include / obsolete / probslet.h < prev    next >
C/C++ Source or Header  |  1998-11-02  |  9KB  |  226 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*
  20. ** A collection of things thought to be obsolete
  21. */
  22.  
  23. #if defined(PROBSLET_H)
  24. #else
  25. #define PROBSLET_H
  26.  
  27. #include "prio.h"
  28.  
  29. PR_BEGIN_EXTERN_C
  30.  
  31. /*
  32. ** Yield the current thread.  The proper function to use in place of
  33. ** PR_Yield() is PR_Sleep() with an argument of PR_INTERVAL_NO_WAIT.
  34. */
  35. PR_EXTERN(PRStatus) PR_Yield(void);
  36.  
  37. /*
  38. ** These are obsolete and are replaced by PR_GetSocketOption() and
  39. ** PR_SetSocketOption().
  40. */
  41.  
  42. PR_EXTERN(PRStatus) PR_GetSockOpt(
  43.     PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen);
  44.  
  45. PR_EXTERN(PRStatus) PR_SetSockOpt(
  46.     PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen);
  47.  
  48. /************************************************************************/
  49. /************* The following definitions are for select *****************/
  50. /************************************************************************/
  51.  
  52. /*
  53. ** The following is obsolete and will be deleted in the next release!
  54. ** These are provided for compatibility, but are GUARANTEED to be slow.
  55. **
  56. ** Override PR_MAX_SELECT_DESC if you need more space in the select set.
  57. */
  58. #ifndef PR_MAX_SELECT_DESC
  59. #define PR_MAX_SELECT_DESC 1024
  60. #endif
  61. typedef struct PR_fd_set {
  62.     PRUint32      hsize;
  63.     PRFileDesc   *harray[PR_MAX_SELECT_DESC];
  64.     PRUint32      nsize;
  65.     PRInt32       narray[PR_MAX_SELECT_DESC];
  66. } PR_fd_set;
  67.  
  68. /*
  69. *************************************************************************
  70. ** FUNCTION:    PR_Select
  71. ** DESCRIPTION:
  72. **
  73. ** The call returns as soon as I/O is ready on one or more of the underlying
  74. ** file/socket descriptors or an exceptional condition is pending. A count of the 
  75. ** number of ready descriptors is returned unless a timeout occurs in which case 
  76. ** zero is returned.  On return, PR_Select replaces the given descriptor sets with 
  77. ** subsets consisting of those descriptors that are ready for the requested condition.
  78. ** The total number of ready descriptors in all the sets is the return value.
  79. **
  80. ** INPUTS:
  81. **   PRInt32 num             
  82. **       This argument is unused but is provided for select(unix) interface
  83. **       compatability.  All input PR_fd_set arguments are self-describing
  84. **       with its own maximum number of elements in the set.
  85. **                               
  86. **   PR_fd_set *readfds
  87. **       A set describing the io descriptors for which ready for reading
  88. **       condition is of interest.  
  89. **                               
  90. **   PR_fd_set *writefds
  91. **       A set describing the io descriptors for which ready for writing
  92. **       condition is of interest.  
  93. **                               
  94. **   PR_fd_set *exceptfds
  95. **       A set describing the io descriptors for which exception pending
  96. **       condition is of interest.  
  97. **
  98. **   Any of the above readfds, writefds or exceptfds may be given as NULL 
  99. **   pointers if no descriptors are of interest for that particular condition.                          
  100. **   
  101. **   PRIntervalTime timeout  
  102. **       Amount of time the call will block waiting for I/O to become ready. 
  103. **       If this time expires without any I/O becoming ready, the result will
  104. **       be zero.
  105. **
  106. ** OUTPUTS:    
  107. **   PR_fd_set *readfds
  108. **       A set describing the io descriptors which are ready for reading.
  109. **                               
  110. **   PR_fd_set *writefds
  111. **       A set describing the io descriptors which are ready for writing.
  112. **                               
  113. **   PR_fd_set *exceptfds
  114. **       A set describing the io descriptors which have pending exception.
  115. **
  116. ** RETURN:PRInt32
  117. **   Number of io descriptors with asked for conditions or zero if the function
  118. **   timed out or -1 on failure.  The reason for the failure is obtained by 
  119. **   calling PR_GetError().
  120. ** XXX can we implement this on windoze and mac?
  121. **************************************************************************
  122. */
  123. PR_EXTERN(PRInt32) PR_Select(
  124.     PRInt32 num, PR_fd_set *readfds, PR_fd_set *writefds,
  125.     PR_fd_set *exceptfds, PRIntervalTime timeout);
  126.  
  127. /* 
  128. ** The following are not thread safe for two threads operating on them at the
  129. ** same time.
  130. **
  131. ** The following routines are provided for manipulating io descriptor sets.
  132. ** PR_FD_ZERO(&fdset) initializes a descriptor set fdset to the null set.
  133. ** PR_FD_SET(fd, &fdset) includes a particular file descriptor fd in fdset.
  134. ** PR_FD_CLR(fd, &fdset) removes a file descriptor fd from fdset.  
  135. ** PR_FD_ISSET(fd, &fdset) is nonzero if file descriptor fd is a member of 
  136. ** fdset, zero otherwise.
  137. **
  138. ** PR_FD_NSET(osfd, &fdset) includes a particular native file descriptor osfd
  139. ** in fdset.
  140. ** PR_FD_NCLR(osfd, &fdset) removes a native file descriptor osfd from fdset.  
  141. ** PR_FD_NISSET(osfd, &fdset) is nonzero if native file descriptor osfd is a member of 
  142. ** fdset, zero otherwise.
  143. */
  144.  
  145. PR_EXTERN(void)        PR_FD_ZERO(PR_fd_set *set);
  146. PR_EXTERN(void)        PR_FD_SET(PRFileDesc *fd, PR_fd_set *set);
  147. PR_EXTERN(void)        PR_FD_CLR(PRFileDesc *fd, PR_fd_set *set);
  148. PR_EXTERN(PRInt32)     PR_FD_ISSET(PRFileDesc *fd, PR_fd_set *set);
  149. PR_EXTERN(void)        PR_FD_NSET(PRInt32 osfd, PR_fd_set *set);
  150. PR_EXTERN(void)        PR_FD_NCLR(PRInt32 osfd, PR_fd_set *set);
  151. PR_EXTERN(PRInt32)     PR_FD_NISSET(PRInt32 osfd, PR_fd_set *set);
  152.  
  153. #ifndef NO_NSPR_10_SUPPORT
  154. #ifdef XP_MAC
  155. #include <stat.h>
  156. #else
  157. #include <sys/stat.h>
  158. #endif
  159.  
  160. PR_EXTERN(PRInt32) PR_Stat(const char *path, struct stat *buf);
  161. #endif /* NO_NSPR_10_SUPPORT */
  162.  
  163. /***********************************************************************
  164. ** FUNCTION: PR_CreateNetAddr(), PR_DestroyNetAddr()
  165. ** DESCRIPTION:
  166. **  Create an instance of a PRNetAddr, assigning well known values as
  167. **  appropriate.
  168. **
  169. ** INPUTS
  170. **  PRNetAddrValue val  The value to be assigned to the IP Address portion
  171. **                      of the network address. This can only specify the
  172. **                      special well known values that are equivalent to
  173. **                      INADDR_ANY and INADDR_LOOPBACK.
  174. **
  175. **  PRUInt16 port       The port number to be assigned in the structure.
  176. **
  177. ** OUTPUTS:
  178. **  None
  179. **
  180. ** RETURN:
  181. **  PRNetAddr *addr     The initialized address that has been allocated
  182. **                      from the heap. It must be freed by the caller.
  183. **                      A returned value of zero indicates an error. The
  184. **                      cause of the error (most likely low memory) may
  185. **                      be retrieved by calling PR_GetError().
  186. **
  187. ***********************************************************************/
  188. PR_EXTERN(PRNetAddr*) PR_CreateNetAddr(PRNetAddrValue val, PRUint16 port);
  189. PR_EXTERN(PRStatus) PR_DestroyNetAddr(PRNetAddr *addr);
  190.  
  191.  
  192.  
  193. /***********************************************************************
  194. ** FUNCTION: PR_GetHostName() **OBSOLETE**
  195. **   Use PR_GetSystemInfo() (prsystem.h) with an argument of
  196. **   PR_SI_HOSTNAME instead.
  197. ** DESCRIPTION:    
  198. ** Get the DNS name of the hosting computer.
  199. **
  200. ** INPUTS:
  201. **  char *name          The location where the host's name is stored.
  202. **  PRIntn bufsize      Number of bytes in 'name'.
  203. ** OUTPUTS:
  204. **  PRHostEnt *name
  205. **                      This string is filled in by the runtime if the
  206. **                      function returns PR_SUCCESS. The string must be
  207. **                      allocated by the caller
  208. ** RETURN:
  209. **  PRStatus            PR_SUCCESS if the  succeeds. If it fails the
  210. **                      result will be PR_FAILURE and the reason for
  211. **                      the failure can be retrieved by PR_GetError().
  212. ***********************************************************************/
  213. PR_EXTERN(PRStatus) PR_GetHostName(char *name, PRUint32 namelen);
  214.  
  215. /*
  216. ** Return the current thread's last error string.
  217. ** obsoleted by PR_GetErrorText().
  218. */
  219. PR_EXTERN(const char *) PR_GetErrorString(void);
  220.  
  221. PR_END_EXTERN_C
  222.  
  223. #endif /* defined(PROBSLET_H) */
  224.  
  225. /* probslet.h */
  226.