Whamcloud - gitweb
LU-16723 parser: fix help hanging
[fs/lustre-release.git] / libcfs / include / libcfs / util / parser.h
1 // SPDX-License-Identifier: GPL-2.0
2
3 /*
4  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
5  * Use is subject to license terms.
6  *
7  * Copyright (c) 2014, 2017, Intel Corporation.
8  *
9  */
10
11 /*
12  * This file is part of Lustre, http://www.lustre.org/
13  *
14  * libcfs/include/libcfs/util/parser.h
15  *
16  * A command line parser.
17  *
18  */
19
20 #ifndef _PARSER_H_
21 #define _PARSER_H_
22
23 #define HISTORY 100
24 #define MAXARGS 512
25 #define MAXCMDS 1024
26
27 #define CMD_COMPLETE    0
28 #define CMD_INCOMPLETE  1
29 #define CMD_NONE        2
30 #define CMD_AMBIG       3
31 #define CMD_HELP        4
32
33 typedef struct parser_cmd {
34         char    *pc_name;
35         int     (* pc_func)(int, char **);
36         struct parser_cmd * pc_sub_cmd;
37         char *pc_help;
38 } command_t;
39
40 typedef struct argcmd {
41         char    *ac_name;
42         int      (*ac_func)(int, char **);
43         char     *ac_help;
44 } argcmd_t;
45
46 typedef struct network {
47         char    *type;
48         char    *server;
49         int     port;
50 } network_t;
51
52 int cfs_parser(int argc, char **argv, command_t cmds[]);
53
54 #endif