main_header_exists.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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, struct score *score)
  17. {
  18. struct ccan_file *f;
  19. list_for_each(&m->h_files, f, list) {
  20. if (strstarts(f->name, m->basename)
  21. && strlen(f->name) == strlen(m->basename) + 2) {
  22. score->pass = true;
  23. score->score = score->total;
  24. return;
  25. }
  26. }
  27. score->error = tal_fmt(score,
  28. "You have no %s/%s.h header file.\n\n"
  29. "CCAN modules have a name, the same as the directory name. They're\n"
  30. "expected to have an interface in the header of the same name.\n",
  31. m->modname, m->basename);
  32. }
  33. struct ccanlint main_header_exists = {
  34. .key = "main_header_exists",
  35. .name = "Module has main header file",
  36. .check = check_has_main_header,
  37. .needs = ""
  38. };
  39. REGISTER_TEST(main_header_exists);