main_header_exists.c 1.1 KB

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