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.

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

mercurial