1 #include <tools/ccanlint/ccanlint.h>
12 #include <ccan/noerr/noerr.h>
13 #include <ccan/talloc/talloc.h>
15 static void check_has_info(struct manifest *m,
17 unsigned int *timeleft,
22 score->score = score->total;
24 score->error = "You have no _info file.\n\n"
25 "The file _info contains the metadata for a ccan package: things\n"
26 "like the dependencies, the documentation for the package as a whole\n"
27 "and license information.\n";
31 static const char template[] =
32 "#include <string.h>\n"
33 "#include \"config.h\"\n"
36 " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
38 " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
41 " * FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
43 "int main(int argc, char *argv[])\n"
45 " /* Expect exactly one argument */\n"
49 " if (strcmp(argv[1], \"depends\") == 0) {\n"
50 " PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
57 static void create_info_template(struct manifest *m, struct score *score)
62 if (!ask("Should I create a template _info file for you?"))
65 filename = talloc_asprintf(m, "%s/%s", m->dir, "_info");
66 info = fopen(filename, "w");
68 err(1, "Trying to create a template _info in %s", filename);
70 if (fprintf(info, template, m->basename) < 0) {
71 unlink_noerr(filename);
72 err(1, "Writing template into %s", filename);
77 struct ccanlint has_info = {
79 .name = "Module has _info file",
80 .check = check_has_info,
81 .handle = create_info_template,
84 REGISTER_TEST(has_info, NULL);