⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prio.h

📁 Netscape NSPR库源码
💻 H
📖 第 1 页 / 共 5 页
字号:
typedef PRInt32 (PR_CALLBACK *PRRecvFN)(    PRFileDesc *fd, void *buf, PRInt32 amount,    PRIntn flags, PRIntervalTime timeout);typedef PRInt32 (PR_CALLBACK *PRSendFN) (    PRFileDesc *fd, const void *buf, PRInt32 amount,    PRIntn flags, PRIntervalTime timeout);typedef PRInt32 (PR_CALLBACK *PRRecvfromFN)(    PRFileDesc *fd, void *buf, PRInt32 amount,    PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout);typedef PRInt32 (PR_CALLBACK *PRSendtoFN)(    PRFileDesc *fd, const void *buf, PRInt32 amount,    PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout);typedef PRInt16 (PR_CALLBACK *PRPollFN)(    PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags);typedef PRInt32 (PR_CALLBACK *PRAcceptreadFN)(    PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr,    void *buf, PRInt32 amount, PRIntervalTime t);typedef PRInt32 (PR_CALLBACK *PRTransmitfileFN)(     PRFileDesc *sd, PRFileDesc *fd, const void *headers,     PRInt32 hlen, PRTransmitFileFlags flags, PRIntervalTime t);typedef PRStatus (PR_CALLBACK *PRGetsocknameFN)(PRFileDesc *fd, PRNetAddr *addr);typedef PRStatus (PR_CALLBACK *PRGetpeernameFN)(PRFileDesc *fd, PRNetAddr *addr);typedef PRStatus (PR_CALLBACK *PRGetsocketoptionFN)(    PRFileDesc *fd, PRSocketOptionData *data);typedef PRStatus (PR_CALLBACK *PRSetsocketoptionFN)(    PRFileDesc *fd, const PRSocketOptionData *data);typedef PRInt32 (PR_CALLBACK *PRSendfileFN)(	PRFileDesc *networkSocket, PRSendFileData *sendData,	PRTransmitFileFlags flags, PRIntervalTime timeout);typedef PRStatus (PR_CALLBACK *PRConnectcontinueFN)(    PRFileDesc *fd, PRInt16 out_flags);typedef PRIntn (PR_CALLBACK *PRReservedFN)(PRFileDesc *fd);struct PRIOMethods {    PRDescType file_type;           /* Type of file represented (tos)           */    PRCloseFN close;                /* close file and destroy descriptor        */    PRReadFN read;                  /* read up to specified bytes into buffer   */    PRWriteFN write;                /* write specified bytes from buffer        */    PRAvailableFN available;        /* determine number of bytes available      */    PRAvailable64FN available64;    /*          ditto, 64 bit                   */    PRFsyncFN fsync;                /* flush all buffers to permanent store     */    PRSeekFN seek;                  /* position the file to the desired place   */    PRSeek64FN seek64;              /*           ditto, 64 bit                  */    PRFileInfoFN fileInfo;          /* Get information about an open file       */    PRFileInfo64FN fileInfo64;      /*           ditto, 64 bit                  */    PRWritevFN writev;              /* Write segments as described by iovector  */    PRConnectFN connect;            /* Connect to the specified (net) address   */    PRAcceptFN accept;              /* Accept a connection for a (net) peer     */    PRBindFN bind;                  /* Associate a (net) address with the fd    */    PRListenFN listen;              /* Prepare to listen for (net) connections  */    PRShutdownFN shutdown;          /* Shutdown a (net) connection              */    PRRecvFN recv;                  /* Solicit up the the specified bytes       */    PRSendFN send;                  /* Send all the bytes specified             */    PRRecvfromFN recvfrom;          /* Solicit (net) bytes and report source    */    PRSendtoFN sendto;              /* Send bytes to (net) address specified    */    PRPollFN poll;                  /* Test the fd to see if it is ready        */    PRAcceptreadFN acceptread;      /* Accept and read on a new (net) fd        */    PRTransmitfileFN transmitfile;  /* Transmit at entire file                  */    PRGetsocknameFN getsockname;    /* Get (net) address associated with fd     */    PRGetpeernameFN getpeername;    /* Get peer's (net) address                 */    PRReservedFN reserved_fn_6;     /* reserved for future use */    PRReservedFN reserved_fn_5;     /* reserved for future use */    PRGetsocketoptionFN getsocketoption;                                    /* Get current setting of specified option  */    PRSetsocketoptionFN setsocketoption;                                    /* Set value of specified option            */    PRSendfileFN sendfile;			/* Send a (partial) file with header/trailer*/    PRConnectcontinueFN connectcontinue;                                    /* Continue a nonblocking connect */    PRReservedFN reserved_fn_3;		/* reserved for future use */    PRReservedFN reserved_fn_2;		/* reserved for future use */    PRReservedFN reserved_fn_1;		/* reserved for future use */    PRReservedFN reserved_fn_0;		/* reserved for future use */};/* ************************************************************************** * FUNCTION: PR_GetSpecialFD * DESCRIPTION: Get the file descriptor that represents the standard input, *              output, or error stream. * INPUTS: *     PRSpecialFD id *         A value indicating the type of stream desired: *             PR_StandardInput: standard input *             PR_StandardOuput: standard output *             PR_StandardError: standard error * OUTPUTS: none * RETURNS: PRFileDesc * *     If the argument is valid, PR_GetSpecialFD returns a file descriptor *     that represents the corresponding standard I/O stream.  Otherwise, *     PR_GetSpecialFD returns NULL and sets error PR_INVALID_ARGUMENT_ERROR. ************************************************************************** */typedef enum PRSpecialFD{    PR_StandardInput,          /* standard input */    PR_StandardOutput,         /* standard output */    PR_StandardError           /* standard error */} PRSpecialFD;NSPR_API(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD id);#define PR_STDIN	PR_GetSpecialFD(PR_StandardInput)#define PR_STDOUT	PR_GetSpecialFD(PR_StandardOutput)#define PR_STDERR	PR_GetSpecialFD(PR_StandardError)/* ************************************************************************** * Layering file descriptors * * File descriptors may be layered. Each layer has it's own identity. * Identities are allocated by the runtime and are to be associated * (by the layer implementor) with all layers that are of that type. * It is then possible to scan the chain of layers and find a layer * that one recongizes and therefore predict that it will implement * a desired protocol. * * There are three well-known identities: *      PR_INVALID_IO_LAYER => an invalid layer identity, for error return *      PR_TOP_IO_LAYER     => the identity of the top of the stack *      PR_NSPR_IO_LAYER    => the identity used by NSPR proper * PR_TOP_IO_LAYER may be used as a shorthand for identifying the topmost * layer of an existing stack. Ie., the following two constructs are * equivalent. * *      rv = PR_PushIOLayer(stack, PR_TOP_IO_LAYER, my_layer); *      rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), my_layer) * * A string may be associated with the creation of the identity. It * will be copied by the runtime. If queried the runtime will return * a reference to that copied string (not yet another copy). There * is no facility for deleting an identity. ************************************************************************** */#define PR_IO_LAYER_HEAD (PRDescIdentity)-3#define PR_INVALID_IO_LAYER (PRDescIdentity)-1#define PR_TOP_IO_LAYER (PRDescIdentity)-2#define PR_NSPR_IO_LAYER (PRDescIdentity)0NSPR_API(PRDescIdentity) PR_GetUniqueIdentity(const char *layer_name);NSPR_API(const char*) PR_GetNameForIdentity(PRDescIdentity ident);NSPR_API(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd);NSPR_API(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);/* ************************************************************************** * PR_GetDefaultIOMethods: Accessing the default methods table. * You may get a pointer to the default methods table by calling this function. * You may then select any elements from that table with which to build your * layer's methods table. You may NOT modify the table directly. ************************************************************************** */NSPR_API(const PRIOMethods *) PR_GetDefaultIOMethods(void);/* ************************************************************************** * Creating a layer * * A new layer may be allocated by calling PR_CreateIOLayerStub(). The * file descriptor returned will contain the pointer to the methods table * provided. The runtime will not modify the table nor test its correctness. ************************************************************************** */NSPR_API(PRFileDesc*) PR_CreateIOLayerStub(    PRDescIdentity ident, const PRIOMethods *methods);/* ************************************************************************** * Creating a layer * * A new stack may be created by calling PR_CreateIOLayer(). The * file descriptor returned will point to the top of the stack, which has * the layer 'fd' as the topmost layer. *  * NOTE: This function creates a new style stack, which has a fixed, dummy * header. The old style stack, created by a call to PR_PushIOLayer, * results in modifying contents of the top layer of the stack, when * pushing and popping layers of the stack. ************************************************************************** */NSPR_API(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* fd);/* ************************************************************************** * Pushing a layer * * A file descriptor (perhaps allocated using PR_CreateIOLayerStub()) may * be pushed into an existing stack of file descriptors at any point the * caller deems appropriate. The new layer will be inserted into the stack * just above the layer with the indicated identity. * * Note: Even if the identity parameter indicates the top-most layer of * the stack, the value of the file descriptor describing the original * stack will not change. ************************************************************************** */NSPR_API(PRStatus) PR_PushIOLayer(    PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer);/* ************************************************************************** * Popping a layer * * A layer may be popped from a stack by indicating the identity of the * layer to be removed. If found, a pointer to the removed object will * be returned to the caller. The object then becomes the responsibility * of the caller. * * Note: Even if the identity indicates the top layer of the stack, the * reference returned will not be the file descriptor for the stack and * that file descriptor will remain valid. ************************************************************************** */NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id);/* ************************************************************************** * FUNCTION:    PR_Open * DESCRIPTION:    Open a file for reading, writing, or both. * INPUTS: *     const char *name *         The path name of the file to be opened *     PRIntn flags *         The file status flags. *         It is a bitwise OR of the following bit flags (only one of *         the first three flags below may be used): *		PR_RDONLY        Open for reading only. *		PR_WRONLY        Open for writing only. *		PR_RDWR          Open for reading and writing. *		PR_CREATE_FILE   If the file does not exist, the file is created *                              If the file exists, this flag has no effect. *      PR_SYNC          If set, each write will wait for both the file data *                              and file status to be physically updated. *		PR_APPEND        The file pointer is set to the end of *                              the file prior to each write. *		PR_TRUNCATE      If the file exists, its length is truncated to 0. *      PR_EXCL          With PR_CREATE_FILE, if the file does not exist, *                              the file is created. If the file already  *                              exists, no action and NULL is returned * *     PRIntn mode *         The access permission bits of the file mode, if the file is *         created when PR_CREATE_FILE is on. * OUTPUTS:    None * RETURNS:    PRFileDesc * *     If the file is successfully opened, *     returns a pointer to the PRFileDesc *     created for the newly opened file. *     Returns a NULL pointer if the open *     failed. * SIDE EFFECTS: * RESTRICTIONS: * MEMORY: *     The return value, if not NULL, points to a dynamically allocated *     PRFileDesc object. * ALGORITHM: ************************************************************************** *//* Open flags */#define PR_RDONLY       0x01#define PR_WRONLY       0x02#define PR_RDWR         0x04#define PR_CREATE_FILE  0x08#define PR_APPEND       0x10#define PR_TRUNCATE     0x20#define PR_SYNC         0x40#define PR_EXCL         0x80/*** File modes ....**** CAVEAT: 'mode' is currently only applicable on UNIX platforms.** The 'mode' argument may be ignored by PR_Open on other platforms.****   00400   Read by owner.**   00200   Write by owner.**   00100   Execute (search if a directory) by owner.**   00040   Read by group.**   00020   Write by group.**   00010   Execute by group.**   00004   Read by others.**   00002   Write by others**   00001   Execute by others.***/NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);/* ************************************************************************** * FUNCTION: PR_OpenFile * DESCRIPTION: *     Open a file for reading, writing, or both. *     PR_OpenFile has the same prototype as PR_Open but implements *     the specified file mode where possible. ************************************************************************** *//* File mode bits */#define PR_IRWXU 00700  /* read, write, execute/search by owner */#define PR_IRUSR 00400  /* read permission, owner */#define PR_IWUSR 00200  /* write permission, owner */#define PR_IXUSR 00100  /* execute/search permission, owner */#define PR_IRWXG 00070  /* read, write, execute/search by group */#define PR_IRGRP 00040  /* read permission, group */#define PR_IWGRP 00020  /* write permission, group */#define PR_IXGRP 00010  /* execute/search permission, group */#define PR_IRWXO 00007  /* read, write, execute/search by others */#define PR_IROTH 00004  /* read permission, others */#define PR_IWOTH 00002  /* write permission, others */#define PR_IXOTH 00001  /* execute/search permission, others */NSPR_API(PRFileDesc*) PR_OpenFile(    const char *name, PRIntn flags, PRIntn mode);/* ************************************************************************** * FUNCTION: PR_Close * DESCRIPTION: *     Close a file or socket. * INPUTS: *     PRFileDesc *fd *         a pointer to a PRFileDesc. * OUTPUTS: *     None. * RETURN: *     PRStatus * SIDE EFFECTS: * RESTRICTIONS: *     None. * MEMORY:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -