William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 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 | struct cli_kw { |
| 27 | const char *str_kw[5]; /* keywords ended by NULL, limited to 5 |
| 28 | separated keywords combination */ |
| 29 | const char *usage; /* usage message */ |
Aurélien Nephtali | abbf607 | 2018-04-18 13:26:46 +0200 | [diff] [blame] | 30 | int (*parse)(char **args, char *payload, struct appctx *appctx, void *private); |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 31 | int (*io_handler)(struct appctx *appctx); |
| 32 | void (*io_release)(struct appctx *appctx); |
| 33 | void *private; |
William Lallemand | 14721be | 2018-10-26 14:47:37 +0200 | [diff] [blame] | 34 | int level; /* this is the level needed to show the keyword usage and to use it */ |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | struct cli_kw_list { |
| 38 | struct list list; |
| 39 | struct cli_kw kw[VAR_ARRAY]; |
| 40 | }; |
| 41 | |
Willy Tarreau | 3b6e547 | 2016-11-24 15:53:53 +0100 | [diff] [blame] | 42 | /* CLI states */ |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 43 | enum { |
Willy Tarreau | 3b6e547 | 2016-11-24 15:53:53 +0100 | [diff] [blame] | 44 | CLI_ST_INIT = 0, /* initial state, must leave to zero ! */ |
| 45 | CLI_ST_END, /* final state, let's close */ |
| 46 | CLI_ST_GETREQ, /* wait for a request */ |
| 47 | CLI_ST_OUTPUT, /* all states after this one are responses */ |
| 48 | CLI_ST_PROMPT, /* display the prompt (first output, same code) */ |
| 49 | CLI_ST_PRINT, /* display message in cli->msg */ |
| 50 | CLI_ST_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */ |
| 51 | CLI_ST_CALLBACK, /* custom callback pointer */ |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Andjelko Iharos | c4df59e | 2017-07-20 11:59:48 +0200 | [diff] [blame] | 54 | /* CLI severity output formats */ |
| 55 | enum { |
| 56 | CLI_SEVERITY_UNDEFINED = 0, /* undefined severity format */ |
| 57 | CLI_SEVERITY_NONE, /* no severity information prepended */ |
| 58 | CLI_SEVERITY_NUMBER, /* prepend informational cli messages with a severity as number */ |
| 59 | CLI_SEVERITY_STRING, /* prepend informational cli messages with a severity as string */ |
| 60 | }; |
| 61 | |
William Lallemand | 9ed6203 | 2016-11-21 17:49:11 +0100 | [diff] [blame] | 62 | |
| 63 | #endif /* _TYPES_CLI_H */ |