4 #ifndef RUDIMENTS_FILEDESCRIPTOR_H 5 #define RUDIMENTS_FILEDESCRIPTOR_H 7 #include <rudiments/private/filedescriptorincludes.h> 35 int32_t getFileDescriptor()
const;
39 void setFileDescriptor(int32_t filedesc);
50 int32_t duplicate()
const;
58 bool duplicate(int32_t newfd)
const;
71 virtual bool supportsBlockingNonBlockingModes();
76 virtual bool useNonBlockingMode()
const;
81 virtual bool useBlockingMode()
const;
85 virtual bool isUsingNonBlockingMode()
const;
90 ssize_t write(uint16_t number);
95 ssize_t write(uint32_t number);
100 ssize_t write(uint64_t number);
105 ssize_t write(int16_t number);
110 ssize_t write(int32_t number);
115 ssize_t write(int64_t number);
120 ssize_t write(
float number);
125 ssize_t write(
double number);
140 ssize_t write(
bool value);
145 ssize_t write(
const unsigned char *
string);
150 ssize_t write(
const char *
string);
157 ssize_t write(
const unsigned char *
string,
size_t size);
164 ssize_t write(
const char *
string,
size_t size);
169 ssize_t write(
const void *buffer,
size_t size);
176 ssize_t write(uint16_t number, int32_t sec, int32_t usec);
183 ssize_t write(uint32_t number, int32_t sec, int32_t usec);
190 ssize_t write(uint64_t number, int32_t sec, int32_t usec);
197 ssize_t write(int16_t number, int32_t sec, int32_t usec);
204 ssize_t write(int32_t number, int32_t sec, int32_t usec);
211 ssize_t write(int64_t number, int32_t sec, int32_t usec);
218 ssize_t write(
float number, int32_t sec, int32_t usec);
225 ssize_t write(
double number, int32_t sec, int32_t usec);
233 int32_t sec, int32_t usec);
240 ssize_t write(
char character, int32_t sec, int32_t usec);
247 ssize_t write(
bool value, int32_t sec, int32_t usec);
254 ssize_t write(
const unsigned char *
string,
255 int32_t sec, int32_t usec);
262 ssize_t write(
const char *
string,
263 int32_t sec, int32_t usec);
271 ssize_t write(
const unsigned char *
string,
size_t size,
272 int32_t sec, int32_t usec);
280 ssize_t write(
const char *
string,
size_t size,
281 int32_t sec, int32_t usec);
288 ssize_t write(
const void *buffer,
size_t size,
289 int32_t sec, int32_t usec);
293 size_t printf(
const char *format, ...);
300 size_t printf(
const char *format, va_list *argp);
306 void safePrint(
unsigned char c);
312 void safePrint(
const unsigned char *str);
318 void safePrint(
const unsigned char *str, int32_t length);
324 void safePrint(
char c);
330 void safePrint(
const char *str);
336 void safePrint(
const char *str, int32_t length);
340 void printBits(
unsigned char value);
344 void printBits(uint16_t value);
348 void printBits(uint32_t value);
352 void printBits(uint64_t value);
356 void printBits(
char value);
360 void printBits(int16_t value);
364 void printBits(int32_t value);
368 void printBits(int64_t value);
372 void printBits(
const unsigned char *bits, uint64_t size);
378 ssize_t read(uint16_t *buffer);
384 ssize_t read(uint32_t *buffer);
390 ssize_t read(uint64_t *buffer);
395 ssize_t read(int16_t *buffer);
400 ssize_t read(int32_t *buffer);
405 ssize_t read(int64_t *buffer);
411 ssize_t read(
float *buffer);
417 ssize_t read(
double *buffer);
423 ssize_t read(
unsigned char *buffer);
428 ssize_t read(
char *buffer);
433 ssize_t read(
bool *buffer);
438 ssize_t read(
unsigned char *buffer,
size_t size);
443 ssize_t read(
char *buffer,
size_t size);
448 ssize_t read(
void *buf,
size_t size);
458 ssize_t read(
char **buffer,
const char *terminator);
471 ssize_t read(
char **buffer,
472 const char *terminator,
size_t maxbytes);
479 ssize_t read(uint16_t *buffer, int32_t sec, int32_t usec);
486 ssize_t read(uint32_t *buffer, int32_t sec, int32_t usec);
493 ssize_t read(uint64_t *buffer, int32_t sec, int32_t usec);
500 ssize_t read(int16_t *buffer, int32_t sec, int32_t usec);
507 ssize_t read(int32_t *buffer, int32_t sec, int32_t usec);
514 ssize_t read(int64_t *buffer, int32_t sec, int32_t usec);
521 ssize_t read(
float *buffer, int32_t sec, int32_t usec);
528 ssize_t read(
double *buffer, int32_t sec, int32_t usec);
535 ssize_t read(
unsigned char *buffer, int32_t sec, int32_t usec);
542 ssize_t read(
char *buffer, int32_t sec, int32_t usec);
549 ssize_t read(
bool *buffer, int32_t sec, int32_t usec);
556 ssize_t read(
unsigned char *buffer,
size_t size,
557 int32_t sec, int32_t usec);
564 ssize_t read(
char *buffer,
size_t size,
565 int32_t sec, int32_t usec);
572 ssize_t read(
void *buf,
size_t size,
573 int32_t sec, int32_t usec);
584 ssize_t read(
char **buffer,
const char *terminator,
585 int32_t sec, int32_t usec);
599 ssize_t read(
char **buffer,
600 const char *terminator,
size_t maxbytes,
601 int32_t sec, int32_t usec);
618 ssize_t read(
char **buffer,
619 const char *terminator,
size_t maxbytes,
620 char escapechar, int32_t sec, int32_t usec);
642 int32_t waitForNonBlockingRead(int32_t sec, int32_t usec)
665 int32_t waitForNonBlockingWrite(int32_t sec, int32_t usec)
673 void retryInterruptedReads();
680 void dontRetryInterruptedReads();
684 bool getRetryInterruptedReads()
const;
690 void retryInterruptedWrites();
697 void dontRetryInterruptedWrites();
701 bool getRetryInterruptedWrites()
const;
708 void retryInterruptedWaits();
715 void dontRetryInterruptedWaits();
719 bool getRetryInterruptedWaits()
const;
726 void retryInterruptedFcntl();
733 void dontRetryInterruptedFcntl();
737 bool getRetryInterruptedFcntl()
const;
744 void retryInterruptedIoctl();
751 void dontRetryInterruptedIoctl();
755 bool getRetryInterruptedIoctl()
const;
768 void allowShortReads();
775 void dontAllowShortReads();
788 void allowShortWrites();
795 void dontAllowShortWrites();
801 virtual bool passFileDescriptor(int32_t fd);
806 virtual bool receiveFileDescriptor(int32_t *fd);
812 virtual bool passSocket(int32_t sock);
817 virtual bool receiveSocket(int32_t *sock);
823 void translateByteOrder();
828 void dontTranslateByteOrder();
832 virtual int32_t fCntl(int32_t command,
long arg)
const;
836 virtual int32_t ioCtl(int32_t command,
void *arg)
const;
846 bool useNaglesAlgorithm();
852 bool dontUseNaglesAlgorithm();
857 bool setSocketWriteBufferSize(int32_t size);
863 bool getSocketWriteBufferSize(int32_t *size);
868 bool setSocketReadBufferSize(int32_t size);
874 bool getSocketReadBufferSize(int32_t *size);
891 const char *getType()
const;
899 char *getPeerAddress()
const;
923 bool setWriteBufferSize(ssize_t size)
const;
951 bool flushWriteBuffer(int32_t sec, int32_t usec);
973 bool setReadBufferSize(ssize_t size)
const;
988 bool dontCloseOnExec();
996 bool getCloseOnExec();
1005 static uint16_t hostToNet(uint16_t value);
1009 static uint32_t hostToNet(uint32_t value);
1013 static uint64_t hostToNet(uint64_t value);
1017 static uint16_t netToHost(uint16_t value);
1021 static uint32_t netToHost(uint32_t value);
1025 static uint64_t netToHost(uint64_t value);
1029 static uint16_t hostToLittleEndian(uint16_t value);
1033 static uint32_t hostToLittleEndian(uint32_t value);
1037 static uint64_t hostToLittleEndian(uint64_t value);
1041 static uint16_t littleEndianToHost(uint16_t value);
1045 static uint32_t littleEndianToHost(uint32_t value);
1049 static uint64_t littleEndianToHost(uint64_t value);
1051 #include <rudiments/private/filedescriptor.h>
Definition: character.h:11
Definition: listener.h:14
Definition: filedescriptor.h:13
Definition: security.h:16