FLIO(3)

NAME
flio - file-like i/o for stdio files and dynamic buffers

SYNOPSIS
#include <pgplib.h>
flio_t *
flio_fopen(const char *fname, const char *mode);
flio_t *
flio_newbuff(void);
int
flio_getpos(flio_t *p, flio_pos_t *pos);
int
flio_setpos(flio_t *p, flio_pos_t *pos);
int
flio_getc(flio_t *p);
char *
flio_gets(char *b, u_long s, flio_t *p);
int
flio_putc(int c, flio_t *p);
int
flio_puts(const char *s, flio_t *p);
int
flio_write(void *ptr, u_long s, u_long n, flio_t *p);
void
flio_close(flio_t *p);
.

DESCRIPTION
Routines that provides file-like i/o for stdio files and dynamic buffers. When flio_fopen() is used to initialize a "stream", all operation are passed to the stdio library, while when flio_newbuff() is used, all operations are performed on buffers in memory. . In general, all routines take argumenents and have semantics like their stdio counterparts.

RETURN VALUES
The routines flio_fopen() and flio_newbuff(), if sucessful, returns a pointer to a newly allocated structure. If an error occurs, a NULL pointer is returned. Upon sucess, the routines flio_getpos() and flio_setpos() both returns 0. If an error occurs, -1 is returned. Upon sucess, flio_getc() will return the next character in the "stream" pointed to by the argument while flio_putc() will write a character to the tream. If an error occurs, both will return EOF and errno set to indicate the reason. The function flio_puts() will return 0 on sucess and EOF on failure. The function flio_write() advance the file position indicator for the stream by the number of bytes written. It returns the number of objects written. If an error occurs, or the end-of-file is reached, the return value is a short object count (or zero). .

SEE ALSO
errno(2) fgetc(3) fgetpos(3) fgets(3) fopen(3) fputc(3) fputs(3) free(3) fsetpos(3) fwrite(3) malloc(3) stdio(3) PGPlib(3) .

BUGS
Written by Thomas Roessler. First appeared in PGPlib 0.3.