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_ignore_errors(int ignore); /* Set the ignore errors flag */
38 void Parser_printhelp(char *); /* Detailed help routine */
39 void Parser_exit(int, char **); /* Shuts down command parser */
40 int Parser_execarg(int argc, char **argv, command_t cmds[]);
41 int execute_line(char * line);
43 /* Converts a string to an integer */
44 int Parser_int(char *, int *);
46 /* Prompts for a string, with default values and a maximum length */
47 char *Parser_getstr(const char *prompt, const char *deft, char *res,
50 /* Prompts for an integer, with minimum, maximum and default values and base */
51 int Parser_getint(const char *prompt, long min, long max, long deft,
54 /* Prompts for a yes/no, with default */
55 int Parser_getbool(const char *prompt, int deft);
57 /* Extracts an integer from a string, or prompts if it cannot get one */
58 long Parser_intarg(const char *inp, const char *prompt, int deft,
59 int min, int max, int base);
61 /* Extracts a word from the input, or propmts if it cannot get one */
62 char *Parser_strarg(char *inp, const char *prompt, const char *deft,
63 char *answer, int len);
65 /* Extracts an integer from a string with a base */
66 int Parser_arg2int(const char *inp, long *result, int base);
68 /* Convert human readable size string to and int; "1k" -> 1000 */
69 int Parser_size(int *sizep, char *str);
71 /* Convert a string boolean to an int; "enable" -> 1 */
72 int Parser_bool(int *b, char *str);