3 * $Id: scan.c,v 1.1 1999/07/01 08:56:23 mdw Exp $
7 * (c) 1999 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the `fw' port forwarder.
14 * `fw' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `fw' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `fw'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1999/07/01 08:56:23 mdw
37 /*----- Header files ------------------------------------------------------*/
45 #include <mLib/dstr.h>
49 /*----- Main code ---------------------------------------------------------*/
51 /* --- Generic scanner setup --- */
53 static void scan_init(scanner *sc, scan_ops *ops, const char *src)
61 /* --- @argv@ scanner --- */
63 static int argv_scan(void *p)
82 static void argv_unscan(int ch, void *p)
88 void scan_argvinit(scan_argvctx *c, char **pp)
90 static struct scan_ops ops = { argv_scan, argv_unscan };
94 scan_init(&c->sc, &ops, "<args>");
97 /* --- File scanner --- */
99 static int file_scan(void *p)
102 return (getc(c->fp));
105 static void file_unscan(int ch, void *p)
111 void scan_fileinit(scan_filectx *c, FILE *fp, const char *file)
113 static struct scan_ops ops = { file_scan, file_unscan };
115 scan_init(&c->sc, &ops, file);
118 /* --- Miscellaneous functions --- */
120 void scan_destroy(void *p)
123 dstr_destroy(&sc->d);
126 /*----- That's all, folks -------------------------------------------------*/