Coda Distributed File System
parser.h
Go to the documentation of this file.
1/* BLURB lgpl
2
3 Coda File System
4 Release 6
5
6 Copyright (c) 1987-2003 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU Library General Public Licence Version 2, as
11shown in the file LICENSE. The technical and financial contributors to
12Coda are listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19#ifndef _PARSER_H_
20#define _PARSER_H_
21
22#define HISTORY 100 /* Don't let history grow unbounded */
23#define MAXARGS 100
24
25typedef struct cmd {
26 const char *name;
27 void (*func)(int, char **);
28 struct cmd *sub_cmd;
29 const char *help;
30} command_t;
31
32typedef struct argcmd {
33 const char *ac_name;
34 int (*ac_func)(int, char **);
35 const char *ac_help;
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41void Parser_init(const char *, command_t *); /* Set prompt and load cmd list */
42void Parser_commands(void); /* Start the command parser */
43void Parser_qhelp(int, char **); /* Quick help routine */
44void Parser_help(int, char **); /* Detailed help routine */
45void Parser_exit(int, char **); /* Shuts down command parser */
46int Parser_execarg(int argc, char **argv, argcmd_t cmds[]);
47void execute_line(char *line);
48
49/* Converts a string to an integer */
50int Parser_uint(char *, unsigned int *);
51
52/* Prompts for a string, with default values and a maximum length */
53char *Parser_getstr(const char *prompt, const char *deft, char *res,
54 size_t len);
55
56/* Prompts for an integer, with minimum, maximum and default values and base */
57int Parser_getint(const char *prompt, long min, long max, long deft, int base);
58
59/* Prompts for a yes/no, with default */
60int Parser_getbool(const char *prompt, int deft);
61
62/* Extracts an integer from a string, or prompts if it cannot get one */
63long Parser_intarg(const char *inp, const char *prompt, int deft, int min,
64 int max, int base);
65
66/* Extracts a word from the input, or propmts if it cannot get one */
67char *Parser_strarg(char *inp, const char *prompt, const char *deft,
68 char *answer, int len);
69
70/* Extracts an integer from a string with a base */
71int Parser_arg2int(const char *inp, long *result, int base);
72#ifdef __cplusplus
73}
74#endif
75
76#endif /* _PARSER_H_ */
Definition: ruletypes.h:90
char * argv[]
Definition: dir.cc:35
RPC2_PacketBuffer * answer
Definition: test.c:176
void Parser_commands(void)
Definition: parser.c:297
void execute_line(char *line)
Definition: parser.c:257
long Parser_intarg(const char *inp, const char *prompt, int deft, int min, int max, int base)
Definition: parser.c:562
struct cmd command_t
Definition: ruletypes.h:73
char * Parser_strarg(char *inp, const char *prompt, const char *deft, char *answer, int len)
Definition: parser.c:578
int Parser_getint(const char *prompt, long min, long max, long deft, int base)
Definition: parser.c:467
int Parser_getbool(const char *prompt, int deft)
Definition: parser.c:512
int Parser_arg2int(const char *inp, long *result, int base)
Definition: parser.c:589
int Parser_execarg(int argc, char **argv, argcmd_t cmds[])
Definition: parser.c:134
char * Parser_getstr(const char *prompt, const char *deft, char *res, size_t len)
Definition: parser.c:439
void Parser_qhelp(int, char **)
struct argcmd argcmd_t
int Parser_uint(char *, unsigned int *)
Definition: parser.c:343
void Parser_init(const char *, command_t *)
Definition: parser.c:325
void Parser_help(int, char **)
Definition: parser.c:366
void Parser_exit(int, char **)
Definition: parser.h:32
const char * ac_name
Definition: parser.h:33
const char * ac_help
Definition: parser.h:35
int(* ac_func)(int, char **)
Definition: parser.h:34
Definition: parser.h:25
const char * help
Definition: parser.h:29
void(* func)(int, char **)
Definition: parser.h:27
const char * name
Definition: parser.h:26
struct cmd * sub_cmd
Definition: parser.h:28