4 #define HISTORY 100 /* Don't let history grow unbounded */
8 #define CMD_INCOMPLETE 1
13 typedef struct parser_cmd {
15 int (* pc_func)(int, char **);
16 struct parser_cmd * pc_sub_cmd;
20 typedef struct argcmd {
22 int (*ac_func)(int, char **);
26 typedef struct network {
32 int Parser_quit(int argc, char **argv);
33 void Parser_init(char *, command_t *); /* Set prompt and load command list */
34 int Parser_commands(void); /* Start the command parser */
35 void Parser_qhelp(int, char **); /* Quick help routine */
36 int Parser_help(int, char **); /* Detailed help routine */
37 void Parser_printhelp(char *); /* Detailed help routine */
38 void Parser_exit(int, char **); /* Shuts down command parser */
39 int Parser_execarg(int argc, char **argv, command_t cmds[]);
40 int execute_line(char * line);
42 /* Converts a string to an integer */
43 int Parser_int(char *, int *);
45 /* Prompts for a string, with default values and a maximum length */
46 char *Parser_getstr(const char *prompt, const char *deft, char *res,
49 /* Prompts for an integer, with minimum, maximum and default values and base */
50 int Parser_getint(const char *prompt, long min, long max, long deft,
53 /* Prompts for a yes/no, with default */
54 int Parser_getbool(const char *prompt, int deft);
56 /* Extracts an integer from a string, or prompts if it cannot get one */
57 long Parser_intarg(const char *inp, const char *prompt, int deft,
58 int min, int max, int base);
60 /* Extracts a word from the input, or propmts if it cannot get one */
61 char *Parser_strarg(char *inp, const char *prompt, const char *deft,
62 char *answer, int len);
64 /* Extracts an integer from a string with a base */
65 int Parser_arg2int(const char *inp, long *result, int base);
67 /* Convert human readable size string to and int; "1k" -> 1000 */
68 int Parser_size(int *sizep, char *str);
70 /* Convert a string boolean to an int; "enable" -> 1 */
71 int Parser_bool(int *b, char *str);