home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / xp_sock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.7 KB  |  209 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. #ifndef __XP_SOCK_h_
  20. #define __XP_SOCK_h_
  21.  
  22. #include "xp_core.h"
  23. #include "xp_error.h"
  24.  
  25. #ifdef XP_UNIX
  26.  
  27. #ifdef AIXV3
  28. #include <sys/signal.h>
  29. #include <sys/select.h>
  30. #endif /* AIXV3 */
  31.  
  32. #include <sys/types.h>
  33. #include <string.h>
  34.  
  35. #include <errno.h>   
  36. #include <sys/time.h>
  37. #include <sys/stat.h>
  38. #include <sys/param.h>
  39. #include <sys/file.h> 
  40. #include <sys/ioctl.h> 
  41. #include <sys/socket.h>
  42. #include <netinet/in.h>
  43. #include <unistd.h>
  44. #ifndef __hpux 
  45. #include <arpa/inet.h> 
  46. #endif /* __hpux */
  47. #include <netdb.h>
  48. #endif /* XP_UNIX */
  49.  
  50. #ifdef XP_MAC
  51. #include "macsocket.h"
  52. #define SOCKET_BUFFER_SIZE 4096
  53. #endif /* XP_MAC */
  54.  
  55. #ifdef XP_OS2 /* IBM-VPB050196 */
  56. #    include "os2sock.h"
  57. #    ifdef XP_OS2_DOUGSOCK
  58. #        include "dsfunc.h"
  59. #    endif
  60. #    define SOCKET_BUFFER_SIZE 4096
  61. #endif
  62.  
  63. #ifdef XP_WIN
  64. #include "winsock.h"
  65. #define SOCKET_BUFFER_SIZE 4096
  66.  
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70.  
  71. extern int dupsocket(int foo); /* always fails */
  72.  
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76.  
  77. #ifndef EPIPE
  78. #define EPIPE ECONNRESET
  79. #endif
  80.  
  81. #undef BOOLEAN
  82. #define BOOLEAN char
  83. #endif /* XP_WIN */
  84.  
  85. #define SOCKET_ERRNO    XP_GetError()
  86.  
  87. /************************************************************************/
  88.  
  89. #ifdef XP_UNIX
  90.  
  91. /* Network i/o wrappers */
  92. #define XP_SOCKET int
  93. #define XP_SOCK_ERRNO errno
  94. #define XP_SOCK_SOCKET socket
  95. #define XP_SOCK_CONNECT connect
  96. #define XP_SOCK_ACCEPT accept
  97. #define XP_SOCK_BIND bind
  98. #define XP_SOCK_LISTEN listen
  99. #define XP_SOCK_SHUTDOWN shutdown
  100. #define XP_SOCK_IOCTL ioctl
  101. #define XP_SOCK_RECV recv
  102. #define XP_SOCK_RECVFROM recvfrom
  103. #define XP_SOCK_RECVMSG recvmsg
  104. #define XP_SOCK_SEND send
  105. #define XP_SOCK_SENDTO sendto
  106. #define XP_SOCK_SENDMSG sendmsg
  107. #define XP_SOCK_READ read
  108. #define XP_SOCK_WRITE write
  109. #define XP_SOCK_READV readv
  110. #define XP_SOCK_WRITEV writev
  111. #define XP_SOCK_GETPEERNAME getpeername
  112. #define XP_SOCK_GETSOCKNAME getsockname
  113. #define XP_SOCK_GETSOCKOPT getsockopt
  114. #define XP_SOCK_SETSOCKOPT setsockopt
  115. #define XP_SOCK_CLOSE close
  116. #define XP_SOCK_DUP dup
  117.  
  118. #endif /* XP_UNIX */
  119.  
  120. /*IBM-DSR072296 - now using WinSock 1.1 support in OS/2 Merlin instead of DOUGSOCK...*/
  121. #if defined(XP_WIN) || ( defined(XP_OS2) && !defined(XP_OS2_DOUGSOCK) )
  122. #define XP_SOCKET SOCKET
  123. #define XP_SOCK_ERRNO WSAGetLastError()
  124.  
  125. #define XP_SOCK_SOCKET socket
  126. #define XP_SOCK_CONNECT connect
  127. #define XP_SOCK_ACCEPT accept
  128. #define XP_SOCK_BIND bind
  129. #define XP_SOCK_LISTEN listen
  130. #define XP_SOCK_SHUTDOWN shutdown
  131. #define XP_SOCK_IOCTL ioctlsocket
  132. #define XP_SOCK_RECV recv
  133. #define XP_SOCK_RECVFROM recvfrom
  134. #define XP_SOCK_RECVMSG recvmsg
  135. #define XP_SOCK_SEND send
  136. #define XP_SOCK_SENDTO sendto
  137. #define XP_SOCK_SENDMSG sendmsg
  138. #define XP_SOCK_READ(s,b,l) recv(s,b,l,0)
  139. #define XP_SOCK_WRITE(s,b,l) send(s,b,l,0)
  140. #define XP_SOCK_READV readv
  141. #define XP_SOCK_WRITEV writev
  142. #define XP_SOCK_GETPEERNAME getpeername
  143. #define XP_SOCK_GETSOCKNAME getsockname
  144. #define XP_SOCK_GETSOCKOPT getsockopt
  145. #define XP_SOCK_SETSOCKOPT setsockopt
  146. #define XP_SOCK_CLOSE closesocket
  147. #define XP_SOCK_DUP dupsocket
  148.  
  149. #endif /* XP_WIN/ XP_OS2 && not DOUGSOCK */
  150.  
  151. #if defined(XP_OS2) && defined(XP_OS2_DOUGSOCK)
  152.  
  153. /* Network i/o wrappers */
  154. #define XP_SOCKET int
  155. #define XP_SOCK_ERRNO sock_errno()
  156. #define XP_SOCK_SOCKET socket
  157. #define XP_SOCK_CONNECT connect
  158. #define XP_SOCK_ACCEPT accept
  159. #define XP_SOCK_BIND bind
  160. #define XP_SOCK_LISTEN listen
  161. #define XP_SOCK_SHUTDOWN shutdown
  162. #define XP_SOCK_IOCTL ioctl
  163. #define XP_SOCK_RECV receiveAndMakeReadSocketActive
  164. #define XP_SOCK_RECVFROM recvfrom
  165. #define XP_SOCK_RECVMSG recvmsg
  166. #define XP_SOCK_SEND send
  167. #define XP_SOCK_SENDTO sendto
  168. #define XP_SOCK_SENDMSG sendmsg
  169. #define XP_SOCK_READ(s,b,l) receiveAndMakeReadSocketActive(s,b,l,0)
  170. #define XP_SOCK_WRITE(s,b,l) send(s,b,l,0)
  171. #define XP_SOCK_READV readv
  172. #define XP_SOCK_WRITEV writev
  173. #define XP_SOCK_GETPEERNAME getpeername
  174. #define XP_SOCK_GETSOCKNAME getsockname
  175. #define XP_SOCK_GETSOCKOPT getsockopt
  176. #define XP_SOCK_SETSOCKOPT setsockopt
  177. #define XP_SOCK_CLOSE closeAndRemoveSocketFromPostList
  178. #define XP_SOCK_DUP dupsocket 
  179.  
  180. #endif /*XP_OS2 with DOUGSOCK*/ 
  181.  
  182. #ifdef XP_MAC
  183. /*
  184.     Remap unix sockets into GUSI
  185. */
  186. #define XP_SOCKET int
  187. #define XP_SOCK_ERRNO errno
  188. #define XP_SOCK_SOCKET macsock_socket
  189. #define XP_SOCK_CONNECT macsock_connect
  190. #define XP_SOCK_ACCEPT macsock_accept
  191. #define XP_SOCK_BIND macsock_bind
  192. #define XP_SOCK_LISTEN macsock_listen
  193. #define XP_SOCK_SHUTDOWN macsock_shutdown
  194. #define XP_SOCK_IOCTL macsock_ioctl
  195. #define XP_SOCK_RECV(s,b,l,f) XP_SOCK_READ(s,b,l)
  196. #define XP_SOCK_SEND(s,b,l,f) XP_SOCK_WRITE(s,b,l)
  197. #define XP_SOCK_READ macsock_read
  198. #define XP_SOCK_WRITE macsock_write
  199. #define XP_SOCK_GETPEERNAME macsock_getpeername
  200. #define XP_SOCK_GETSOCKNAME macsock_getsockname
  201. #define XP_SOCK_GETSOCKOPT macsock_getsockopt
  202. #define XP_SOCK_SETSOCKOPT macsock_setsockopt
  203. #define XP_SOCK_CLOSE macsock_close
  204. #define XP_SOCK_DUP macsock_dup
  205.  
  206. #endif /* XP_MAC */
  207.  
  208. #endif /* __XP_SOCK_h_ */
  209.