From: Christopher Faulet Date: Wed, 23 Apr 2025 14:27:45 +0000 (+0200) Subject: MINOR: cli: Rename some CLI applet states to reflect recent refactoring X-Git-Tag: v3.2-dev12~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44ace9a1b7929a46f19383e1ccca72004b91aef3;p=thirdparty%2Fhaproxy.git MINOR: cli: Rename some CLI applet states to reflect recent refactoring CLI_ST_GETREQ state was renamed into CLI_ST_PARSE_CMDLINE and CLI_ST_PARSEREQ into CLI_ST_PROCESS_CMDLINE to reflect the real action performed in these states. --- diff --git a/include/haproxy/cli-t.h b/include/haproxy/cli-t.h index 8555ea8c7..219984cf6 100644 --- a/include/haproxy/cli-t.h +++ b/include/haproxy/cli-t.h @@ -55,8 +55,8 @@ enum { CLI_ST_INIT = 0, /* initial state, must leave to zero ! */ CLI_ST_END, /* final state, let's close */ - CLI_ST_GETREQ, /* wait for a request */ - CLI_ST_PARSEREQ, /* parse a request */ + CLI_ST_PARSE_CMDLINE, /* wait for a full command line */ + CLI_ST_PROCESS_CMDLINE, /* process all commands on the command line */ CLI_ST_OUTPUT, /* all states after this one are responses */ CLI_ST_PROMPT, /* display the prompt (first output, same code) */ CLI_ST_PRINT, /* display const message in cli->msg */ diff --git a/src/cli.c b/src/cli.c index 7813ed9b2..f56ef9961 100644 --- a/src/cli.c +++ b/src/cli.c @@ -917,7 +917,7 @@ int cli_init(struct appctx *appctx) appctx->cli_severity_output = bind_conf->severity_output; applet_reset_svcctx(appctx); - appctx->st0 = CLI_ST_GETREQ; + appctx->st0 = CLI_ST_PARSE_CMDLINE; appctx->cli_level = bind_conf->level; appctx->cli_payload = NULL; appctx->chunk = NULL; @@ -1055,7 +1055,7 @@ int cli_parse_cmdline(struct appctx *appctx) } if (!(appctx->st1 & APPCTX_CLI_ST1_PAYLOAD)) { - appctx->st0 = CLI_ST_PARSEREQ; + appctx->st0 = CLI_ST_PROCESS_CMDLINE; break; } } @@ -1063,7 +1063,7 @@ int cli_parse_cmdline(struct appctx *appctx) appctx->st0 = CLI_ST_PROMPT; end: - if (appctx->st0 != CLI_ST_GETREQ) + if (appctx->st0 != CLI_ST_PARSE_CMDLINE) ret = 1; return ret; } @@ -1099,11 +1099,11 @@ void cli_io_handler(struct appctx *appctx) applet_set_eos(appctx); break; } - else if (appctx->st0 == CLI_ST_GETREQ) { + else if (appctx->st0 == CLI_ST_PARSE_CMDLINE) { if (cli_parse_cmdline(appctx) == 0) break; } - else if (appctx->st0 == CLI_ST_PARSEREQ) { + else if (appctx->st0 == CLI_ST_PROCESS_CMDLINE) { /* ensure we have some output room left in the event we * would want to return some info right after parsing. */ @@ -1229,7 +1229,7 @@ void cli_io_handler(struct appctx *appctx) if (applet_putstr(appctx, prompt) != -1) { applet_reset_svcctx(appctx); - appctx->st0 = (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) ? CLI_ST_GETREQ : CLI_ST_PARSEREQ; + appctx->st0 = (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) ? CLI_ST_PARSE_CMDLINE : CLI_ST_PROCESS_CMDLINE; } } @@ -1243,7 +1243,7 @@ void cli_io_handler(struct appctx *appctx) /* reactivate the \n at the end of the response for the next command */ appctx->st1 &= ~APPCTX_CLI_ST1_NOLF; - /* switch state back to GETREQ to read next requests in interactove mode, otherwise close */ + /* switch state back to PARSE_CMDLINE to read next requests in interactove mode, otherwise close */ if (appctx->st1 & APPCTX_CLI_ST1_LASTCMD) { applet_reset_svcctx(appctx); free_trash_chunk(appctx->chunk); @@ -1251,7 +1251,7 @@ void cli_io_handler(struct appctx *appctx) appctx->chunk = NULL; appctx->st1 &= ~APPCTX_CLI_ST1_LASTCMD; if (appctx->st1 & APPCTX_CLI_ST1_PROMPT) { - appctx->st0 = CLI_ST_GETREQ; + appctx->st0 = CLI_ST_PARSE_CMDLINE; applet_will_consume(appctx); applet_expect_data(appctx); } @@ -1262,7 +1262,7 @@ void cli_io_handler(struct appctx *appctx) } } - if ((b_data(&appctx->inbuf) && appctx->st0 == CLI_ST_GETREQ) || appctx->st0 == CLI_ST_PARSEREQ) + if ((b_data(&appctx->inbuf) && appctx->st0 == CLI_ST_PARSE_CMDLINE) || appctx->st0 == CLI_ST_PROCESS_CMDLINE) appctx_wakeup(appctx); /* this forces us to yield between pipelined commands and