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

Function is_literal

cli/lightning-cli.c:258–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258static bool is_literal(const char *arg)
259{
260 size_t arglen = strlen(arg);
261 if (arglen == 0) {
262 return false;
263 }
264 /* A string of digits with a leading zero cannot be a literal unless it
265 * is "0". It should be passed with quotes as it might encode a hex
266 * data. */
267 if (strspn(arg, "0123456789") == arglen && arglen > 1 &&
268 arg[0] == '0') {
269 return false;
270 }
271 return strspn(arg, "0123456789.") == arglen
272 || streq(arg, "true")
273 || streq(arg, "false")
274 || streq(arg, "null")
275 || (arg[0] == '{' && arg[arglen - 1] == '}')
276 || (arg[0] == '[' && arg[arglen - 1] == ']')
277 || (arg[0] == '"' && arg[arglen - 1] == '"');
278}
279
280static void add_input(char **cmd, const char *input,
281 int i, int argc)

Callers 1

add_inputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected