ccanlint.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef CCAN_LINT_H
  2. #define CCAN_LINT_H
  3. #include <list/list.h>
  4. #include <stdbool.h>
  5. struct manifest {
  6. char *basename;
  7. struct ccan_file *info_file;
  8. struct list_head c_files;
  9. struct list_head h_files;
  10. struct list_head run_tests;
  11. struct list_head compile_ok_tests;
  12. struct list_head compile_fail_tests;
  13. struct list_head other_test_files;
  14. struct list_head other_files;
  15. };
  16. struct manifest *get_manifest(void);
  17. struct ccanlint {
  18. struct list_node list;
  19. /* Unique name of test */
  20. const char *name;
  21. /* Total score that this test is worth. 0 means compulsory tests. */
  22. unsigned int total_score;
  23. /* If this returns non-NULL, it means the check failed. */
  24. void *(*check)(struct manifest *m);
  25. /* The non-NULL return from check is passed to one of these: */
  26. /* So, what did this get out of the total_score? (NULL means 0). */
  27. unsigned int (*score)(struct manifest *m, void *check_result);
  28. /* Verbose description of what was wrong. */
  29. const char *(*describe)(struct manifest *m, void *check_result);
  30. /* Can we do something about it? (NULL if not) */
  31. void (*handle)(struct manifest *m, void *check_result);
  32. };
  33. /* Ask the user a yes/no question: the answer is NO if there's an error. */
  34. bool ask(const char *question);
  35. struct ccan_file {
  36. struct list_node list;
  37. char *name;
  38. unsigned int num_lines;
  39. char **lines;
  40. };
  41. /* Use this rather than accessing f->lines directly: loads on demand. */
  42. char **get_ccan_file_lines(struct ccan_file *f);
  43. /* Call the reporting on every line in the file. sofar contains
  44. * previous results. */
  45. char *report_on_lines(struct list_head *files,
  46. char *(*report)(const char *),
  47. char *sofar);
  48. /* The critical tests which mean fail if they don't pass. */
  49. extern struct ccanlint no_info;
  50. extern struct ccanlint has_main_header;
  51. /* Normal tests. */
  52. extern struct ccanlint trailing_whitespace;
  53. #endif /* CCAN_LINT_H */