File: nblib.h

package info (click to toggle)
netboot 0.8.1-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,728 kB
  • ctags: 4,740
  • sloc: ansic: 15,152; asm: 11,623; yacc: 2,248; makefile: 1,110; pascal: 1,108; lex: 748; sh: 233
file content (102 lines) | stat: -rw-r--r-- 3,333 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * nblib.h  -  Header file for netboot library
 *
 * Copyright (C) 1998 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


/*
 * Structure defining program options
 */
struct cmdopt {
	char		*longopt;	/* long option name */
	char		 shortopt;	/* short option character */
	enum {
		noval,			/* end of option list */
		boolval,		/* option has no argument */
		intval,			/* option has integer argument */
		strval,			/* option has string argument */
		procval,		/* call procedure when option given */
		nonopt			/* argument without option name */
	}		 valtype;
	union {
		char **strptr;		/* pointer to string buffer */
		int   *intptr;		/* pointer to integer buffer */
		int   *boolptr;		/* pointer to boolean buffer */
		void (*procptr) __P((struct cmdopt *));
	}		 valptr;
	char		*envdefault;	/* environment var name for default */
	char		*helptext;	/* help text for option */
	char		*helparg;	/* help text for argument */
};



/*
 * Structures holding all the information required to parse config file
 */
struct paramdef {
	char		 *name;		/* name of parameter in config file */
	enum {
		par_null,		/* end of parameter list */
		par_string,		/* string value */
		par_int,		/* integer value */
		par_bool,		/* boolean value */
		par_enum,		/* enumeration value */
		par_proc		/* procedure to handle argument */
	}		  type;
	char		**enumlist;	/* list of enumeration values */
	union {
		char  **strptr;		/* pointer to string buffer */
		int    *intptr;		/* pointer to integer value */
		int    *boolptr;	/* pointer to boolean value */
		int    *enumptr;	/* pointer to enumeration value */
		char *(*procptr) __P((char *, char *));
	}		  valptr;
};

struct sectdef {
	char		 *name;		/* name of section */
	struct paramdef  *params;	/* pointer to parameter list */
	char		*(*startsect) __P((char *, struct sectdef *));
	char		*(*endsect) __P((char *, struct sectdef *));
};



/*
 * Variables exported by library
 */
extern char *progname;		/* name of current program */
extern char *dbname;		/* name of system database file */
extern int write_chksum;	/* checksum for all bytes when writing */
extern int verbose;		/* verbosity flag */



/*
 * Routines exported by library
 */
extern voidstar nbmalloc __P((size_t amount));
extern int nbread __P((unsigned char *buf, unsigned int bufsize, int infile));
extern int nbwrite __P((unsigned char *buf, unsigned int bufsize, int outfile));
extern void copystr __P((char **dest, char *src));
extern void setpath __P((char **pathname, char *defaultname));
extern void readdb __P((struct sectdef *sect));
extern void nbsetup __P((int argc, char **argv,
				struct cmdopt *opts, struct sectdef *sects));