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

Function grab_and_check

lightningd/configs.c:382–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382static const char *grab_and_check(const tal_t *ctx,
383 const char *fname,
384 size_t linenum,
385 const char *expected,
386 char ***lines)
387{
388 char *contents;
389
390 contents = grab_file_str(tmpctx, fname);
391 if (!contents)
392 return tal_fmt(ctx, "Could not load configfile %s: %s",
393 fname, strerror(errno));
394
395 /* These are 1-based! */
396 assert(linenum > 0);
397 *lines = tal_strsplit(ctx, contents, "\r\n", STR_EMPTY_OK);
398 if (linenum >= tal_count(*lines))
399 return tal_fmt(ctx, "Configfile %s no longer has %zu lines!",
400 fname, linenum);
401
402 if (!streq((*lines)[linenum - 1], expected))
403 return tal_fmt(ctx, "Configfile %s line %zu changed from %s to %s!",
404 fname, linenum,
405 expected,
406 (*lines)[linenum - 1]);
407 return NULL;
408}
409
410/* This comments out the config file entry or maybe replace one */
411static void configfile_replace_var(struct lightningd *ld,

Callers 2

configfile_replace_varFunction · 0.85
json_setconfigFunction · 0.85

Calls 1

grab_file_strFunction · 0.85

Tested by

no test coverage detected