]>
Commit | Line | Data |
---|---|---|
ad02a0eb SH |
1 | /************************************************************************ |
2 | * RSTP library - Rapid Spanning Tree (802.1t, 802.1w) | |
3 | * Copyright (C) 2001-2003 Optical Access | |
4 | * Author: Alex Rozin | |
5 | * | |
6 | * This file is part of RSTP library. | |
7 | * | |
8 | * RSTP library is free software; you can redistribute it and/or modify it | |
9 | * under the terms of the GNU Lesser General Public License as published by the | |
10 | * Free Software Foundation; version 2.1 | |
11 | * | |
12 | * RSTP library is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public License | |
18 | * along with RSTP library; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | **********************************************************************/ | |
22 | ||
23 | #ifndef _CLI_API__ | |
24 | #define _CLI_API__ | |
25 | ||
26 | #define MAX_CLI_BUFF 80 | |
27 | #define MAXPARAMNUM 6 | |
28 | #define MAXPARAMLEN 40 | |
29 | #define MAX_CLI_PROMT 24 | |
30 | #define MAX_SELECTOR 12 | |
31 | ||
32 | typedef int CLI_CMD_CLBK (int argc, char** argv); | |
33 | ||
34 | typedef enum { | |
35 | CMD_PAR_NUMBER, | |
36 | CMD_PAR_STRING, | |
37 | CMD_PAR_BOOL_YN, | |
38 | CMD_PAR_ENUM, | |
39 | } CMD_PARAM_TYPE_T; | |
40 | ||
41 | typedef struct cmd_par_number_limits_s { | |
42 | unsigned long min; | |
43 | unsigned long max; | |
44 | } CMD_PAR_LIMITS; | |
45 | ||
46 | typedef struct cmd_par_string_selector_s { | |
47 | char* string_value; | |
48 | char* string_help; | |
49 | } CMD_PAR_SELECTOR; | |
50 | ||
51 | typedef struct cmd_par_dscr_s { | |
52 | char* param_help; | |
53 | CMD_PARAM_TYPE_T param_type; | |
54 | CMD_PAR_LIMITS number_limits; | |
55 | CMD_PAR_SELECTOR string_selector[MAX_SELECTOR]; | |
56 | char* default_value; | |
57 | } CMD_PAR_DSCR_T; | |
58 | ||
59 | typedef struct cmd_dscr_s { | |
60 | char* cmd_name; | |
61 | char* cmd_help; | |
62 | CMD_PAR_DSCR_T param[MAXPARAMNUM]; | |
63 | CLI_CMD_CLBK* clbk; | |
64 | } CMD_DSCR_T; | |
65 | ||
66 | #define THE_COMMAND(x, y) {x, y, { | |
67 | #define PARAM_NUMBER(x,zmin,zmax,def) {x,CMD_PAR_NUMBER, {zmin, zmax}, {}, def}, | |
68 | #define PARAM_STRING(x, def) {x,CMD_PAR_STRING, {}, {}, def}, | |
69 | #define PARAM_ENUM(x) {x,CMD_PAR_ENUM, {}, { | |
70 | #define PARAM_ENUM_SEL(x, y) {x, y}, | |
71 | #define PARAM_ENUM_DEFAULT(def) }, def}, | |
72 | #define PARAM_BOOL(x,yesd,nod,def) {x, CMD_PAR_ENUM, {}, {{"y",yesd},{"n",nod}},def} | |
73 | #define THE_FUNC(x) }, &x}, | |
74 | #define END_OF_LANG {NULL,NULL} | |
75 | ||
76 | char *get_prompt (void); /* this function not from the lib ! */ | |
77 | ||
78 | void cli_debug_dump_args (char* title, int argc, char** argv); | |
79 | ||
80 | void cli_register_language (const CMD_DSCR_T* cmd_list); | |
81 | void usage (void); | |
82 | int cli_execute_command (const char* line); | |
83 | #ifdef OLD_READLINE | |
84 | void rl_read_cli (void); | |
85 | #else | |
86 | void rl_read_cli (char *); | |
87 | #endif | |
88 | void rl_init (void); | |
89 | void rl_shutdown (void); | |
90 | char* UT_sprint_time_stamp (void); | |
91 | ||
92 | #endif /* _CLI_API__ */ | |
93 |