configlint.c 708 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <libmegapixels.h>
  2. #include <stdio.h>
  3. #include <stdbool.h>
  4. int
  5. main(int argc, char *argv[])
  6. {
  7. if (argc != 2) {
  8. fprintf(stderr, "Usage: %s <configfile>\n", argv[0]);
  9. return 1;
  10. }
  11. libmegapixels_devconfig *config = {0};
  12. libmegapixels_init(&config);
  13. if (!libmegapixels_load_file_lint(config, argv[1], 1)) {
  14. return 1;
  15. }
  16. if (config->count == 0) {
  17. fprintf(stderr, "Config file does not define any cameras\n");
  18. return 1;
  19. }
  20. bool faulty = false;
  21. for (int i = 0; i < config->count; i++) {
  22. if (config->cameras[i]->num_modes == 0) {
  23. fprintf(stderr, "No modes are defined for sensor '%s'\n", config->cameras[i]->name);
  24. faulty = true;
  25. }
  26. }
  27. if (faulty) {
  28. return 1;
  29. }
  30. return 0;
  31. }