3 * $Id: scan.h,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
44 /*----- Header files ------------------------------------------------------*/
48 #include <mLib/dstr.h>
50 /*----- Data structures ---------------------------------------------------*/
52 /* --- A configuration scanner --- */
54 typedef struct scan_ops {
55 int (*scan)(void */*p*/); /* Character scan function */
56 void (*unscan)(int /*ch*/, void */*p*/); /* Character pushback function */
59 typedef struct scanner {
60 scan_ops *ops; /* Pointer to scanner operations */
61 const char *src; /* Name of this source */
62 int line; /* Current line number */
63 int t; /* Token type */
64 dstr d; /* Current token value */
67 /*----- Scanners provided -------------------------------------------------*/
69 /* --- The @argv@ scanner --- */
71 typedef struct scan_argvctx {
72 scanner sc; /* Scanner base structure */
73 char *p; /* Pointer to next character */
74 char **pp; /* Pointer to next string */
75 int ch; /* Pushback character */
78 extern void scan_argvinit(scan_argvctx */*c*/, char **/*pp*/);
80 /* --- The file scanner --- */
82 typedef struct scan_filectx {
83 scanner sc; /* Scanner base structure */
84 FILE *fp; /* Stream pointer */
87 extern void scan_fileinit(scan_filectx */*c*/,
88 FILE */*fp*/, const char */*file*/);
90 /*----- That's all, folks -------------------------------------------------*/