| 40 | "}\n"; |
| 41 | |
| 42 | int 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 | } |
nothing calls this directly
no test coverage detected