X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fhas_info.c;h=77867dedd9c875ff22bcc4f42c7886065bd99265;hp=e7f2622d45df54eab03dd1cd24228ce7328e2581;hb=fb4c4c3ddc24772f71a64ec02d2c9ddaeb6e9f6b;hpb=8f61c0bccb152b2365baf70deac1e59264d7feb7 diff --git a/tools/ccanlint/compulsory_tests/has_info.c b/tools/ccanlint/compulsory_tests/has_info.c index e7f2622d..77867ded 100644 --- a/tools/ccanlint/compulsory_tests/has_info.c +++ b/tools/ccanlint/compulsory_tests/has_info.c @@ -10,8 +10,11 @@ #include #include #include +#include -static void *check_has_info(struct manifest *m) +static void *check_has_info(struct manifest *m, + bool keep, + unsigned int *timeleft) { if (m->info_file) return NULL; @@ -20,8 +23,8 @@ static void *check_has_info(struct manifest *m) static const char *describe_has_info(struct manifest *m, void *check_result) { - return "You have no _info.c file.\n\n" - "The file _info.c contains the metadata for a ccan package: things\n" + return "You have no _info file.\n\n" + "The file _info contains the metadata for a ccan package: things\n" "like the dependencies, the documentation for the package as a whole\n" "and license information.\n"; } @@ -55,24 +58,29 @@ static const char template[] = static void create_info_template(struct manifest *m, void *check_result) { FILE *info; + const char *filename; - if (!ask("Should I create a template _info.c file for you?")) + if (!ask("Should I create a template _info file for you?")) return; - info = fopen("_info.c", "w"); + filename = talloc_asprintf(m, "%s/%s", m->dir, "_info"); + info = fopen(filename, "w"); if (!info) - err(1, "Trying to create a template _info.c"); + err(1, "Trying to create a template _info in %s", filename); if (fprintf(info, template, m->basename) < 0) { - unlink_noerr("_info.c"); - err(1, "Writing template into _info.c"); + unlink_noerr(filename); + err(1, "Writing template into %s", filename); } fclose(info); } struct ccanlint has_info = { - .name = "Has _info.c file", + .key = "info", + .name = "Module has _info file", .check = check_has_info, .describe = describe_has_info, .handle = create_info_template, }; + +REGISTER_TEST(has_info, NULL);