diff options
author | Martin Willi <martin@strongswan.org> | 2009-09-15 11:49:14 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-09-15 11:53:46 +0200 |
commit | ae7452e87ce98b1644157d57f4aed247c99050e1 (patch) | |
tree | 039d64cf1762c83e88c4c558ec333d7dd0b4e70b /src/pki/command.h | |
parent | 4fdb9f6f74435948143ae60397beb2eb2e02f804 (diff) | |
download | strongswan-ae7452e87ce98b1644157d57f4aed247c99050e1.tar.bz2 strongswan-ae7452e87ce98b1644157d57f4aed247c99050e1.tar.xz |
Handle pki --debug and --options in a generic way for all command
Diffstat (limited to 'src/pki/command.h')
-rw-r--r-- | src/pki/command.h | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/pki/command.h b/src/pki/command.h index 874bdaa80..fad598c0b 100644 --- a/src/pki/command.h +++ b/src/pki/command.h @@ -21,9 +21,6 @@ #ifndef COMMAND_H_ #define COMMAND_H_ -#define _GNU_SOURCE -#include <getopt.h> - /** * Maximum number of commands. */ @@ -40,14 +37,29 @@ #define MAX_LINES 10 typedef struct command_t command_t; +typedef struct command_option_t command_option_t; typedef enum command_type_t command_type_t; /** + * Option specification + */ +struct command_option_t { + /** long option string of the option */ + char *name; + /** short option character of the option */ + char op; + /** expected argument to option, no/req/opt_argument */ + int arg; + /** description of the option */ + char *desc; +}; + +/** * Command specification. */ struct command_t { /** Function implementing the command */ - int (*call)(int, char*[]); + int (*call)(); /** short option character */ char op; /** long option string */ @@ -57,27 +69,13 @@ struct command_t { /** usage summary of the command */ char *line[MAX_LINES]; /** list of options the command accepts */ - struct { - /** long option string of the option */ - char *name; - /** short option character of the option */ - char op; - /** expected argument to option, no/req/opt_argument */ - int arg; - /** description of the option */ - char *desc; - } options[MAX_OPTIONS]; + command_option_t options[MAX_OPTIONS]; }; /** - * Options of the active command. - */ -extern struct option command_opts[]; - -/** - * Short option string of the active command. + * Get the next option, as with getopt. */ -extern char command_optstring[]; +int command_getopt(char **arg); /** * Register a command. |