mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-26 21:31:01 +01:00
MINOR: services: extend list_services() to dump to stdout
When no output stream is passed, stdout is used with one entry per line, and this is called from dump_registered_services() when passed the class "svc".
This commit is contained in:
parent
3b65e14842
commit
5fcc100d91
@ -1827,6 +1827,7 @@ static void dump_registered_keywords(void)
|
||||
printf("all: list all keywords\n");
|
||||
printf("cfg: configuration keywords\n");
|
||||
printf("flt: filter names\n");
|
||||
printf("svc: service names\n");
|
||||
continue;
|
||||
}
|
||||
else if (strcmp(kwd_dump, "all") == 0) {
|
||||
@ -1842,6 +1843,11 @@ static void dump_registered_keywords(void)
|
||||
printf("# List of registered filter names:\n");
|
||||
flt_dump_kws(NULL);
|
||||
}
|
||||
|
||||
if (all || strcmp(kwd_dump, "svc") == 0) {
|
||||
printf("# List of registered service names:\n");
|
||||
list_services(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
src/stream.c
14
src/stream.c
@ -3072,21 +3072,27 @@ struct action_kw *service_find(const char *kw)
|
||||
return action_lookup(&service_keywords, kw);
|
||||
}
|
||||
|
||||
/* Lists the known services on <out> */
|
||||
/* Lists the known services on <out>. If <out> is null, emit them on stdout one
|
||||
* per line.
|
||||
*/
|
||||
void list_services(FILE *out)
|
||||
{
|
||||
struct action_kw_list *kw_list;
|
||||
int found = 0;
|
||||
int i;
|
||||
|
||||
fprintf(out, "Available services :");
|
||||
if (out)
|
||||
fprintf(out, "Available services :");
|
||||
list_for_each_entry(kw_list, &service_keywords, list) {
|
||||
for (i = 0; kw_list->kw[i].kw != NULL; i++) {
|
||||
found = 1;
|
||||
fprintf(out, " %s", kw_list->kw[i].kw);
|
||||
if (out)
|
||||
fprintf(out, " %s", kw_list->kw[i].kw);
|
||||
else
|
||||
printf("%s\n", kw_list->kw[i].kw);
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (!found && out)
|
||||
fprintf(out, " none\n");
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user