📄 prio.h
字号:
* dynamically allocated and a pointer to it is returned. * If the directory cannot be opened, a NULL pointer is returned. * MEMORY: * Upon successful completion, the return value points to * dynamically allocated memory. ************************************************************************* */NSPR_API(PRDir*) PR_OpenDir(const char *name);/* ************************************************************************* * FUNCTION: PR_ReadDir * DESCRIPTION: * INPUTS: * PRDir *dir * pointer to a PRDir object that designates an open directory * PRDirFlags flags * PR_SKIP_NONE Do not skip any files * PR_SKIP_DOT Skip the directory entry "." that * represents the current directory * PR_SKIP_DOT_DOT Skip the directory entry ".." that * represents the parent directory. * PR_SKIP_BOTH Skip both '.' and '..' * PR_SKIP_HIDDEN Skip hidden files * OUTPUTS: * RETURN: PRDirEntry* * Returns a pointer to the next entry in the directory. Returns * a NULL pointer upon reaching the end of the directory or when an * error occurs. The actual reason can be retrieved via PR_GetError(). ************************************************************************* */typedef enum PRDirFlags { PR_SKIP_NONE = 0x0, PR_SKIP_DOT = 0x1, PR_SKIP_DOT_DOT = 0x2, PR_SKIP_BOTH = 0x3, PR_SKIP_HIDDEN = 0x4} PRDirFlags;NSPR_API(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags);/* ************************************************************************* * FUNCTION: PR_CloseDir * DESCRIPTION: * Close the specified directory. * INPUTS: * PRDir *dir * The directory to be closed. * OUTPUTS: * None * RETURN: PRStatus * If successful, will return a status of PR_SUCCESS. Otherwise * a value of PR_FAILURE. The reason for the failure may be re- * trieved using PR_GetError(). ************************************************************************* */NSPR_API(PRStatus) PR_CloseDir(PRDir *dir);/* ************************************************************************* * FUNCTION: PR_MkDir * DESCRIPTION: * Create a new directory with the given name and access mode. * INPUTS: * const char *name * The name of the directory to be created. All the path components * up to but not including the leaf component must already exist. * PRIntn mode * See 'mode' definiton in PR_Open(). * OUTPUTS: * None * RETURN: PRStatus * If successful, will return a status of PR_SUCCESS. Otherwise * a value of PR_FAILURE. The reason for the failure may be re- * trieved using PR_GetError(). ************************************************************************* */NSPR_API(PRStatus) PR_MkDir(const char *name, PRIntn mode);/* ************************************************************************* * FUNCTION: PR_MakeDir * DESCRIPTION: * Create a new directory with the given name and access mode. * PR_MakeDir has the same prototype as PR_MkDir but implements * the specified access mode where possible. ************************************************************************* */NSPR_API(PRStatus) PR_MakeDir(const char *name, PRIntn mode);/* ************************************************************************* * FUNCTION: PR_RmDir * DESCRIPTION: * Remove a directory by the given name. * INPUTS: * const char *name * The name of the directory to be removed. All the path components * must already exist. Only the leaf component will be removed. * OUTPUTS: * None * RETURN: PRStatus * If successful, will return a status of PR_SUCCESS. Otherwise * a value of PR_FAILURE. The reason for the failure may be re- * trieved using PR_GetError(). ************************************************************************** */NSPR_API(PRStatus) PR_RmDir(const char *name);/* ************************************************************************* * FUNCTION: PR_NewUDPSocket * DESCRIPTION: * Create a new UDP socket. * INPUTS: * None * OUTPUTS: * None * RETURN: PRFileDesc* * Upon successful completion, PR_NewUDPSocket returns a pointer * to the PRFileDesc created for the newly opened UDP socket. * Returns a NULL pointer if the creation of a new UDP socket failed. * ************************************************************************** */NSPR_API(PRFileDesc*) PR_NewUDPSocket(void);/* ************************************************************************* * FUNCTION: PR_NewTCPSocket * DESCRIPTION: * Create a new TCP socket. * INPUTS: * None * OUTPUTS: * None * RETURN: PRFileDesc* * Upon successful completion, PR_NewTCPSocket returns a pointer * to the PRFileDesc created for the newly opened TCP socket. * Returns a NULL pointer if the creation of a new TCP socket failed. * ************************************************************************** */NSPR_API(PRFileDesc*) PR_NewTCPSocket(void);/* ************************************************************************* * FUNCTION: PR_OpenUDPSocket * DESCRIPTION: * Create a new UDP socket of the specified address family. * INPUTS: * PRIntn af * Address family * OUTPUTS: * None * RETURN: PRFileDesc* * Upon successful completion, PR_OpenUDPSocket returns a pointer * to the PRFileDesc created for the newly opened UDP socket. * Returns a NULL pointer if the creation of a new UDP socket failed. * ************************************************************************** */NSPR_API(PRFileDesc*) PR_OpenUDPSocket(PRIntn af);/* ************************************************************************* * FUNCTION: PR_OpenTCPSocket * DESCRIPTION: * Create a new TCP socket of the specified address family. * INPUTS: * PRIntn af * Address family * OUTPUTS: * None * RETURN: PRFileDesc* * Upon successful completion, PR_NewTCPSocket returns a pointer * to the PRFileDesc created for the newly opened TCP socket. * Returns a NULL pointer if the creation of a new TCP socket failed. * ************************************************************************** */NSPR_API(PRFileDesc*) PR_OpenTCPSocket(PRIntn af);/* ************************************************************************* * FUNCTION: PR_Connect * DESCRIPTION: * Initiate a connection on a socket. * INPUTS: * PRFileDesc *fd * Points to a PRFileDesc object representing a socket * PRNetAddr *addr * Specifies the address of the socket in its own communication * space. * PRIntervalTime timeout * Time limit for completion of the connect operation. * OUTPUTS: * None * RETURN: PRStatus * Upon successful completion of connection initiation, PR_Connect * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further * failure information can be obtained by calling PR_GetError(). ************************************************************************** */NSPR_API(PRStatus) PR_Connect( PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);/* ************************************************************************* * FUNCTION: PR_ConnectContinue * DESCRIPTION: * Continue a nonblocking connect. After a nonblocking connect * is initiated with PR_Connect() (which fails with * PR_IN_PROGRESS_ERROR), one should call PR_Poll() on the socket, * with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT. When * PR_Poll() returns, one calls PR_ConnectContinue() on the * socket to determine whether the nonblocking connect has * completed or is still in progress. Repeat the PR_Poll(), * PR_ConnectContinue() sequence until the nonblocking connect * has completed. * INPUTS: * PRFileDesc *fd * the file descriptor representing a socket * PRInt16 out_flags * the out_flags field of the poll descriptor returned by * PR_Poll() * RETURN: PRStatus * If the nonblocking connect has successfully completed, * PR_ConnectContinue returns PR_SUCCESS. If PR_ConnectContinue() * returns PR_FAILURE, call PR_GetError(): * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in * progress and has not completed yet. The caller should poll * on the file descriptor for the in_flags * PR_POLL_WRITE|PR_POLL_EXCEPT and retry PR_ConnectContinue * later when PR_Poll() returns. * - Other errors: the nonblocking connect has failed with this * error code. */NSPR_API(PRStatus) PR_ConnectContinue(PRFileDesc *fd, PRInt16 out_flags);/* ************************************************************************* * THIS FUNCTION IS DEPRECATED. USE PR_ConnectContinue INSTEAD. * * FUNCTION: PR_GetConnectStatus * DESCRIPTION: * Get the completion status of a nonblocking connect. After * a nonblocking connect is initiated with PR_Connect() (which * fails with PR_IN_PROGRESS_ERROR), one should call PR_Poll() * on the socket, with the in_flags PR_POLL_WRITE | PR_POLL_EXCEPT. * When PR_Poll() returns, one calls PR_GetConnectStatus on the * PRPollDesc structure to determine whether the nonblocking * connect has succeeded or failed. * INPUTS: * const PRPollDesc *pd * Pointer to a PRPollDesc whose fd member is the socket, * and in_flags must contain PR_POLL_WRITE and PR_POLL_EXCEPT. * PR_Poll() should have been called and set the out_flags. * RETURN: PRStatus * If the nonblocking connect has successfully completed, * PR_GetConnectStatus returns PR_SUCCESS. If PR_GetConnectStatus() * returns PR_FAILURE, call PR_GetError(): * - PR_IN_PROGRESS_ERROR: the nonblocking connect is still in * progress and has not completed yet. * - Other errors: the nonblocking connect has failed with this * error code. */NSPR_API(PRStatus) PR_GetConnectStatus(const PRPollDesc *pd);/* ************************************************************************* * FUNCTION: PR_Accept * DESCRIPTION: * Accept a connection on a socket. * INPUTS: * PRFileDesc *fd * Points to a PRFileDesc object representing the rendezvous socket * on which the caller is willing to accept new connections. * PRIntervalTime timeout * Time limit for completion of the accept operation. * OUTPUTS: * PRNetAddr *addr * Returns the address of the connecting entity in its own * communication space. It may be NULL. * RETURN: PRFileDesc* * Upon successful acceptance of a connection, PR_Accept * returns a valid file descriptor. Otherwise, it returns NULL. * Further failure information can be obtained by calling PR_GetError(). ************************************************************************** */NSPR_API(PRFileDesc*) PR_Accept( PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);/* ************************************************************************* * FUNCTION: PR_Bind * DESCRIPTION: * Bind an address to a socket. * INPUTS: * PRFileDesc *fd * Points to a PRFileDesc object representing a socket. * PRNetAddr *addr * Specifies the address to which the socket will be bound. * OUTPUTS: * None * RETURN: PRStatus * Upon successful binding of an address to a socket, PR_Bind * returns PR_SUCCESS. Otherwise, it returns PR_FAILURE. Further * failure information can be obtained by calling PR_GetError(). ************************************************************************** */NSPR_API(PRStatus) PR_Bind(PRFileDesc *fd, const PRNetAddr *addr);/* ************************************************************************* * FUNCTION: PR_Listen * DESCRIPTION: * Listen for connections on a socket.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -