1 #include <tools/ccanlint/ccanlint.h>
2 #include <ccan/foreach/foreach.h>
12 #include <ccan/talloc/talloc.h>
13 #include <ccan/str/str.h>
14 #include <ccan/str_talloc/str_talloc.h>
16 static void check_license_comment(struct manifest *m,
17 unsigned int *timeleft, struct score *score)
19 struct list_head *list;
21 /* No requirements on public domain. */
22 if (m->license == LICENSE_PUBLIC_DOMAIN
23 || m->license == LICENSE_UNKNOWN) {
25 score->score = score->total;
29 foreach_ptr(list, &m->c_files, &m->h_files) {
32 list_for_each(list, f, list) {
34 char **lines = get_ccan_file_lines(f);
35 struct line_info *info = get_ccan_line_info(f);
36 bool found_license = false, found_flavor = false;
38 for (i = 0; lines[i]; i++) {
39 if (info[i].type == CODE_LINE)
41 if (strstr(lines[i], "LICENSE"))
44 licenses[m->license].shortname))
47 if ((!found_license || !found_flavor)
48 && !find_boilerplate(f, m->license)) {
49 score_file_error(score, f, lines[i] ? i : 0,
50 "No reference to license"
56 if (list_empty(&score->per_file_errors)) {
58 score->score = score->total;
62 struct ccanlint license_comment = {
63 .key = "license_comment",
64 .name = "Source and header files refer to LICENSE",
65 .check = check_license_comment,
66 .needs = "license_exists"
68 REGISTER_TEST(license_comment);