135 lines
2.6 KiB
C
135 lines
2.6 KiB
C
#if defined BASE \
|
|
|| !defined BASE && !defined PRIVATE && !defined PROTO /* <!-- base */
|
|
#define BOOKS \
|
|
X(Genesis),\
|
|
X(Exodus),\
|
|
X(Leviticus),\
|
|
X(Numbers),\
|
|
X(Deuteronomy),\
|
|
X(Joshua),\
|
|
X(Judges),\
|
|
X(Ruth),\
|
|
X(ISamuel),\
|
|
X(IISamuel),\
|
|
X(IKings),\
|
|
X(IIKings),\
|
|
X(IChronicles),\
|
|
X(IIChronicles),\
|
|
X(Ezra),\
|
|
X(Nehemiah),\
|
|
X(Esther),\
|
|
X(Job),\
|
|
X(Psalms),\
|
|
X(Proverbs),\
|
|
X(Ecclesiastes),\
|
|
X(Song_of_Solomon),\
|
|
X(Isaiah),\
|
|
X(Jeremiah),\
|
|
X(Lamentations),\
|
|
X(Ezekiel),\
|
|
X(Daniel),\
|
|
X(Hosea),\
|
|
X(Joel),\
|
|
X(Amos),\
|
|
X(Obadiah),\
|
|
X(Jonah),\
|
|
X(Micah),\
|
|
X(Nahum),\
|
|
X(Habakkuk),\
|
|
X(Zephaniah),\
|
|
X(Haggai),\
|
|
X(Zechariah),\
|
|
X(Malachi),\
|
|
\
|
|
X(Matthew),\
|
|
X(Mark),\
|
|
X(Luke),\
|
|
X(John),\
|
|
X(Acts),\
|
|
X(Romans),\
|
|
X(ICorinthians),\
|
|
X(IICorinthians),\
|
|
X(Galatians),\
|
|
X(Ephesians),\
|
|
X(Philippians),\
|
|
X(Colossians),\
|
|
X(IThessalonians),\
|
|
X(IIThessalonians),\
|
|
X(ITimothy),\
|
|
X(IITimothy),\
|
|
X(Titus),\
|
|
X(Philemon),\
|
|
X(Hebrews),\
|
|
X(James),\
|
|
X(IPeter),\
|
|
X(IIPeter),\
|
|
X(IJohn),\
|
|
X(IIJohn),\
|
|
X(IIIJohn),\
|
|
X(Jude),\
|
|
X(Revelation),\
|
|
X(KJV_BOOK_SIZE)
|
|
#define X(book) book
|
|
enum kjv_book { BOOKS };
|
|
#undef X
|
|
#define X(book) #book
|
|
static const char *kjv_book_string[] = { BOOKS };
|
|
#undef X
|
|
#undef BOOKS
|
|
#include <stdint.h> /* C99 */
|
|
union kjvcite {
|
|
struct { uint32_t verse : 12, chapter : 13, book : 7; }; /* C11, reverse */
|
|
uint32_t u32;
|
|
};
|
|
struct kjvrange { union kjvcite start; uint32_t verse_end; };
|
|
void kjvcite_to_string(const union kjvcite, char (*)[12]);
|
|
#endif /* base --> */
|
|
|
|
|
|
#if defined PRIVATE \
|
|
|| !defined BASE && !defined PRIVATE && !defined PROTO /* <!-- private */
|
|
struct table_kjvset_bucket;
|
|
struct kjvset_table {
|
|
struct table_kjvset_bucket *buckets;
|
|
uint32_t log_capacity, size, top;
|
|
};
|
|
struct table_count_bucket;
|
|
struct count_table {
|
|
struct table_count_bucket *buckets;
|
|
uint32_t log_capacity, size, top;
|
|
};
|
|
#endif /* private --> */
|
|
|
|
|
|
#if defined PROTO \
|
|
|| !defined BASE && !defined PRIVATE && !defined PROTO /* <!-- proto */
|
|
#include <stddef.h>
|
|
struct kjvcount {
|
|
struct count_table verses;
|
|
struct { size_t total, cumulative, set; } words;
|
|
};
|
|
void kjvcount_(struct kjvcount *);
|
|
struct kjvcount kjvcount(void);
|
|
int kjvcount_is_empty(const struct kjvcount *);
|
|
const char *kjvcount_to_string(const struct kjvcount *);
|
|
|
|
|
|
/* FIXME: this should be in something else. */
|
|
struct kjvset_table kjv_set(void);
|
|
void kjv_set_(struct kjvset_table *);
|
|
int kjv_set_add(struct kjvset_table *const set,
|
|
struct kjvcount *const count, const union kjvcite cite);
|
|
const char *kjv_set_to_string(const struct kjvset_table *);
|
|
#endif /* proto --> */
|
|
|
|
|
|
#ifdef BASE
|
|
#undef BASE
|
|
#endif
|
|
#ifdef PRIVATE
|
|
#undef PRIVATE
|
|
#endif
|
|
#ifdef PROTO
|
|
#undef PROTO
|
|
#endif
|