2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup command command
25 * Maximum number of commands (+1).
27 #define MAX_COMMANDS 11
30 * Maximum number of options in a command (+1)
32 #define MAX_OPTIONS 32
35 * Maximum number of usage summary lines (+1)
39 typedef struct command_t command_t
;
40 typedef struct command_option_t command_option_t
;
41 typedef enum command_type_t command_type_t
;
44 * Option specification
46 struct command_option_t
{
47 /** long option string of the option */
49 /** short option character of the option */
51 /** expected argument to option, no/req/opt_argument */
53 /** description of the option */
58 * Command specification.
61 /** Function implementing the command */
63 /** short option character */
65 /** long option string */
67 /** description of the command */
69 /** usage summary of the command */
70 char *line
[MAX_LINES
];
71 /** list of options the command accepts */
72 command_option_t options
[MAX_OPTIONS
];
76 * Get the next option, as with getopt.
78 int command_getopt(char **arg
);
83 void command_register(command_t command
);
88 int command_dispatch(int argc
, char *argv
[]);
91 * Show usage information of active command.
93 int command_usage(char *error
);
95 #endif /** COMMAND_H_ @}*/