blob: 63e0e9d05de2899c11b0f62fbd4ef09574e0df54 [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 */
30 int (*parse)(char **args, struct appctx *appctx, void *private);
31 int (*io_handler)(struct appctx *appctx);
32 void (*io_release)(struct appctx *appctx);
33 void *private;
34};
35
36struct cli_kw_list {
37 struct list list;
38 struct cli_kw kw[VAR_ARRAY];
39};
40
Willy Tarreau3b6e5472016-11-24 15:53:53 +010041/* CLI states */
William Lallemand9ed62032016-11-21 17:49:11 +010042enum {
Willy Tarreau3b6e5472016-11-24 15:53:53 +010043 CLI_ST_INIT = 0, /* initial state, must leave to zero ! */
44 CLI_ST_END, /* final state, let's close */
45 CLI_ST_GETREQ, /* wait for a request */
46 CLI_ST_OUTPUT, /* all states after this one are responses */
47 CLI_ST_PROMPT, /* display the prompt (first output, same code) */
48 CLI_ST_PRINT, /* display message in cli->msg */
49 CLI_ST_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */
50 CLI_ST_CALLBACK, /* custom callback pointer */
William Lallemand9ed62032016-11-21 17:49:11 +010051};
52
Andjelko Iharosc4df59e2017-07-20 11:59:48 +020053/* CLI severity output formats */
54enum {
55 CLI_SEVERITY_UNDEFINED = 0, /* undefined severity format */
56 CLI_SEVERITY_NONE, /* no severity information prepended */
57 CLI_SEVERITY_NUMBER, /* prepend informational cli messages with a severity as number */
58 CLI_SEVERITY_STRING, /* prepend informational cli messages with a severity as string */
59};
60
William Lallemand9ed62032016-11-21 17:49:11 +010061
62#endif /* _TYPES_CLI_H */