1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is the Netscape Portable Runtime (NSPR).
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998-2000
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either the GNU General Public License Version 2 or later (the "GPL"), or
|
---|
26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | /*
|
---|
39 | ** File: pprio.h
|
---|
40 | **
|
---|
41 | ** Description: Private definitions for I/O related structures
|
---|
42 | */
|
---|
43 |
|
---|
44 | #ifndef pprio_h___
|
---|
45 | #define pprio_h___
|
---|
46 |
|
---|
47 | #include "prtypes.h"
|
---|
48 | #include "prio.h"
|
---|
49 |
|
---|
50 | #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
|
---|
51 | #define PR_GetFileMethods VBoxNsprPR_GetFileMethods
|
---|
52 | #define PR_GetTCPMethods VBoxNsprPR_GetTCPMethods
|
---|
53 | #define PR_GetUDPMethods VBoxNsprPR_GetUDPMethods
|
---|
54 | #define PR_GetPipeMethods VBoxNsprPR_GetPipeMethods
|
---|
55 | #define PR_FileDesc2NativeHandle VBoxNsprPR_FileDesc2NativeHandle
|
---|
56 | #define PR_ChangeFileDescNativeHandle VBoxNsprPR_ChangeFileDescNativeHandle
|
---|
57 | #define PR_AllocFileDesc VBoxNsprPR_AllocFileDesc
|
---|
58 | #define PR_FreeFileDesc VBoxNsprPR_FreeFileDesc
|
---|
59 | #define PR_ImportFile VBoxNsprPR_ImportFile
|
---|
60 | #define PR_ImportPipe VBoxNsprPR_ImportPipe
|
---|
61 | #define PR_ImportTCPSocket VBoxNsprPR_ImportTCPSocket
|
---|
62 | #define PR_ImportUDPSocket VBoxNsprPR_ImportUDPSocket
|
---|
63 | #define PR_CreateSocketPollFd VBoxNsprPR_CreateSocketPollFd
|
---|
64 | #define PR_DestroySocketPollFd VBoxNsprPR_DestroySocketPollFd
|
---|
65 | #define PR_Socket VBoxNsprPR_Socket
|
---|
66 | #define PR_LockFile VBoxNsprPR_LockFile
|
---|
67 | #define PR_TLockFile VBoxNsprPR_TLockFile
|
---|
68 | #define PR_UnlockFile VBoxNsprPR_UnlockFile
|
---|
69 | #define PR_EmulateAcceptRead VBoxNsprPR_EmulateAcceptRead
|
---|
70 | #define PR_EmulateSendFile VBoxNsprPR_EmulateSendFile
|
---|
71 | #define PR_NTFast_AcceptRead VBoxNsprPR_NTFast_AcceptRead
|
---|
72 | #define PR_NTFast_AcceptRead_WithTimeoutCallback VBoxNsprPR_NTFast_AcceptRead_WithTimeoutCallback
|
---|
73 | #define PR_NTFast_Accept VBoxNsprPR_NTFast_Accept
|
---|
74 | #define PR_NTFast_UpdateAcceptContext VBoxNsprPR_NTFast_UpdateAcceptContext
|
---|
75 | #define PR_NT_CancelIo VBoxNsprPR_NT_CancelIo
|
---|
76 | #define PR_Init_Log VBoxNsprPR_Init_Log
|
---|
77 | #endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
|
---|
78 |
|
---|
79 | PR_BEGIN_EXTERN_C
|
---|
80 |
|
---|
81 | /************************************************************************/
|
---|
82 | /************************************************************************/
|
---|
83 |
|
---|
84 | /* Return the method tables for files, tcp sockets and udp sockets */
|
---|
85 | NSPR_API(const PRIOMethods*) PR_GetFileMethods(void);
|
---|
86 | NSPR_API(const PRIOMethods*) PR_GetTCPMethods(void);
|
---|
87 | NSPR_API(const PRIOMethods*) PR_GetUDPMethods(void);
|
---|
88 | NSPR_API(const PRIOMethods*) PR_GetPipeMethods(void);
|
---|
89 |
|
---|
90 | /*
|
---|
91 | ** Convert a NSPR Socket Handle to a Native Socket handle.
|
---|
92 | ** This function will be obsoleted with the next release; avoid using it.
|
---|
93 | */
|
---|
94 | NSPR_API(PRInt32) PR_FileDesc2NativeHandle(PRFileDesc *);
|
---|
95 | NSPR_API(void) PR_ChangeFileDescNativeHandle(PRFileDesc *, PRInt32);
|
---|
96 | NSPR_API(PRFileDesc*) PR_AllocFileDesc(PRInt32 osfd,
|
---|
97 | const PRIOMethods *methods);
|
---|
98 | NSPR_API(void) PR_FreeFileDesc(PRFileDesc *fd);
|
---|
99 | /*
|
---|
100 | ** Import an existing OS file to NSPR.
|
---|
101 | */
|
---|
102 | NSPR_API(PRFileDesc*) PR_ImportFile(PRInt32 osfd);
|
---|
103 | NSPR_API(PRFileDesc*) PR_ImportPipe(PRInt32 osfd);
|
---|
104 | NSPR_API(PRFileDesc*) PR_ImportTCPSocket(PRInt32 osfd);
|
---|
105 | NSPR_API(PRFileDesc*) PR_ImportUDPSocket(PRInt32 osfd);
|
---|
106 |
|
---|
107 |
|
---|
108 | /*
|
---|
109 | *************************************************************************
|
---|
110 | * FUNCTION: PR_CreateSocketPollFd
|
---|
111 | * DESCRIPTION:
|
---|
112 | * Create a PRFileDesc wrapper for a native socket handle, for use with
|
---|
113 | * PR_Poll only
|
---|
114 | * INPUTS:
|
---|
115 | * None
|
---|
116 | * OUTPUTS:
|
---|
117 | * None
|
---|
118 | * RETURN: PRFileDesc*
|
---|
119 | * Upon successful completion, PR_CreateSocketPollFd returns a pointer
|
---|
120 | * to the PRFileDesc created for the native socket handle
|
---|
121 | * Returns a NULL pointer if the create of a new PRFileDesc failed
|
---|
122 | *
|
---|
123 | **************************************************************************
|
---|
124 | */
|
---|
125 |
|
---|
126 | NSPR_API(PRFileDesc*) PR_CreateSocketPollFd(PRInt32 osfd);
|
---|
127 |
|
---|
128 | /*
|
---|
129 | *************************************************************************
|
---|
130 | * FUNCTION: PR_DestroySocketPollFd
|
---|
131 | * DESCRIPTION:
|
---|
132 | * Destroy the PRFileDesc wrapper created by PR_CreateSocketPollFd
|
---|
133 | * INPUTS:
|
---|
134 | * None
|
---|
135 | * OUTPUTS:
|
---|
136 | * None
|
---|
137 | * RETURN: PRFileDesc*
|
---|
138 | * Upon successful completion, PR_DestroySocketPollFd returns
|
---|
139 | * PR_SUCCESS, else PR_FAILURE
|
---|
140 | *
|
---|
141 | **************************************************************************
|
---|
142 | */
|
---|
143 |
|
---|
144 | NSPR_API(PRStatus) PR_DestroySocketPollFd(PRFileDesc *fd);
|
---|
145 |
|
---|
146 |
|
---|
147 | /*
|
---|
148 | ** Macros for PR_Socket
|
---|
149 | **
|
---|
150 | ** Socket types: PR_SOCK_STREAM, PR_SOCK_DGRAM
|
---|
151 | */
|
---|
152 |
|
---|
153 | #define PR_SOCK_STREAM SOCK_STREAM
|
---|
154 | #define PR_SOCK_DGRAM SOCK_DGRAM
|
---|
155 |
|
---|
156 | /*
|
---|
157 | ** Create a new Socket; this function is obsolete.
|
---|
158 | */
|
---|
159 | NSPR_API(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto);
|
---|
160 |
|
---|
161 | /* FUNCTION: PR_LockFile
|
---|
162 | ** DESCRIPTION:
|
---|
163 | ** Lock a file for exclusive access.
|
---|
164 | ** RETURNS:
|
---|
165 | ** PR_SUCCESS when the lock is held
|
---|
166 | ** PR_FAILURE otherwise
|
---|
167 | */
|
---|
168 | NSPR_API(PRStatus) PR_LockFile(PRFileDesc *fd);
|
---|
169 |
|
---|
170 | /* FUNCTION: PR_TLockFile
|
---|
171 | ** DESCRIPTION:
|
---|
172 | ** Test and Lock a file for exclusive access. Do not block if the
|
---|
173 | ** file cannot be locked immediately.
|
---|
174 | ** RETURNS:
|
---|
175 | ** PR_SUCCESS when the lock is held
|
---|
176 | ** PR_FAILURE otherwise
|
---|
177 | */
|
---|
178 | NSPR_API(PRStatus) PR_TLockFile(PRFileDesc *fd);
|
---|
179 |
|
---|
180 | /* FUNCTION: PR_UnlockFile
|
---|
181 | ** DESCRIPTION:
|
---|
182 | ** Unlock a file which has been previously locked successfully by this
|
---|
183 | ** process.
|
---|
184 | ** RETURNS:
|
---|
185 | ** PR_SUCCESS when the lock is released
|
---|
186 | ** PR_FAILURE otherwise
|
---|
187 | */
|
---|
188 | NSPR_API(PRStatus) PR_UnlockFile(PRFileDesc *fd);
|
---|
189 |
|
---|
190 | /*
|
---|
191 | ** Emulate acceptread by accept and recv.
|
---|
192 | */
|
---|
193 | NSPR_API(PRInt32) PR_EmulateAcceptRead(PRFileDesc *sd, PRFileDesc **nd,
|
---|
194 | PRNetAddr **raddr, void *buf, PRInt32 amount, PRIntervalTime timeout);
|
---|
195 |
|
---|
196 | /*
|
---|
197 | ** Emulate sendfile by reading from the file and writing to the socket.
|
---|
198 | ** The file is memory-mapped if memory-mapped files are supported.
|
---|
199 | */
|
---|
200 | NSPR_API(PRInt32) PR_EmulateSendFile(
|
---|
201 | PRFileDesc *networkSocket, PRSendFileData *sendData,
|
---|
202 | PRTransmitFileFlags flags, PRIntervalTime timeout);
|
---|
203 |
|
---|
204 | PR_END_EXTERN_C
|
---|
205 |
|
---|
206 | #endif /* pprio_h___ */
|
---|