40 using namespace sword;
43 char findbreak(
int fp,
long *offset,
int *num1,
int *num2,
int *rangemax,
short *
size);
55 int main(
int argc,
char **argv)
58 int num1, num2, rangemax;
67 num1 =
key1.getChapter();
68 num2 =
key1.getVerse();
83 while(!
findbreak(
fp, &offset, &num1, &num2, &rangemax, &size)) {
88 if (num2 <
key2.getVerse()) {
89 if (num1 <=
key2.getChapter()) {
94 printf(
"Found Chapter Break: %d ('%s')\n", num1, (
const char *)
key2);
101 key2.setChapter(num1);
129 if (key1.getVerse() == 1) {
130 if (key1.getChapter() == 1) {
144 write(
vfp, &offset, 4);
145 write(
vfp, &size, 2);
201 char findbreak(
int fp,
long *offset,
int *num1,
int *num2,
int *rangemax,
short *
size)
214 chapstart = lseek(fp, 0,
SEEK_CUR) - 7;
217 for (loop = 3; loop < 6; loop++) {
218 if (isdigit(buf[loop]))
232 for (loop = 3; loop < 6; loop++) {
233 if (isdigit(buf[loop]))
245 *offset = lseek(fp, 0,
SEEK_CUR) - (7 - loop);
246 else *offset = (chapstart) ? chapstart : lseek(fp, 0,
SEEK_CUR) - 7;
250 if (
findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) {
251 *size = (short) (lseek(fp, 0,
SEEK_END) - (*offset));
255 *size = (offset2 - (*offset));
262 memmove(buf, &buf[1], 6);
263 if (read(fp, &buf[6], 1) != 1)
274 fprintf(stderr,
"Couldn't open file: %s\n", fname);
278 buf.setFormatted(
"%s.vss", fname);
280 fprintf(stderr,
"Couldn't open file: %s\n", buf.c_str());
284 buf.setFormatted(
"%s.cps", fname);
286 fprintf(stderr,
"Couldn't open file: %s\n", buf.c_str());
290 buf.setFormatted(
"%s.bks", fname);
292 fprintf(stderr,
"Couldn't open file: %s\n", buf.c_str());
301 fprintf(stderr,
"usage: %s <file to process> [nt - for new testmt file]\n", argv[0]);
void openfiles(char *fname)
char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size)
static int openFileReadOnly(const char *fName)
void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size)
void checkparams(int argc, char **argv)
#define KEYERR_OUTOFBOUNDS
static int createPathAndFile(const char *fName)
char startentry(char *buf)
char startchap(char *buf)