]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/compulsory_tests/has_info.c
ccanlint: Add -k option to keep results.
[ccan] / tools / ccanlint / compulsory_tests / has_info.c
index a5c825265b3266bf9f6b00edc624345d255dd97f..77867dedd9c875ff22bcc4f42c7886065bd99265 100644 (file)
 #include <err.h>
 #include <string.h>
 #include <ccan/noerr/noerr.h>
 #include <err.h>
 #include <string.h>
 #include <ccan/noerr/noerr.h>
+#include <ccan/talloc/talloc.h>
 
 
-static void *check_has_info(struct manifest *m)
+static void *check_has_info(struct manifest *m,
+                           bool keep,
+                           unsigned int *timeleft)
 {
        if (m->info_file)
                return NULL;
 {
        if (m->info_file)
                return NULL;
@@ -55,24 +58,26 @@ static const char template[] =
 static void create_info_template(struct manifest *m, void *check_result)
 {
        FILE *info;
 static void create_info_template(struct manifest *m, void *check_result)
 {
        FILE *info;
+       const char *filename;
 
        if (!ask("Should I create a template _info file for you?"))
                return;
 
 
        if (!ask("Should I create a template _info file for you?"))
                return;
 
-       info = fopen("_info", "w");
+       filename = talloc_asprintf(m, "%s/%s", m->dir, "_info");
+       info = fopen(filename, "w");
        if (!info)
        if (!info)
-               err(1, "Trying to create a template _info");
+               err(1, "Trying to create a template _info in %s", filename);
 
        if (fprintf(info, template, m->basename) < 0) {
 
        if (fprintf(info, template, m->basename) < 0) {
-               unlink_noerr("_info");
-               err(1, "Writing template into _info");
+               unlink_noerr(filename);
+               err(1, "Writing template into %s", filename);
        }
        fclose(info);
 }
 
 struct ccanlint has_info = {
        .key = "info",
        }
        fclose(info);
 }
 
 struct ccanlint has_info = {
        .key = "info",
-       .name = "Has _info file",
+       .name = "Module has _info file",
        .check = check_has_info,
        .describe = describe_has_info,
        .handle = create_info_template,
        .check = check_has_info,
        .describe = describe_has_info,
        .handle = create_info_template,