|
Packit |
022b05 |
/* $Id: shhopt.h 8040 2008-04-14 09:20:35Z schoenw $ */
|
|
Packit |
022b05 |
#ifndef SHHOPT_H
|
|
Packit |
022b05 |
#define SHHOPT_H
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
#ifdef __cplusplus
|
|
Packit |
022b05 |
extern "C" {
|
|
Packit |
022b05 |
#endif
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
/* constants for recognized option types. */
|
|
Packit |
022b05 |
typedef enum {
|
|
Packit |
022b05 |
OPT_END, /* nothing. used as ending element. */
|
|
Packit |
022b05 |
OPT_FLAG, /* no argument following. sets variable to 1. */
|
|
Packit |
022b05 |
OPT_STRING, /* string argument. */
|
|
Packit |
022b05 |
OPT_INT, /* signed integer argument. */
|
|
Packit |
022b05 |
OPT_UINT, /* unsigned integer argument. */
|
|
Packit |
022b05 |
OPT_LONG, /* signed long integer argument. */
|
|
Packit |
022b05 |
OPT_ULONG /* unsigned long integer argument. */
|
|
Packit |
022b05 |
} optArgType;
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
/* flags modifying the default way options are handeled. */
|
|
Packit |
022b05 |
#define OPT_CALLFUNC 1 /* pass argument to a function. */
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
typedef struct {
|
|
Packit |
022b05 |
char shortName; /* short option name. */
|
|
Packit |
022b05 |
char *longName; /* long option name, no including '--'. */
|
|
Packit |
022b05 |
optArgType type; /* option type. */
|
|
Packit |
022b05 |
void *arg; /* pointer to variable to fill with argument,
|
|
Packit |
022b05 |
* or pointer to function if type == OPT_FUNC. */
|
|
Packit |
022b05 |
int flags; /* modifier flags. */
|
|
Packit |
022b05 |
} optStruct;
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
extern void optSetFatalFunc(void (*f)(const char *, ...));
|
|
Packit |
022b05 |
extern void optParseOptions(int *argc, char *argv[],
|
|
Packit |
022b05 |
optStruct opt[], int allowNegNum);
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
#ifdef __cplusplus
|
|
Packit |
022b05 |
}
|
|
Packit |
022b05 |
#endif
|
|
Packit |
022b05 |
|
|
Packit |
022b05 |
#endif
|