void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size) { long pos; short tmp; for (; ((key1 <= key3) && (key1.popError() != KEYERR_OUTOFBOUNDS) && (key1.getTestament() == testmnt)); key1+=1) { if (key1.getVerse() == 1) { // new chapter if (key1.getChapter() == 1) { // new book pos = lseek(cfp, 0, SEEK_CUR); write(bfp, &pos, 4); pos = lseek(vfp, 0, SEEK_CUR); /* Book intro (cps) */ write(cfp, &pos, 4); 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)*/ write(vfp, &chapsize, 2); } pos = lseek(vfp, 0, SEEK_CUR); write(cfp, &pos, 4); write(vfp, &chapoffset, 4); /* Chapter intro */ write(vfp, &chapsize, 2); } if (key1 >= key2) { write(vfp, &offset, 4); write(vfp, &size, 2); } else { pos = 0; tmp = 0; write(vfp, &pos, 4); write(vfp, &tmp, 2); } } }
void parallelDisplay(vector<SWModule *>modules, const char *key) { // We'll use the first module's key as our master key to position all other modules. VerseKey *master = (VerseKey *)modules[0]->createKey(); master->setText(key); int curVerse = master->getVerse(); int curChapter = master->getChapter(); int curBook = master->getBook(); for (master->setVerse(1); (master->getBook() == curBook) && (master->getChapter() == curChapter) && !master->popError(); (*master)++) { cout << "<tr class=\"" << (master->getVerse() == curVerse ? "currentverse":"verse") << "\">"; for (vector<SWModule *>::iterator module = modules.begin(); module != modules.end(); ++module) { (*module)->setKey(master); if (!(*module)->popError()) { cout << "<td>" << "<span class=\"versenum\">" << master->getVerse() << "</span> "; cout << (*module)->renderText() << "</td>"; } } cout << "</tr>"; } delete master; }
int main() { SWMgr library; auto const book(library.getModule("KJV")); VerseKey *vk = (VerseKey *) book->getKey(); for (;!vk->popError();vk->setChapter(vk->getChapter()+1)) { vk->setVerse(vk->getVerseMax()); std::string text = book->stripText(); trimString(text); if (!text.empty() && (*text.rbegin()) == ',') { cout << vk->getText() << ":\n\n"; cout << text << endl; } } return 0; }
int main(int argc, char **argv) { SWMgr library; SWModule *book = library.getModule("KJV"); VerseKey *vk = (VerseKey *) book->getKey(); for (;!vk->popError();vk->setChapter(vk->getChapter()+1)) { vk->setVerse(vk->getVerseMax()); SWBuf text = book->stripText(); text = text.trim(); if (text.endsWith(",")) { cout << vk->getText() << ":\n\n"; cout << text << endl; } } return 0; }
int main(int argc, char **argv) { cout << "\n"; const char *modName = (argc > 1) ? argv[1] : "KJV"; SWMgr manager; SWModule *bible = manager.getModule(modName); if (!bible) { cout << modName << " module is not installed.\nPlease install to show versification (v11n) from this specific Bible.\nShowing builtin KJV v11n scheme..\n\n"; } VerseKey *vk = (bible) ? (VerseKey *)bible->getKey() : new VerseKey(); for ((*vk) = TOP; !vk->popError(); vk->setBook(vk->getBook()+1)) { cout << vk->getBookName() << "\n"; } // if we 'new'ed a VerseKey unassociated with a module, above, then we should delete it. if (!bible) delete vk; return 0; }
char RawVerse::createModule(const char *ipath, const char *v11n) { char *path = 0; char *buf = new char [ strlen (ipath) + 20 ]; FileDesc *fd, *fd2; stdstr(&path, ipath); if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\')) path[strlen(path)-1] = 0; sprintf(buf, "%s/ot", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/nt", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/ot.vss", path); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd->getFd(); sprintf(buf, "%s/nt.vss", path); FileMgr::removeFile(buf); fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); fd2->getFd(); VerseKey vk; vk.setVersificationSystem(v11n); vk.setIntros(1); __s32 offset = 0; __u16 size = 0; offset = archtosword32(offset); size = archtosword16(size); for (vk = TOP; !vk.popError(); vk++) { if (vk.getTestament() < 2) { fd->write(&offset, 4); fd->write(&size, 2); } else { fd2->write(&offset, 4); fd2->write(&size, 2); } } fd2->write(&offset, 4); fd2->write(&size, 2); FileMgr::getSystemFileMgr()->close(fd); FileMgr::getSystemFileMgr()->close(fd2); delete [] path; delete [] buf; return 0; }
char zVerse::createModule(const char *ipath, int blockBound, const char *v11n) { char *path = 0; char *buf = new char [ strlen (ipath) + 20 ]; char retVal = 0; FileDesc *fd, *fd2; __s32 offset = 0; __s16 size = 0; VerseKey vk; stdstr(&path, ipath); if ((path[strlen(path)-1] == '/') || (path[strlen(path)-1] == '\\')) path[strlen(path)-1] = 0; sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd->getFd() < 1) goto erroropen1; FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd->getFd() < 1) goto erroropen1; FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd->getFd() < 1) goto erroropen1; FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd->getFd() < 1) goto erroropen1; FileMgr::getSystemFileMgr()->close(fd); sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd->getFd() < 1) goto erroropen1; sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockBound]); FileMgr::removeFile(buf); fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE); if (fd2->getFd() < 1) goto erroropen2; vk.setVersificationSystem(v11n); vk.setIntros(true); offset = archtosword32(offset); size = archtosword16(size); for (vk = TOP; !vk.popError(); vk++) { if (vk.getTestament() < 2) { if (fd->write(&offset, 4) != 4) goto writefailure; //compBufIdxOffset if (fd->write(&offset, 4) != 4) goto writefailure; if (fd->write(&size, 2) != 2) goto writefailure; } else { if (fd2->write(&offset, 4) != 4) goto writefailure; //compBufIdxOffset if (fd2->write(&offset, 4) != 4) goto writefailure; if (fd2->write(&size, 2) != 2) goto writefailure; } } fd2->write(&offset, 4); //compBufIdxOffset fd2->write(&offset, 4); fd2->write(&size, 2); goto cleanup; erroropen1: retVal = -1; goto cleanup1; erroropen2: retVal = -1; goto cleanup; writefailure: retVal = -2; cleanup: FileMgr::getSystemFileMgr()->close(fd2); cleanup1: FileMgr::getSystemFileMgr()->close(fd); delete [] path; delete [] buf; return retVal; }
int main(int argc, char **argv) { SWCipher *zobj; VerseKey key; RawVerse *rawdrv; int ofd[2], oxfd[2]; long tmpoff = 0, offset, loffset = 0, lzoffset = 0; unsigned short size, lsize = 0, lzsize; char *tmpbuf; if (argc != 3) { fprintf(stderr, "usage: %s <datapath> \"<key>\"\n", argv[0]); exit(1); } rawdrv = new RawVerse(argv[1]); zobj = new SWCipher((unsigned char *)argv[2]); tmpbuf = new char [ strlen(argv[1]) + 11 ]; sprintf(tmpbuf, "%sot.zzz", argv[1]); ofd[0] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%sot.zzz.vss", argv[1]); oxfd[0] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%snt.zzz", argv[1]); ofd[1] = FileMgr::createPathAndFile(tmpbuf); sprintf(tmpbuf, "%snt.zzz.vss", argv[1]); oxfd[1] = FileMgr::createPathAndFile(tmpbuf); delete [] tmpbuf; printf("\n"); write(oxfd[0], &lzoffset, 4); write(oxfd[0], &lzsize, 2); write(oxfd[1], &lzoffset, 4); write(oxfd[1], &lzsize, 2); key.setAutoNormalize(false); key.setIntros(true); for (key.setIndex(0); (!key.popError()); key++) { rawdrv->findOffset(key.getTestament(), key.getIndex(), &offset, &size); printf("%s: OLD offset: %ld; size: %d\n", (const char *)key, offset, size); if ((offset == loffset) && (size == lsize)) { printf("using previous offset,size %d\n", size); offset = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR); printf("%ld %ld %d \n", offset, lzoffset, lzsize); write(oxfd[key.getTestament() - 1], &lzoffset, 4); write(oxfd[key.getTestament() - 1], &lzsize, 2); } else { lsize = size; loffset = offset; if (size) { SWBuf tmpbuf; rawdrv->readText(key.getTestament(), offset, size, tmpbuf); zobj->Buf(tmpbuf.c_str(), size); unsigned long ulSize = size; zobj->cipherBuf(&ulSize); size = (unsigned int)ulSize; } offset = lseek(ofd[key.getTestament() - 1], 0, SEEK_CUR); tmpoff = lseek(oxfd[key.getTestament() - 1], 0, SEEK_CUR); printf("%s: (%ld) NEW offset: %ld; size: %d\n", (const char *)key, tmpoff, offset, size); write(oxfd[key.getTestament() - 1], &offset, 4); unsigned long ulSize = size; if (size) write(ofd[key.getTestament() - 1], zobj->cipherBuf(&ulSize), size); size = (unsigned int)ulSize; lzoffset = offset; write(oxfd[key.getTestament() - 1], &size, 2); lzsize = size; } } delete zobj; close(ofd[0]); close(oxfd[0]); close(ofd[1]); close(oxfd[1]); return 0; }
int main(int argc, char **argv) { // Let's test our command line arguments if (argc < 2) { // fprintf(stderr, "usage: %s <vpl_file> </path/to/mod> [0|1 - file includes prepended verse references]\n", argv[0]); fprintf(stderr, "usage: %s <source_vpl_file> </path/to/output/mod/> [0|1 - prepended verse refs] [0|1 - NT only]\n\n", argv[0]); fprintf(stderr, "\tWARNING: THIS IS CURRENTLY A KJV-VERSIFICATION-ONLY UTILITY\n"); fprintf(stderr, "\tWith no verse refs, source file must contain exactly 31102 lines.\n"); fprintf(stderr, "\tThis is KJV verse count plus headings for MODULE,\n"); fprintf(stderr, "\tTESTAMENT, BOOK, CHAPTER. An example snippet follows:\n\n"); fprintf(stderr, "\t\tMODULE HEADER\n"); fprintf(stderr, "\t\tOLD TESTAMENT HEADER\n"); fprintf(stderr, "\t\tGENESIS HEADER\n"); fprintf(stderr, "\t\tCHAPTER 1 HEADER\n"); fprintf(stderr, "\t\tIn the beginning...\n\n"); fprintf(stderr, "\t... implying there must also be a CHAPTER2 HEADER,\n"); fprintf(stderr, "\tEXODUS HEADER, NEW TESTAMENT HEADER, etc. If there is no text for\n"); fprintf(stderr, "\tthe header, a blank line must, at least, hold place.\n\n"); fprintf(stderr, "\tWith verse refs, source file must simply contain any number of lines,\n"); fprintf(stderr, "\tthat begin with the verse reference for which it is an entry. e.g.:\n\n"); fprintf(stderr, "\t\tgen 1:0 CHAPTER 1 HEADER\n"); fprintf(stderr, "\t\tgen 1:1 In the beginning...\n\n"); exit(-1); } // Let's see if we can open our input file int fd = FileMgr::openFileReadOnly(argv[1]); if (fd < 0) { fprintf(stderr, "error: %s: couldn't open input file: %s \n", argv[0], argv[1]); exit(-2); } // Try to initialize a default set of datafiles and indicies at our // datapath location passed to us from the user. if (RawText::createModule(argv[2])) { fprintf(stderr, "error: %s: couldn't create module at path: %s \n", argv[0], argv[2]); exit(-3); } // not used yet, but for future support of a vpl file with each line // prepended with verse reference, eg. "Gen 1:1 In the beginning..." bool vref = false; if (argc > 3) vref = (argv[3][0] == '0') ? false : true; // if 'nt' is the 4th arg, our vpl file only has the NT bool ntonly = false; if (argc > 4) ntonly = (argv[4][0] == '0') ? false : true; // Do some initialization stuff char *buffer = 0; RawText mod(argv[2]); // open our datapath with our RawText driver. VerseKey vk; vk.setAutoNormalize(false); vk.setIntros(true); // turn on mod/testmnt/book/chap headings vk.setPersist(true); mod.setKey(vk); // Loop through module from TOP to BOTTOM and set next line from // input file as text for this entry in the module mod = TOP; if (ntonly) vk = "Matthew 1:1"; int successive = 0; //part of hack below while ((!mod.popError()) && (!readline(fd, &buffer))) { if (*buffer == '|') // comments, ignore line continue; if (vref) { const char *verseText = parseVReg(buffer); if (!verseText) { // if we didn't find a valid verse ref std::cerr << "No valid verse ref found on line: " << buffer << "\n"; exit(-4); } vk = buffer; if (vk.popError()) { std::cerr << "Error parsing key: " << buffer << "\n"; exit(-5); } string orig = mod.getRawEntry(); if (!isKJVRef(buffer)) { VerseKey origVK = vk; /* This block is functioning improperly -- problem with AutoNormalize??? do { vk--; } while (!vk.popError() && !isKJVRef(vk)); */ //hack to replace above: successive++; vk -= successive; orig = mod.getRawEntry(); std::cerr << "Not a valid KJV ref: " << origVK << "\n"; std::cerr << "appending to ref: " << vk << "\n"; orig += " [ ("; orig += origVK; orig += ") "; orig += verseText; orig += " ] "; verseText = orig.c_str(); } else { successive = 0; } if (orig.length() > 1) std::cerr << "Warning, overwriting verse: " << vk << std::endl; // ------------- End verse tests ----------------- mod << verseText; // save text to module at current position } else { fixText(buffer); mod << buffer; // save text to module at current position mod++; // increment module position } } // clear up our buffer that readline might have allocated if (buffer) delete [] buffer; }
int main(int argc, char **argv) { int loop; int max; VerseKey yo("Gen.1.1", "Gen.1.2"); std::cout << yo.getRangeText(); if (argc > 1) LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(argv[1]); VerseKey bla; long index; if (argc < 2) bla = "James 1:19"; else bla = argv[2]; std::cout << "\n Headings: " << (bool)bla.isIntros() << "\n"; std::cout << " (.Index(Index()+1))\n"; max = (argc < 4) ? 10 : atoi(argv[3]); for (loop = 0; loop < max; loop++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")"; bla.setIndex(index+1); std::cout << "-> " << (const char *)bla << "\n"; } std::cout << "-----------------\n"; std::cout << "\n (.Index(Index()-1))\n"; if (argc < 2) bla = "James 1:19"; else bla = argv[2]; for (loop = max; loop; loop--) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")"; bla.setIndex(index-1); std::cout << "-> " << (const char *)bla << "\n"; } std::cout << "-----------------\n"; bla.setIntros(true); std::cout << "\n Headings: " << (bool)bla.isIntros() << "\n"; std::cout << " key++\n"; if (argc < 2) bla = "Matthew 1:5"; else bla = argv[2]; for (loop = 0; loop < max && !bla.popError(); loop++,bla++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; bla.setIntros(true); std::cout << "\n Headings: " << (bool)bla.isIntros() << "\n"; std::cout << " key--\n"; if (argc < 2) bla = "Matthew 1:5"; else bla = argv[2]; for (loop = max; loop && !bla.popError(); loop--, bla--) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Genesis 1:5"; else bla = argv[2]; for (loop = max; loop; loop--, bla--) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Malachi 4:2"; else bla = argv[2]; for (loop = max; loop; loop--, bla++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Revelation of John 22:17"; else bla = argv[2]; for (loop = max; loop; loop--, bla++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; std::cout << "-------- Headings ---------\n"; bla.setIntros(true); if (argc < 2) bla = "Matthew 1:5"; else bla = argv[2]; for (loop = max; loop; loop--, bla--) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Genesis 1:5"; else bla = argv[2]; for (loop = max; loop; loop--, bla--) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Malachi 4:2"; else bla = argv[2]; for (loop = max; loop; loop--, bla++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "-----------------\n"; if (argc < 2) bla = "Revelation of John 22:17"; else bla = argv[2]; for (loop = max; loop; loop--, bla++) { index = bla.getIndex(); std::cout << (const char *)bla << "(" << index << ")\n"; } std::cout << "\n\n"; std::cout << "-------- Error Check ------------\n\n"; bla = "Revelation of John 23:19"; std::cout << "bla = \"Revelation of John 23:19\"\n"; std::cout << "(const char *)bla = " << (const char *)bla << "\n"; std::cout << "bla.popError() = " << (int)bla.popError() << " \n"; std::cout << "bla++ \n"; bla++; std::cout << "bla.popError() = " << (int)bla.popError() << " \n"; bla.setIntros(false); for (bla = BOTTOM; !bla.popError(); bla.setBook(bla.getBook()-1)) std::cout << (const char *)bla << "\n"; bla.setTestament(1); bla = BOTTOM; std::cout << bla.getTestamentIndex() << "\n"; std::cout << bla.getIndex() << "\n"; std::cout << bla << "\n"; bla.setTestament(2); bla = BOTTOM; std::cout << bla.getTestamentIndex() << "\n"; std::cout << bla.getIndex() << "\n"; std::cout << bla << "\n"; return 0; }