24.2. Data Definitions for libnspr4

This section defines global identifiers and their values that are associated with interfaces contained in libnspr4. These definitions are organized into groups that correspond to system headers. This convention is used as a convenience for the reader, and does not imply the existence of these headers, or their content. Where an interface is defined as requiring a particular system header file all of the data definitions for that system header file presented here shall be in effect.

This section gives data definitions to promote binary application portability, not to repeat source interface definitions available elsewhere. System providers and application developers should use this ABI to supplement - not to replace - source interface definition specifications.

This specification uses the ISO C (1999) C Language as the reference programming language, and data definitions are specified in ISO C format. The C language is used here as a convenient notation. Using a C language description of these data objects does not preclude their use by other programming languages.

24.2.1. nspr4/nspr.h

#define nspr_h___

24.2.2. nspr4/plarena.h

#define plarena_h___

typedef struct PLArenaPool {
    struct PLArena first;
    struct PLArena *current;
    PRUint32 arenasize;
    PRUword mask;
} PLArenaPool;
struct PLArena {
    struct PLArena *next;
    PRUword base;
    PRUword limit;
    PRUword avail;

24.2.3. nspr4/plhash.h

#define plhash_h___

typedef PRUint32 PLHashNumber;
typedef PRIntn(*PLHashComparator) (const void *, const void *);
typedef struct PLHashAllocOps {
    void *(*allocTable) (void *, PRSize);
    void (*freeTable) (void *, void *);
    struct PLHashEntry *(*allocEntry) (void *, const void *);
    void (*freeEntry) (void *, struct PLHashEntry *, PRUintn);
} PLHashAllocOps;
typedef PLHashNumber(*PLHashFunction) (const void *);
struct PLHashEntry {
    struct PLHashEntry *next;
    PLHashNumber keyHash;
    const void *key;
    void *value;
struct PLHashTable {
    struct PLHashEntry **buckets;
    PRUint32 nentries;
    PRUint32 shift;
    PLHashFunction keyHash;
    PLHashComparator keyCompare;
    PLHashComparator valueCompare;
    const PLHashAllocOps *allocOps;
    void *allocPriv;

24.2.4. nspr4/pratom.h

#define PR_ATOMIC_ADD(val)	PR_AtomicAdd(val)
#define PR_ATOMIC_DECREMENT(val)	PR_AtomicDecrement(val)
#define PR_ATOMIC_INCREMENT(val)	PR_AtomicIncrement(val)
#define PR_ATOMIC_SET(val)	PR_AtomicSet(val)

extern PRInt32 PR_AtomicAdd(PRInt32 * ptr, PRInt32 val);
extern PRInt32 PR_AtomicDecrement(PRInt32 * val);
extern PRInt32 PR_AtomicIncrement(PRInt32 * val);
extern PRInt32 PR_AtomicSet(PRInt32 * val, PRInt32 newval);

24.2.5. nspr4/prclist.h

#define prclist_h___

typedef struct PRCListStr {
    PRCList *next;
    PRCList *prev;
} PRCList;

24.2.6. nspr4/prcvar.h

typedef struct PRCondVar PRCondVar;
extern void PR_DestroyCondVar(PRCondVar * cvar);
extern PRCondVar *PR_NewCondVar(PRLock * lock);
extern PRStatus PR_NotifyAllCondVar(PRCondVar * cvar);
extern PRStatus PR_NotifyCondVar(PRCondVar * cvar);
extern PRStatus PR_WaitCondVar(PRCondVar * cvar, PRIntervalTime timeout);

24.2.7. nspr4/prerror.h

#define prerror_h___

typedef PRInt32 PRErrorCode;
extern PRErrorCode PR_GetError(void);
extern PRInt32 PR_GetErrorText(char *text);
extern PRInt32 PR_GetErrorTextLength(void);
extern PRInt32 PR_GetOSError(void);
extern void PR_SetError(PRErrorCode errorCode, PRInt32 oserr);
extern void PR_SetErrorText(PRIntn textLength, const char *text);

24.2.8. nspr4/prinit.h

#define prinit_h___

typedef PRIntn(*PRPrimordialFn) (PRIntn argc, char **argv);
typedef PRStatus(*PRCallOnceFN) (void);
typedef PRStatus(*PRCallOnceWithArgFN) (void *arg);
extern void PR_Abort(void);
extern PRStatus PR_Cleanup(void);
extern void PR_Init(PRThreadType type, PRThreadPriority priority,
		    PRUintn maxPTDs);
extern PRIntn PR_Initialize(PRPrimordialFn prmain, PRIntn argc,
			    char **argv, PRUintn maxPTDs);
extern PRBool PR_Initialized(void);
extern void PR_ProcessExit(PRIntn status);

24.2.9. nspr4/prinrval.h

#define prinrval_h
#define PR_INTERVAL_NO_TIMEOUT	0xffffffffUL

typedef PRUint32 PRIntervalTime;
extern PRIntervalTime PR_IntervalNow(void);
extern PRUint32 PR_IntervalToMicroseconds(PRIntervalTime ticks);
extern PRUint32 PR_IntervalToMilliseconds(PRIntervalTime ticks);
extern PRUint32 PR_IntervalToSeconds(PRIntervalTime ticks);
extern PRIntervalTime PR_MicrosecondsToInterval(PRUint32 micro);
extern PRIntervalTime PR_MillisecondsToInterval(PRUint32 milli);
extern PRIntervalTime PR_SecondsToInterval(PRUint32 seconds);
extern PRUint32 PR_TicksPerSecond(void);

24.2.10. nspr4/prio.h

#define prio_h___
#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

typedef enum PRDescType {
    PR_DESC_FILE = 1,
    PR_DESC_PIPE = 5
} PRDescType;
typedef struct PRIPv6Addr {
    union {
	PRUint8 _S6_u8[15];
	PRUint16 _S6_u16[7];
	PRUint32 _S6_u32[3];
	PRUint64 _S6_u64[1];
    } _S6_un;
} PRIPv6Addr;
typedef enum PRTransmitFileFlags {
} PRTransmitFileFlags;
typedef struct PRLinger {
    PRBool polarity;
    PRIntervalTime linger;
} PRLinger;
typedef struct PRFilePrivate PRFilePrivate;
typedef struct PRFileDesc {
    const struct PRIOMethods *methods;
    PRFilePrivate *secret;
    PRFileDesc *lower;
    PRFileDesc *higher;
    void (*dtor) (PRFileDesc *);
    PRDescIdentity identity;
} PRFileDesc;
typedef union PRNetAddr {
    struct {
	PRUint16 family;
	char data[14];
    } raw;
    struct {
	PRUint16 family;
	PRUint16 port;
	PRUint32 ip;
	char pad[7];
    } inet;
    struct {
	PRUint16 family;
	PRUint16 port;
	PRUint32 flowinfo;
	PRIPv6Addr ip;
	PRUint32 scope_id;
    } ipv6;
    struct {
	PRUint16 family;
	char path[103];
    } local;
} PRNetAddr;
typedef struct PRMcastRequest {
    union PRNetAddr mcaddr;
    union PRNetAddr ifaddr;
} PRMcastRequest;
typedef struct PRIOVec {
    char *iov_base;
    int iov_len;
} PRIOVec;
typedef struct PRSocketOptionData {
    PRSockOption option;
    union {
	PRUintn ip_ttl;
	PRUintn mcast_ttl;
	PRUintn tos;
	PRBool non_blocking;
	PRBool reuse_addr;
	PRBool keep_alive;
	PRBool mcast_loopback;
	PRBool no_delay;
	PRBool broadcast;
	PRSize max_segment;
	PRSize recv_buffer_size;
	PRSize send_buffer_size;
	PRLinger linger;
	PRMcastRequest add_member;
	PRMcastRequest drop_member;
	union PRNetAddr mcast_if;
    } value;
} PRSocketOptionData;
typedef PRStatus(*PRFsyncFN) (PRFileDesc * fd);
typedef PRStatus(*PRListenFN) (PRFileDesc * fd, PRIntn how);
typedef enum PRSeekWhence {
    PR_SEEK_SET = 0,
    PR_SEEK_CUR = 1,
    PR_SEEK_END = 2
} PRSeekWhence;
typedef PRInt32(*PRAcceptreadFN) (PRFileDesc * sd, PRFileDesc * *nd,
				  PRNetAddr * *raddr, void *buf,
				  PRInt32 amount, PRIntervalTime t);
typedef PRStatus(*PRCloseFN) (PRFileDesc * fd);
typedef PRInt32(*PRTransmitfileFN) (PRFileDesc * sd, PRFileDesc * fd,
				    const void *headers, PRInt32 hlen,
				    PRTransmitFileFlags flags,
				    PRIntervalTime t);
typedef enum PRSockOption {
    PR_SockOpt_Linger = 1,
    PR_SockOpt_Reuseaddr = 2,
    PR_SockOpt_Keepalive = 3,
    PR_SockOpt_RecvBufferSize = 4,
    PR_SockOpt_SendBufferSize = 5,
    PR_SockOpt_IpTimeToLive = 6,
    PR_SockOpt_IpTypeOfService = 7,
    PR_SockOpt_AddMember = 8,
    PR_SockOpt_DropMember = 9,
    PR_SockOpt_McastInterface = 10,
    PR_SockOpt_McastTimeToLive = 11,
    PR_SockOpt_McastLoopback = 12,
    PR_SockOpt_NoDelay = 13,
    PR_SockOpt_MaxSegment = 14,
    PR_SockOpt_Broadcast = 15,
    PR_SockOpt_Last = 16
} PRSockOption;
typedef PRFileDesc *(*PRAcceptFN) (PRFileDesc * fd, PRNetAddr * addr,
				   PRIntervalTime timeout);
typedef PRStatus(*PRConnectcontinueFN) (PRFileDesc * fd,
					PRInt16 out_flags);
typedef PRInt32(*PRReadFN) (PRFileDesc * fd, void *buf, PRInt32 amount);
typedef struct PRFileInfo64 {
    PRFileType type;
    PROffset64 size;
    PRTime creationTime;
    PRTime modifyTime;
} PRFileInfo64;
typedef PRStatus(*PRGetsocketoptionFN) (PRFileDesc * fd,
					PRSocketOptionData * data);
typedef PRInt32(*PRSendtoFN) (PRFileDesc * fd, const void *buf,
			      PRInt32 amount, PRIntn flags,
			      const PRNetAddr * addr,
			      PRIntervalTime timeout);
typedef PRStatus(*PRGetsocknameFN) (PRFileDesc * fd, PRNetAddr * addr);
typedef PRInt32(*PRSendFN) (PRFileDesc * fd, const void *buf,
			    PRInt32 amount, PRIntn flags,
			    PRIntervalTime timeout);
typedef PROffset32(*PRSeekFN) (PRFileDesc * fd, PROffset32 offset,
			       PRSeekWhence how);
typedef PRInt64(*PRAvailable64FN) (PRFileDesc * fd);
typedef PRInt32(*PRAvailableFN) (PRFileDesc * fd);
typedef struct PRFileInfo {
    PRFileType type;
    PROffset32 size;
    PRTime creationTime;
    PRTime modifyTime;
} PRFileInfo;
typedef PROffset64(*PRSeek64FN) (PRFileDesc * fd, PROffset64 offset,
				 PRSeekWhence how);
typedef PRStatus(*PRSetsocketoptionFN) (PRFileDesc * fd,
					const PRSocketOptionData * data);
typedef PRInt32(*PRRecvFN) (PRFileDesc * fd, void *buf, PRInt32 amount,
			    PRIntn flags, PRIntervalTime timeout);
typedef struct PRSendFileData {
    PRFileDesc *fd;
    PRUint32 file_offset;
    PRSize file_nbytes;
    const void *header;
    PRInt32 hlen;
    const void *trailer;
    PRInt32 tlen;
} PRSendFileData;
typedef PRIntn PRDescIdentity;
typedef PRStatus(*PRConnectFN) (PRFileDesc * fd, const PRNetAddr * addr,
				PRIntervalTime timeout);
typedef PRInt32(*PRSendfileFN) (PRFileDesc * networkSocket,
				PRSendFileData * sendData,
				PRTransmitFileFlags flags,
				PRIntervalTime timeout);
typedef PRInt32(*PRRecvfromFN) (PRFileDesc * fd, void *buf, PRInt32 amount,
				PRIntn flags, PRNetAddr * addr,
				PRIntervalTime timeout);
typedef struct PRPollDesc {
    PRFileDesc *fd;
    PRInt16 in_flags;
    PRInt16 out_flags;
} PRPollDesc;
typedef PRInt32(*PRWriteFN) (PRFileDesc * fd, const void *buf,
			     PRInt32 amount);
typedef PRStatus(*PRFileInfo64FN) (PRFileDesc * fd, PRFileInfo64 * info);
typedef PRStatus(*PRShutdownFN) (PRFileDesc * fd, PRIntn how);
typedef PRIntn(*PRReservedFN) (PRFileDesc * fd);
typedef PRStatus(*PRFileInfoFN) (PRFileDesc * fd, PRFileInfo * info);
typedef PRInt32(*PRWritevFN) (PRFileDesc * fd, const PRIOVec * iov,
			      PRInt32 iov_size, PRIntervalTime timeout);
typedef enum PRFileType {
    PR_FILE_FILE = 1,
} PRFileType;
typedef PRStatus(*PRBindFN) (PRFileDesc * fd, const PRNetAddr * addr);
typedef PRInt16(*PRPollFN) (PRFileDesc * fd, PRInt16 in_flags,
			    PRInt16 * out_flags);
struct PRIOMethods {
    PRDescType file_type;
    PRCloseFN close;
    PRReadFN read;
    PRWriteFN write;
    PRAvailableFN available;
    PRAvailable64FN available64;
    PRFsyncFN fsync;
    PRSeekFN seek;
    PRSeek64FN seek64;
    PRFileInfoFN fileInfo;
    PRFileInfo64FN fileInfo64;
    PRWritevFN writev;
    PRConnectFN connect;
    PRAcceptFN accept;
    PRBindFN bind;
    PRListenFN listen;
    PRShutdownFN shutdown;
    PRRecvFN recv;
    PRSendFN send;
    PRRecvfromFN recvfrom;
    PRSendtoFN sendto;
    PRPollFN poll;
    PRAcceptreadFN acceptread;
    PRTransmitfileFN transmitfile;
    PRGetsocknameFN getsockname;
    PRGetpeernameFN getpeername;
    PRReservedFN reserved_fn_6;
    PRReservedFN reserved_fn_5;
    PRGetsocketoptionFN getsocketoption;
    PRSetsocketoptionFN setsocketoption;
    PRSendfileFN sendfile;
    PRConnectcontinueFN connectcontinue;
    PRReservedFN reserved_fn_3;
    PRReservedFN reserved_fn_2;
    PRReservedFN reserved_fn_1;
    PRReservedFN reserved_fn_0;
typedef PRStatus(*PRGetpeernameFN) (PRFileDesc * fd, PRNetAddr * addr);
typedef enum PRShutdownHow {
} PRShutdownHow;
extern PRFileDesc *PR_Accept(PRFileDesc * fd, PRNetAddr * addr,
			     PRIntervalTime timeout);
extern PRStatus PR_Bind(PRFileDesc * fd, const PRNetAddr * addr);
extern PRStatus PR_Close(PRFileDesc * fd);
extern PRStatus PR_Connect(PRFileDesc * fd, const PRNetAddr * addr,
			   PRIntervalTime timeout);
extern PRStatus PR_ConnectContinue(PRFileDesc * fd, PRInt16 out_flags);
extern PRFileDesc *PR_CreateIOLayerStub(PRDescIdentity ident,
					const struct PRIOMethods *methods);
extern PRStatus PR_CreatePipe(PRFileDesc * *readPipe,
			      PRFileDesc * *writePipe);
extern const struct PRIOMethods *PR_GetDefaultIOMethods(void);
extern PRDescType PR_GetDescType(PRFileDesc * file);
extern PRDescIdentity PR_GetLayersIdentity(PRFileDesc * fd);
extern PRStatus PR_GetSocketOption(PRFileDesc * fd,
				   PRSocketOptionData * data);
extern PRDescIdentity PR_GetUniqueIdentity(const char *layer_name);
extern PRStatus PR_Listen(PRFileDesc * fd, PRIntn backlog);
extern PRFileDesc *PR_Open(const char *name, PRIntn flags, PRIntn mode);
extern PRFileDesc *PR_OpenTCPSocket(PRIntn af);
extern PRFileDesc *PR_OpenUDPSocket(PRIntn af);
extern PRInt32 PR_Poll(PRPollDesc * pds, PRIntn npds,
		       PRIntervalTime timeout);
extern PRFileDesc *PR_PopIOLayer(PRFileDesc * fd_stack, PRDescIdentity id);
extern PRStatus PR_PushIOLayer(PRFileDesc * fd_stack, PRDescIdentity id,
			       PRFileDesc * layer);
extern PRInt32 PR_Read(PRFileDesc * fd, void *buf, PRInt32 amount);
extern PRInt32 PR_Recv(PRFileDesc * fd, void *buf, PRInt32 amount,
		       PRIntn flags, PRIntervalTime timeout);
extern PRInt32 PR_RecvFrom(PRFileDesc * fd, void *buf, PRInt32 amount,
			   PRIntn flags, PRNetAddr * addr,
			   PRIntervalTime timeout);
extern PRInt32 PR_Send(PRFileDesc * fd, const void *buf, PRInt32 amount,
		       PRIntn flags, PRIntervalTime timeout);
extern PRInt32 PR_SendTo(PRFileDesc * fd, const void *buf, PRInt32 amount,
			 PRIntn flags, const PRNetAddr * addr,
			 PRIntervalTime timeout);
extern PRStatus PR_SetSocketOption(PRFileDesc * fd,
				   const PRSocketOptionData * data);
extern PRStatus PR_Shutdown(PRFileDesc * fd, PRShutdownHow how);
extern PRInt32 PR_Write(PRFileDesc * fd, const void *buf, PRInt32 amount);

24.2.11. nspr4/private/pprio.h

#define pprio_h___

typedef PRInt32 PROsfd;
extern PRFileDesc *PR_ImportTCPSocket(PROsfd osfd);

24.2.12. nspr4/prlock.h

#define prlock_h___

typedef struct PRLock PRLock;
extern void PR_DestroyLock(PRLock * lock);
extern void PR_Lock(PRLock * lock);
extern PRLock *PR_NewLock(void);
extern PRStatus PR_Unlock(PRLock * lock);

24.2.13. nspr4/prmem.h

#define PR_NEW(_struct)	((_struct *) PR_MALLOC(sizeof(_struct)))
#define PR_NEWZAP(_struct)	((_struct*)PR_Calloc(1, sizeof(_struct)))
#define PR_CALLOC(_size)	(PR_Calloc(1, (_size)))
#define PR_MALLOC(_bytes)	(PR_Malloc(_bytes))
#define PR_REALLOC(_ptr, _size)	(PR_Realloc((_ptr), (_size)))
#define PR_FREEIF(_ptr)	if (_ptr) PR_DELETE(_ptr)
#define PR_DELETE(_ptr)	{ PR_Free(_ptr); (_ptr) = NULL; }

extern void *PR_Calloc(PRUint32 nelem, PRUint32 elsize);
extern void PR_Free(void *ptr);
extern void *PR_Malloc(PRUint32 size);
extern void *PR_Realloc(void *ptr, PRUint32 size);

24.2.14. nspr4/prmon.h

#define prmon_h___

typedef struct PRMonitor PRMonitor;

24.2.15. nspr4/prnetdb.h

#define prnetdb_h___
#define PR_NetAddrFamily(addr)	((addr)->raw.family)
#define PR_NetAddrInetPort(addr)	\
     ((addr)->raw.family == PR_AF_INET6 ? (addr)->ipv6.port : (addr)->inet.port)

typedef struct PRHostEnt {
    char *h_name;
    char **h_aliases;
    PRInt32 h_addrtype;
    PRInt32 h_length;
    char **h_addr_list;
} PRHostEnt;
typedef struct PRAddrInfo PRAddrInfo;
typedef enum PRNetAddrValue {
} PRNetAddrValue;
extern void PR_ConvertIPv4AddrToIPv6(PRUint32 v4addr, PRIPv6Addr * v6addr);
extern void *PR_EnumerateAddrInfo(void *enumPtr,
				  const PRAddrInfo * addrInfo,
				  PRUint16 port, PRNetAddr * result);
extern void PR_FreeAddrInfo(PRAddrInfo * addrInfo);
extern PRAddrInfo *PR_GetAddrInfoByName(const char *hostname, PRUint16 af,
					PRIntn flags);
extern const char *PR_GetCanonNameFromAddrInfo(const PRAddrInfo *
extern PRStatus PR_InitializeNetAddr(PRNetAddrValue val, PRUint16 port,
				     PRNetAddr * addr);
extern PRStatus PR_NetAddrToString(const PRNetAddr * addr, char *string,
				   PRUint32 size);
extern PRStatus PR_StringToNetAddr(const char *string, PRNetAddr * addr);

24.2.16. nspr4/prthread.h

#define prthread_h___

typedef struct PRThread PRThread;
typedef enum PRThreadType {
} PRThreadType;
typedef enum PRThreadScope {
} PRThreadScope;
typedef enum PRThreadState {
} PRThreadState;
typedef enum PRThreadPriority {
} PRThreadPriority;
typedef void (*PRThreadPrivateDTOR) (void *priv);
extern PRStatus PR_ClearInterrupt(void);
extern void *PR_GetThreadPrivate(PRUintn tpdIndex);
extern PRThreadScope PR_GetThreadScope(const PRThread * thread);
extern PRThreadState PR_GetThreadState(const PRThread * thread);
extern PRStatus PR_Interrupt(PRThread * thread);
extern PRStatus PR_NewThreadPrivateIndex(PRUintn * newIndex,
					 PRThreadPrivateDTOR destructor);
extern PRStatus PR_SetThreadPrivate(PRUintn tpIndex, void *priv);
extern PRStatus PR_Sleep(PRIntervalTime ticks);

24.2.17. nspr4/prtime.h

#define prtime_h___

typedef PRInt64 PRTime;
typedef struct PRTimeParameters {
    PRInt32 tp_gmt_offset;
    PRInt32 tp_dst_offset;
} PRTimeParameters;
typedef struct PRExplodedTime {
    PRInt32 tm_usec;
    PRInt32 tm_sec;
    PRInt32 tm_min;
    PRInt32 tm_hour;
    PRInt32 tm_mday;
    PRInt32 tm_month;
    PRInt16 tm_year;
    PRInt8 tm_wday;
    PRInt16 tm_yday;
    PRTimeParameters tm_params;
} PRExplodedTime;
typedef PRTimeParameters(*PRTimeParamFn) (const PRExplodedTime * gmt);
extern void PR_ExplodeTime(PRTime usecs, PRTimeParamFn params,
			   PRExplodedTime * expoded);
extern PRUint32 PR_FormatTime(char *buf, int buflen, const char *fmt,
			      const PRExplodedTime * tm);
extern PRTimeParameters PR_GMTParameters(const PRExplodedTime * gmt);
extern PRTime PR_ImplodeTime(const PRExplodedTime * exploded);
extern PRTimeParameters PR_LocalTimeParameters(const PRExplodedTime * gmt);
extern void PR_NormalizeTime(PRExplodedTime * exploded,
			     PRTimeParamFn params);
extern PRTime PR_Now(void);
extern PRStatus PR_ParseTimeString(const char *string,
				   PRBool default_to_gmt, PRTime * result);
extern PRStatus PR_ParseTimeStringToExplodedTime(const char *string,
						 PRBool default_to_gmt,
						 PRExplodedTime * result);

24.2.18. nspr4/prtypes.h

#define prtypes_h___

typedef int PRInt32;
typedef unsigned long int PRUword;
typedef int PRIntn;
typedef unsigned long int PRUint64;
typedef unsigned char PRUint8;
typedef short int PRInt16;
typedef long int PRInt64;
typedef PRIntn PRBool;
typedef unsigned short PRUint16;
typedef unsigned int PRUint32;
typedef size_t PRSize;
typedef unsigned int PRUintn;
typedef PRInt64 PROffset64;
typedef PRInt32 PROffset32;
typedef enum {
    PR_FAILURE = -1,
    PR_SUCCESS = 0
} PRStatus;
typedef signed char PRInt8;