From: William Lallemand Date: Thu, 13 Dec 2018 08:05:46 +0000 (+0100) Subject: CLEANUP: cli: use dedicated define instead of appctx ones X-Git-Tag: v1.9-dev11~74 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dc12c2e56cd99150e637ad0f5e1ed3578cbab171;p=thirdparty%2Fhaproxy.git CLEANUP: cli: use dedicated define instead of appctx ones Replace APPCTX_CLI_ST1_PAYLOAD and APPCTX_CLI_ST1_PROMPT by PCLI_F_PAYLOAD and PCLI_F_PROMPT in the master CLI code. --- diff --git a/include/types/stream.h b/include/types/stream.h index 8cee760d9e..cdd6a51197 100644 --- a/include/types/stream.h +++ b/include/types/stream.h @@ -92,6 +92,12 @@ #define SF_SRV_REUSED 0x00100000 /* the server-side connection was reused */ + +/* flags for the proxy of the master CLI */ + +#define PCLI_F_PROMPT 0x4 +#define PCLI_F_PAYLOAD 0x8 + /* some external definitions */ struct strm_logs { int logwait; /* log fields waiting to be collected : LW_* */ diff --git a/src/cli.c b/src/cli.c index 9fa50779c3..9a8a636461 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1702,10 +1702,10 @@ void pcli_write_prompt(struct stream *s) struct buffer *msg = get_trash_chunk(); struct channel *oc = si_oc(&s->si[0]); - if (!(s->pcli_flags & APPCTX_CLI_ST1_PROMPT)) + if (!(s->pcli_flags & PCLI_F_PROMPT)) return; - if (s->pcli_flags & APPCTX_CLI_ST1_PAYLOAD) { + if (s->pcli_flags & PCLI_F_PAYLOAD) { chunk_appendf(msg, "+ "); } else { if (s->pcli_next_pid == 0) @@ -1834,7 +1834,7 @@ int pcli_find_and_exec_kw(struct stream *s, char **args, int argl, char **errmsg *next_pid = target_pid; return 1; } else if (!strcmp("prompt", args[0])) { - s->pcli_flags ^= APPCTX_CLI_ST1_PROMPT; + s->pcli_flags ^= PCLI_F_PROMPT; return argl; /* return the number of elements in the array */ } else if (!strcmp("quit", args[0])) { @@ -1870,7 +1870,7 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int p = str; - if (!(s->pcli_flags & APPCTX_CLI_ST1_PAYLOAD)) { + if (!(s->pcli_flags & PCLI_F_PAYLOAD)) { /* Looks for the end of one command */ while (p+reql < end) { @@ -1907,15 +1907,15 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int } /* last line of the payload */ - if ((s->pcli_flags & APPCTX_CLI_ST1_PAYLOAD) && (reql == 1)) { - s->pcli_flags &= ~APPCTX_CLI_ST1_PAYLOAD; + if ((s->pcli_flags & PCLI_F_PAYLOAD) && (reql == 1)) { + s->pcli_flags &= ~PCLI_F_PAYLOAD; return reql; } payload = strstr(p, PAYLOAD_PATTERN); if ((end - 1) == (payload + strlen(PAYLOAD_PATTERN))) { /* if the payload pattern is at the end */ - s->pcli_flags |= APPCTX_CLI_ST1_PAYLOAD; + s->pcli_flags |= PCLI_F_PAYLOAD; return reql; } @@ -2027,7 +2027,7 @@ read_again: /* forward only 1 command */ channel_forward(req, to_forward); - if (!(s->pcli_flags & APPCTX_CLI_ST1_PAYLOAD)) { + if (!(s->pcli_flags & PCLI_F_PAYLOAD)) { /* we send only 1 command per request, and we write close after it */ channel_shutw_now(req); } else { @@ -2094,7 +2094,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) channel_dont_close(&s->res); channel_dont_close(&s->req); - if (s->pcli_flags & APPCTX_CLI_ST1_PAYLOAD) { + if (s->pcli_flags & PCLI_F_PAYLOAD) { s->req.analysers |= AN_REQ_WAIT_CLI; s->res.analysers &= ~AN_RES_WAIT_CLI; s->req.flags |= CF_WAKE_ONCE; /* need to be called again if there is some command left in the request */