X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan_tools%2Fccanlint%2Fhas_main_header.c;fp=ccan_tools%2Fccanlint%2Fhas_main_header.c;h=75e3f91dc51dc78007b621479433fdd7f0a2068c;hp=0000000000000000000000000000000000000000;hb=c8acddea39d222312102952e91c32cfe4dd2cea0;hpb=89afb563a8fea1e1c6d4bbcc6b1c51aa6cc8f045 diff --git a/ccan_tools/ccanlint/has_main_header.c b/ccan_tools/ccanlint/has_main_header.c new file mode 100644 index 00000000..75e3f91d --- /dev/null +++ b/ccan_tools/ccanlint/has_main_header.c @@ -0,0 +1,41 @@ +#include "ccanlint.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void *check_has_main_header(struct manifest *m) +{ + struct ccan_file *f; + + list_for_each(&m->h_files, f, list) { + if (strstarts(f->name, m->basename) + && strlen(f->name) == strlen(m->basename) + 2) + return NULL; + } + return m; +} + +static const char *describe_has_main_header(struct manifest *m, + void *check_result) +{ + return talloc_asprintf(m, + "You have no %s/%s.h header file.\n\n" + "CCAN modules have a name, the same as the directory name. They're\n" + "expected to have an interface in the header of the same name.\n", + m->basename, m->basename); +} + +struct ccanlint has_main_header = { + .name = "No main header file", + .check = check_has_main_header, + .describe = describe_has_main_header, +};