2
getlopt: command line option/parameter parsing
4
copyright ?-2006 by the mpg123 project - free software under the terms of the LGPL 2.1
5
see COPYING and AUTHORS files in distribution or http://mpg123.de
6
initially written Oliver Fromme
7
old timestamp: Tue Apr 8 07:13:39 MET DST 1997
14
#ifndef _MPG123_GETLOPT_H_
15
#define _MPG123_GETLOPT_H_
17
extern int loptind; /* index in argv[] */
18
extern int loptchr; /* index in argv[loptind] */
19
extern char *loptarg; /* points to argument if present, else to option */
22
char sname; /* short option name, can be 0 */
23
char *lname; /* long option name, can be 0 */
24
int flags; /* see below */
25
void (*func)(char *); /* called if != 0 (after setting of var) */
26
void *var; /* type is *long, *char or **char, see below */
30
/* ThOr: make this clear; distict long from int (since this is != on my Alpha) and really use a flag for every case (spare the 0 case
38
* bit 0 = 0 - no argument
40
* *var := value or (char)value [see bit 1]
43
* return ((value != 0) ? value : sname)
44
* bit 0 = 1 - argument required
46
* *var := atoi(arg) or strdup(arg) [see bit 1]
49
* return ((value != 0) ? value : sname)
51
* bit 1 = 1 - var is a pointer to a char (or string),
52
* and value is interpreted as char
53
* bit 2 = 1 - var is a pointer to int
54
* bit 3 = 1 - var is a pointer to long
56
* Note: The options definition is terminated by a topt
57
* containing only zeroes.
61
#define GLO_UNKNOWN -1
63
#define GLO_CONTINUE -3
65
int getlopt (int argc, char *argv[], topt *opts);
68
* GLO_END (0) end of options
69
* GLO_UNKNOWN (-1) unknown option *loptarg
70
* GLO_NOARG (-2) missing argument
71
* GLO_CONTINUE (-3) (reserved for internal use)
72
* else - return value according to flags (see above)