]> git.ozlabs.org Git - ccan/blob - tools/ccanlint/ccanlint.h
Deleting duplicate grab_file in tools/
[ccan] / tools / ccanlint / ccanlint.h
1 #ifndef CCAN_LINT_H
2 #define CCAN_LINT_H
3 #include <list/list.h>
4 #include <stdbool.h>
5
6 struct manifest {
7         char *basename;
8         struct ccan_file *info_file;
9
10         struct list_head c_files;
11         struct list_head h_files;
12
13         struct list_head run_tests;
14         struct list_head compile_ok_tests;
15         struct list_head compile_fail_tests;
16         struct list_head other_test_files;
17
18         struct list_head other_files;
19 };
20
21 struct manifest *get_manifest(void);
22
23 struct ccanlint {
24         struct list_node list;
25
26         /* Unique name of test */
27         const char *name;
28
29         /* Total score that this test is worth.  0 means compulsory tests. */
30         unsigned int total_score;
31
32         /* If this returns non-NULL, it means the check failed. */
33         void *(*check)(struct manifest *m);
34
35         /* The non-NULL return from check is passed to one of these: */
36
37         /* So, what did this get out of the total_score?  (NULL means 0). */
38         unsigned int (*score)(struct manifest *m, void *check_result);
39
40         /* Verbose description of what was wrong. */
41         const char *(*describe)(struct manifest *m, void *check_result);
42
43         /* Can we do something about it? (NULL if not) */
44         void (*handle)(struct manifest *m, void *check_result);
45 };
46
47 /* Ask the user a yes/no question: the answer is NO if there's an error. */
48 bool ask(const char *question);
49
50 struct ccan_file {
51         struct list_node list;
52
53         char *name;
54
55         unsigned int num_lines;
56         char **lines;
57 };
58
59 /* Use this rather than accessing f->lines directly: loads on demand. */
60 char **get_ccan_file_lines(struct ccan_file *f);
61
62 /* Call the reporting on every line in the file.  sofar contains
63  * previous results. */
64 char *report_on_lines(struct list_head *files,
65                       char *(*report)(const char *),
66                       char *sofar);
67
68 /* The critical tests which mean fail if they don't pass. */
69 extern struct ccanlint no_info;
70 extern struct ccanlint has_main_header;
71
72 /* Normal tests. */
73 extern struct ccanlint trailing_whitespace;
74
75
76 #endif /* CCAN_LINT_H */