X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan_tools%2Fccanlint%2Fno_info.c;fp=ccan_tools%2Fccanlint%2Fno_info.c;h=9ee5f709c614c88a5eddb2dc126e2c956984c23b;hb=c8acddea39d222312102952e91c32cfe4dd2cea0;hp=0000000000000000000000000000000000000000;hpb=89afb563a8fea1e1c6d4bbcc6b1c51aa6cc8f045;p=ccan diff --git a/ccan_tools/ccanlint/no_info.c b/ccan_tools/ccanlint/no_info.c new file mode 100644 index 00000000..9ee5f709 --- /dev/null +++ b/ccan_tools/ccanlint/no_info.c @@ -0,0 +1,78 @@ +#include "ccanlint.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void *check_no_info(struct manifest *m) +{ + if (m->info_file) + return NULL; + return m; +} + +static const char *describe_no_info(struct manifest *m, void *check_result) +{ + return "You have no _info.c file.\n\n" + "The file _info.c 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[] = + "#include \n" + "#include \"config.h\"\n" + "\n" + "/**\n" + " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n" + " *\n" + " * This code ... YOUR-BRIEF-SUMMARY-HERE\n" + " *\n" + " * Example:\n" + " * FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n" + " */\n" + "int main(int argc, char *argv[])\n" + "{\n" + " /* Expect exactly one argument\n" + " if (argc != 2)\n" + " return 1;\n" + "\n" + " if (strcmp(argv[1], \"depends\") == 0) {\n" + " PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n" + " return 0;\n" + " }\n" + "\n" + " return 1;\n" + "}\n"; + +static void create_info_template(struct manifest *m, void *check_result) +{ + FILE *info; + + if (!ask("Should I create a template _info.c file for you?")) + return; + + info = fopen("_info.c", "w"); + if (!info) + err(1, "Trying to create a template _info.c"); + + if (fprintf(info, template, m->basename) < 0) { + unlink_noerr("_info.c"); + err(1, "Writing template into _info.c"); + } + fclose(info); +} + +struct ccanlint no_info = { + .name = "No _info.c file", + .check = check_no_info, + .describe = describe_no_info, + .handle = create_info_template, +};