Expand PMF_FN_* macros.
[netbsd-mini2440.git] / distrib / utils / sysinst / txtwalk.h
blobac00e073d28fc98847d51ac55296fc195c4c072f
1 /* $NetBSD: txtwalk.h,v 1.9 2003/11/30 14:36:44 dsl Exp $ */
3 /*
4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved.
7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Piermont Information Systems Inc.
21 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
25 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
39 /* txtwalk.h - definitions for textwalk to be useful! */
41 /* data extractions */
42 enum kind {INT, STR};
44 struct data {
45 enum kind what;
46 union udata {
47 int i_val;
48 char *s_val;
49 } u;
52 /* Strings of interest! */
53 struct lookfor {
54 const char *head; /* Line starts this way. */
55 const char *fmt; /* Expected format. */
56 const char *todo; /* What to do ... */
57 void *var; /* Possible var */
58 size_t nument; /* Number of entries in the "array" */
59 size_t size; /* size of string variables */
60 int (*func) (struct data *list, size_t num); /* function to call */
63 /* Format string for the expected string:
64 * space => skip white space
65 * %ic => skip until you find char c, if c == space, matches any white space
66 * %d => expect an integer
67 * %s => expect a non-white space string
68 * \0 => ignore remainder of line
69 * %% => match a %
73 /* What to do ....
75 * a -- assign to var, $n is data from the expect strings.
76 * c -- call the function
80 /* prototypes */
82 int walk(char *, size_t, const struct lookfor *, size_t);
85 /* Maximum number of matched data elements per line! */
86 #define MAXDATA 20