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

Function main

tools/headerversions.c:42–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 "}\n";
41
42int main(int argc, char *argv[])
43{
44 char *file, *new;
45
46 /* We don't bother with setup_locale(); we're a build tool */
47 err_set_progname(argv[0]);
48
49 if (argc != 2)
50 errx(1, "Usage: %s <versionheader>", argv[0]);
51
52 file = grab_file_str(NULL, argv[1]);
53 if (!file && errno != ENOENT)
54 err(1, "Reading %s", argv[1]);
55
56 new = tal_fmt(NULL, template
57 IF_SQLITE3(, sqlite3_libversion_number()));
58 if (!file || !streq(new, file)) {
59 int fd = open(argv[1], O_TRUNC|O_WRONLY|O_CREAT, 0666);
60 if (fd < 0)
61 err(1, "Writing %s", argv[1]);
62 if (!write_all(fd, new, strlen(new)))
63 err(1, "Writing to %s", argv[1]);
64 close(fd);
65 }
66 tal_free(new);
67 tal_free(file);
68 return 0;
69}

Callers

nothing calls this directly

Calls 6

err_set_prognameFunction · 0.85
errxFunction · 0.85
grab_file_strFunction · 0.85
errFunction · 0.85
tal_freeFunction · 0.85
write_allFunction · 0.50

Tested by

no test coverage detected