json_add_opt_plugins_array * * @brief add a named array of plugins to the given response, * depending on whether it is important or not important. * * @param response - the `json_stream` to write into. * @param name - the field name of the array. * @param plugins - the plugins object to query. * @param important - match the `important` setting of the * plugins to be added. */
| 2367 | * plugins to be added. |
| 2368 | */ |
| 2369 | static |
| 2370 | void json_add_opt_plugins_array(struct json_stream *response, |
| 2371 | const char *name, |
| 2372 | const struct plugins *plugins, |
| 2373 | bool important) |
| 2374 | { |
| 2375 | struct plugin *p; |
| 2376 | |
| 2377 | /* we output 'plugins' and their options as an array of substructures */ |
| 2378 | json_array_start(response, name); |
| 2379 | list_for_each(&plugins->plugins, p, list) { |
| 2380 | /* Skip if not matching. */ |
| 2381 | if (p->important != important) |
| 2382 | continue; |
| 2383 | |
| 2384 | json_object_start(response, NULL); |
| 2385 | json_add_string(response, "path", p->cmd); |
| 2386 | |
| 2387 | /* FIXME: use executables basename until plugins can define their names */ |
| 2388 | json_add_string(response, "name", p->shortname); |
| 2389 | |
| 2390 | if (!list_empty(&p->plugin_opts)) { |
| 2391 | json_add_plugin_options(response, "options", p, false); |
| 2392 | } |
| 2393 | json_object_end(response); |
| 2394 | } |
| 2395 | json_array_end(response); |
| 2396 | } |
| 2397 | |
| 2398 | void json_add_opt_plugins(struct json_stream *response, |
| 2399 | const struct plugins *plugins) |
no test coverage detected