nsprpub/pr/src/cplus/rcio.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 ** Base class definitions for I/O (ref: prio.h)
michael@0 8 **
michael@0 9 ** This class is a virtual base class. Construction must be done by a
michael@0 10 ** subclass, but the I/O operations can be done on a RCIO object reference.
michael@0 11 */
michael@0 12
michael@0 13 #if defined(_RCIO_H)
michael@0 14 #else
michael@0 15 #define _RCIO_H
michael@0 16
michael@0 17 #include "rcbase.h"
michael@0 18 #include "rcnetdb.h"
michael@0 19 #include "rcinrval.h"
michael@0 20
michael@0 21 #include "prio.h"
michael@0 22
michael@0 23 class RCFileInfo;
michael@0 24
michael@0 25 class PR_IMPLEMENT(RCIO): public RCBase
michael@0 26 {
michael@0 27 public:
michael@0 28 typedef enum {
michael@0 29 open = PR_TRANSMITFILE_KEEP_OPEN, /* socket is left open after file
michael@0 30 * is transmitted. */
michael@0 31 close = PR_TRANSMITFILE_CLOSE_SOCKET/* socket is closed after file
michael@0 32 * is transmitted. */
michael@0 33 } FileDisposition;
michael@0 34
michael@0 35 typedef enum {
michael@0 36 set = PR_SEEK_SET, /* Set to value specified */
michael@0 37 current = PR_SEEK_CUR, /* Seek relative to current position */
michael@0 38 end = PR_SEEK_END /* seek past end of current eof */
michael@0 39 } Whence;
michael@0 40
michael@0 41 typedef enum {
michael@0 42 recv = PR_SHUTDOWN_RCV, /* receives will be disallowed */
michael@0 43 send = PR_SHUTDOWN_SEND, /* sends will be disallowed */
michael@0 44 both = PR_SHUTDOWN_BOTH /* sends & receives will be disallowed */
michael@0 45 } ShutdownHow;
michael@0 46
michael@0 47 public:
michael@0 48 virtual ~RCIO();
michael@0 49
michael@0 50 virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout) = 0;
michael@0 51 virtual PRInt32 AcceptRead(
michael@0 52 RCIO **nd, RCNetAddr **raddr, void *buf,
michael@0 53 PRSize amount, const RCInterval& timeout) = 0;
michael@0 54 virtual PRInt64 Available() = 0;
michael@0 55 virtual PRStatus Bind(const RCNetAddr& addr) = 0;
michael@0 56 virtual PRStatus Close() = 0;
michael@0 57 virtual PRStatus Connect(
michael@0 58 const RCNetAddr& addr,
michael@0 59 const RCInterval& timeout) = 0;
michael@0 60 virtual PRStatus FileInfo(RCFileInfo *info) const = 0;
michael@0 61 virtual PRStatus Fsync() = 0;
michael@0 62 virtual PRStatus GetLocalName(RCNetAddr *addr) const = 0;
michael@0 63 virtual PRStatus GetPeerName(RCNetAddr *addr) const = 0;
michael@0 64 virtual PRStatus GetSocketOption(PRSocketOptionData *data) const = 0;
michael@0 65 virtual PRStatus Listen(PRIntn backlog) = 0;
michael@0 66 virtual PRStatus Open(const char *name, PRIntn flags, PRIntn mode) = 0;
michael@0 67 virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0;
michael@0 68 virtual PRInt32 Read(void *buf, PRSize amount) = 0;
michael@0 69 virtual PRInt32 Recv(
michael@0 70 void *buf, PRSize amount, PRIntn flags,
michael@0 71 const RCInterval& timeout) = 0;
michael@0 72 virtual PRInt32 Recvfrom(
michael@0 73 void *buf, PRSize amount, PRIntn flags,
michael@0 74 RCNetAddr* addr, const RCInterval& timeout) = 0;
michael@0 75 virtual PRInt64 Seek(PRInt64 offset, Whence how) = 0;
michael@0 76 virtual PRInt32 Send(
michael@0 77 const void *buf, PRSize amount, PRIntn flags,
michael@0 78 const RCInterval& timeout) = 0;
michael@0 79 virtual PRInt32 Sendto(
michael@0 80 const void *buf, PRSize amount, PRIntn flags,
michael@0 81 const RCNetAddr& addr,
michael@0 82 const RCInterval& timeout) = 0;
michael@0 83 virtual PRStatus SetSocketOption(const PRSocketOptionData *data) = 0;
michael@0 84 virtual PRStatus Shutdown(ShutdownHow how) = 0;
michael@0 85 virtual PRInt32 TransmitFile(
michael@0 86 RCIO *source, const void *headers,
michael@0 87 PRSize hlen, RCIO::FileDisposition flags,
michael@0 88 const RCInterval& timeout) = 0;
michael@0 89 virtual PRInt32 Write(const void *buf, PRSize amount) = 0;
michael@0 90 virtual PRInt32 Writev(
michael@0 91 const PRIOVec *iov, PRSize size,
michael@0 92 const RCInterval& timeout) = 0;
michael@0 93
michael@0 94 protected:
michael@0 95 typedef enum {
michael@0 96 file = PR_DESC_FILE,
michael@0 97 tcp = PR_DESC_SOCKET_TCP,
michael@0 98 udp = PR_DESC_SOCKET_UDP,
michael@0 99 layered = PR_DESC_LAYERED} RCIOType;
michael@0 100
michael@0 101 RCIO(RCIOType);
michael@0 102
michael@0 103 PRFileDesc *fd; /* where the real code hides */
michael@0 104
michael@0 105 private:
michael@0 106 /* no default construction and no copies allowed */
michael@0 107 RCIO();
michael@0 108 RCIO(const RCIO&);
michael@0 109
michael@0 110 }; /* RCIO */
michael@0 111
michael@0 112 #endif /* defined(_RCIO_H) */
michael@0 113
michael@0 114 /* RCIO.h */
michael@0 115
michael@0 116

mercurial