1
/*****************************************************************************
23
void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size);
24
char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size);
26
void checkparams(int argc, char **argv);
27
void charsetconvert(char *data);
30
VerseKey key1, key2, key3;
31
int fp, vfp, cfp, bfp;
38
main(int argc, char **argv)
41
int num1, num2, rangemax, curbook = 0, curchap = 0, curverse = 0;
44
extern struct zonline online;
46
checkparams(argc, argv);
48
key1 = key2 = key3 = "Genesis 1:1";
52
num1 = key1.Chapter();
55
while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) {
60
if (num2 < key2.Verse()) { // new chapter
61
if (num1 <= key2.Chapter()) { // new book
64
key2.Book(key2.Book()+1);
66
printf("Created Empty Entry: %d ('%s')\n", num1, (const char *)key2);
77
// key3 += (rangemax - key3.Verse());
79
writeidx(key1, key2, key3, offset, size);
88
/**************************************************************************
89
* ENT: key1 - current location of index
90
* key2 - minimum keyval for which this offset is valid
91
* key3 - maximum keyval for which this offset is valid
94
void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
99
if (key1.Verse() == 1) { // new chapter
100
if (key1.Chapter() == 1) { // new book
101
pos = lseek(cfp, 0, SEEK_CUR);
103
pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */
105
write(vfp, &chapoffset, 4); /* Book intro (vss) set to same as chap for now(it should be chap 1 which usually contains the book into anyway)*/
106
write(vfp, &chapsize, 2);
108
pos = lseek(vfp, 0, SEEK_CUR);
110
write(vfp, &chapoffset, 4); /* Chapter intro */
111
write(vfp, &chapsize, 2);
114
write(vfp, &offset, 4);
116
write(vfp, &size, 2);
128
static VerseKey inckey = "Genesis 1:1";
130
char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size)
140
static int olbvnum = 0;
145
if (++olbvnum <= 31102) {
147
if (olbvnum == 23146) { // "Matthew 1:1"
152
key1 = key2 = key3 = inckey = "Matthew 1:1";
158
*offset = lseek(fp, 0, SEEK_CUR);
160
if ((olbvnum!=1) && (olbvnum != 23146))
163
*num1 = inckey.Chapter();
164
*num2 = inckey.Verse();
169
*size = lseek(fp, 0, SEEK_CUR) - *offset;
183
testmnt = key1.Testament();
185
strcpy(fname, (testmnt==2) ? "nt" : "ot");
187
if ((fp = open(fname, O_CREAT|O_RDWR|O_BINARY)) == -1) {
188
fprintf(stderr, "Couldn't open file: %s\n", fname);
192
sprintf(buf, "%s.vss", fname);
194
if ((vfp = open(buf, O_CREAT|O_WRONLY|O_BINARY)) == -1) {
195
fprintf(stderr, "Couldn't open file: %s\n", buf);
199
sprintf(buf, "%s.cps", fname);
201
if ((cfp = open(buf, O_CREAT|O_WRONLY|O_BINARY)) == -1) {
202
fprintf(stderr, "Couldn't open file: %s\n", buf);
206
sprintf(buf, "%s.bks", fname);
208
if ((bfp = open(buf, O_CREAT|O_WRONLY|O_BINARY)) == -1) {
209
fprintf(stderr, "Couldn't open file: %s\n", buf);
214
write(bfp, &pos, 4); /* Book offset for testament intros */
216
write(cfp, &pos, 4); /* Chapter offset for testament intro */
219
/* Right now just zero out intros until parsing correctly */
222
write(vfp, &pos, 4); /* Module intro */
223
write(vfp, &size, 2);
224
write(vfp, &pos, 4); /* Testament intro */
225
write(vfp, &size, 2);
230
void checkparams(int argc, char **argv)
233
fprintf(stderr, "usage: %s\n", argv[0]);