2 * cmdline.h -- generic commandline editing (uses getopt, only short)
4 * Copyright (c) 1999 Alessandro Rubini (rubini@gnu.org)
5 * Copyright (c) 1999 Prosa Srl. (prosa@prosa.it)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
24 * The options may have different arguments of different type
27 CMDLINE_NONE=0, /* no argument after option */
28 CMDLINE_I, /* integer (any base) */
29 CMDLINE_D, /* decimal integer */
30 CMDLINE_X, /* hex integer */
31 CMDLINE_O, /* octal integer */
32 CMDLINE_S, /* string */
33 CMDLINE_F, /* double float */
34 CMDLINE_P, /* pointer */
39 int option; /* Single byte: option id */
40 int type; /* Type of argument, used in sscanf */
41 void *result; /* Store data here, if non null */
42 int (*fun)(void *); /* Call if defined: arg is "result" or input string */
43 char *env; /* Where to get runtime defaults, may be NULL */
44 char *default_v; /* The compile-time default, may be NULL */
45 char *descrip; /* For err msg. May have %s's for default and env */
48 /* returns: 0 or -1. "optarg" is global (see getopt) */
49 extern int commandline(struct commandline *args,
50 int argc, char **argv, char *errorhead);
52 /* prints an error message based on "args" */
53 extern int commandline_errormsg(FILE *f, struct commandline *args,
54 char *prgname, char *messagehead);