1 /* 2 * Copyright (C) 1999 Uwe Ohse 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 * 18 * As a special exception this source may be used as part of the 19 * SRS project by CORE/Computer Service Langenbach 20 * regardless of the copyright they choose. 21 * 22 * Contact: uwe@ohse.de 23 */ 24 #ifndef UOGETOPT_H 25 #define UOGETOPT_H 26 27 #define UOGO_FLAG 0 /* (*var) shall be "val": this means _no_ argument */ 28 #define UOGO_FLAGOR 1 /* (*var) shall be "(*arg)|val": this means _no_ argument */ 29 #define UOGO_STRING 2 /* (*var) shall be pointer to argument */ 30 #define UOGO_ULONG 4 /* (*var)=strtoul(argument) */ 31 #define UOGO_LONG 5 /* (*var)=strtol(argument) */ 32 #define UOGO_CALLBACK 6 /* var is function ptr: int (*fn)(uogetopt_t *, const char *) */ 33 #define UOGO_NOOPT 7 /* this is not really an option */ 34 #define UOGO_PRINT 8 /* just print the help text and exit */ 35 /* to OR into the argtype */ 36 #define UOGO_HIDDEN 0x10000 /* do not show this option in --help or --longhelp */ 37 38 typedef struct { 39 char shortname; 40 const char *longname; 41 int argtype; /* 0 or 1 no argument, set (*arg) from val. */ 42 void *var; /* mandatory */ 43 int val; /* val for *var in case of type 0 or 1 */ 44 const char *help; 45 const char *paraname; 46 } uogetopt_t; 47 48 #ifndef P__ 49 #define P__(x) x 50 #endif 51 void uogetopt P__(( 52 const char *prog, const char *package, const char *version, 53 int *argc, char **argv, /* note: "int *" */ 54 void (*out)(int iserr,const char *), 55 const char *head, 56 uogetopt_t *, 57 const char *tail)); 58 59 void uogetopt_out P__((int iserr,const char *s)); 60 61 #endif 62