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
28 * Maximum number of commands (+1).
30 #define MAX_COMMANDS 11
33 * Maximum number of options in a command (+3)
35 #define MAX_OPTIONS 32
38 * Maximum number of usage summary lines (+1)
42 typedef struct command_t command_t
;
43 typedef struct command_option_t command_option_t
;
44 typedef enum command_type_t command_type_t
;
47 * Option specification
49 struct command_option_t
{
50 /** long option string of the option */
52 /** short option character of the option */
54 /** expected argument to option, no/req/opt_argument */
56 /** description of the option */
61 * Command specification.
64 /** Function implementing the command */
65 int (*call
)(vici_conn_t
*conn
);
66 /** short option character */
68 /** long option string */
70 /** description of the command */
72 /** usage summary of the command */
73 char *line
[MAX_LINES
];
74 /** list of options the command accepts */
75 command_option_t options
[MAX_OPTIONS
];
79 * Get the next option, as with getopt.
81 int command_getopt(char **arg
);
86 void command_register(command_t command
);
91 int command_dispatch(int argc
, char *argv
[]);
94 * Show usage information of active command.
96 int command_usage(char *error
, ...);
98 #endif /** COMMAND_H_ @}*/