]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/tests/main_header_exists.c
base64: fix for unsigned chars (e.g. ARM).
[ccan] / tools / ccanlint / tests / main_header_exists.c
1 #include <tools/ccanlint/ccanlint.h>
2 #include <ccan/tal/tal.h>
3 #include <ccan/tal/str/str.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <limits.h>
9 #include <errno.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <err.h>
13 #include <ccan/str/str.h>
14 #include <ccan/noerr/noerr.h>
15
16 static void check_has_main_header(struct manifest *m,
17                                   unsigned int *timeleft UNNEEDED,
18                                   struct score *score)
19 {
20         struct ccan_file *f;
21
22         list_for_each(&m->h_files, f, list) {
23                 if (strstarts(f->name, m->basename)
24                     && strlen(f->name) == strlen(m->basename) + 2) {
25                         score->pass = true;
26                         score->score = score->total;
27                         return;
28                 }
29         }
30         score->error = tal_fmt(score,
31         "You have no %s/%s.h header file.\n\n"
32         "CCAN modules have a name, the same as the directory name.  They're\n"
33         "expected to have an interface in the header of the same name.\n",
34                                        m->modname, m->basename);
35 }
36
37 struct ccanlint main_header_exists = {
38         .key = "main_header_exists",
39         .name = "Module has main header file",
40         .check = check_has_main_header,
41         .needs = ""
42 };
43
44 REGISTER_TEST(main_header_exists);