A minimal Bible format
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.
 
 
 

77 lines
1.2 KiB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include "biblec.h"
  6. struct BiblecTranslation translation;
  7. void test(char name[], int chapter, int from, int to) {
  8. printf("Parsing: %s %d %d:%d\n", name, chapter, from, to);
  9. struct BiblecReader reader;
  10. int tryReader = biblec_new(
  11. &reader,
  12. &translation,
  13. name,
  14. chapter,
  15. from,
  16. to
  17. );
  18. if (tryReader) {
  19. puts("BibleC error");
  20. biblec_close(&reader);
  21. return;
  22. }
  23. while (biblec_next(&reader)) {
  24. puts(reader.result);
  25. }
  26. biblec_close(&reader);
  27. }
  28. int main() {
  29. int tryFile = biblec_parse(
  30. &translation,
  31. "../bibles/web.i"
  32. );
  33. if (tryFile) {
  34. puts("Index parsing error");
  35. return 1;
  36. }
  37. struct BiblecReader reader;
  38. clock_t start_time = clock();
  39. for (int i = 0; i < 100; i++) {
  40. int tryReader = biblec_new(
  41. &reader,
  42. &translation,
  43. "Exod",
  44. 1,
  45. 1,
  46. 1
  47. );
  48. if (tryReader) {
  49. biblec_close(&reader);
  50. exit(1);
  51. }
  52. while (biblec_next(&reader));
  53. biblec_close(&reader);
  54. }
  55. double elapsed_time = (double)(clock() - start_time) / CLOCKS_PER_SEC;
  56. printf("Done in %f seconds\n", elapsed_time);
  57. test("Gen", -1000, -1000, 16);
  58. test("Gen", 2147483647, 2147483647, 2147483647);
  59. test("Gen", -10, 0, 0);
  60. test("Gen", 0, 0, -10);
  61. }