mirror of
https://github.com/haproxy/haproxy.git
synced 2026-02-03 20:39:41 -05:00
The table dump code was a horrible mess, with common parts interleaved all the way to deal with the various actions (set/clear/show). A few error messages were still incorrect, as the "set" operation did not update them so they would still report "unknown action" (now fixed). The action was now passed as a private argument to the CLI keyword which itself is copied into the appctx private field. It's just an int cast to a pointer. Some minor issues were noticed while doing this, for example when dumping an entry by key, if the key doesn't exist, nothing is printed, not even the table's header. It's unclear whether this was intentional but it doesn't really match what is done for data-based dumps. It was left unchanged for now so that a later fix can be backported if needed. Enum entries STAT_CLI_O_TAB, STAT_CLI_O_CLR and STAT_CLI_O_SET were removed.
56 lines
1.9 KiB
C
56 lines
1.9 KiB
C
/*
|
|
* include/types/cli.h
|
|
* This file provides structures and types for CLI.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _TYPES_CLI_H
|
|
#define _TYPES_CLI_H
|
|
|
|
#include <common/mini-clist.h>
|
|
#include <types/applet.h>
|
|
|
|
struct cli_kw {
|
|
const char *str_kw[5]; /* keywords ended by NULL, limited to 5
|
|
separated keywords combination */
|
|
const char *usage; /* usage message */
|
|
int (*parse)(char **args, struct appctx *appctx, void *private);
|
|
int (*io_handler)(struct appctx *appctx);
|
|
void (*io_release)(struct appctx *appctx);
|
|
void *private;
|
|
};
|
|
|
|
struct cli_kw_list {
|
|
struct list list;
|
|
struct cli_kw kw[VAR_ARRAY];
|
|
};
|
|
|
|
/* stats socket states */
|
|
enum {
|
|
STAT_CLI_INIT = 0, /* initial state, must leave to zero ! */
|
|
STAT_CLI_END, /* final state, let's close */
|
|
STAT_CLI_GETREQ, /* wait for a request */
|
|
STAT_CLI_OUTPUT, /* all states after this one are responses */
|
|
STAT_CLI_PROMPT, /* display the prompt (first output, same code) */
|
|
STAT_CLI_PRINT, /* display message in cli->msg */
|
|
STAT_CLI_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */
|
|
STAT_CLI_O_ERR, /* dump errors */
|
|
STAT_CLI_O_ENV, /* dump environment */
|
|
STAT_CLI_O_CUSTOM, /* custom callback pointer */
|
|
};
|
|
|
|
|
|
#endif /* _TYPES_CLI_H */
|