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

Function main

tools/headerversions.c:58–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56 "}\n";
57
58int main(int argc, char *argv[])
59{
60 char *file, *new;
61
62 /* We don't bother with setup_locale(); we're a build tool */
63 err_set_progname(argv[0]);
64
65 if (argc != 2)
66 errx(1, "Usage: %s <versionheader>", argv[0]);
67
68 file = grab_file(NULL, argv[1]);
69 if (!file && errno != ENOENT)
70 err(1, "Reading %s", argv[1]);
71
72 new = tal_fmt(NULL, template,
73 gmp_version,
74 IF_SQLITE3(sqlite3_libversion_number(),)
75 zlibVersion());
76 if (!file || !streq(new, file)) {
77 int fd = open(argv[1], O_TRUNC|O_WRONLY|O_CREAT, 0666);
78 if (fd < 0)
79 err(1, "Writing %s", argv[1]);
80 if (!write_all(fd, new, strlen(new)))
81 err(1, "Writing to %s", argv[1]);
82 close(fd);
83 }
84 tal_free(new);
85 tal_free(file);
86 return 0;
87}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected