Commit e464a940 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Move the "loop" word up to global level, so it works everywhere.

parent d4135153
......@@ -306,6 +306,7 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv,
char *e, *p, *q, *f, *buf;
int nest_brace;
int tn;
unsigned n, m;
const struct cmds *cp;
AN(spec);
......@@ -414,6 +415,24 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv,
}
}
/* SECTION: loop loop
*
* loop NUMBER STRING
* Process STRING as a specification, NUMBER times.
*
* This works inside all specification strings
*/
if (!strcmp(token_s[0], "loop")) {
n = strtoul(token_s[1], NULL, 0);
for (m = 0; m < n; m++) {
vtc_log(vl, 4, "Loop #%u", m);
parse_string(token_s[2], cmd, priv, vl);
}
continue;
}
for (cp = cmd; cp->name != NULL; cp++)
if (!strcmp(token_s[0], cp->name))
break;
......
......@@ -1616,29 +1616,6 @@ cmd_http_accept(CMD_ARGS)
vtc_log(vl, 3, "Accepted socket fd is %d", hp->fd);
}
/* SECTION: client-server.spec.loop
*
* loop NUMBER STRING
* Process STRING as a specification, NUMBER times.
*/
static void
cmd_http_loop(CMD_ARGS)
{
struct http *hp;
unsigned n, m;
CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
AN(av[1]);
AN(av[2]);
AZ(av[3]);
n = strtoul(av[1], NULL, 0);
for (m = 1 ; m <= n; m++) {
vtc_log(vl, 4, "Loop #%u", m);
parse_string(av[2], cmd, hp, vl);
}
}
/* SECTION: client-server.spec.fatal
*
* fatal|non_fatal
......@@ -1820,7 +1797,6 @@ const struct cmds http_cmds[] = {
/* spec */
CMD_HTTP(fatal)
CMD_HTTP(loop)
CMD_HTTP(non_fatal)
/* body */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment