ccanlint.h 2.0 KB

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