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, unsigned int *timeleft)
22 static const char *describe_has_info(struct manifest *m, void *check_result)
24 return "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";
30 static const char template[] =
31 "#include <string.h>\n"
32 "#include \"config.h\"\n"
35 " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
37 " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
40 " * FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
42 "int main(int argc, char *argv[])\n"
44 " /* Expect exactly one argument */\n"
48 " if (strcmp(argv[1], \"depends\") == 0) {\n"
49 " PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
56 static void create_info_template(struct manifest *m, void *check_result)
61 if (!ask("Should I create a template _info file for you?"))
64 filename = talloc_asprintf(m, "%s/%s", m->dir, "_info");
65 info = fopen(filename, "w");
67 err(1, "Trying to create a template _info in %s", filename);
69 if (fprintf(info, template, m->basename) < 0) {
70 unlink_noerr(filename);
71 err(1, "Writing template into %s", filename);
76 struct ccanlint has_info = {
78 .name = "Module has _info file",
79 .check = check_has_info,
80 .describe = describe_has_info,
81 .handle = create_info_template,
84 REGISTER_TEST(has_info, NULL);