Data Structures | |
| struct | iobuf |
Status Flags | |
| unsigned | iobuf_bufsize |
| #define | IOBUF_EOF 1 |
| #define | IOBUF_ERROR 2 |
| #define | IOBUF_TIMEOUT 4 |
| #define | IOBUF_BADFLAGS 0xf |
| #define | IOBUF_SEEKABLE 0x10 |
| #define | IOBUF_NEEDSCLOSE 0x20 |
| #define | IOBUF_NEEDSFREE 0x40 |
| #define | IOBUF_NEEDSMUNMAP 0x80 |
Common | |
| typedef struct iobuf | iobuf |
| int | iobuf_init (iobuf *io, int fd, unsigned bufsize, char *buffer, unsigned flags) |
| int | iobuf_close (iobuf *io) |
| int | iobuf_timeout (iobuf *io, int poll_out) |
| #define | IOBUF_SET_ERROR(io) |
| #define | iobuf_closed(io) ((io)->fd == -1) |
| #define | iobuf_error(io) ((io)->flags & IOBUF_ERROR) |
| #define | iobuf_timedout(io) ((io)->flags & IOBUF_TIMEOUT) |
| #define | iobuf_bad(io) ((io)->flags & IOBUF_BADFLAGS) |
Mass copying functions. | |
| int | iobuf_copy (ibuf *in, obuf *out) |
| int | iobuf_copyflush (ibuf *in, obuf *out) |
| int | ibuf_copytofd (ibuf *in, int out) |
| int | obuf_copyfromfd (int in, obuf *out) |
0 (false) otherwise. | #define iobuf_bad | ( | io | ) | ((io)->flags & IOBUF_BADFLAGS) |
True if the iobuf is in a "bad" state.
| #define IOBUF_BADFLAGS 0xf |
Mask of all the error type flags.
| #define iobuf_closed | ( | io | ) | ((io)->fd == -1) |
True if the iobuf has been closed.
| #define IOBUF_EOF 1 |
Reading reached end of file.
| #define iobuf_error | ( | io | ) | ((io)->flags & IOBUF_ERROR) |
True if the iobuf has an error flag.
| #define IOBUF_ERROR 2 |
The iobuf has encountered an error.
| #define IOBUF_NEEDSCLOSE 0x20 |
The file descriptor needs to be closed.
| #define IOBUF_NEEDSFREE 0x40 |
The buffer needs to be deallocated with free
| #define IOBUF_NEEDSMUNMAP 0x80 |
The buffer needs to be deallocated with munmap
| #define IOBUF_SEEKABLE 0x10 |
lseek is possible on the file descriptor.
| #define IOBUF_SET_ERROR | ( | io | ) |
Value:
do{ \ io->flags |= IOBUF_ERROR; \ io->errnum = errno; \ return 0; \ }while(0)
errno, and return false.
| #define iobuf_timedout | ( | io | ) | ((io)->flags & IOBUF_TIMEOUT) |
True if the input or output to the iobuf previously timed out.
| #define IOBUF_TIMEOUT 4 |
The timeout expired before the read or write could be completed.
| int ibuf_copytofd | ( | ibuf * | in, | |
| int | out | |||
| ) |
Copy all the data from an ibuf to an output file descriptor.
| int iobuf_init | ( | iobuf * | io, | |
| int | fd, | |||
| unsigned | bufsize, | |||
| char * | buffer, | |||
| unsigned | flags | |||
| ) |
Initialize an iobuf structure.
| int iobuf_timeout | ( | iobuf * | io, | |
| int | poll_out | |||
| ) |
Wait for a file descriptor to be ready for reading or writing.
| int obuf_copyfromfd | ( | int | in, | |
| obuf * | out | |||
| ) |
Copy all the data from an input file descriptor to an obuf.
| unsigned iobuf_bufsize |
The default iobuf buffer size, defaults to 8192.
1.5.4