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,
16 unsigned int *timeleft,
21 score->score = score->total;
22 add_info_options(m->info_file);
24 score->error = talloc_strdup(score,
25 "You have no _info file.\n\n"
26 "The file _info contains the metadata for a ccan package: things\n"
27 "like the dependencies, the documentation for the package as a whole\n"
28 "and license information.\n");
32 static const char template[] =
33 "#include <string.h>\n"
34 "#include \"config.h\"\n"
37 " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
39 " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
42 " * FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
44 "int main(int argc, char *argv[])\n"
46 " /* Expect exactly one argument */\n"
50 " if (strcmp(argv[1], \"depends\") == 0) {\n"
51 " PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
58 static void create_info_template(struct manifest *m, struct score *score)
63 if (!ask("Should I create a template _info file for you?"))
66 filename = talloc_asprintf(m, "%s/%s", m->dir, "_info");
67 info = fopen(filename, "w");
69 err(1, "Trying to create a template _info in %s", filename);
71 if (fprintf(info, template, m->basename) < 0) {
72 unlink_noerr(filename);
73 err(1, "Writing template into %s", filename);
78 struct ccanlint info_exists = {
80 .name = "Module has _info file",
82 .check = check_has_info,
83 .handle = create_info_template,
87 REGISTER_TEST(info_exists);