blob: 913167a479b723aac65e72a2d808ac4be600b22f [file] [log] [blame]
William Lallemand9ed62032016-11-21 17:49:11 +01001/*
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
26struct 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 Nephtaliabbf6072018-04-18 13:26:46 +020030 int (*parse)(char **args, char *payload, struct appctx *appctx, void *private);
William Lallemand9ed62032016-11-21 17:49:11 +010031 int (*io_handler)(struct appctx *appctx);
32 void (*io_release)(struct appctx *appctx);
33 void *private;
William Lallemand14721be2018-10-26 14:47:37 +020034 int level; /* this is the level needed to show the keyword usage and to use it */
William Lallemand9ed62032016-11-21 17:49:11 +010035};
36
37struct cli_kw_list {
38 struct list list;
39 struct cli_kw kw[VAR_ARRAY];
40};
41
Willy Tarreau3b6e5472016-11-24 15:53:53 +010042/* CLI states */
William Lallemand9ed62032016-11-21 17:49:11 +010043enum {
Willy Tarreau3b6e5472016-11-24 15:53:53 +010044 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 Lallemand9ed62032016-11-21 17:49:11 +010052};
53
Andjelko Iharosc4df59e2017-07-20 11:59:48 +020054/* CLI severity output formats */
55enum {
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 Lallemand9ed62032016-11-21 17:49:11 +010062
63#endif /* _TYPES_CLI_H */