Changeset 102063 in vbox for trunk/src/libs/xpcom18a4/nsprpub/pr/include/prio.h
- Timestamp:
- Nov 10, 2023 2:01:03 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/include/prio.h
r101935 r102063 441 441 /* 442 442 ************************************************************************** 443 * FUNCTION: PR_GetSpecialFD444 * DESCRIPTION: Get the file descriptor that represents the standard input,445 * output, or error stream.446 * INPUTS:447 * PRSpecialFD id448 * A value indicating the type of stream desired:449 * PR_StandardInput: standard input450 * PR_StandardOuput: standard output451 * PR_StandardError: standard error452 * OUTPUTS: none453 * RETURNS: PRFileDesc *454 * If the argument is valid, PR_GetSpecialFD returns a file descriptor455 * that represents the corresponding standard I/O stream. Otherwise,456 * PR_GetSpecialFD returns NULL and sets error PR_INVALID_ARGUMENT_ERROR.457 **************************************************************************458 */459 460 typedef enum PRSpecialFD461 {462 PR_StandardInput, /* standard input */463 PR_StandardOutput, /* standard output */464 PR_StandardError /* standard error */465 } PRSpecialFD;466 467 NSPR_API(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD id);468 469 #define PR_STDIN PR_GetSpecialFD(PR_StandardInput)470 #define PR_STDOUT PR_GetSpecialFD(PR_StandardOutput)471 #define PR_STDERR PR_GetSpecialFD(PR_StandardError)472 473 /*474 **************************************************************************475 * Layering file descriptors476 *477 * File descriptors may be layered. Each layer has it's own identity.478 * Identities are allocated by the runtime and are to be associated479 * (by the layer implementor) with all layers that are of that type.480 * It is then possible to scan the chain of layers and find a layer481 * that one recongizes and therefore predict that it will implement482 * a desired protocol.483 *484 * There are three well-known identities:485 * PR_INVALID_IO_LAYER => an invalid layer identity, for error return486 * PR_TOP_IO_LAYER => the identity of the top of the stack487 * PR_NSPR_IO_LAYER => the identity used by NSPR proper488 * PR_TOP_IO_LAYER may be used as a shorthand for identifying the topmost489 * layer of an existing stack. Ie., the following two constructs are490 * equivalent.491 *492 * rv = PR_PushIOLayer(stack, PR_TOP_IO_LAYER, my_layer);493 * rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), my_layer)494 *495 * A string may be associated with the creation of the identity. It496 * will be copied by the runtime. If queried the runtime will return497 * a reference to that copied string (not yet another copy). There498 * is no facility for deleting an identity.499 **************************************************************************500 */501 502 #define PR_IO_LAYER_HEAD (PRDescIdentity)-3503 #define PR_INVALID_IO_LAYER (PRDescIdentity)-1504 #define PR_TOP_IO_LAYER (PRDescIdentity)-2505 #define PR_NSPR_IO_LAYER (PRDescIdentity)0506 507 NSPR_API(PRDescIdentity) PR_GetUniqueIdentity(const char *layer_name);508 NSPR_API(const char*) PR_GetNameForIdentity(PRDescIdentity ident);509 NSPR_API(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd);510 NSPR_API(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);511 512 /*513 **************************************************************************514 * PR_GetDefaultIOMethods: Accessing the default methods table.515 * You may get a pointer to the default methods table by calling this function.516 * You may then select any elements from that table with which to build your517 * layer's methods table. You may NOT modify the table directly.518 **************************************************************************519 */520 NSPR_API(const PRIOMethods *) PR_GetDefaultIOMethods(void);521 522 /*523 **************************************************************************524 * Creating a layer525 *526 * A new layer may be allocated by calling PR_CreateIOLayerStub(). The527 * file descriptor returned will contain the pointer to the methods table528 * provided. The runtime will not modify the table nor test its correctness.529 **************************************************************************530 */531 NSPR_API(PRFileDesc*) PR_CreateIOLayerStub(532 PRDescIdentity ident, const PRIOMethods *methods);533 534 /*535 **************************************************************************536 * Creating a layer537 *538 * A new stack may be created by calling PR_CreateIOLayer(). The539 * file descriptor returned will point to the top of the stack, which has540 * the layer 'fd' as the topmost layer.541 *542 * NOTE: This function creates a new style stack, which has a fixed, dummy543 * header. The old style stack, created by a call to PR_PushIOLayer,544 * results in modifying contents of the top layer of the stack, when545 * pushing and popping layers of the stack.546 **************************************************************************547 */548 NSPR_API(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* fd);549 550 /*551 **************************************************************************552 * Pushing a layer553 *554 * A file descriptor (perhaps allocated using PR_CreateIOLayerStub()) may555 * be pushed into an existing stack of file descriptors at any point the556 * caller deems appropriate. The new layer will be inserted into the stack557 * just above the layer with the indicated identity.558 *559 * Note: Even if the identity parameter indicates the top-most layer of560 * the stack, the value of the file descriptor describing the original561 * stack will not change.562 **************************************************************************563 */564 NSPR_API(PRStatus) PR_PushIOLayer(565 PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer);566 567 /*568 **************************************************************************569 * Popping a layer570 *571 * A layer may be popped from a stack by indicating the identity of the572 * layer to be removed. If found, a pointer to the removed object will573 * be returned to the caller. The object then becomes the responsibility574 * of the caller.575 *576 * Note: Even if the identity indicates the top layer of the stack, the577 * reference returned will not be the file descriptor for the stack and578 * that file descriptor will remain valid.579 **************************************************************************580 */581 NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id);582 583 /*584 **************************************************************************585 443 * FUNCTION: PR_Open 586 444 * DESCRIPTION: Open a file for reading, writing, or both. … … 763 621 NSPR_API(PRInt32) PR_Write(PRFileDesc *fd,const void *buf,PRInt32 amount); 764 622 765 /*766 ***************************************************************************767 * FUNCTION: PR_Writev768 * DESCRIPTION:769 * Write data to a socket. The data is organized in a PRIOVec array. The770 * operation will block until all the data is written or the operation771 * fails.772 * INPUTS:773 * PRFileDesc *fd774 * Pointer that points to a PRFileDesc object for a socket.775 * const PRIOVec *iov776 * An array of PRIOVec. PRIOVec is a struct with the following777 * two fields:778 * char *iov_base;779 * int iov_len;780 * PRInt32 iov_size781 * Number of elements in the iov array. The value of this782 * argument must not be greater than PR_MAX_IOVECTOR_SIZE.783 * If it is, the method will fail (PR_BUFFER_OVERFLOW_ERROR).784 * PRIntervalTime timeout785 * Time limit for completion of the entire write operation.786 * OUTPUTS:787 * None788 * RETURN:789 * A positive number indicates the number of bytes successfully written.790 * A -1 is an indication that the operation failed. The reason791 * for the failure is obtained by calling PR_GetError().792 ***************************************************************************793 */794 795 #define PR_MAX_IOVECTOR_SIZE 16 /* 'iov_size' must be <= */796 797 NSPR_API(PRInt32) PR_Writev(798 PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,799 PRIntervalTime timeout);800 801 /*802 ***************************************************************************803 * FUNCTION: PR_Delete804 * DESCRIPTION:805 * Delete a file from the filesystem. The operation may fail if the806 * file is open.807 * INPUTS:808 * const char *name809 * Path name of the file to be deleted.810 * OUTPUTS:811 * None.812 * RETURN: PRStatus813 * The function returns PR_SUCCESS if the file is successfully814 * deleted, otherwise it returns PR_FAILURE.815 ***************************************************************************816 */817 818 NSPR_API(PRStatus) PR_Delete(const char *name);819 820 623 /**************************************************************************/ 821 624 … … 861 664 NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info); 862 665 NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info); 863 864 /*865 **************************************************************************866 * FUNCTION: PR_GetOpenFileInfo, PR_GetOpenFileInfo64867 * DESCRIPTION:868 * Get information about an open file referred to by the869 * given PRFileDesc object.870 * INPUTS:871 * const PRFileDesc *fd872 * A reference to a valid, open file.873 * OUTPUTS:874 * Same as PR_GetFileInfo, PR_GetFileInfo64875 * RETURN: PRStatus876 * PR_GetFileInfo returns PR_SUCCESS if file information is successfully877 * obtained, otherwise it returns PR_FAILURE.878 ***************************************************************************879 */880 881 NSPR_API(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);882 NSPR_API(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info);883 666 884 667 /* … … 918 701 NSPR_API(PROffset64) PR_Seek64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence); 919 702 920 /*921 ************************************************************************922 * FUNCTION: PR_Available923 * DESCRIPTION:924 * Determine the amount of data in bytes available for reading925 * in the given file or socket.926 * INPUTS:927 * PRFileDesc *fd928 * Pointer to a PRFileDesc object that refers to a file or929 * socket.930 * OUTPUTS:931 * None932 * RETURN: PRInt32, PRInt64933 * Upon successful completion, PR_Available returns the number of934 * bytes beyond the current read pointer that is available for935 * reading. Otherwise, it returns a -1 and the reason for the936 * failure can be retrieved via PR_GetError().937 ************************************************************************938 */939 940 NSPR_API(PRInt32) PR_Available(PRFileDesc *fd);941 942 /*943 ************************************************************************944 * FUNCTION: PR_Sync945 * DESCRIPTION:946 * Sync any buffered data for a fd to its backing device (disk).947 * INPUTS:948 * PRFileDesc *fd949 * Pointer to a PRFileDesc object that refers to a file or950 * socket951 * OUTPUTS:952 * None953 * RETURN: PRStatus954 * PR_SUCCESS is returned if the requested access is permitted.955 * Otherwise, PR_FAILURE is returned.956 ************************************************************************957 */958 959 NSPR_API(PRStatus) PR_Sync(PRFileDesc *fd);960 961 /*962 *************************************************************************963 * FUNCTION: PR_OpenTCPSocket964 * DESCRIPTION:965 * Create a new TCP socket of the specified address family.966 * INPUTS:967 * PRIntn af968 * Address family969 * OUTPUTS:970 * None971 * RETURN: PRFileDesc*972 * Upon successful completion, PR_NewTCPSocket returns a pointer973 * to the PRFileDesc created for the newly opened TCP socket.974 * Returns a NULL pointer if the creation of a new TCP socket failed.975 *976 **************************************************************************977 */978 979 NSPR_API(PRFileDesc*) PR_OpenTCPSocket(PRIntn af);980 981 /*982 *************************************************************************983 * FUNCTION: PR_Connect984 * DESCRIPTION:985 * Initiate a connection on a socket.986 * INPUTS:987 * PRFileDesc *fd988 * Points to a PRFileDesc object representing a socket989 * PRNetAddr *addr990 * Specifies the address of the socket in its own communication991 * space.992 * PRIntervalTime timeout993 * Time limit for completion of the connect operation.994 * OUTPUTS:995 * None996 * RETURN: PRStatus997 * Upon successful completion of connection initiation, PR_Connect998 * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further999 * failure information can be obtained by calling PR_GetError().1000 **************************************************************************1001 */1002 1003 NSPR_API(PRStatus) PR_Connect(1004 PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);1005 1006 /*1007 *************************************************************************1008 * FUNCTION: PR_ConnectContinue1009 * DESCRIPTION:1010 * Continue a nonblocking connect. After a nonblocking connect1011 * is initiated with PR_Connect() (which fails with1012 * PR_IN_PROGRESS_ERROR), one should call PR_Poll() on the socket,1013 * with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT. When1014 * PR_Poll() returns, one calls PR_ConnectContinue() on the1015 * socket to determine whether the nonblocking connect has1016 * completed or is still in progress. Repeat the PR_Poll(),1017 * PR_ConnectContinue() sequence until the nonblocking connect1018 * has completed.1019 * INPUTS:1020 * PRFileDesc *fd1021 * the file descriptor representing a socket1022 * PRInt16 out_flags1023 * the out_flags field of the poll descriptor returned by1024 * PR_Poll()1025 * RETURN: PRStatus1026 * If the nonblocking connect has successfully completed,1027 * PR_ConnectContinue returns PR_SUCCESS. If PR_ConnectContinue()1028 * returns PR_FAILURE, call PR_GetError():1029 * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in1030 * progress and has not completed yet. The caller should poll1031 * on the file descriptor for the in_flags1032 * PR_POLL_WRITE|PR_POLL_EXCEPT and retry PR_ConnectContinue1033 * later when PR_Poll() returns.1034 * - Other errors: the nonblocking connect has failed with this1035 * error code.1036 */1037 1038 NSPR_API(PRStatus) PR_ConnectContinue(PRFileDesc *fd, PRInt16 out_flags);1039 1040 /*1041 *************************************************************************1042 * THIS FUNCTION IS DEPRECATED. USE PR_ConnectContinue INSTEAD.1043 *1044 * FUNCTION: PR_GetConnectStatus1045 * DESCRIPTION:1046 * Get the completion status of a nonblocking connect. After1047 * a nonblocking connect is initiated with PR_Connect() (which1048 * fails with PR_IN_PROGRESS_ERROR), one should call PR_Poll()1049 * on the socket, with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT.1050 * When PR_Poll() returns, one calls PR_GetConnectStatus on the1051 * PRPollDesc structure to determine whether the nonblocking1052 * connect has succeeded or failed.1053 * INPUTS:1054 * const PRPollDesc *pd1055 * Pointer to a PRPollDesc whose fd member is the socket,1056 * and in_flags must contain PR_POLL_WRITE and PR_POLL_EXCEPT.1057 * PR_Poll() should have been called and set the out_flags.1058 * RETURN: PRStatus1059 * If the nonblocking connect has successfully completed,1060 * PR_GetConnectStatus returns PR_SUCCESS. If PR_GetConnectStatus()1061 * returns PR_FAILURE, call PR_GetError():1062 * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in1063 * progress and has not completed yet.1064 * - Other errors: the nonblocking connect has failed with this1065 * error code.1066 */1067 1068 NSPR_API(PRStatus) PR_GetConnectStatus(const PRPollDesc *pd);1069 1070 /*1071 *************************************************************************1072 * FUNCTION: PR_Accept1073 * DESCRIPTION:1074 * Accept a connection on a socket.1075 * INPUTS:1076 * PRFileDesc *fd1077 * Points to a PRFileDesc object representing the rendezvous socket1078 * on which the caller is willing to accept new connections.1079 * PRIntervalTime timeout1080 * Time limit for completion of the accept operation.1081 * OUTPUTS:1082 * PRNetAddr *addr1083 * Returns the address of the connecting entity in its own1084 * communication space. It may be NULL.1085 * RETURN: PRFileDesc*1086 * Upon successful acceptance of a connection, PR_Accept1087 * returns a valid file descriptor. Otherwise, it returns NULL.1088 * Further failure information can be obtained by calling PR_GetError().1089 **************************************************************************1090 */1091 1092 NSPR_API(PRFileDesc*) PR_Accept(1093 PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);1094 1095 /*1096 *************************************************************************1097 * FUNCTION: PR_Bind1098 * DESCRIPTION:1099 * Bind an address to a socket.1100 * INPUTS:1101 * PRFileDesc *fd1102 * Points to a PRFileDesc object representing a socket.1103 * PRNetAddr *addr1104 * Specifies the address to which the socket will be bound.1105 * OUTPUTS:1106 * None1107 * RETURN: PRStatus1108 * Upon successful binding of an address to a socket, PR_Bind1109 * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further1110 * failure information can be obtained by calling PR_GetError().1111 **************************************************************************1112 */1113 1114 NSPR_API(PRStatus) PR_Bind(PRFileDesc *fd, const PRNetAddr *addr);1115 1116 /*1117 *************************************************************************1118 * FUNCTION: PR_Listen1119 * DESCRIPTION:1120 * Listen for connections on a socket.1121 * INPUTS:1122 * PRFileDesc *fd1123 * Points to a PRFileDesc object representing a socket that will be1124 * used to listen for new connections.1125 * PRIntn backlog1126 * Specifies the maximum length of the queue of pending connections.1127 * OUTPUTS:1128 * None1129 * RETURN: PRStatus1130 * Upon successful completion of listen request, PR_Listen1131 * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further1132 * failure information can be obtained by calling PR_GetError().1133 **************************************************************************1134 */1135 1136 NSPR_API(PRStatus) PR_Listen(PRFileDesc *fd, PRIntn backlog);1137 1138 /*1139 *************************************************************************1140 * FUNCTION: PR_Shutdown1141 * DESCRIPTION:1142 * Shut down part of a full-duplex connection on a socket.1143 * INPUTS:1144 * PRFileDesc *fd1145 * Points to a PRFileDesc object representing a connected socket.1146 * PRIntn how1147 * Specifies the kind of disallowed operations on the socket.1148 * PR_SHUTDOWN_RCV - Further receives will be disallowed1149 * PR_SHUTDOWN_SEND - Further sends will be disallowed1150 * PR_SHUTDOWN_BOTH - Further sends and receives will be disallowed1151 * OUTPUTS:1152 * None1153 * RETURN: PRStatus1154 * Upon successful completion of shutdown request, PR_Shutdown1155 * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further1156 * failure information can be obtained by calling PR_GetError().1157 **************************************************************************1158 */1159 1160 typedef enum PRShutdownHow1161 {1162 PR_SHUTDOWN_RCV = 0, /* disallow further receives */1163 PR_SHUTDOWN_SEND = 1, /* disallow further sends */1164 PR_SHUTDOWN_BOTH = 2 /* disallow further receives and sends */1165 } PRShutdownHow;1166 1167 NSPR_API(PRStatus) PR_Shutdown(PRFileDesc *fd, PRShutdownHow how);1168 1169 /*1170 *************************************************************************1171 * FUNCTION: PR_Recv1172 * DESCRIPTION:1173 * Receive a specified number of bytes from a connected socket.1174 * The operation will block until some positive number of bytes are1175 * transferred, a time out has occurred, or there is an error.1176 * No more than 'amount' bytes will be transferred.1177 * INPUTS:1178 * PRFileDesc *fd1179 * points to a PRFileDesc object representing a socket.1180 * void *buf1181 * pointer to a buffer to hold the data received.1182 * PRInt32 amount1183 * the size of 'buf' (in bytes)1184 * PRIntn flags1185 * must be zero or PR_MSG_PEEK.1186 * PRIntervalTime timeout1187 * Time limit for completion of the receive operation.1188 * OUTPUTS:1189 * None1190 * RETURN: PRInt321191 * a positive number indicates the number of bytes actually received.1192 * 0 means the network connection is closed.1193 * -1 indicates a failure. The reason for the failure is obtained1194 * by calling PR_GetError().1195 **************************************************************************1196 */1197 1198 #define PR_MSG_PEEK 0x21199 1200 NSPR_API(PRInt32) PR_Recv(PRFileDesc *fd, void *buf, PRInt32 amount,1201 PRIntn flags, PRIntervalTime timeout);1202 1203 /*1204 *************************************************************************1205 * FUNCTION: PR_Send1206 * DESCRIPTION:1207 * Send a specified number of bytes from a connected socket.1208 * The operation will block until all bytes are1209 * processed, a time out has occurred, or there is an error.1210 * INPUTS:1211 * PRFileDesc *fd1212 * points to a PRFileDesc object representing a socket.1213 * void *buf1214 * pointer to a buffer from where the data is sent.1215 * PRInt32 amount1216 * the size of 'buf' (in bytes)1217 * PRIntn flags1218 * (OBSOLETE - must always be zero)1219 * PRIntervalTime timeout1220 * Time limit for completion of the send operation.1221 * OUTPUTS:1222 * None1223 * RETURN: PRInt321224 * A positive number indicates the number of bytes successfully processed.1225 * This number must always equal 'amount'. A -1 is an indication that the1226 * operation failed. The reason for the failure is obtained by calling1227 * PR_GetError().1228 **************************************************************************1229 */1230 1231 NSPR_API(PRInt32) PR_Send(PRFileDesc *fd, const void *buf, PRInt32 amount,1232 PRIntn flags, PRIntervalTime timeout);1233 1234 /*1235 *************************************************************************1236 ** FUNCTION: PR_GetSockName1237 ** DESCRIPTION:1238 ** Get socket name. Return the network address for this socket.1239 **1240 ** INPUTS:1241 ** PRFileDesc *fd1242 ** Points to a PRFileDesc object representing the socket.1243 ** OUTPUTS:1244 ** PRNetAddr *addr1245 ** Returns the address of the socket in its own communication space.1246 ** RETURN: PRStatus1247 ** Upon successful completion, PR_GetSockName returns PR_SUCCESS.1248 ** Otherwise, it returns PR_FAILURE. Further failure information can1249 ** be obtained by calling PR_GetError().1250 **************************************************************************1251 **/1252 NSPR_API(PRStatus) PR_GetSockName(PRFileDesc *fd, PRNetAddr *addr);1253 1254 /*1255 *************************************************************************1256 ** FUNCTION: PR_GetPeerName1257 ** DESCRIPTION:1258 ** Get name of the connected peer. Return the network address for the1259 ** connected peer socket.1260 **1261 ** INPUTS:1262 ** PRFileDesc *fd1263 ** Points to a PRFileDesc object representing the connected peer.1264 ** OUTPUTS:1265 ** PRNetAddr *addr1266 ** Returns the address of the connected peer in its own communication1267 ** space.1268 ** RETURN: PRStatus1269 ** Upon successful completion, PR_GetPeerName returns PR_SUCCESS.1270 ** Otherwise, it returns PR_FAILURE. Further failure information can1271 ** be obtained by calling PR_GetError().1272 **************************************************************************1273 **/1274 NSPR_API(PRStatus) PR_GetPeerName(PRFileDesc *fd, PRNetAddr *addr);1275 1276 NSPR_API(PRStatus) PR_GetSocketOption(1277 PRFileDesc *fd, PRSocketOptionData *data);1278 1279 NSPR_API(PRStatus) PR_SetSocketOption(1280 PRFileDesc *fd, const PRSocketOptionData *data);1281 1282 /*1283 *********************************************************************1284 *1285 * File descriptor inheritance1286 *1287 *********************************************************************1288 */1289 1290 /*1291 ************************************************************************1292 * FUNCTION: PR_SetFDInheritable1293 * DESCRIPTION:1294 * Set the inheritance attribute of a file descriptor.1295 *1296 * INPUTS:1297 * PRFileDesc *fd1298 * Points to a PRFileDesc object.1299 * PRBool inheritable1300 * If PR_TRUE, the file descriptor fd is set to be inheritable1301 * by a child process. If PR_FALSE, the file descriptor is set1302 * to be not inheritable by a child process.1303 * RETURN: PRStatus1304 * Upon successful completion, PR_SetFDInheritable returns PR_SUCCESS.1305 * Otherwise, it returns PR_FAILURE. Further failure information can1306 * be obtained by calling PR_GetError().1307 *************************************************************************1308 */1309 NSPR_API(PRStatus) PR_SetFDInheritable(1310 PRFileDesc *fd,1311 PRBool inheritable);1312 1313 /*1314 ************************************************************************1315 * FUNCTION: PR_GetInheritedFD1316 * DESCRIPTION:1317 * Get an inherited file descriptor with the specified name.1318 *1319 * INPUTS:1320 * const char *name1321 * The name of the inherited file descriptor.1322 * RETURN: PRFileDesc *1323 * Upon successful completion, PR_GetInheritedFD returns the1324 * inherited file descriptor with the specified name. Otherwise,1325 * it returns NULL. Further failure information can be obtained1326 * by calling PR_GetError().1327 *************************************************************************1328 */1329 NSPR_API(PRFileDesc *) PR_GetInheritedFD(const char *name);1330 1331 /*1332 ******************************************************************1333 *1334 * Interprocess communication1335 *1336 ******************************************************************1337 */1338 1339 /*1340 * Creates an anonymous pipe and returns file descriptors for the1341 * read and write ends of the pipe.1342 */1343 1344 NSPR_API(PRStatus) PR_CreatePipe(1345 PRFileDesc **readPipe,1346 PRFileDesc **writePipe1347 );1348 1349 /************************************************************************/1350 /************** The following definitions are for poll ******************/1351 /************************************************************************/1352 1353 struct PRPollDesc {1354 PRFileDesc* fd;1355 PRInt16 in_flags;1356 PRInt16 out_flags;1357 };1358 1359 /*1360 ** Bit values for PRPollDesc.in_flags or PRPollDesc.out_flags. Binary-or1361 ** these together to produce the desired poll request.1362 */1363 1364 #if defined(_PR_POLL_BACKCOMPAT)1365 1366 #include <poll.h>1367 #define PR_POLL_READ POLLIN1368 #define PR_POLL_WRITE POLLOUT1369 #define PR_POLL_EXCEPT POLLPRI1370 #define PR_POLL_ERR POLLERR /* only in out_flags */1371 #define PR_POLL_NVAL POLLNVAL /* only in out_flags when fd is bad */1372 #define PR_POLL_HUP POLLHUP /* only in out_flags */1373 1374 #else /* _PR_POLL_BACKCOMPAT */1375 1376 #define PR_POLL_READ 0x11377 #define PR_POLL_WRITE 0x21378 #define PR_POLL_EXCEPT 0x41379 #define PR_POLL_ERR 0x8 /* only in out_flags */1380 #define PR_POLL_NVAL 0x10 /* only in out_flags when fd is bad */1381 #define PR_POLL_HUP 0x20 /* only in out_flags */1382 1383 #endif /* _PR_POLL_BACKCOMPAT */1384 1385 /*1386 *************************************************************************1387 ** FUNCTION: PR_Poll1388 ** DESCRIPTION:1389 **1390 ** The call returns as soon as I/O is ready on one or more of the underlying1391 ** socket objects. A count of the number of ready descriptors is1392 ** returned unless a timeout occurs in which case zero is returned.1393 **1394 ** PRPollDesc.fd should be set to a pointer to a PRFileDesc object1395 ** representing a socket. This field can be set to NULL to indicate to1396 ** PR_Poll that this PRFileDesc object should be ignored.1397 ** PRPollDesc.in_flags should be set to the desired request1398 ** (read/write/except or some combination). Upon successful return from1399 ** this call PRPollDesc.out_flags will be set to indicate what kind of1400 ** i/o can be performed on the respective descriptor. PR_Poll() uses the1401 ** out_flags fields as scratch variables during the call. If PR_Poll()1402 ** returns 0 or -1, the out_flags fields do not contain meaningful values1403 ** and must not be used.1404 **1405 ** INPUTS:1406 ** PRPollDesc *pds A pointer to an array of PRPollDesc1407 **1408 ** PRIntn npds The number of elements in the array1409 ** If this argument is zero PR_Poll is1410 ** equivalent to a PR_Sleep(timeout).1411 **1412 ** PRIntervalTime timeout Amount of time the call will block waiting1413 ** for I/O to become ready. If this time expires1414 ** w/o any I/O becoming ready, the result will1415 ** be zero.1416 **1417 ** OUTPUTS: None1418 ** RETURN:1419 ** PRInt32 Number of PRPollDesc's with events or zero1420 ** if the function timed out or -1 on failure.1421 ** The reason for the failure is obtained by1422 ** calling PR_GetError().1423 **************************************************************************1424 */1425 NSPR_API(PRInt32) PR_Poll(1426 PRPollDesc *pds, PRIntn npds, PRIntervalTime timeout);1427 1428 703 PR_END_EXTERN_C 1429 704
Note:
See TracChangeset
for help on using the changeset viewer.