3 #include <ccan/list/list.h>
5 #include "../doc_extract.h"
7 #define REGISTER_TEST(name, ...) extern struct ccanlint name
8 #include "generated-init-tests"
11 #define REGISTER_TEST(name, ...)
15 struct ccan_file *info_file;
17 struct list_head c_files;
18 struct list_head h_files;
20 struct list_head run_tests;
21 struct list_head api_tests;
22 struct list_head compile_ok_tests;
23 struct list_head compile_fail_tests;
24 struct list_head other_test_files;
26 struct list_head other_files;
29 struct manifest *get_manifest(void);
32 struct list_node list;
34 /* Unique name of test */
37 /* Total score that this test is worth. 0 means compulsory tests. */
38 unsigned int total_score;
40 /* If this returns non-NULL, it means the check failed. */
41 void *(*check)(struct manifest *m);
43 /* The non-NULL return from check is passed to one of these: */
45 /* So, what did this get out of the total_score? (NULL means 0). */
46 unsigned int (*score)(struct manifest *m, void *check_result);
48 /* Verbose description of what was wrong. */
49 const char *(*describe)(struct manifest *m, void *check_result);
51 /* Can we do something about it? (NULL if not) */
52 void (*handle)(struct manifest *m, void *check_result);
54 /* Internal use fields: */
55 /* Who depends on us? */
56 struct list_head dependencies;
57 /* How many things do we (still) depend on? */
58 unsigned int num_depends;
61 /* Ask the user a yes/no question: the answer is NO if there's an error. */
62 bool ask(const char *question);
65 PREPROC_LINE, /* Line starts with # */
66 CODE_LINE, /* Code (ie. not pure comment). */
67 DOC_LINE, /* Line with kernel-doc-style comment. */
68 COMMENT_LINE, /* (pure) comment line */
71 /* So far, only do simple #ifdef/#ifndef/#if defined/#if !defined tests,
72 * and #if <SYMBOL>/#if !<SYMBOL> */
73 struct pp_conditions {
74 /* We're inside another ifdef? */
75 struct pp_conditions *parent;
87 /* Preprocessor information about each line. */
89 enum line_info_type type;
91 /* Is this actually a continuation of line above? (which ends in \) */
94 /* Conditions for this line to be compiled. */
95 struct pp_conditions *cond;
99 struct list_node list;
103 /* Pristine version of the original file.
104 * Use get_ccan_file_lines to fill this. */
105 const char *contents;
106 size_t contents_size;
108 /* Use get_ccan_file_lines / get_ccan_line_info to fill these. */
109 unsigned int num_lines;
111 struct line_info *line_info;
113 struct list_head *doc_sections;
116 /* Use this rather than accessing f->lines directly: loads on demand. */
117 char **get_ccan_file_lines(struct ccan_file *f);
119 /* Use this rather than accessing f->lines directly: loads on demand. */
120 struct line_info *get_ccan_line_info(struct ccan_file *f);
128 /* Simple evaluator. If symbols are set this way, is this condition true?
129 * NULL values mean undefined, NULL symbol terminates. */
130 enum line_compiled get_ccan_line_pp(struct pp_conditions *cond,
132 const unsigned int *value, ...);
134 /* Get token if it's equal to token. */
135 bool get_token(const char **line, const char *token);
136 /* Talloc copy of symbol token, or NULL. Increment line. */
137 char *get_symbol_token(void *ctx, const char **line);
139 /* Similarly for ->doc_sections */
140 struct list_head *get_ccan_file_docs(struct ccan_file *f);
143 /* Call the reporting on every line in the file. sofar contains
144 * previous results. */
145 char *report_on_lines(struct list_head *files,
146 char *(*report)(const char *),
150 extern struct ccanlint trailing_whitespace;
154 struct list_node node;
155 struct ccanlint *dependent;
158 #endif /* CCAN_LINT_H */