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

Function get_opt_val

lightningd/configs.c:63–99  ·  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 if (ot->type & OPT_CONCEAL)
68 return "...";
69
70 if (ot->show == (void *)opt_show_charp) {
71 /* Don't truncate or quote! */
72 return *(char **)ot->u.carg;
73 }
74 if (ot->show) {
75 /* Plugins options' show only shows defaults, so show val if
76 * we have it */
77 if (is_plugin_opt(ot) && cv)
78 return cv->optarg;
79 strcpy(buf + CONFIG_SHOW_BUFSIZE, "...");
80 if (ot->show(buf, CONFIG_SHOW_BUFSIZE, ot->u.carg))
81 return buf;
82 return NULL;
83 }
84
85 /* For everything else we only display if it's set,
86 * BUT we check here to make sure you've handled
87 * everything! */
88 if (is_known_opt_cb_arg(ot->cb_arg)
89 || is_restricted_print_if_nonnull(ot->cb_arg)) {
90 /* Only if set! */
91 if (cv)
92 return cv->optarg;
93 else
94 return NULL;
95 }
96
97 /* Insert more decodes here! */
98 errx(1, "Unknown decode for %s", ot->names);
99}
100
101static void check_literal(const char *name, const char *val)
102{

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