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

Function get_opt_val

lightningd/configs.c:63–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61#define CONFIG_SHOW_BUFSIZE 4096
62
63static const char *get_opt_val(const struct opt_table *ot,
64 char buf[],
65 const struct configvar *cv)
66{
67 /* Only show that it's set, not the value */
68 if (ot->type & OPT_CONCEAL)
69 return cv ? "..." : NULL;
70
71 if (ot->show == (void *)opt_show_charp) {
72 /* Don't truncate or quote! */
73 return *(char **)ot->u.carg;
74 }
75 if (ot->show) {
76 /* Plugins options' show only shows defaults, so show val if
77 * we have it */
78 if (is_plugin_opt(ot) && cv)
79 return cv->optarg;
80 strcpy(buf + CONFIG_SHOW_BUFSIZE, "...");
81 if (ot->show(buf, CONFIG_SHOW_BUFSIZE, ot->u.carg))
82 return buf;
83 return NULL;
84 }
85
86 /* For everything else we only display if it's set,
87 * BUT we check here to make sure you've handled
88 * everything! */
89 if (is_known_opt_cb_arg(ot->cb_arg)
90 || is_restricted_print_if_nonnull(ot->cb_arg)) {
91 /* Only if set! */
92 if (cv)
93 return cv->optarg;
94 else
95 return NULL;
96 }
97
98 /* Insert more decodes here! */
99 errx(1, "Unknown decode for %s", ot->names);
100}
101
102static void check_literal(const char *name, const char *val)
103{

Callers 1

json_add_configFunction · 0.85

Calls 4

is_plugin_optFunction · 0.85
is_known_opt_cb_argFunction · 0.85
errxFunction · 0.85

Tested by

no test coverage detected