Commit 745b2f66 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

parent 0051cbe3
......@@ -316,6 +316,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);
......@@ -424,6 +425,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;
......
......@@ -1573,29 +1573,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
......@@ -1777,7 +1754,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