15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The contents of this file are subject to the Mozilla Public 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * License Version 1.1 (the "License"); you may not use this file 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * except in compliance with the License. You may obtain a copy of 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the License at http://www.mozilla.org/MPL/ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Software distributed under the License is distributed on an "AS 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * implied. See the License for the specific language governing 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * rights and limitations under the License. 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Original Code is the Netscape Portable Runtime (NSPR). 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Initial Developer of the Original Code is Netscape 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Communications Corporation. Portions created by Netscape are 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (C) 1998-2000 Netscape Communications Corporation. All 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Rights Reserved. 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contributor(s): 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Alternatively, the contents of this file may be used under the 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * terms of the GNU General Public License Version 2 or later (the 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * "GPL"), in which case the provisions of the GPL are applicable 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * instead of those above. If you wish to allow use of your 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * version of this file only under the terms of the GPL and not to 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * allow others to use your version of this file under the MPL, 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * indicate your decision by deleting the provisions above and 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * replace them with the notice and other provisions required by 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the GPL. If you do not delete the provisions above, a recipient 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * may use your version of this file under either the MPL or the 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * GPL. 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** File: pprio.h 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Description: Private definitions for I/O related structures 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef pprio_h___ 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define pprio_h___ 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prtypes.h" 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prio.h" 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_BEGIN_EXTERN_C 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/************************************************************************/ 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/************************************************************************/ 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Return the method tables for files, tcp sockets and udp sockets */ 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const PRIOMethods*) PR_GetFileMethods(void); 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const PRIOMethods*) PR_GetTCPMethods(void); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const PRIOMethods*) PR_GetUDPMethods(void); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Convert a NSPR Socket Handle to a Native Socket handle. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** This function will be obsoleted with the next release; avoid using it. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_FileDesc2NativeHandle(PRFileDesc *); 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PRInt32); 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_AllocFileDesc(PRInt32 osfd, 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const PRIOMethods *methods); 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd); 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Import an existing OS file to NSPR. 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_ImportFile(PRInt32 osfd); 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_ImportPipe(PRInt32 osfd); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd); 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PRInt32 osfd); 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************* 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_CreateSocketPollFd 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION: 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Create a PRFileDesc wrapper for a native socket handle, for use with 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * PR_Poll only 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS: 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * None 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS: 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * None 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRFileDesc* 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Upon successful completion, PR_CreateSocketPollFd returns a pointer 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * to the PRFileDesc created for the native socket handle 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns a NULL pointer if the create of a new PRFileDesc failed 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************** 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd); 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************* 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_DestroySocketPollFd 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION: 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Destroy the PRFileDesc wrapper created by PR_CreateSocketPollFd 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS: 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * None 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS: 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * None 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRFileDesc* 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Upon successful completion, PR_DestroySocketPollFd returns 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * PR_SUCCESS, else PR_FAILURE 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************** 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd); 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Macros for PR_Socket 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Socket types: PR_SOCK_STREAM, PR_SOCK_DGRAM 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef WIN32 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SOCK_STREAM 1 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SOCK_DGRAM 2 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else /* WIN32 */ 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SOCK_STREAM SOCK_STREAM 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SOCK_DGRAM SOCK_DGRAM 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* WIN32 */ 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Create a new Socket; this function is obsolete. 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_LockFile 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Lock a file for exclusive access. 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_SUCCESS when the lock is held 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FAILURE otherwise 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_LockFile(PRFileDesc *fd); 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_TLockFile 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Test and Lock a file for exclusive access. Do not block if the 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** file cannot be locked immediately. 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_SUCCESS when the lock is held 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FAILURE otherwise 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_TLockFile(PRFileDesc *fd); 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_UnlockFile 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Unlock a file which has been previously locked successfully by this 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** process. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** RETURNS: 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_SUCCESS when the lock is released 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_FAILURE otherwise 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_UnlockFile(PRFileDesc *fd); 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Emulate acceptread by accept and recv. 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_EmulateAcceptRead(PRFileDesc *sd, PRFileDesc **nd, 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout); 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Emulate sendfile by reading from the file and writing to the socket. 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The file is memory-mapped if memory-mapped files are supported. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_EmulateSendFile( 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRFileDesc *networkSocket, PRSendFileData *sendData, 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRTransmitFileFlags flags, PRIntervalTime timeout); 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef WIN32 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_NTFast_AcceptRead 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** NT has the notion of an "accept context", which is only needed in 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** order to make certain calls. By default, a socket connected via 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** AcceptEx can only do a limited number of things without updating 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the acceptcontext. The generic version of PR_AcceptRead always 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** updates the accept context. This version does not. 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**/ 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_NTFast_AcceptRead(PRFileDesc *sd, PRFileDesc **nd, 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime t); 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void (*_PR_AcceptTimeoutCallback)(void *); 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_NTFast_AcceptRead_WithTimeoutCallback 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The AcceptEx call combines the accept with the read function. However, 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** our daemon threads need to be able to wakeup and reliably flush their 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** log buffers if the Accept times out. However, with the current blocking 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** interface to AcceptRead, there is no way for us to timeout the Accept; 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** this is because when we timeout the Read, we can close the newly 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** socket and continue; but when we timeout the accept itself, there is no 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** new socket to timeout. So instead, this version of the function is 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** provided. After the initial timeout period elapses on the accept() 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** portion of the function, it will call the callback routine and then 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** continue the accept. If the timeout occurs on the read, it will 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** close the connection and return error. 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_NTFast_AcceptRead_WithTimeoutCallback( 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRFileDesc *sd, 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRFileDesc **nd, 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRNetAddr **raddr, 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void *buf, 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRInt32 amount, 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRIntervalTime t, 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) _PR_AcceptTimeoutCallback callback, 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void *callback_arg); 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_NTFast_Accept 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** NT has the notion of an "accept context", which is only needed in 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** order to make certain calls. By default, a socket connected via 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** AcceptEx can only do a limited number of things without updating 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the acceptcontext. The generic version of PR_Accept always 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** updates the accept context. This version does not. 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**/ 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_NTFast_Accept(PRFileDesc *fd, PRNetAddr *addr, 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRIntervalTime timeout); 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_NTFast_Update 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** For sockets accepted with PR_NTFast_Accept or PR_NTFastAcceptRead, 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** this function will update the accept context for those sockets, 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** so that the socket can make general purpose socket calls. 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Without calling this, the only operations supported on the socket 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Are PR_Read, PR_Write, PR_Transmitfile, and PR_Close. 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_NTFast_UpdateAcceptContext(PRFileDesc *acceptSock, 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PRFileDesc *listenSock); 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* FUNCTION: PR_NT_CancelIo 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** DESCRIPTION: 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Cancel IO operations on fd. 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_NT_CancelIo(PRFileDesc *fd); 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* WIN32 */ 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Need external access to this on Mac so we can first set up our faux 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** environment vars 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/ 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef XP_MAC 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(void) PR_Init_Log(void); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_END_EXTERN_C 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* pprio_h___ */ 263