main_header_exists.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <tools/ccanlint/ccanlint.h>
  2. #include <ccan/tal/tal.h>
  3. #include <ccan/tal/str/str.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. #include <unistd.h>
  8. #include <limits.h>
  9. #include <errno.h>
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <err.h>
  13. #include <ccan/str/str.h>
  14. #include <ccan/noerr/noerr.h>
  15. static void check_has_main_header(struct manifest *m,
  16. unsigned int *timeleft UNNEEDED,
  17. struct score *score)
  18. {
  19. struct ccan_file *f;
  20. list_for_each(&m->h_files, f, list) {
  21. if (strstarts(f->name, m->basename)
  22. && strlen(f->name) == strlen(m->basename) + 2) {
  23. score->pass = true;
  24. score->score = score->total;
  25. return;
  26. }
  27. }
  28. score->error = tal_fmt(score,
  29. "You have no %s/%s.h header file.\n\n"
  30. "CCAN modules have a name, the same as the directory name. They're\n"
  31. "expected to have an interface in the header of the same name.\n",
  32. m->modname, m->basename);
  33. }
  34. struct ccanlint main_header_exists = {
  35. .key = "main_header_exists",
  36. .name = "Module has main header file",
  37. .check = check_has_main_header,
  38. .needs = ""
  39. };
  40. REGISTER_TEST(main_header_exists);