Rudiments
filedescriptor.h
1// Copyright (c) 1999-2018 David Muse
2// See the COPYING file for more information.
3
4#ifndef RUDIMENTS_FILEDESCRIPTOR_H
5#define RUDIMENTS_FILEDESCRIPTOR_H
6
7#include <rudiments/private/filedescriptorincludes.h>
8
9class listener;
10
13class RUDIMENTS_DLLSPEC filedescriptor : public input, public output {
14 public:
17
20 virtual ~filedescriptor();
21
24 virtual bool close();
25
28
32
58
62
72 int32_t duplicate();
73
80 bool duplicate(int32_t newfd);
81
86
91
95
109
112 virtual bool getNonBlockingMode();
113
117 virtual off64_t getPosition();
118
123 virtual off64_t setPositionRelativeToBeginning(off64_t offset);
124
128 virtual off64_t setPositionRelativeToCurrent(off64_t offset);
129
137 virtual off64_t setPositionRelativeToEnd(off64_t offset);
138
142 ssize_t write(uint16_t number);
143
147 ssize_t write(uint32_t number);
148
152 ssize_t write(uint64_t number);
153
157 ssize_t write(int16_t number);
158
162 ssize_t write(int32_t number);
163
167 ssize_t write(int64_t number);
168
172 ssize_t write(float number);
173
177 ssize_t write(double number);
178
182 ssize_t write(byte_t character);
183
187 ssize_t write(char character);
188
192 ssize_t write(wchar_t character);
193
197 ssize_t writeUcs2(ucs2_t character);
198
202 ssize_t write(bool value);
203
207 ssize_t write(const byte_t *string);
208
212 ssize_t write(const char *string);
213
217 ssize_t write(const wchar_t *string);
218
222 ssize_t writeUcs2(const ucs2_t *string);
223
227 ssize_t write(const byte_t *string, size_t size);
228
234 ssize_t write(const char *string, size_t length);
235
241 ssize_t write(const wchar_t *string, size_t length);
242
248 ssize_t writeUcs2(const ucs2_t *string, size_t length);
249
253 ssize_t write(const void *buffer, size_t size);
254
260 ssize_t write(uint16_t number, int32_t sec, int32_t usec);
261
267 ssize_t write(uint32_t number, int32_t sec, int32_t usec);
268
274 ssize_t write(uint64_t number, int32_t sec, int32_t usec);
275
281 ssize_t write(int16_t number, int32_t sec, int32_t usec);
282
288 ssize_t write(int32_t number, int32_t sec, int32_t usec);
289
295 ssize_t write(int64_t number, int32_t sec, int32_t usec);
296
302 ssize_t write(float number, int32_t sec, int32_t usec);
303
309 ssize_t write(double number, int32_t sec, int32_t usec);
310
316 ssize_t write(byte_t character, int32_t sec, int32_t usec);
317
323 ssize_t write(char character, int32_t sec, int32_t usec);
324
330 ssize_t write(wchar_t character, int32_t sec, int32_t usec);
331
337 ssize_t writeUcs2(ucs2_t character, int32_t sec, int32_t usec);
338
344 ssize_t write(bool value, int32_t sec, int32_t usec);
345
351 ssize_t write(const byte_t *string, int32_t sec, int32_t usec);
352
358 ssize_t write(const char *string,
359 int32_t sec, int32_t usec);
360
366 ssize_t write(const wchar_t *string,
367 int32_t sec, int32_t usec);
368
374 ssize_t writeUcs2(const ucs2_t *string,
375 int32_t sec, int32_t usec);
376
383 ssize_t write(const byte_t *string, size_t size,
384 int32_t sec, int32_t usec);
385
393 ssize_t write(const char *string, size_t length,
394 int32_t sec, int32_t usec);
395
403 ssize_t write(const wchar_t *string, size_t length,
404 int32_t sec, int32_t usec);
405
413 ssize_t writeUcs2(const ucs2_t *string, size_t length,
414 int32_t sec, int32_t usec);
415
421 ssize_t write(const void *buffer, size_t size,
422 int32_t sec, int32_t usec);
423
428 ssize_t read(uint16_t *buffer);
429
434 ssize_t read(uint32_t *buffer);
435
440 ssize_t read(uint64_t *buffer);
441
445 ssize_t read(int16_t *buffer);
446
450 ssize_t read(int32_t *buffer);
451
455 ssize_t read(int64_t *buffer);
456
461 ssize_t read(float *buffer);
462
467 ssize_t read(double *buffer);
468
472 ssize_t read(byte_t *buffer);
473
477 ssize_t read(char *buffer);
478
482 ssize_t read(wchar_t *buffer);
483
487 ssize_t readUcs2(ucs2_t *buffer);
488
492 ssize_t read(bool *buffer);
493
497 ssize_t read(byte_t *buffer, size_t size);
498
502 ssize_t read(char *buffer, size_t length);
503
507 ssize_t read(wchar_t *buffer, size_t length);
508
512 ssize_t readUcs2(ucs2_t *buffer, size_t length);
513
517 ssize_t read(void *buf, size_t size);
518
527 ssize_t read(char **buffer, const char *terminator);
528
540 ssize_t read(char **buffer,
541 const char *terminator, size_t maxbytes);
542
548 ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec);
549
555 ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec);
556
562 ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec);
563
569 ssize_t read(int16_t *buffer, int32_t sec, int32_t usec);
570
576 ssize_t read(int32_t *buffer, int32_t sec, int32_t usec);
577
583 ssize_t read(int64_t *buffer, int32_t sec, int32_t usec);
584
590 ssize_t read(float *buffer, int32_t sec, int32_t usec);
591
597 ssize_t read(double *buffer, int32_t sec, int32_t usec);
598
604 ssize_t read(byte_t *buffer, int32_t sec, int32_t usec);
605
611 ssize_t read(char *buffer, int32_t sec, int32_t usec);
612
618 ssize_t read(wchar_t *buffer, int32_t sec, int32_t usec);
619
625 ssize_t readUcs2(ucs2_t *buffer, int32_t sec, int32_t usec);
626
632 ssize_t read(bool *buffer, int32_t sec, int32_t usec);
633
639 ssize_t read(byte_t *buffer, size_t size,
640 int32_t sec, int32_t usec);
641
647 ssize_t read(char *buffer, size_t length,
648 int32_t sec, int32_t usec);
649
655 ssize_t read(wchar_t *buffer, size_t length,
656 int32_t sec, int32_t usec);
657
663 ssize_t readUcs2(ucs2_t *buffer, size_t length,
664 int32_t sec, int32_t usec);
665
671 ssize_t read(void *buf, size_t size,
672 int32_t sec, int32_t usec);
673
683 ssize_t read(char **buffer, const char *terminator,
684 int32_t sec, int32_t usec);
685
698 ssize_t read(char **buffer,
699 const char *terminator, size_t maxbytes,
700 int32_t sec, int32_t usec);
701
717 ssize_t read(char **buffer,
718 const char *terminator, size_t maxbytes,
719 char escapechar, int32_t sec, int32_t usec);
720
721
741 int32_t waitForNonBlockingRead(int32_t sec, int32_t usec);
742
763 int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec);
764
765
773
777
785
789
798
802
811
815
824
828
829
841
846
858
863
864
868 virtual bool passFileDescriptor(int32_t fd);
869
874 virtual bool passFileDescriptor(int32_t fd,
875 int32_t sec, int32_t usec);
876
880 virtual bool receiveFileDescriptor(int32_t *fd);
881
886 virtual bool receiveFileDescriptor(int32_t *fd,
887 int32_t sec, int32_t usec);
888
892
893
897 virtual bool passSocket(int32_t sock);
898
903 virtual bool passSocket(int32_t sock,
904 int32_t sec, int32_t usec);
905
909 virtual bool receiveSocket(int32_t *sock);
910
915 virtual bool receiveSocket(int32_t *sock,
916 int32_t sec, int32_t usec);
917
921
922
932
937
940 virtual int32_t fCntl(int32_t command, long arg);
941
944 virtual int32_t ioCtl(int32_t command, void *arg);
945
958
964
969
975
980
986
991
997
1002 const char *getType();
1003
1011
1012
1081
1084
1095 bool flushWriteBuffer(int32_t sec, int32_t usec);
1096
1097
1170
1173
1191
1197
1202
1208
1215 bool setCloseOnExec(bool close);
1216
1220
1225
1228 static uint16_t convertHostToNet(uint16_t value);
1229
1232 static uint32_t convertHostToNet(uint32_t value);
1233
1236 static uint64_t convertHostToNet(uint64_t value);
1237
1240 static uint16_t convertNetToHost(uint16_t value);
1241
1244 static uint32_t convertNetToHost(uint32_t value);
1245
1248 static uint64_t convertNetToHost(uint64_t value);
1249
1253 uint16_t value);
1254
1258 uint32_t value);
1259
1263 uint64_t value);
1264
1268 uint16_t value);
1269
1273 uint32_t value);
1274
1278 uint64_t value);
1279
1280 #include <rudiments/private/filedescriptor.h>
1281};
1282
1283#include <rudiments/private/filedescriptorinlines.h>
1284
1285#endif
Definition avltree.h:11
Definition character.h:11
Definition filedescriptor.h:13
bool isCurrentBlockMmapBuffered()
bool getAllowShortReads()
virtual bool receiveSocket(int32_t *sock)
socketlayer * getSocketLayer()
ssize_t write(int64_t number)
ssize_t read(int16_t *buffer)
virtual bool setNonBlockingMode(bool usenonblockingmode)
ssize_t write(uint16_t number)
void setRetryInterruptedIoctl(bool retry)
static uint64_t convertLittleEndianToHost(uint64_t value)
static bool supportsPassAndReceiveSocket()
virtual off64_t setPositionRelativeToCurrent(off64_t offset)
int32_t duplicate()
bool setIsStream(bool isstream)
bool getNaglesAlgorithmEnabled()
ssize_t write(uint16_t number, int32_t sec, int32_t usec)
virtual bool passFileDescriptor(int32_t fd)
static uint16_t convertHostToNet(uint16_t value)
ssize_t write(uint64_t number, int32_t sec, int32_t usec)
virtual bool passSocket(int32_t sock, int32_t sec, int32_t usec)
virtual int32_t fCntl(int32_t command, long arg)
bool getCloseOnExec()
virtual bool receiveSocket(int32_t *sock, int32_t sec, int32_t usec)
ssize_t write(uint32_t number, int32_t sec, int32_t usec)
size_t getWriteBufferSize()
static uint16_t convertNetToHost(uint16_t value)
int32_t waitForNonBlockingRead(int32_t sec, int32_t usec)
virtual off64_t getPosition()
ssize_t write(int32_t number)
bool getAllowShortWrites()
ssize_t read(int16_t *buffer, int32_t sec, int32_t usec)
ssize_t write(uint32_t number)
bool setWriteBufferSize(size_t size)
virtual bool supportsBlockingAndNonBlockingModes()
bool getRetryInterruptedWrites()
size_t getReadBufferSize()
void setFileDescriptor(int32_t filedesc)
ssize_t read(uint64_t *buffer)
ssize_t read(int32_t *buffer)
void setTranslateByteOrder(bool translate)
int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec)
virtual bool close()
ssize_t read(uint32_t *buffer)
static uint64_t convertHostToNet(uint64_t value)
bool getRetryInterruptedIoctl()
ssize_t read(int64_t *buffer, int32_t sec, int32_t usec)
bool setSocketWriteBufferSize(int32_t size)
const char * getType()
bool getIsStream()
void setRetryInterruptedFcntl(bool retry)
bool getTranslateByteOrder()
virtual bool receiveFileDescriptor(int32_t *fd, int32_t sec, int32_t usec)
off64_t getCurrentBlockOffset()
void setAllowShortReads(bool allow)
static uint16_t convertHostToLittleEndian(uint16_t value)
void setRetryInterruptedWrites(bool retry)
bool getRetryInterruptedFcntl()
void setSocketLayer(socketlayer *layer)
static uint32_t convertHostToNet(uint32_t value)
static uint64_t convertHostToLittleEndian(uint64_t value)
ssize_t write(int32_t number, int32_t sec, int32_t usec)
static bool createPipe(filedescriptor *readfd, filedescriptor *writefd)
virtual off64_t setPositionRelativeToEnd(off64_t offset)
virtual bool passFileDescriptor(int32_t fd, int32_t sec, int32_t usec)
virtual off64_t setPositionRelativeToBeginning(off64_t offset)
bool setReadBufferSize(size_t size)
bool flushWriteBuffer(int32_t sec, int32_t usec)
bool setSocketReadBufferSize(int32_t size)
virtual int32_t ioCtl(int32_t command, void *arg)
bool setNaglesAlgorithmEnabled(bool enabled)
static uint32_t convertLittleEndianToHost(uint32_t value)
ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec)
ssize_t read(uint16_t *buffer)
ssize_t read(int64_t *buffer)
ssize_t write(int16_t number)
bool getSocketReadBufferSize(int32_t *size)
bool getMmapBufferingEnabled()
int32_t getFileDescriptor()
bool setCloseOnExec(bool close)
static uint16_t convertLittleEndianToHost(uint16_t value)
virtual bool passSocket(int32_t sock)
void setMmapBufferingEnabled(bool enabled)
ssize_t write(int16_t number, int32_t sec, int32_t usec)
ssize_t read(int32_t *buffer, int32_t sec, int32_t usec)
ssize_t write(int64_t number, int32_t sec, int32_t usec)
ssize_t write(uint64_t number)
virtual bool getNonBlockingMode()
bool getRetryInterruptedReads()
void setRetryInterruptedWaits(bool retry)
static uint32_t convertNetToHost(uint32_t value)
void setAllowShortWrites(bool allow)
static uint32_t convertHostToLittleEndian(uint32_t value)
char * getPeerAddress()
virtual ~filedescriptor()
bool duplicate(int32_t newfd)
void setRetryInterruptedReads(bool retry)
bool getRetryInterruptedWaits()
ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec)
static uint64_t convertNetToHost(uint64_t value)
bool getSocketWriteBufferSize(int32_t *size)
bool disableIPv4()
virtual bool receiveFileDescriptor(int32_t *fd)
static bool supportsPassAndReceiveFileDescriptor()
ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec)
Definition input.h:11
virtual ssize_t readUcs2(ucs2_t *buffer, size_t length)=0
virtual ssize_t read(byte_t *buffer, size_t size)=0
Definition listener.h:11
Definition output.h:11
virtual ssize_t writeUcs2(const ucs2_t *string)=0
virtual ssize_t write(const byte_t *string, size_t size)=0
Definition socketlayer.h:11