Standalone Haplous Bible Parser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
933 B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <assert.h>
  4. #include <time.h>
  5. #include "haplous.h"
  6. struct haplous_work work;
  7. int err = 0;
  8. void testRef(char *name, int chapter, int start, int to)
  9. {
  10. struct haplous_reference ref = {
  11. name,
  12. chapter,
  13. start,
  14. to + 1,
  15. };
  16. struct haplous_reader reader = haplous_reader_new(work, ref, &err);
  17. assert(err == 0);
  18. while (haplous_next(&reader) == HAPLOUS_CONTINUE) {
  19. //puts(reader.verse);
  20. free(reader.verse);
  21. }
  22. free(reader.verse);
  23. if (err != HAPLOUS_OK) {
  24. printf("Error parsing: %s %d %d:%d (%d)\n", name, chapter, start, to, err);
  25. }
  26. }
  27. int main()
  28. {
  29. work = haplous_work_init("../kjv.txt", &err);
  30. if (err != HAPLOUS_OK) {
  31. puts("Err");
  32. return -1;
  33. }
  34. clock_t start_time = clock();
  35. testRef("John", 3, 16, 20);
  36. double elapsed_time =
  37. (double)(clock() - start_time) / CLOCKS_PER_SEC;
  38. printf("Done in %f seconds\n", elapsed_time);
  39. haplous_work_cleanup(&work);
  40. }