1 #include <tools/ccanlint/ccanlint.h>
2 #include <ccan/tal/tal.h>
3 #include <ccan/tal/str/str.h>
14 #include <ccan/noerr/noerr.h>
16 static void check_has_info(struct manifest *m,
17 unsigned int *timeleft,
22 score->score = score->total;
23 add_info_options(m->info_file);
25 score->error = tal_strdup(score,
26 "You have no _info file.\n\n"
27 "The file _info contains the metadata for a ccan package: things\n"
28 "like the dependencies, the documentation for the package as a whole\n"
29 "and license information.\n");
33 static const char template[] =
34 "#include \"config.h\"\n"
35 "#include <stdio.h>\n"
36 "#include <string.h>\n"
39 " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
41 " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
44 " * FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
46 "int main(int argc, char *argv[])\n"
48 " /* Expect exactly one argument */\n"
52 " if (strcmp(argv[1], \"depends\") == 0) {\n"
53 " PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
60 static void create_info_template(struct manifest *m, struct score *score)
65 if (!ask("Should I create a template _info file for you?"))
68 filename = tal_fmt(m, "%s/%s", m->dir, "_info");
69 info = fopen(filename, "w");
71 err(1, "Trying to create a template _info in %s", filename);
73 if (fprintf(info, template, m->modname) < 0) {
74 unlink_noerr(filename);
75 err(1, "Writing template into %s", filename);
80 struct ccanlint info_exists = {
82 .name = "Module has _info file",
84 .check = check_has_info,
85 .handle = create_info_template,
89 REGISTER_TEST(info_exists);