/* * nblib.h - Header file for netboot library * * Copyright (C) 1998-2003 Gero Kuhlmann * * 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. * * $Id: nblib.h,v 1.7 2003/03/09 00:43:08 gkminix Exp $ */ #ifndef NBLIB_H #define NBLIB_H /* * File access time types used by filetime() */ #define FT_ATIME 0 /* last access time */ #define FT_MTIME 1 /* last modification time */ #define FT_CTIME 2 /* last status change time */ /* * Values used by boolean variables: */ #define BOOL_UNDEF -1 /* value not assigned yet */ #define BOOL_FALSE FALSE /* FALSE value */ #define BOOL_TRUE TRUE /* TRUE value */ /* * 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 short integer argument */ longval, /* option has long 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 short integer buffer */ long *longptr; /* pointer to long 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, /* short integer value */ par_long, /* long 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 short integer value */ long *longptr; /* pointer to long 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 unsigned long write_chksum; /* checksum when writing */ extern int verbose; /* verbosity flag */ extern int quiet; /* quiet flag */ /* * Definitions for printing error messages */ #define prnerr0(st) if (!quiet) \ fprintf(stderr, "%s: " st "\n",\ progname) #define prnerr1(st, a1) if (!quiet) \ fprintf(stderr, "%s: " st "\n",\ progname, a1) #define prnerr2(st, a1, a2) if (!quiet) \ fprintf(stderr, "%s: " st "\n",\ progname, a1, a2) #define prnerr3(st, a1, a2, a3) if (!quiet) \ fprintf(stderr, "%s: " st "\n",\ progname, a1, a2, a3) #define prnerr4(st, a1, a2, a3, a4) if (!quiet) \ fprintf(stderr, "%s: " st "\n",\ progname, a1, a2, a3, a4) /* * Routines exported by library */ extern voidstar nbmalloc __P((size_t amount)); extern void setpath __P((char **pathname, char *maindir)); extern void checkaccess __P((char **filename, char *maindir)); extern long filesize __P((char *filename)); extern time_t filetime __P((char *filename, int timetype)); extern __u8 totarget __P((int c)); extern int nbread __P((__u8 *buf, unsigned int bufsize, int infile)); extern int nbwrite __P((__u8 *buf, unsigned int bufsize, int outfile)); extern int bytecmp __P((char *str, __u8 *buf, size_t len)); extern void bytecpy __P((char *str, __u8 *buf, size_t len)); extern void copystr __P((char **dest, char *src)); extern void readdb __P((struct sectdef *sect, char *fname)); extern void readconfig __P((struct sectdef *sects, char *fname)); extern void nbsetup __P((int argc, char **argv, struct cmdopt *opts, struct sectdef *sects)); #ifndef HAVE_STRSTR extern char *strstr __P((char *haystack, char *needle)); #endif #ifndef HAVE_MEMMOVE extern voidstar memmove __P((voidstar dest, voidstar src, size_t len)); #endif #ifndef HAVE_STRSPN extern int strspn __P((char *str, char *accept)); #endif #ifndef HAVE_STRCSPN extern int strcspn __P((char *str, char *reject)); #endif #endif