/* 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 */ #include #include /* VFILE driver for normal C streams */ f_putc(c, f) char c; FILE *f; { putc(c, f); } int f_getc(f) FILE *f; { return getc(f); } int f_eof(f) FILE *f; { return feof(f); } /* -------------------------------------------------------- */ extern fclose(); VFILE *open_ffile(name, mode) /* Works just like fopen() */ char *name; char *mode; { VFILE *v; v = malloc(sizeof(*v)); v->curpos = &ftell; v->do_eof = &f_eof; v->do_getc = &f_getc; v->do_putc = &f_putc; v->do_close = &fclose; if (name == NULL) { /* Don't open, just bind to an old open file, given in mode */ v->p = mode; return v; } if ((v->p = fopen(name, mode)) == 0) { free(v); return 0; } return v; } /* -------------------------------------------------------- */