15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The contents of this file are subject to the Mozilla Public
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * License Version 1.1 (the "License"); you may not use this file
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * except in compliance with the License. You may obtain a copy of
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the License at http://www.mozilla.org/MPL/
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Software distributed under the License is distributed on an "AS
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * implied. See the License for the specific language governing
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * rights and limitations under the License.
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Original Code is the Netscape Portable Runtime (NSPR).
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * The Initial Developer of the Original Code is Netscape
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Communications Corporation.  Portions created by Netscape are
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (C) 1998-2000 Netscape Communications Corporation.  All
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Rights Reserved.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Contributor(s):
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Alternatively, the contents of this file may be used under the
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * terms of the GNU General Public License Version 2 or later (the
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * "GPL"), in which case the provisions of the GPL are applicable
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * instead of those above.  If you wish to allow use of your
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * version of this file only under the terms of the GPL and not to
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * allow others to use your version of this file under the MPL,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * indicate your decision by deleting the provisions above and
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * replace them with the notice and other provisions required by
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the GPL.  If you do not delete the provisions above, a recipient
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * may use your version of this file under either the MPL or the
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * GPL.
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * File:     prio.h
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Description:    PR i/o related stuff, such as file system access, file
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         i/o, socket i/o, etc.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef prio_h___
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define prio_h___
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prlong.h"
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prtime.h"
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prinrval.h"
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "prinet.h"
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)PR_BEGIN_EXTERN_C
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Typedefs */
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRDir            PRDir;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRDirEntry       PRDirEntry;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef MOZ_UNICODE
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRDirUTF16       PRDirUTF16;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRDirEntryUTF16  PRDirEntryUTF16;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* MOZ_UNICODE */
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRFileDesc       PRFileDesc;
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRFileInfo       PRFileInfo;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRFileInfo64     PRFileInfo64;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef union  PRNetAddr        PRNetAddr;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRIOMethods      PRIOMethods;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRPollDesc       PRPollDesc;
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRFilePrivate    PRFilePrivate;
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRSendFileData   PRSendFileData;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The file descriptor.
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** This is the primary structure to represent any active open socket,
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** whether it be a normal file or a network connection. Such objects
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** are stackable (or layerable). Each layer may have its own set of
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** method pointers and context private to that layer. All each layer
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** knows about its neighbors is how to get to their method table.
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRIntn PRDescIdentity;          /* see: Layering file descriptors */
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRFileDesc {
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const PRIOMethods *methods;         /* the I/O methods table */
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFilePrivate *secret;              /* layer dependent data */
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *lower, *higher;         /* pointers to adjacent layers */
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    void (PR_CALLBACK *dtor)(PRFileDesc *fd);
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        /* A destructor function for layer */
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRDescIdentity identity;            /* Identity of this particular layer  */
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRTransmitFileFlags
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Flags for PR_TransmitFile.  Pass PR_TRANSMITFILE_CLOSE_SOCKET to
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PR_TransmitFile if the connection should be closed after the file
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** is transmitted.
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRTransmitFileFlags {
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_TRANSMITFILE_KEEP_OPEN = 0,    /* socket is left open after file
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       * is transmitted. */
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_TRANSMITFILE_CLOSE_SOCKET = 1  /* socket is closed after file
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                       * is transmitted. */
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRTransmitFileFlags;
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**************************************************************************
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Macros for PRNetAddr
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Address families: PR_AF_INET, PR_AF_INET6, PR_AF_LOCAL
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** IP addresses: PR_INADDR_ANY, PR_INADDR_LOOPBACK, PR_INADDR_BROADCAST
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**************************************************************************
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef WIN32
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_INET 2
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_LOCAL 1
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_ANY (unsigned long)0x00000000
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_LOOPBACK 0x7f000001
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_BROADCAST (unsigned long)0xffffffff
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else /* WIN32 */
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_INET AF_INET
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_LOCAL AF_UNIX
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_ANY INADDR_ANY
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_LOOPBACK INADDR_LOOPBACK
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INADDR_BROADCAST INADDR_BROADCAST
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* WIN32 */
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Define PR_AF_INET6 in prcpucfg.h with the same
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** value as AF_INET6 on platforms with IPv6 support.
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Otherwise define it here.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PR_AF_INET6
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_INET6 100
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef PR_AF_UNSPEC
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_AF_UNSPEC 0
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**************************************************************************
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** A network address
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Only Internet Protocol (IPv4 and IPv6) addresses are supported.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The address family must always represent IPv4 (AF_INET, probably == 2)
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** or IPv6 (AF_INET6).
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**************************************************************************
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*************************************************************************/
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRIPv6Addr {
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	union {
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRUint8  _S6_u8[16];
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRUint16 _S6_u16[8];
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRUint32 _S6_u32[4];
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)		PRUint64 _S6_u64[2];
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	} _S6_un;
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define pr_s6_addr		_S6_un._S6_u8
1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define pr_s6_addr16	_S6_un._S6_u16
1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define pr_s6_addr32	_S6_un._S6_u32
1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define pr_s6_addr64 	_S6_un._S6_u64
1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRIPv6Addr PRIPv6Addr;
1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)union PRNetAddr {
1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    struct {
1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 family;                /* address family (0x00ff maskable) */
1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef XP_BEOS
1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char data[10];                  /* Be has a smaller structure */
1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char data[14];                  /* raw address data */
1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } raw;
1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    struct {
1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 family;                /* address family (AF_INET) */
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 port;                  /* port number */
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint32 ip;                    /* The actual 32 bits of address */
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef XP_BEOS
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char pad[4];                    /* Be has a smaller structure */
1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char pad[8];
1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } inet;
1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    struct {
1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 family;                /* address family (AF_INET6) */
1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 port;                  /* port number */
1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint32 flowinfo;              /* routing information */
1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRIPv6Addr ip;                  /* the actual 128 bits of address */
1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint32 scope_id;              /* set of interfaces for a scope */
1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } ipv6;
1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(XP_UNIX) || defined(XP_OS2)
1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    struct {                            /* Unix domain socket address */
1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUint16 family;                /* address family (AF_UNIX) */
2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef XP_OS2
2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char path[108];                 /* null-terminated pathname */
2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                        /* bind fails if size is not 108. */
2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else
2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        char path[104];                 /* null-terminated pathname */
2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } local;
2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRSockOption
2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The file descriptors can have predefined options set after they file
2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** descriptor is created to change their behavior. Only the options in
2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the following enumeration are supported.
2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRSockOption
2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Nonblocking,     /* nonblocking io */
2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Linger,          /* linger on close if data present */
2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Reuseaddr,       /* allow local address reuse */
2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Keepalive,       /* keep connections alive */
2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_RecvBufferSize,  /* send buffer size */
2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_SendBufferSize,  /* receive buffer size */
2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_IpTimeToLive,    /* time to live */
2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_IpTypeOfService, /* type of service and precedence */
2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_AddMember,       /* add an IP group membership */
2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_DropMember,      /* drop an IP group membership */
2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_McastInterface,  /* multicast interface address */
2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_McastTimeToLive, /* multicast timetolive */
2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_McastLoopback,   /* multicast loopback */
2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_NoDelay,         /* don't delay send to coalesce packets */
2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_MaxSegment,      /* maximum segment size */
2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Broadcast,       /* enable broadcast */
2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SockOpt_Last
2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRSockOption;
2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRLinger {
2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRBool polarity;		    /* Polarity of the option's setting */
2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRIntervalTime linger;	    /* Time to linger before closing */
2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRLinger;
2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRMcastRequest {
2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRNetAddr mcaddr;			/* IP multicast address of group */
2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRNetAddr ifaddr;			/* local IP address of interface */
2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRMcastRequest;
2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRSocketOptionData
2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSockOption option;
2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    union
2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    {
2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUintn ip_ttl;             /* IP time to live */
2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUintn mcast_ttl;          /* IP multicast time to live */
2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRUintn tos;                /* IP type of service and precedence */
2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool non_blocking;        /* Non-blocking (network) I/O */
2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool reuse_addr;          /* Allow local address reuse */
2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool keep_alive;          /* Keep connections alive */
2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool mcast_loopback;      /* IP multicast loopback */
2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool no_delay;            /* Don't delay send to coalesce packets */
2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRBool broadcast;           /* Enable broadcast */
2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRSize max_segment;         /* Maximum segment size */
2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRSize recv_buffer_size;    /* Receive buffer size */
2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRSize send_buffer_size;    /* Send buffer size */
2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRLinger linger;            /* Time to linger on close if data present */
2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRMcastRequest add_member;  /* add an IP group membership */
2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRMcastRequest drop_member; /* Drop an IP group membership */
2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        PRNetAddr mcast_if;         /* multicast interface address */
2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } value;
2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRSocketOptionData;
2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRIOVec
2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The I/O vector is used by the write vector method to describe the areas
2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** that are affected by the ouput operation.
2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct PRIOVec {
2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    char *iov_base;
2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    int iov_len;
2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRIOVec;
2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Discover what type of socket is being described by the file descriptor.
2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
2945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRDescType
2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_DESC_FILE = 1,
2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_DESC_SOCKET_TCP = 2,
2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_DESC_SOCKET_UDP = 3,
3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_DESC_LAYERED = 4,
3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_DESC_PIPE = 5
3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRDescType;
3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRSeekWhence {
3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SEEK_SET = 0,
3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SEEK_CUR = 1,
3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_SEEK_END = 2
3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRSeekWhence;
3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRDescType) PR_GetDescType(PRFileDesc *file);
3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** PRIOMethods
3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The I/O methods table provides procedural access to the functions of
3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** the file descriptor. It is the responsibility of a layer implementor
3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** to provide suitable functions at every entry point. If a layer provides
3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** no functionality, it should call the next lower(higher) function of the
3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** same name (e.g., return fd->lower->method->close(fd->lower));
3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** Not all functions are implemented for all types of files. In cases where
3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** that is true, the function will return a error indication with an error
3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** code of PR_INVALID_METHOD_ERROR.
3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)***************************************************************************
3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRCloseFN)(PRFileDesc *fd);
3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRReadFN)(PRFileDesc *fd, void *buf, PRInt32 amount);
3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRWriteFN)(PRFileDesc *fd, const void *buf, PRInt32 amount);
3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRAvailableFN)(PRFileDesc *fd);
3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt64 (PR_CALLBACK *PRAvailable64FN)(PRFileDesc *fd);
3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRFsyncFN)(PRFileDesc *fd);
3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PROffset32 (PR_CALLBACK *PRSeekFN)(PRFileDesc *fd, PROffset32 offset, PRSeekWhence how);
3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PROffset64 (PR_CALLBACK *PRSeek64FN)(PRFileDesc *fd, PROffset64 offset, PRSeekWhence how);
3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRFileInfoFN)(PRFileDesc *fd, PRFileInfo *info);
3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRFileInfo64FN)(PRFileDesc *fd, PRFileInfo64 *info);
3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRWritevFN)(
3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntervalTime timeout);
3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRConnectFN)(
3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);
3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRFileDesc* (PR_CALLBACK *PRAcceptFN) (
3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);
3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRBindFN)(PRFileDesc *fd, const PRNetAddr *addr);
3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRListenFN)(PRFileDesc *fd, PRIntn backlog);
3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRShutdownFN)(PRFileDesc *fd, PRIntn how);
3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRRecvFN)(
3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, void *buf, PRInt32 amount,
3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntn flags, PRIntervalTime timeout);
3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRSendFN) (
3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const void *buf, PRInt32 amount,
3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntn flags, PRIntervalTime timeout);
3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRRecvfromFN)(
3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, void *buf, PRInt32 amount,
3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntn flags, PRNetAddr *addr, PRIntervalTime timeout);
3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRSendtoFN)(
3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const void *buf, PRInt32 amount,
3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntn flags, const PRNetAddr *addr, PRIntervalTime timeout);
3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt16 (PR_CALLBACK *PRPollFN)(
3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags);
3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRAcceptreadFN)(
3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *sd, PRFileDesc **nd, PRNetAddr **raddr,
3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    void *buf, PRInt32 amount, PRIntervalTime t);
3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRTransmitfileFN)(
3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)     PRFileDesc *sd, PRFileDesc *fd, const void *headers,
3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)     PRInt32 hlen, PRTransmitFileFlags flags, PRIntervalTime t);
3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRGetsocknameFN)(PRFileDesc *fd, PRNetAddr *addr);
3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRGetpeernameFN)(PRFileDesc *fd, PRNetAddr *addr);
3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRGetsocketoptionFN)(
3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, PRSocketOptionData *data);
3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRSetsocketoptionFN)(
3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const PRSocketOptionData *data);
3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRInt32 (PR_CALLBACK *PRSendfileFN)(
3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRFileDesc *networkSocket, PRSendFileData *sendData,
3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)	PRTransmitFileFlags flags, PRIntervalTime timeout);
3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRStatus (PR_CALLBACK *PRConnectcontinueFN)(
3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, PRInt16 out_flags);
3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef PRIntn (PR_CALLBACK *PRReservedFN)(PRFileDesc *fd);
3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRIOMethods {
3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRDescType file_type;           /* Type of file represented (tos)           */
3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRCloseFN close;                /* close file and destroy descriptor        */
3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReadFN read;                  /* read up to specified bytes into buffer   */
3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRWriteFN write;                /* write specified bytes from buffer        */
3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRAvailableFN available;        /* determine number of bytes available      */
3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRAvailable64FN available64;    /*          ditto, 64 bit                   */
3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFsyncFN fsync;                /* flush all buffers to permanent store     */
3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSeekFN seek;                  /* position the file to the desired place   */
3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSeek64FN seek64;              /*           ditto, 64 bit                  */
3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileInfoFN fileInfo;          /* Get information about an open file       */
3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileInfo64FN fileInfo64;      /*           ditto, 64 bit                  */
3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRWritevFN writev;              /* Write segments as described by iovector  */
3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRConnectFN connect;            /* Connect to the specified (net) address   */
3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRAcceptFN accept;              /* Accept a connection for a (net) peer     */
3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRBindFN bind;                  /* Associate a (net) address with the fd    */
3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRListenFN listen;              /* Prepare to listen for (net) connections  */
3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRShutdownFN shutdown;          /* Shutdown a (net) connection              */
3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRRecvFN recv;                  /* Solicit up the the specified bytes       */
4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSendFN send;                  /* Send all the bytes specified             */
4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRRecvfromFN recvfrom;          /* Solicit (net) bytes and report source    */
4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSendtoFN sendto;              /* Send bytes to (net) address specified    */
4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRPollFN poll;                  /* Test the fd to see if it is ready        */
4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRAcceptreadFN acceptread;      /* Accept and read on a new (net) fd        */
4055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRTransmitfileFN transmitfile;  /* Transmit at entire file                  */
4065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRGetsocknameFN getsockname;    /* Get (net) address associated with fd     */
4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRGetpeernameFN getpeername;    /* Get peer's (net) address                 */
4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_6;     /* reserved for future use */
4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_5;     /* reserved for future use */
4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRGetsocketoptionFN getsocketoption;
4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    /* Get current setting of specified option  */
4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSetsocketoptionFN setsocketoption;
4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    /* Set value of specified option            */
4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRSendfileFN sendfile;			/* Send a (partial) file with header/trailer*/
4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRConnectcontinueFN connectcontinue;
4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                    /* Continue a nonblocking connect */
4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_3;		/* reserved for future use */
4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_2;		/* reserved for future use */
4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_1;		/* reserved for future use */
4205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRReservedFN reserved_fn_0;		/* reserved for future use */
4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_GetSpecialFD
4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION: Get the file descriptor that represents the standard input,
4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *              output, or error stream.
4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRSpecialFD id
4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         A value indicating the type of stream desired:
4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_StandardInput: standard input
4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_StandardOuput: standard output
4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_StandardError: standard error
4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS: none
4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURNS: PRFileDesc *
4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     If the argument is valid, PR_GetSpecialFD returns a file descriptor
4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     that represents the corresponding standard I/O stream.  Otherwise,
4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_GetSpecialFD returns NULL and sets error PR_INVALID_ARGUMENT_ERROR.
4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRSpecialFD
4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_StandardInput,          /* standard input */
4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_StandardOutput,         /* standard output */
4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_StandardError           /* standard error */
4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRSpecialFD;
4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD id);
4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_STDIN	PR_GetSpecialFD(PR_StandardInput)
4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_STDOUT	PR_GetSpecialFD(PR_StandardOutput)
4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_STDERR	PR_GetSpecialFD(PR_StandardError)
4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Layering file descriptors
4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * File descriptors may be layered. Each layer has it's own identity.
4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Identities are allocated by the runtime and are to be associated
4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * (by the layer implementor) with all layers that are of that type.
4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * It is then possible to scan the chain of layers and find a layer
4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * that one recongizes and therefore predict that it will implement
4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * a desired protocol.
4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * There are three well-known identities:
4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      PR_INVALID_IO_LAYER => an invalid layer identity, for error return
4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      PR_TOP_IO_LAYER     => the identity of the top of the stack
4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      PR_NSPR_IO_LAYER    => the identity used by NSPR proper
4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * PR_TOP_IO_LAYER may be used as a shorthand for identifying the topmost
4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * layer of an existing stack. Ie., the following two constructs are
4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * equivalent.
4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      rv = PR_PushIOLayer(stack, PR_TOP_IO_LAYER, my_layer);
4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      rv = PR_PushIOLayer(stack, PR_GetLayersIdentity(stack), my_layer)
4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A string may be associated with the creation of the identity. It
4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * will be copied by the runtime. If queried the runtime will return
4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * a reference to that copied string (not yet another copy). There
4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * is no facility for deleting an identity.
4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IO_LAYER_HEAD (PRDescIdentity)-3
4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_INVALID_IO_LAYER (PRDescIdentity)-1
4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_TOP_IO_LAYER (PRDescIdentity)-2
4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_NSPR_IO_LAYER (PRDescIdentity)0
4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRDescIdentity) PR_GetUniqueIdentity(const char *layer_name);
4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const char*) PR_GetNameForIdentity(PRDescIdentity ident);
4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRDescIdentity) PR_GetLayersIdentity(PRFileDesc* fd);
4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_GetIdentitiesLayer(PRFileDesc* fd_stack, PRDescIdentity id);
4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * PR_GetDefaultIOMethods: Accessing the default methods table.
4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * You may get a pointer to the default methods table by calling this function.
4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * You may then select any elements from that table with which to build your
4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * layer's methods table. You may NOT modify the table directly.
5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(const PRIOMethods *) PR_GetDefaultIOMethods(void);
5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Creating a layer
5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A new layer may be allocated by calling PR_CreateIOLayerStub(). The
5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * file descriptor returned will contain the pointer to the methods table
5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * provided. The runtime will not modify the table nor test its correctness.
5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_CreateIOLayerStub(
5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRDescIdentity ident, const PRIOMethods *methods);
5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Creating a layer
5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A new stack may be created by calling PR_CreateIOLayer(). The
5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * file descriptor returned will point to the top of the stack, which has
5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the layer 'fd' as the topmost layer.
5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * NOTE: This function creates a new style stack, which has a fixed, dummy
5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * header. The old style stack, created by a call to PR_PushIOLayer,
5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * results in modifying contents of the top layer of the stack, when
5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * pushing and popping layers of the stack.
5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_CreateIOLayer(PRFileDesc* fd);
5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Pushing a layer
5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A file descriptor (perhaps allocated using PR_CreateIOLayerStub()) may
5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * be pushed into an existing stack of file descriptors at any point the
5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * caller deems appropriate. The new layer will be inserted into the stack
5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * just above the layer with the indicated identity.
5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Note: Even if the identity parameter indicates the top-most layer of
5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * the stack, the value of the file descriptor describing the original
5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * stack will not change.
5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_PushIOLayer(
5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd_stack, PRDescIdentity id, PRFileDesc *layer);
5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Popping a layer
5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A layer may be popped from a stack by indicating the identity of the
5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * layer to be removed. If found, a pointer to the removed object will
5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * be returned to the caller. The object then becomes the responsibility
5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * of the caller.
5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Note: Even if the identity indicates the top layer of the stack, the
5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * reference returned will not be the file descriptor for the stack and
5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * that file descriptor will remain valid.
5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_PopIOLayer(PRFileDesc *fd_stack, PRDescIdentity id);
5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION:    PR_Open
5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:    Open a file for reading, writing, or both.
5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *name
5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         The path name of the file to be opened
5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRIntn flags
5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         The file status flags.
5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         It is a bitwise OR of the following bit flags (only one of
5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         the first three flags below may be used):
5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_RDONLY        Open for reading only.
5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_WRONLY        Open for writing only.
5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_RDWR          Open for reading and writing.
5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_CREATE_FILE   If the file does not exist, the file is created
5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                              If the file exists, this flag has no effect.
5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      PR_SYNC          If set, each write will wait for both the file data
5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                              and file status to be physically updated.
5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_APPEND        The file pointer is set to the end of
5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                              the file prior to each write.
5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *		PR_TRUNCATE      If the file exists, its length is truncated to 0.
5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *      PR_EXCL          With PR_CREATE_FILE, if the file does not exist,
5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                              the file is created. If the file already
5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                              exists, no action and NULL is returned
5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRIntn mode
5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         The access permission bits of the file mode, if the file is
5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         created when PR_CREATE_FILE is on.
5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:    None
5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURNS:    PRFileDesc *
5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     If the file is successfully opened,
5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     returns a pointer to the PRFileDesc
5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     created for the newly opened file.
5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Returns a NULL pointer if the open
5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     failed.
6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * SIDE EFFECTS:
6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RESTRICTIONS:
6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * MEMORY:
6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     The return value, if not NULL, points to a dynamically allocated
6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc object.
6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * ALGORITHM:
6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Open flags */
6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_RDONLY       0x01
6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_WRONLY       0x02
6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_RDWR         0x04
6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_CREATE_FILE  0x08
6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_APPEND       0x10
6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_TRUNCATE     0x20
6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_SYNC         0x40
6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_EXCL         0x80
6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** File modes ....
6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** CAVEAT: 'mode' is currently only applicable on UNIX platforms.
6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)** The 'mode' argument may be ignored by PR_Open on other platforms.
6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00400   Read by owner.
6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00200   Write by owner.
6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00100   Execute (search if a directory) by owner.
6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00040   Read by group.
6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00020   Write by group.
6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00010   Execute by group.
6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00004   Read by others.
6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00002   Write by others
6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**   00001   Execute by others.
6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)**
6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)*/
6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_Open(const char *name, PRIntn flags, PRIntn mode);
6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_OpenFile
6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Open a file for reading, writing, or both.
6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_OpenFile has the same prototype as PR_Open but implements
6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     the specified file mode where possible.
6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* File mode bits */
6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IRWXU 00700  /* read, write, execute/search by owner */
6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IRUSR 00400  /* read permission, owner */
6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IWUSR 00200  /* write permission, owner */
6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IXUSR 00100  /* execute/search permission, owner */
6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IRWXG 00070  /* read, write, execute/search by group */
6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IRGRP 00040  /* read permission, group */
6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IWGRP 00020  /* write permission, group */
6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IXGRP 00010  /* execute/search permission, group */
6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IRWXO 00007  /* read, write, execute/search by others */
6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IROTH 00004  /* read permission, others */
6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IWOTH 00002  /* write permission, others */
6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_IXOTH 00001  /* execute/search permission, others */
6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_OpenFile(
6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const char *name, PRIntn flags, PRIntn mode);
6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef MOZ_UNICODE
6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * EXPERIMENTAL: This function may be removed in a future release.
6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRFileDesc*) PR_OpenFileUTF16(
6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const PRUnichar *name, PRIntn flags, PRIntn mode);
6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* MOZ_UNICODE */
6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Close
6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Close a file or socket.
6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         a pointer to a PRFileDesc.
6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN:
6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRStatus
6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * SIDE EFFECTS:
6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RESTRICTIONS:
6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * MEMORY:
6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     The dynamic memory pointed to by the argument fd is freed.
6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus)    PR_Close(PRFileDesc *fd);
6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Read
6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Read bytes from a file or socket.
7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     The operation will block until either an end of stream indication is
7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     encountered, some positive number of bytes are transferred, or there
7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     is an error. No more than 'amount' bytes will be transferred.
7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         pointer to the PRFileDesc object for the file or socket
7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     void *buf
7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         pointer to a buffer to hold the data read in.
7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRInt32 amount
7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         the size of 'buf' (in bytes)
7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN:
7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRInt32
7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         a positive number indicates the number of bytes actually read in.
7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         0 means end of file is reached or the network connection is closed.
7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         -1 indicates a failure. The reason for the failure is obtained
7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         by calling PR_GetError().
7185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * SIDE EFFECTS:
7195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     data is written into the buffer pointed to by 'buf'.
7205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RESTRICTIONS:
7215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * MEMORY:
7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     N/A
7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * ALGORITHM:
7255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     N/A
7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_Read(PRFileDesc *fd, void *buf, PRInt32 amount);
7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Write
7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Write a specified number of bytes to a file or socket.  The thread
7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     invoking this function blocks until all the data is written.
7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         pointer to a PRFileDesc object that refers to a file or socket
7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const void *buf
7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         pointer to the buffer holding the data
7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRInt32 amount
7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         amount of data in bytes to be written from the buffer
7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
7465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRInt32
7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     A positive number indicates the number of bytes successfully written.
7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     A -1 is an indication that the operation failed. The reason
7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     for the failure is obtained by calling PR_GetError().
7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_Write(PRFileDesc *fd,const void *buf,PRInt32 amount);
7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Writev
7585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Write data to a socket.  The data is organized in a PRIOVec array. The
7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     operation will block until all the data is written or the operation
7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     fails.
7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Pointer that points to a PRFileDesc object for a socket.
7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const PRIOVec *iov
7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         An array of PRIOVec.  PRIOVec is a struct with the following
7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         two fields:
7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             char *iov_base;
7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             int iov_len;
7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRInt32 iov_size
7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Number of elements in the iov array. The value of this
7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         argument must not be greater than PR_MAX_IOVECTOR_SIZE.
7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         If it is, the method will fail (PR_BUFFER_OVERFLOW_ERROR).
7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRIntervalTime timeout
7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *       Time limit for completion of the entire write operation.
7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
7775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None
7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN:
7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     A positive number indicates the number of bytes successfully written.
7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     A -1 is an indication that the operation failed. The reason
7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     for the failure is obtained by calling PR_GetError().
7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
7845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define PR_MAX_IOVECTOR_SIZE 16   /* 'iov_size' must be <= */
7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_Writev(
7885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size,
7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRIntervalTime timeout);
7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Delete
7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Delete a file from the filesystem. The operation may fail if the
7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     file is open.
7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *name
7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Path name of the file to be deleted.
8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     The function returns PR_SUCCESS if the file is successfully
8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     deleted, otherwise it returns PR_FAILURE.
8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_Delete(const char *name);
8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/**************************************************************************/
8115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRFileType
8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles){
8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_FILE_FILE = 1,
8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_FILE_DIRECTORY = 2,
8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_FILE_OTHER = 3
8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRFileType;
8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRFileInfo {
8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileType type;        /* Type of file */
8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PROffset32 size;        /* Size, in bytes, of file's contents */
8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRTime creationTime;    /* Creation time per definition of PRTime */
8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRTime modifyTime;      /* Last modification time per definition of PRTime */
8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRFileInfo64 {
8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRFileType type;        /* Type of file */
8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PROffset64 size;        /* Size, in bytes, of file's contents */
8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRTime creationTime;    /* Creation time per definition of PRTime */
8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PRTime modifyTime;      /* Last modification time per definition of PRTime */
8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/****************************************************************************
8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_GetFileInfo, PR_GetFileInfo64
8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Get the information about the file with the given path name. This is
8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     applicable only to NSFileDesc describing 'file' types (see
8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *fn
8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         path name of the file
8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileInfo *info
8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Information about the given file is written into the file
8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         information object pointer to by 'info'.
8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_GetFileInfo returns PR_SUCCESS if file information is successfully
8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     obtained, otherwise it returns PR_FAILURE.
8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_GetFileInfo(const char *fn, PRFileInfo *info);
8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_GetFileInfo64(const char *fn, PRFileInfo64 *info);
8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef MOZ_UNICODE
8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * EXPERIMENTAL: This function may be removed in a future release.
8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_GetFileInfo64UTF16(const PRUnichar *fn, PRFileInfo64 *info);
8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* MOZ_UNICODE */
8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_GetOpenFileInfo, PR_GetOpenFileInfo64
8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
8655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Get information about an open file referred to by the
8665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     given PRFileDesc object.
8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const PRFileDesc *fd
8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *          A reference to a valid, open file.
8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Same as PR_GetFileInfo, PR_GetFileInfo64
8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_GetFileInfo returns PR_SUCCESS if file information is successfully
8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     obtained, otherwise it returns PR_FAILURE.
8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ***************************************************************************
8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_GetOpenFileInfo(PRFileDesc *fd, PRFileInfo *info);
8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_GetOpenFileInfo64(PRFileDesc *fd, PRFileInfo64 *info);
8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
8825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Rename
8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
8855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Rename a file from the old name 'from' to the new name 'to'.
8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *from
8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         The old name of the file to be renamed.
8895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *to
8905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         The new name of the file.
8915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
8925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) **************************************************************************
8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus)    PR_Rename(const char *from, const char *to);
8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *************************************************************************
9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Access
9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Determine accessibility of a file.
9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     const char *name
9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         path name of the file
9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRAccessHow how
9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         specifies which access permission to check for.
9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         It can be one of the following values:
9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_ACCESS_READ_OK       Test for read permission
9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_ACCESS_WRITE_OK      Test for write permission
9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_ACCESS_EXISTS        Check existence of file
9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
9145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_SUCCESS is returned if the requested access is permitted.
9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Otherwise, PR_FAILURE is returned. Additional information
9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     regarding the reason for the failure may be retrieved from
9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_GetError().
9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *************************************************************************
9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
9225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef enum PRAccessHow {
9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_ACCESS_EXISTS = 1,
9255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_ACCESS_WRITE_OK = 2,
9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    PR_ACCESS_READ_OK = 3
9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} PRAccessHow;
9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus) PR_Access(const char *name, PRAccessHow how);
9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *************************************************************************
9335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Seek, PR_Seek64
9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
9355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Moves read-write file offset
9365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
9375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Pointer to a PRFileDesc object.
9395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PROffset32, PROffset64 offset
9405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Specifies a value, in bytes, that is used in conjunction
9415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         with the 'whence' parameter to set the file pointer.  A
9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         negative value causes seeking in the reverse direction.
9435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRSeekWhence whence
9445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Specifies how to interpret the 'offset' parameter in setting
9455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         the file pointer associated with the 'fd' parameter.
9465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Values for the 'whence' parameter are:
9475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_SEEK_SET  Sets the file pointer to the value of the
9485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                          'offset' parameter
9495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_SEEK_CUR  Sets the file pointer to its current location
9505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                          plus the value of the offset parameter.
9515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *             PR_SEEK_END  Sets the file pointer to the size of the
9525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *                          file plus the value of the offset parameter.
9535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
9545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None.
9555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PROffset32, PROffset64
9565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Upon successful completion, the resulting pointer location,
9575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     measured in bytes from the beginning of the file, is returned.
9585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     If the PR_Seek() function fails, the file offset remains
9595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     unchanged, and the returned value is -1. The error code can
9605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     then be retrieved via PR_GetError().
9615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *************************************************************************
9625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
9635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PROffset32) PR_Seek(PRFileDesc *fd, PROffset32 offset, PRSeekWhence whence);
9655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PROffset64) PR_Seek64(PRFileDesc *fd, PROffset64 offset, PRSeekWhence whence);
9665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
9685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************
9695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Available
9705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
9715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Determine the amount of data in bytes available for reading
9725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     in the given file or socket.
9735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
9745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
9755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Pointer to a PRFileDesc object that refers to a file or
9765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         socket.
9775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
9785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None
9795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRInt32, PRInt64
9805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Upon successful completion, PR_Available returns the number of
9815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     bytes beyond the current read pointer that is available for
9825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     reading.  Otherwise, it returns a -1 and the reason for the
9835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     failure can be retrieved via PR_GetError().
9845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************
9855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
9865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt32) PR_Available(PRFileDesc *fd);
9885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRInt64) PR_Available64(PRFileDesc *fd);
9895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/*
9915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************
9925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * FUNCTION: PR_Sync
9935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DESCRIPTION:
9945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Sync any buffered data for a fd to its backing device (disk).
9955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * INPUTS:
9965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PRFileDesc *fd
9975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         Pointer to a PRFileDesc object that refers to a file or
9985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *         socket
9995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OUTPUTS:
10005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     None
10015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * RETURN: PRStatus
10025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     PR_SUCCESS is returned if the requested access is permitted.
10035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     Otherwise, PR_FAILURE is returned.
10045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ************************************************************************
10055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
10065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)NSPR_API(PRStatus)	PR_Sync(PRFileDesc *fd);
10085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/************************************************************************/
10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRDirEntry {
10125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const char *name;        /* name of entry, relative to directory name */
10135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
10145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifdef MOZ_UNICODE
10165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct PRDirEntryUTF16 {
10175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const PRUnichar *name;   /* name of entry in UTF16, relative to
10185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              * directory name */
10195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
10205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif /* MOZ_UNICODE */
10215821806