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.
 
 
 

69 lines
1.3 KiB

  1. #ifndef BIBLEC_H
  2. #define BIBLEC_H
  3. #include <stdio.h>
  4. // Size macros, for internal use only
  5. #define MAX_BOOKS 66
  6. #define MAX_CHAPTERS 151
  7. #define INDEX_MAX_LENGTH 512
  8. #define VERSE_LENGTH 1024
  9. #define MAX_NAME 32
  10. #define MAX_LANG 16
  11. #define MAX_LOCATION 128
  12. #define MAX_BOOK_NAME 64
  13. enum Biblec_error {
  14. // Ensure compatibility for now
  15. FILE_NOT_FOUND = -1,
  16. BOOK_NOT_FOUND = -2,
  17. FILE_OVERFLOW = -3,
  18. FILE_ERROR = -4,
  19. BAD_CHAPTER = -5,
  20. VERSE_ERROR = -6,
  21. BIBLEC_FILE_ERROR = -1,
  22. BIBLEC_BOOK_ERROR = -2,
  23. BIBLEC_OVERFLOW = -3,
  24. BIBLEC_CHAPTER_ERROR = -4,
  25. BIBLEC_VERSE_ERROR = -5
  26. };
  27. struct BiblecReader {
  28. char *book;
  29. int chapter;
  30. int verse;
  31. int to;
  32. char result[VERSE_LENGTH];
  33. int linesRead;
  34. FILE *file;
  35. };
  36. struct BiblecTranslation {
  37. char name[MAX_NAME];
  38. char lang[MAX_LANG];
  39. char location[MAX_LOCATION];
  40. int length; // (in books)
  41. struct Book {
  42. char name[MAX_BOOK_NAME];
  43. int start;
  44. int chapters[MAX_CHAPTERS];
  45. int length; // (in chapters)
  46. }books[MAX_BOOKS];
  47. };
  48. int biblec_parse(struct BiblecTranslation *translation, char *indexLocation);
  49. int biblec_next(struct BiblecReader *reader);
  50. void biblec_close(struct BiblecReader *reader);
  51. int biblec_new(
  52. struct BiblecReader *reader,
  53. struct BiblecTranslation *translation,
  54. char *book,
  55. int chapter,
  56. int verse,
  57. int to
  58. );
  59. #endif