1 /* 2 * include/types/cli.h 3 * This file provides structures and types for CLI. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation, version 2.1 8 * exclusively. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef _TYPES_CLI_H 21 #define _TYPES_CLI_H 22 23 #include <common/mini-clist.h> 24 #include <types/applet.h> 25 26 #define CLI_PREFIX_KW_NB 5 27 28 struct cli_kw { 29 const char *str_kw[CLI_PREFIX_KW_NB]; /* keywords ended by NULL, limited to CLI_PREFIX_KW_NB 30 separated keywords combination */ 31 const char *usage; /* usage message */ 32 int (*parse)(char **args, char *payload, struct appctx *appctx, void *private); 33 int (*io_handler)(struct appctx *appctx); 34 void (*io_release)(struct appctx *appctx); 35 void *private; 36 int level; /* this is the level needed to show the keyword usage and to use it */ 37 }; 38 39 struct cli_kw_list { 40 struct list list; 41 struct cli_kw kw[VAR_ARRAY]; 42 }; 43 44 /* CLI states */ 45 enum { 46 CLI_ST_INIT = 0, /* initial state, must leave to zero ! */ 47 CLI_ST_END, /* final state, let's close */ 48 CLI_ST_GETREQ, /* wait for a request */ 49 CLI_ST_OUTPUT, /* all states after this one are responses */ 50 CLI_ST_PROMPT, /* display the prompt (first output, same code) */ 51 CLI_ST_PRINT, /* display message in cli->msg */ 52 CLI_ST_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */ 53 CLI_ST_CALLBACK, /* custom callback pointer */ 54 }; 55 56 /* CLI severity output formats */ 57 enum { 58 CLI_SEVERITY_UNDEFINED = 0, /* undefined severity format */ 59 CLI_SEVERITY_NONE, /* no severity information prepended */ 60 CLI_SEVERITY_NUMBER, /* prepend informational cli messages with a severity as number */ 61 CLI_SEVERITY_STRING, /* prepend informational cli messages with a severity as string */ 62 }; 63 64 65 #endif /* _TYPES_CLI_H */ 66