Abstract I/O routines.
More...
#include <gfsmConfig.h>
#include <gfsmError.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
Go to the source code of this file.
Functions |
gfsmIOHandle * | gfsmio_handle_new (gfsmIOHandleType typ, void *handle_data) |
void | gfsmio_handle_free (gfsmIOHandle *ioh) |
gfsmIOHandle * | gfsmio_new_file (FILE *f) |
gfsmIOHandle * | gfsmio_new_zfile (FILE *f, const char *mode, int compress_level) |
gfsmIOHandle * | gfsmio_new_filename (const char *filename, const char *mode, int compress_level, gfsmError **errp) |
gfsmIOHandle * | gfsmio_new_gstring (gfsmPosGString *pgs) |
void | gfsmio_close (gfsmIOHandle *ioh) |
void | gfsmio_flush (gfsmIOHandle *ioh) |
gboolean | gfsmio_eof (gfsmIOHandle *ioh) |
int | gfsmio_getc (gfsmIOHandle *ioh) |
gboolean | gfsmio_read (gfsmIOHandle *ioh, void *buf, size_t nbytes) |
ssize_t | gfsmio_getline (gfsmIOHandle *ioh, char **lineptr, size_t *n) |
ssize_t | gfsmio_getdelim (gfsmIOHandle *io, char **lineptr, size_t *n, int delim) |
gboolean | gfsmio_putc (gfsmIOHandle *ioh, int c) |
gboolean | gfsmio_puts (gfsmIOHandle *io, const char *s) |
gboolean | gfsmio_write (gfsmIOHandle *io, const void *buf, size_t nbytes) |
int | gfsmio_printf (gfsmIOHandle *io, const char *fmt,...) |
int | gfsmio_vprintf (gfsmIOHandle *io, const char *fmt, va_list *app) |
Detailed Description
Macro Definition Documentation
#define GFSMIO_EOF ((int)-1) |
Typedef Documentation
typedef void(* gfsmIOFlushFunc)(void *handle) |
Generic I/O Handle function type: fflush() and friends
typedef void(* gfsmIOCloseFunc)(void *handle) |
Generic I/O Handle function type: fclose() and friends
typedef gboolean(* gfsmIOEofFunc)(void *handle) |
Generic I/O Handle function type: feof() and friends
typedef gboolean(* gfsmIOReadFunc)(void *handle, void *buf, size_t nbytes) |
Generic I/O Handle function type: fread() and friends
typedef ssize_t(* gfsmIOGetdelimFunc)(void *handle, char **lineptr, size_t *n, int delim) |
Generic I/O Handle function type: getdelim() and friends
typedef gboolean(* gfsmIOWriteFunc)(void *handle, const void *buf, size_t nbytes) |
Generic I/O Handle function type: fwrite() and friends
typedef int(* gfsmIOVprintfFunc)(void *handle, const char *fmt, va_list *app) |
Generic I/O Handle function type: vprintf() and friends
Enumeration Type Documentation
Builtin I/O types
- Enumerator:
gfsmIOTCFile |
I/O on a C FILE*.
|
gfsmIOTZFile |
I/O on a zlib gzFile* (only if GFSM_ZLIB_ENABLED is defined)
|
gfsmIOTGString |
I/O on a GString*.
|
gfsmIOTUser |
user I/O
|
Function Documentation
create, initialize, and return a new gfsmIOHandle
- Parameters
-
typ | type of this handle |
handle_data | value of the handle structure datum:
- for typ==gfsmIOTCFile , handle_data should be a FILE*
- for typ==gfsmIOTGString , handle_data should be a gfsmPosGString*
- for typ==gfsmIOTZFile , handle_data should be a gzFile
- for typ==gfsmIOTUser , handle_data is whatever you want
|
- Returns
- new gfsmIOHandle
destroy a gfsmIOHandle: does NOT implicitly call close or anything else
Create and return a new gfsmIOHandle to an uncompressed C FILE* Caller is responsible for closing the handle.
gfsmIOHandle* gfsmio_new_zfile |
( |
FILE * |
f, |
|
|
const char * |
mode, |
|
|
int |
compress_level |
|
) |
| |
Create and return a new gfsmIOHandle to a C FILE* using compression (if available) Caller is responsible for closing the handle. The handle returned can always be closed without closing f itself.
gfsmIOHandle* gfsmio_new_filename |
( |
const char * |
filename, |
|
|
const char * |
mode, |
|
|
int |
compress_level, |
|
|
gfsmError ** |
errp |
|
) |
| |
Create and return a new gfsmIOHandle to a named file. Uses gzFile if zlib support was enabled, otherwise C FILE* (uncompressed) Caller is responsible for closing the handle.
Create and return a new gfsmIOHandle for a PosGString* Caller is responsible for allocation and de-allocation of the PosGString*.
close an open I/O handle (calls close_func)
flush all data to an output handle (calls flush_func)
returns true if h is at EOF, false otherwise (or if no eof_func is defined)
read a single byte of data from h, should return GFSMIO_EOF on EOF
gboolean gfsmio_read |
( |
gfsmIOHandle * |
ioh, |
|
|
void * |
buf, |
|
|
size_t |
nbytes |
|
) |
| |
read nbytes of data from io into buf, as fread()
ssize_t gfsmio_getline |
( |
gfsmIOHandle * |
ioh, |
|
|
char ** |
lineptr, |
|
|
size_t * |
n |
|
) |
| |
wrapper for getline(), returns number of bytes read (0 on error)
ssize_t gfsmio_getdelim |
( |
gfsmIOHandle * |
io, |
|
|
char ** |
lineptr, |
|
|
size_t * |
n, |
|
|
int |
delim |
|
) |
| |
wrapper for getdelim(), returns number of bytes read (0 on error)
write a single byte to handle ioh, as fputc()
gboolean gfsmio_write |
( |
gfsmIOHandle * |
io, |
|
|
const void * |
buf, |
|
|
size_t |
nbytes |
|
) |
| |
write nbytes of data from buf into io, as fwrite()
int gfsmio_printf |
( |
gfsmIOHandle * |
io, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
int gfsmio_vprintf |
( |
gfsmIOHandle * |
io, |
|
|
const char * |
fmt, |
|
|
va_list * |
app |
|
) |
| |
wrapper for vprintf(): calls vprintf_func