mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-08 08:07:10 +02:00
CLEANUP: mworker/cli: clean up the mode handling
Cleanup the mode handling by refactoring the strings constant that are written multiple times
This commit is contained in:
parent
48514c118c
commit
75944e266e
25
src/cli.c
25
src/cli.c
@ -2918,16 +2918,19 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
|||||||
|
|
||||||
/* the mcli-debug-mode is only sent to the applet of the master */
|
/* the mcli-debug-mode is only sent to the applet of the master */
|
||||||
if ((s->pcli_flags & ACCESS_MCLI_DEBUG) && *next_pid <= 0) {
|
if ((s->pcli_flags & ACCESS_MCLI_DEBUG) && *next_pid <= 0) {
|
||||||
ci_insert(req, 0, "mcli-debug-mode on -;", strlen("mcli-debug-mode on -;"));
|
const char *cmd = "mcli-debug-mode on -;";
|
||||||
ret += strlen("mcli-debug-mode on -;");
|
ci_insert(req, 0, cmd, strlen(cmd));
|
||||||
|
ret += strlen(cmd);
|
||||||
}
|
}
|
||||||
if (s->pcli_flags & ACCESS_EXPERIMENTAL) {
|
if (s->pcli_flags & ACCESS_EXPERIMENTAL) {
|
||||||
ci_insert(req, 0, "experimental-mode on -;", strlen("experimental-mode on -;"));
|
const char *cmd = "experimental-mode on -;";
|
||||||
ret += strlen("experimental-mode on -;");
|
ci_insert(req, 0, cmd, strlen(cmd));
|
||||||
|
ret += strlen(cmd);
|
||||||
}
|
}
|
||||||
if (s->pcli_flags & ACCESS_EXPERT) {
|
if (s->pcli_flags & ACCESS_EXPERT) {
|
||||||
ci_insert(req, 0, "expert-mode on -;", strlen("expert-mode on -;"));
|
const char *cmd = "expert-mode on -;";
|
||||||
ret += strlen("expert-mode on -;");
|
ci_insert(req, 0, cmd, strlen(cmd));
|
||||||
|
ret += strlen(cmd);
|
||||||
}
|
}
|
||||||
if (s->pcli_flags & ACCESS_MCLI_SEVERITY_STR) {
|
if (s->pcli_flags & ACCESS_MCLI_SEVERITY_STR) {
|
||||||
const char *cmd = "set severity-output string -;";
|
const char *cmd = "set severity-output string -;";
|
||||||
@ -2943,11 +2946,13 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
|||||||
if (pcli_has_level(s, ACCESS_LVL_ADMIN)) {
|
if (pcli_has_level(s, ACCESS_LVL_ADMIN)) {
|
||||||
goto end;
|
goto end;
|
||||||
} else if (pcli_has_level(s, ACCESS_LVL_OPER)) {
|
} else if (pcli_has_level(s, ACCESS_LVL_OPER)) {
|
||||||
ci_insert(req, 0, "operator -;", strlen("operator -;"));
|
const char *cmd = "operator -;";
|
||||||
ret += strlen("operator -;");
|
ci_insert(req, 0, cmd, strlen(cmd));
|
||||||
|
ret += strlen(cmd);
|
||||||
} else if (pcli_has_level(s, ACCESS_LVL_USER)) {
|
} else if (pcli_has_level(s, ACCESS_LVL_USER)) {
|
||||||
ci_insert(req, 0, "user -;", strlen("user -;"));
|
const char *cmd = "user -;";
|
||||||
ret += strlen("user -;");
|
ci_insert(req, 0, cmd, strlen(cmd));
|
||||||
|
ret += strlen(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
Loading…
Reference in New Issue
Block a user