MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_add_plugin_options

Function json_add_plugin_options

lightningd/plugin.c:2121–2177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2119}
2120
2121static void json_add_plugin_options(struct json_stream *stream,
2122 const char *fieldname,
2123 struct plugin *plugin,
2124 bool include_deprecated)
2125{
2126 /* We don't allow multiple option names in plugins */
2127 struct lightningd *ld = plugin->plugins->ld;
2128 const char **namesarr = tal_arr(tmpctx, const char *, 1);
2129 struct plugin_opt *popt;
2130
2131 json_object_start(stream, fieldname);
2132 list_for_each(&plugin->plugin_opts, popt, list) {
2133 struct configvar *cv;
2134 const struct opt_table *ot;
2135
2136 if (!include_deprecated && !plugin_opt_deprecated_out_ok(popt))
2137 continue;
2138
2139 namesarr[0] = popt->name + 2;
2140 cv = configvar_first(ld->configvars, namesarr);
2141 if (!cv && !popt->def)
2142 continue;
2143
2144 ot = opt_find_long(namesarr[0], NULL);
2145 if (ot->type & OPT_MULTI) {
2146 json_array_start(stream, namesarr[0]);
2147 if (!cv) {
2148 json_add_plugin_val(stream, ot, NULL,
2149 popt->def);
2150 } else {
2151 while (cv) {
2152 json_add_plugin_val(stream,
2153 ot, NULL,
2154 cv->optarg);
2155 cv = configvar_next(ld->configvars,
2156 cv, namesarr);
2157 }
2158 }
2159 json_array_end(stream);
2160 } else {
2161 if (!cv) {
2162 json_add_plugin_val(stream, ot,
2163 namesarr[0],
2164 popt->def);
2165 } else if (cv->optarg) {
2166 json_add_plugin_val(stream,
2167 ot,
2168 namesarr[0],
2169 cv->optarg);
2170 } else {
2171 /* We specify non-arg options as 'true' */
2172 json_add_bool(stream, namesarr[0], true);
2173 }
2174 }
2175 }
2176 json_object_end(stream);
2177}
2178

Callers 2

Calls 10

json_object_startFunction · 0.85
configvar_firstFunction · 0.85
opt_find_longFunction · 0.85
json_array_startFunction · 0.85
json_add_plugin_valFunction · 0.85
configvar_nextFunction · 0.85
json_array_endFunction · 0.85
json_add_boolFunction · 0.85
json_object_endFunction · 0.85

Tested by

no test coverage detected