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,
18 unsigned int *timeleft, struct score *score)
20 struct list_head *list;
22 /* No requirements on public domain. */
23 if (m->license == LICENSE_PUBLIC_DOMAIN
24 || m->license == LICENSE_UNKNOWN) {
26 score->score = score->total;
30 foreach_ptr(list, &m->c_files, &m->h_files) {
33 list_for_each(list, f, list) {
35 char **lines = get_ccan_file_lines(f);
36 struct line_info *info = get_ccan_line_info(f);
37 bool found_license = false, found_flavor = false;
39 for (i = 0; lines[i]; i++) {
40 if (info[i].type == CODE_LINE)
42 if (strstr(lines[i], "LICENSE"))
45 licenses[m->license].shortname))
48 if ((!found_license || !found_flavor)
49 && !find_boilerplate(f, m->license)) {
50 score_file_error(score, f, lines[i] ? i : 0,
51 "No reference to license"
57 if (list_empty(&score->per_file_errors)) {
59 score->score = score->total;
63 struct ccanlint license_comment = {
64 .key = "license_comment",
65 .name = "Source and header files refer to LICENSE",
66 .check = check_license_comment,
67 .needs = "license_exists"
69 REGISTER_TEST(license_comment);