1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/src/cplus/rcio.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 +** Base class definitions for I/O (ref: prio.h) 1.11 +** 1.12 +** This class is a virtual base class. Construction must be done by a 1.13 +** subclass, but the I/O operations can be done on a RCIO object reference. 1.14 +*/ 1.15 + 1.16 +#if defined(_RCIO_H) 1.17 +#else 1.18 +#define _RCIO_H 1.19 + 1.20 +#include "rcbase.h" 1.21 +#include "rcnetdb.h" 1.22 +#include "rcinrval.h" 1.23 + 1.24 +#include "prio.h" 1.25 + 1.26 +class RCFileInfo; 1.27 + 1.28 +class PR_IMPLEMENT(RCIO): public RCBase 1.29 +{ 1.30 +public: 1.31 + typedef enum { 1.32 + open = PR_TRANSMITFILE_KEEP_OPEN, /* socket is left open after file 1.33 + * is transmitted. */ 1.34 + close = PR_TRANSMITFILE_CLOSE_SOCKET/* socket is closed after file 1.35 + * is transmitted. */ 1.36 + } FileDisposition; 1.37 + 1.38 + typedef enum { 1.39 + set = PR_SEEK_SET, /* Set to value specified */ 1.40 + current = PR_SEEK_CUR, /* Seek relative to current position */ 1.41 + end = PR_SEEK_END /* seek past end of current eof */ 1.42 + } Whence; 1.43 + 1.44 + typedef enum { 1.45 + recv = PR_SHUTDOWN_RCV, /* receives will be disallowed */ 1.46 + send = PR_SHUTDOWN_SEND, /* sends will be disallowed */ 1.47 + both = PR_SHUTDOWN_BOTH /* sends & receives will be disallowed */ 1.48 + } ShutdownHow; 1.49 + 1.50 +public: 1.51 + virtual ~RCIO(); 1.52 + 1.53 + virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout) = 0; 1.54 + virtual PRInt32 AcceptRead( 1.55 + RCIO **nd, RCNetAddr **raddr, void *buf, 1.56 + PRSize amount, const RCInterval& timeout) = 0; 1.57 + virtual PRInt64 Available() = 0; 1.58 + virtual PRStatus Bind(const RCNetAddr& addr) = 0; 1.59 + virtual PRStatus Close() = 0; 1.60 + virtual PRStatus Connect( 1.61 + const RCNetAddr& addr, 1.62 + const RCInterval& timeout) = 0; 1.63 + virtual PRStatus FileInfo(RCFileInfo *info) const = 0; 1.64 + virtual PRStatus Fsync() = 0; 1.65 + virtual PRStatus GetLocalName(RCNetAddr *addr) const = 0; 1.66 + virtual PRStatus GetPeerName(RCNetAddr *addr) const = 0; 1.67 + virtual PRStatus GetSocketOption(PRSocketOptionData *data) const = 0; 1.68 + virtual PRStatus Listen(PRIntn backlog) = 0; 1.69 + virtual PRStatus Open(const char *name, PRIntn flags, PRIntn mode) = 0; 1.70 + virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0; 1.71 + virtual PRInt32 Read(void *buf, PRSize amount) = 0; 1.72 + virtual PRInt32 Recv( 1.73 + void *buf, PRSize amount, PRIntn flags, 1.74 + const RCInterval& timeout) = 0; 1.75 + virtual PRInt32 Recvfrom( 1.76 + void *buf, PRSize amount, PRIntn flags, 1.77 + RCNetAddr* addr, const RCInterval& timeout) = 0; 1.78 + virtual PRInt64 Seek(PRInt64 offset, Whence how) = 0; 1.79 + virtual PRInt32 Send( 1.80 + const void *buf, PRSize amount, PRIntn flags, 1.81 + const RCInterval& timeout) = 0; 1.82 + virtual PRInt32 Sendto( 1.83 + const void *buf, PRSize amount, PRIntn flags, 1.84 + const RCNetAddr& addr, 1.85 + const RCInterval& timeout) = 0; 1.86 + virtual PRStatus SetSocketOption(const PRSocketOptionData *data) = 0; 1.87 + virtual PRStatus Shutdown(ShutdownHow how) = 0; 1.88 + virtual PRInt32 TransmitFile( 1.89 + RCIO *source, const void *headers, 1.90 + PRSize hlen, RCIO::FileDisposition flags, 1.91 + const RCInterval& timeout) = 0; 1.92 + virtual PRInt32 Write(const void *buf, PRSize amount) = 0; 1.93 + virtual PRInt32 Writev( 1.94 + const PRIOVec *iov, PRSize size, 1.95 + const RCInterval& timeout) = 0; 1.96 + 1.97 +protected: 1.98 + typedef enum { 1.99 + file = PR_DESC_FILE, 1.100 + tcp = PR_DESC_SOCKET_TCP, 1.101 + udp = PR_DESC_SOCKET_UDP, 1.102 + layered = PR_DESC_LAYERED} RCIOType; 1.103 + 1.104 + RCIO(RCIOType); 1.105 + 1.106 + PRFileDesc *fd; /* where the real code hides */ 1.107 + 1.108 +private: 1.109 + /* no default construction and no copies allowed */ 1.110 + RCIO(); 1.111 + RCIO(const RCIO&); 1.112 + 1.113 +}; /* RCIO */ 1.114 + 1.115 +#endif /* defined(_RCIO_H) */ 1.116 + 1.117 +/* RCIO.h */ 1.118 + 1.119 +