home *** CD-ROM | disk | FTP | other *** search
- /* This source file is part of the LynxLib miscellaneous library by
- Robert Fischer, and is Copyright 1990 by Robert Fischer. It costs no
- money, and you may not make money off of it, but you may redistribute
- it. It comes with ABSOLUTELY NO WARRANTY. See the file LYNXLIB.DOC
- for more details.
- To contact the author:
- Robert Fischer \\80 Killdeer Rd \\Hamden, CT 06517 USA
- (203) 288-9599 fischer-robert@cs.yale.edu */
-
- /* By Robert Fischer, August 1988 */
-
- /*
- This is a header file for virtual files A virtual file is a file
- stream that could come from anywhere -- a FILE, memory, etc. The user
- program must implement the different drivers for different kinds of
- VFILEs. mfile.c contains the driver for memory files, and ffile.c
- contains the driver for C files gotten with fopen, fclose, etc. */
-
- #ifndef STDDEF_H
- #include <stddef.h>
- #endif
-
- typedef struct { /* This is a general file from any device or place */
- func *do_putc; /* Routine to call to put char, as putc(char, p) */
- ifunc *do_getc;
- ifunc *do_eof;
- lfunc *curpos; /* Finds the current file pointer position */
- func *do_close; /* Routine to close the file with */
- char *p; /* Pointer to file info for putc, getc, eof */
- } VFILE;
-
- #define vputc(c, v) (*((v)->do_putc))(c, (v)->p)
- #define vgetc(v) ((int)(*((v)->do_getc))((v)->p))
- #define veof(v) (*((v)->do_eof))((v)->p)
- #define vcurpos(v) (*((v)->curpos))((v)->p)
- #define vclose(v) {(*((v)->do_close))((v)->p); free(v);}
-
- /* Here's a list of the different supported open commands */
- extern VFILE *open_mfile(); /* memfile */
- extern VFILE *open_ffile(); /* ffile */
- extern VFILE *open_cofile(); /* cofiles, streams by coroutines */
-
- /* This is a structure of two file pointers, for routines that like to */
- /* take an input and output file argument */
- typedef struct {
- VFILE *in;
- VFILE *out;
- } VFILE_REC;
-