| 380 | } |
| 381 | |
| 382 | static 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 */ |
| 411 | static void configfile_replace_var(struct lightningd *ld, |
no test coverage detected