]> git.sur5r.net Git - glabels/blob - barcode-0.98/cmdline.h
Imported Upstream version 2.2.8
[glabels] / barcode-0.98 / cmdline.h
1 /*
2  * cmdline.h -- generic commandline editing (uses getopt, only short)
3  *
4  * Copyright (c) 1999 Alessandro Rubini (rubini@gnu.org)
5  * Copyright (c) 1999 Prosa Srl. (prosa@prosa.it)
6  * 
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.
11  *
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.
16  *
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.
20  *
21  */
22
23 /*
24  * The options may have different arguments of different type
25  */
26 enum  option_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                  */
35 };
36
37
38 struct commandline {
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 */
46 };
47
48 /* returns: 0 or -1. "optarg" is global (see getopt) */
49 extern int commandline(struct commandline *args,
50                        int argc, char **argv, char *errorhead);
51
52 /* prints an error message based on "args" */
53 extern int commandline_errormsg(FILE *f, struct commandline *args,
54                                 char *prgname, char *messagehead);
55
56
57
58