The FDSTDIO subsystem
Fdstdio is a set of cover routines to implement a STDIO-like
subsystem, but without some of it's annoying limitations (like only
working for the first 64 file descriptors, and not being able to use
a FILE for both input and output concurrently).
Functions:
- int fd_putc(int c, int fd)
- Writes the character s to the file descriptor fd.
- int fd_puts(char *s, int fd)
- Writes the string s to the file descriptor fd.
- int fd_write(int fd, char *buf, int len)
- Writes the buffer buf, of size len to the file
descriptor fd.
- int fd_getc(int fd)
- Read one character from the file descriptor fd.
- char *fd_gets(char *buf, int size, int fd)
- Reads a string, terminated by a newline, from a descriptor.
- int fd_read(int fd, char *buf, int len)
- Read a specific number of bytes from the descriptor.
- void fd_reopen(int fd, int how, int type)
- Associate an fdstdio buffer with a file descriptor.
- int fd_open(const char *file, int how, ...)
- Open a file and associate it with a fdstdio buffer.
- int fd_connect(struct sockaddr *sap, int len)
- Open a new socket connection, and associate it with a fdstdio
buffer.
- int fd_mksockaddr_in(const char *host, char *service, struct sockaddr_in *sin)
- Fill in a sockaddr structure with the host address and port number
which is associated with the host and service strings.
- int fd_sconnect(const char *host, char *service)
- Convenience function combining the two functions above.
- int fd_close(int fd)
- Close a file descriptor (and release the allocated buffers).
- int fd_shutdown(int fd, int how)
- Shutdown a file descriptor for further reading, writing or both.
- int fd_foreach(int (*fcnp)(int fd, struct fd_buffer *bp, void *misc), void *misc)
- Loop over all open file descriptors.
- int fd_avail(int fd)
- Return the number of bytes available to be read on a descriptor.
- int fd_wait(int fd)
- Wait for some bytes to become available on the descriptor.
- int fd_ungetc(int c, int fd)
- "unget" a previously read character from a file descriptor.
- int fd_flush(int fd)
- Force all written characters in the buffers to be transmitted/written.
- int fd_puti(int val, int fd)
- Writes the integer value as a string to the descriptor.
- int fd_puts2nl(const char *s1, const char *s2, int fd)
- Writes two strings and a terminating newline to the descriptor.
- int fd_putsinl(const char *s1, int val, int fd)
- Writes a string, an integer value and a newline to the descriptor.
- int fd_vprintf(int fd, const char *format, va_list ap)
- Formatted printing. See the printf man page.
- int fd_printf(int fd, const char *format, ....)
- Formatted printing. See the printf man page.
- int fd_written(int fd)
- Returns the number of bytes written since the descriptor was
opened/associated with a fdstdio buffer.
- int fd_relay(int fd1, int fd2, int bidir)
- Uni- or Bidirectionally relay data between two descriptors.