X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fhas_info.c;h=ce131f85686ec88111c1b0ea709a04c77fbbcc50;hb=f76c68579cb445177b9957814ba8623a73e5d60e;hp=4b6687e45ea196c2e93de17513aa1f54ef37dec9;hpb=357700fd05c2cf25563a0058fd68f2ffea827e74;p=ccan diff --git a/tools/ccanlint/compulsory_tests/has_info.c b/tools/ccanlint/compulsory_tests/has_info.c index 4b6687e4..ce131f85 100644 --- a/tools/ccanlint/compulsory_tests/has_info.c +++ b/tools/ccanlint/compulsory_tests/has_info.c @@ -10,20 +10,22 @@ #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, + struct score *score) { - if (m->info_file) - return NULL; - return m; -} - -static const char *describe_has_info(struct manifest *m, void *check_result) -{ - return "You have no _info file.\n\n" + if (m->info_file) { + score->pass = true; + score->score = score->total; + } else { + score->error = "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"; + } } static const char template[] = @@ -52,20 +54,22 @@ static const char template[] = " return 1;\n" "}\n"; -static void create_info_template(struct manifest *m, void *check_result) +static void create_info_template(struct manifest *m, struct score *score) { FILE *info; + const char *filename; if (!ask("Should I create a template _info file for you?")) return; - info = fopen("_info", "w"); + filename = talloc_asprintf(m, "%s/%s", m->dir, "_info"); + info = fopen(filename, "w"); if (!info) - err(1, "Trying to create a template _info"); + err(1, "Trying to create a template _info in %s", filename); if (fprintf(info, template, m->basename) < 0) { - unlink_noerr("_info"); - err(1, "Writing template into _info"); + unlink_noerr(filename); + err(1, "Writing template into %s", filename); } fclose(info); } @@ -74,7 +78,6 @@ struct ccanlint has_info = { .key = "info", .name = "Module has _info file", .check = check_has_info, - .describe = describe_has_info, .handle = create_info_template, };