home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / io / priometh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.2 KB  |  233 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. #include "primpl.h"
  20.  
  21. /*
  22.  * An invalid method that returns an integer
  23.  */
  24.  
  25. PRIntn _PR_InvalidInt()
  26. {
  27.     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
  28.     return -1;
  29. }  /* _PR_InvalidInt */
  30.  
  31. PRInt64 _PR_InvalidInt64()
  32. {
  33.     PRInt64 rv = LL_INIT( 0xffffffff, 0xffffffff );
  34.     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
  35.     return rv;
  36. }  /* _PR_InvalidInt */
  37.  
  38. /*
  39.  * An invalid method that returns PRStatus
  40.  */
  41.  
  42. PRStatus _PR_InvalidStatus()
  43. {
  44.     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
  45.     return PR_FAILURE;
  46. }  /* _PR_InvalidDesc */
  47.  
  48. /*
  49.  * An invalid method that returns a pointer
  50.  */
  51.  
  52. PRFileDesc *_PR_InvalidDesc()
  53. {
  54.     PR_SetError(PR_INVALID_METHOD_ERROR, 0);
  55.     return NULL;
  56. }  /* _PR_InvalidDesc */
  57.  
  58. PR_IMPLEMENT(PRDescType) PR_GetDescType(PRFileDesc *file)
  59. {
  60.     return file->methods->file_type;
  61. }
  62.  
  63. PR_IMPLEMENT(PRStatus) PR_Close(PRFileDesc *fd)
  64. {
  65.     return (fd->methods->close)(fd);
  66. }
  67.  
  68. PR_IMPLEMENT(PRInt32) PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount)
  69. {
  70.     return((fd->methods->read)(fd,buf,amount));
  71. }
  72.  
  73. PR_IMPLEMENT(PRInt32) PR_Write(PRFileDesc *fd, const void *buf, PRInt32 amount)
  74. {
  75.     return((fd->methods->write)(fd,buf,amount));
  76. }
  77.  
  78. PR_IMPLEMENT(PRInt32) PR_Seek(PRFileDesc *fd, PRInt32 offset, PRSeekWhence whence)
  79. {
  80.     return((fd->methods->seek)(fd, offset, whence));
  81. }
  82.  
  83. PR_IMPLEMENT(PRInt64) PR_Seek64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence)
  84. {
  85.     return((fd->methods->seek64)(fd, offset, whence));
  86. }
  87.  
  88. PR_IMPLEMENT(PRInt32) PR_Available(PRFileDesc *fd)
  89. {
  90.     return((fd->methods->available)(fd));
  91. }
  92.  
  93. PR_IMPLEMENT(PRInt64) PR_Available64(PRFileDesc *fd)
  94. {
  95.     return((fd->methods->available64)(fd));
  96. }
  97.  
  98. PR_IMPLEMENT(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info)
  99. {
  100.     return((fd->methods->fileInfo)(fd, info));
  101. }
  102.  
  103. PR_IMPLEMENT(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info)
  104. {
  105.     return((fd->methods->fileInfo64)(fd, info));
  106. }
  107.  
  108. PR_IMPLEMENT(PRStatus) PR_Sync(PRFileDesc *fd)
  109. {
  110.     return((fd->methods->fsync)(fd));
  111. }
  112.  
  113. PR_IMPLEMENT(PRStatus) PR_Connect(
  114.     PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout)
  115. {
  116.     return((fd->methods->connect)(fd,addr,timeout));
  117. }
  118.  
  119. PR_IMPLEMENT(PRFileDesc*) PR_Accept(PRFileDesc *fd, PRNetAddr *addr,
  120. PRIntervalTime timeout)
  121. {
  122.     return((fd->methods->accept)(fd,addr,timeout));
  123. }
  124.  
  125. PR_IMPLEMENT(PRStatus) PR_Bind(PRFileDesc *fd, const PRNetAddr *addr)
  126. {
  127.     return((fd->methods->bind)(fd,addr));
  128. }
  129.  
  130. PR_IMPLEMENT(PRStatus) PR_Shutdown(PRFileDesc *fd, PRShutdownHow how)
  131. {
  132.     return((fd->methods->shutdown)(fd,how));
  133. }
  134.  
  135. PR_IMPLEMENT(PRStatus) PR_Listen(PRFileDesc *fd, PRIntn backlog)
  136. {
  137.     return((fd->methods->listen)(fd,backlog));
  138. }
  139.  
  140. PR_IMPLEMENT(PRInt32) PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount,
  141. PRIntn flags, PRIntervalTime timeout)
  142. {
  143.     return((fd->methods->recv)(fd,buf,amount,flags,timeout));
  144. }
  145.  
  146. PR_IMPLEMENT(PRInt32) PR_Send(PRFileDesc *fd, const void *buf, PRInt32 amount,
  147. PRIntn flags, PRIntervalTime timeout)
  148. {
  149.     return((fd->methods->send)(fd,buf,amount,flags,timeout));
  150. }
  151.  
  152. PR_IMPLEMENT(PRInt32) PR_Writev(PRFileDesc *fd, PRIOVec *iov,PRInt32 iov_size,
  153. PRIntervalTime timeout)
  154. {
  155.     if (iov_size > PR_MAX_IOVECTOR_SIZE)
  156.     {
  157.         PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);
  158.         return -1;
  159.     }
  160.     return((fd->methods->writev)(fd,iov,iov_size,timeout));
  161. }
  162.  
  163. PR_IMPLEMENT(PRInt32) PR_RecvFrom(PRFileDesc *fd, void *buf, PRInt32 amount,
  164. PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout)
  165. {
  166.     return((fd->methods->recvfrom)(fd,buf,amount,flags,addr,timeout));
  167. }
  168.  
  169. PR_IMPLEMENT(PRInt32) PR_SendTo(
  170.     PRFileDesc *fd, const void *buf, PRInt32 amount,
  171.     PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout)
  172. {
  173.     return((fd->methods->sendto)(fd,buf,amount,flags,addr,timeout));
  174. }
  175.  
  176. PR_IMPLEMENT(PRInt32) PR_TransmitFile(
  177.     PRFileDesc *sd, PRFileDesc *fd, const void *hdr, PRInt32 hlen,
  178.     PRTransmitFileFlags flags, PRIntervalTime timeout)
  179. {
  180.     return((sd->methods->transmitfile)(sd,fd,hdr,hlen,flags,timeout));
  181. }
  182.  
  183. PR_IMPLEMENT(PRInt32) PR_AcceptRead(
  184.     PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr,
  185.     void *buf, PRInt32 amount, PRIntervalTime timeout)
  186. {
  187.     return((sd->methods->acceptread)(sd, nd, raddr, buf, amount,timeout));
  188. }
  189.  
  190. PR_IMPLEMENT(PRStatus) PR_GetSockName(PRFileDesc *fd, PRNetAddr *addr)
  191. {
  192.     return((fd->methods->getsockname)(fd,addr));
  193. }
  194.  
  195. PR_IMPLEMENT(PRStatus) PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr)
  196. {
  197.     return((fd->methods->getpeername)(fd,addr));
  198. }
  199.  
  200. PR_IMPLEMENT(PRStatus) PR_GetSockOpt(
  201.     PRFileDesc *fd, PRSockOption optname, void* optval, PRInt32* optlen)
  202. {
  203. #if defined(DEBUG)
  204.     static PRBool warn = PR_TRUE;
  205.     if (warn) warn = _PR_Obsolete("PR_GetSockOpt()", "PR_GetSocketOption()");
  206. #endif
  207.     return((fd->methods->getsockopt)(fd, optname, optval, optlen));
  208. }
  209.  
  210. PR_IMPLEMENT(PRStatus) PR_SetSockOpt(
  211.     PRFileDesc *fd, PRSockOption optname, const void* optval, PRInt32 optlen)
  212. {
  213. #if defined(DEBUG)
  214.     static PRBool warn = PR_TRUE;
  215.     if (warn) warn = _PR_Obsolete("PR_SetSockOpt()", "PR_SetSocketOption()");
  216. #endif
  217.     return((fd->methods->setsockopt)(fd, optname, optval, optlen));
  218. }
  219.  
  220. PR_IMPLEMENT(PRStatus) PR_GetSocketOption(
  221.     PRFileDesc *fd, PRSocketOptionData *data)
  222. {
  223.     return((fd->methods->getsocketoption)(fd, data));
  224. }
  225.  
  226. PR_IMPLEMENT(PRStatus) PR_SetSocketOption(
  227.     PRFileDesc *fd, const PRSocketOptionData *data)
  228. {
  229.     return((fd->methods->setsocketoption)(fd, data));
  230. }
  231.  
  232. /* priometh.c */
  233.