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

📄 prio.h

📁 Netscape NSPR库源码
💻 H
📖 第 1 页 / 共 5 页
字号:
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- *//*  * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ *  * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. *  * The Original Code is the Netscape Portable Runtime (NSPR). *  * The Initial Developer of the Original Code is Netscape * Communications Corporation.  Portions created by Netscape are  * Copyright (C) 1998-2000 Netscape Communications Corporation.  All * Rights Reserved. *  * Contributor(s): *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL"), in which case the provisions of the GPL are applicable  * instead of those above.  If you wish to allow use of your  * version of this file only under the terms of the GPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the GPL.  If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * GPL. *//* * File:     prio.h * * Description:    PR i/o related stuff, such as file system access, file *         i/o, socket i/o, etc. */#ifndef prio_h___#define prio_h___#include "prlong.h"#include "prtime.h"#include "prinrval.h"#include "prinet.h"PR_BEGIN_EXTERN_C/* Typedefs */typedef struct PRDir            PRDir;typedef struct PRDirEntry       PRDirEntry;typedef struct PRFileDesc       PRFileDesc;typedef struct PRFileInfo       PRFileInfo;typedef struct PRFileInfo64     PRFileInfo64;typedef union  PRNetAddr        PRNetAddr;typedef struct PRIOMethods      PRIOMethods;typedef struct PRPollDesc       PRPollDesc;typedef struct PRFilePrivate    PRFilePrivate;typedef struct PRSendFileData   PRSendFileData;/****************************************************************************** The file descriptor.** This is the primary structure to represent any active open socket,** whether it be a normal file or a network connection. Such objects** are stackable (or layerable). Each layer may have its own set of** method pointers and context private to that layer. All each layer** knows about its neighbors is how to get to their method table.****************************************************************************/typedef PRIntn PRDescIdentity;          /* see: Layering file descriptors */struct PRFileDesc {    const PRIOMethods *methods;         /* the I/O methods table */    PRFilePrivate *secret;              /* layer dependent data */    PRFileDesc *lower, *higher;         /* pointers to adjacent layers */    void (PR_CALLBACK *dtor)(PRFileDesc *fd);                                        /* A destructor function for layer */    PRDescIdentity identity;            /* Identity of this particular layer  */};/****************************************************************************** PRTransmitFileFlags**** Flags for PR_TransmitFile.  Pass PR_TRANSMITFILE_CLOSE_SOCKET to** PR_TransmitFile if the connection should be closed after the file** is transmitted.****************************************************************************/typedef enum PRTransmitFileFlags {    PR_TRANSMITFILE_KEEP_OPEN = 0,    /* socket is left open after file                                       * is transmitted. */    PR_TRANSMITFILE_CLOSE_SOCKET = 1  /* socket is closed after file                                       * is transmitted. */} PRTransmitFileFlags;/***************************************************************************** Macros for PRNetAddr**** Address families: PR_AF_INET, PR_AF_INET6, PR_AF_LOCAL** IP addresses: PR_INADDR_ANY, PR_INADDR_LOOPBACK, PR_INADDR_BROADCAST***************************************************************************/#ifdef WIN32#define PR_AF_INET 2#define PR_AF_LOCAL 1#define PR_INADDR_ANY (unsigned long)0x00000000#define PR_INADDR_LOOPBACK 0x7f000001#define PR_INADDR_BROADCAST (unsigned long)0xffffffff#else /* WIN32 */#define PR_AF_INET AF_INET#define PR_AF_LOCAL AF_UNIX#define PR_INADDR_ANY INADDR_ANY#define PR_INADDR_LOOPBACK INADDR_LOOPBACK#define PR_INADDR_BROADCAST INADDR_BROADCAST#endif /* WIN32 *//*** Define PR_AF_INET6 in prcpucfg.h with the same** value as AF_INET6 on platforms with IPv6 support.** Otherwise define it here.*/#ifndef PR_AF_INET6#define PR_AF_INET6 100#endif/***************************************************************************** A network address**** Only Internet Protocol (IPv4 and IPv6) addresses are supported.** The address family must always represent IPv4 (AF_INET, probably == 2)** or IPv6 (AF_INET6).***************************************************************************************************************************************************/struct PRIPv6Addr {	union {		PRUint8  _S6_u8[16];		PRUint16 _S6_u16[8];		PRUint32 _S6_u32[4];		PRUint64 _S6_u64[2];	} _S6_un;};#define pr_s6_addr		_S6_un._S6_u8#define pr_s6_addr16	_S6_un._S6_u16#define pr_s6_addr32	_S6_un._S6_u32#define pr_s6_addr64 	_S6_un._S6_u64typedef struct PRIPv6Addr PRIPv6Addr;union PRNetAddr {    struct {        PRUint16 family;                /* address family (0x00ff maskable) */#ifdef XP_BEOS        char data[10];                  /* Be has a smaller structure */#else        char data[14];                  /* raw address data */#endif    } raw;    struct {        PRUint16 family;                /* address family (AF_INET) */        PRUint16 port;                  /* port number */        PRUint32 ip;                    /* The actual 32 bits of address */#ifdef XP_BEOS        char pad[4];                    /* Be has a smaller structure */#else        char pad[8];#endif    } inet;    struct {        PRUint16 family;                /* address family (AF_INET6) */        PRUint16 port;                  /* port number */        PRUint32 flowinfo;              /* routing information */        PRIPv6Addr ip;                  /* the actual 128 bits of address */        PRUint32 scope_id;              /* set of interfaces for a scope */    } ipv6;#if defined(XP_UNIX)    struct {                            /* Unix domain socket address */        PRUint16 family;                /* address family (AF_UNIX) */        char path[104];                 /* null-terminated pathname */    } local;#endif};/****************************************************************************** PRSockOption**** The file descriptors can have predefined options set after they file** descriptor is created to change their behavior. Only the options in** the following enumeration are supported.****************************************************************************/typedef enum PRSockOption{    PR_SockOpt_Nonblocking,     /* nonblocking io */    PR_SockOpt_Linger,          /* linger on close if data present */    PR_SockOpt_Reuseaddr,       /* allow local address reuse */    PR_SockOpt_Keepalive,       /* keep connections alive */    PR_SockOpt_RecvBufferSize,  /* send buffer size */    PR_SockOpt_SendBufferSize,  /* receive buffer size */    PR_SockOpt_IpTimeToLive,    /* time to live */    PR_SockOpt_IpTypeOfService, /* type of service and precedence */    PR_SockOpt_AddMember,       /* add an IP group membership */    PR_SockOpt_DropMember,      /* drop an IP group membership */    PR_SockOpt_McastInterface,  /* multicast interface address */    PR_SockOpt_McastTimeToLive, /* multicast timetolive */    PR_SockOpt_McastLoopback,   /* multicast loopback */    PR_SockOpt_NoDelay,         /* don't delay send to coalesce packets */    PR_SockOpt_MaxSegment,      /* maximum segment size */    PR_SockOpt_Broadcast,       /* enable broadcast */    PR_SockOpt_Last} PRSockOption;typedef struct PRLinger {	PRBool polarity;		    /* Polarity of the option's setting */	PRIntervalTime linger;	    /* Time to linger before closing */} PRLinger;typedef struct PRMcastRequest {	PRNetAddr mcaddr;			/* IP multicast address of group */	PRNetAddr ifaddr;			/* local IP address of interface */} PRMcastRequest;typedef struct PRSocketOptionData{    PRSockOption option;    union    {        PRUintn ip_ttl;             /* IP time to live */        PRUintn mcast_ttl;          /* IP multicast time to live */        PRUintn tos;                /* IP type of service and precedence */        PRBool non_blocking;        /* Non-blocking (network) I/O */        PRBool reuse_addr;          /* Allow local address reuse */        PRBool keep_alive;          /* Keep connections alive */        PRBool mcast_loopback;      /* IP multicast loopback */        PRBool no_delay;            /* Don't delay send to coalesce packets */        PRBool broadcast;           /* Enable broadcast */        PRSize max_segment;         /* Maximum segment size */        PRSize recv_buffer_size;    /* Receive buffer size */        PRSize send_buffer_size;    /* Send buffer size */        PRLinger linger;            /* Time to linger on close if data present */        PRMcastRequest add_member;  /* add an IP group membership */        PRMcastRequest drop_member; /* Drop an IP group membership */        PRNetAddr mcast_if;         /* multicast interface address */    } value;} PRSocketOptionData;/****************************************************************************** PRIOVec**** The I/O vector is used by the write vector method to describe the areas** that are affected by the ouput operation.****************************************************************************/typedef struct PRIOVec {    char *iov_base;    int iov_len;} PRIOVec;/****************************************************************************** Discover what type of socket is being described by the file descriptor.****************************************************************************/typedef enum PRDescType{    PR_DESC_FILE = 1,    PR_DESC_SOCKET_TCP = 2,    PR_DESC_SOCKET_UDP = 3,    PR_DESC_LAYERED = 4,    PR_DESC_PIPE = 5} PRDescType;typedef enum PRSeekWhence {    PR_SEEK_SET = 0,    PR_SEEK_CUR = 1,    PR_SEEK_END = 2} PRSeekWhence;NSPR_API(PRDescType) PR_GetDescType(PRFileDesc *file);/****************************************************************************** PRIOMethods**** The I/O methods table provides procedural access to the functions of** the file descriptor. It is the responsibility of a layer implementor** to provide suitable functions at every entry point. If a layer provides** no functionality, it should call the next lower(higher) function of the** same name (e.g., return fd->lower->method->close(fd->lower));**** Not all functions are implemented for all types of files. In cases where** that is true, the function will return a error indication with an error** code of PR_INVALID_METHOD_ERROR.****************************************************************************/typedef PRStatus (PR_CALLBACK *PRCloseFN)(PRFileDesc *fd);typedef PRInt32 (PR_CALLBACK *PRReadFN)(PRFileDesc *fd, void *buf, PRInt32 amount);typedef PRInt32 (PR_CALLBACK *PRWriteFN)(PRFileDesc *fd, const void *buf, PRInt32 amount);typedef PRInt32 (PR_CALLBACK *PRAvailableFN)(PRFileDesc *fd);typedef PRInt64 (PR_CALLBACK *PRAvailable64FN)(PRFileDesc *fd);typedef PRStatus (PR_CALLBACK *PRFsyncFN)(PRFileDesc *fd);typedef PROffset32 (PR_CALLBACK *PRSeekFN)(PRFileDesc *fd, PROffset32 offset, PRSeekWhence how);typedef PROffset64 (PR_CALLBACK *PRSeek64FN)(PRFileDesc *fd, PROffset64 offset, PRSeekWhence how);typedef PRStatus (PR_CALLBACK *PRFileInfoFN)(PRFileDesc *fd, PRFileInfo *info);typedef PRStatus (PR_CALLBACK *PRFileInfo64FN)(PRFileDesc *fd, PRFileInfo64 *info);typedef PRInt32 (PR_CALLBACK *PRWritevFN)(    PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,    PRIntervalTime timeout);typedef PRStatus (PR_CALLBACK *PRConnectFN)(    PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);typedef PRFileDesc* (PR_CALLBACK *PRAcceptFN) (    PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);typedef PRStatus (PR_CALLBACK *PRBindFN)(PRFileDesc *fd, const PRNetAddr *addr);typedef PRStatus (PR_CALLBACK *PRListenFN)(PRFileDesc *fd, PRIntn backlog);typedef PRStatus (PR_CALLBACK *PRShutdownFN)(PRFileDesc *fd, PRIntn how);

⌨️ 快捷键说明

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