diff options
Diffstat (limited to '.pc/12_fix_compiler_warnings.diff')
12 files changed, 0 insertions, 3470 deletions
diff --git a/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp b/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp deleted file mode 100644 index d801aaa..0000000 --- a/.pc/12_fix_compiler_warnings.diff/src/mgr/filemgr.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/****************************************************************************** - * - * filemgr.cpp - implementation of class FileMgr used for pooling file - * handles - * - * $Id: filemgr.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 1998-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#include <filemgr.h> -#include <utilstr.h> - -#include <dirent.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <stdio.h> -#include <string.h> -#include <swbuf.h> -#if !defined(__GNUC__) && !defined(_WIN32_WCE) -#include <io.h> -#include <direct.h> -#else -#include <unistd.h> -#endif - - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#ifndef S_IRGRP -#define S_IRGRP 0 -#endif - -#ifndef S_IROTH -#define S_IROTH 0 -#endif - -// Fix for VC6 -#ifndef S_IREAD -#ifdef _S_IREAD -#define S_IREAD _S_IREAD -#define S_IWRITE _S_IWRITE -#endif -#endif -// ----------- - -// ------- if we still don't have something -#ifndef S_IREAD -#define S_IREAD 0400 -#endif -#ifndef S_IWRITE -#define S_IWRITE 0200 -#endif -// ------- - - -SWORD_NAMESPACE_START - - -int FileMgr::CREAT = O_CREAT; -int FileMgr::APPEND = O_APPEND; -int FileMgr::TRUNC = O_TRUNC; -int FileMgr::RDONLY = O_RDONLY; -int FileMgr::RDWR = O_RDWR; -int FileMgr::WRONLY = O_WRONLY; -int FileMgr::IREAD = S_IREAD; -int FileMgr::IWRITE = S_IWRITE; - - -// ---------------- statics ----------------- -FileMgr *FileMgr::systemFileMgr = 0; - -class __staticsystemFileMgr { -public: - __staticsystemFileMgr() { } - ~__staticsystemFileMgr() { delete FileMgr::systemFileMgr; } -} _staticsystemFileMgr; - - -FileMgr *FileMgr::getSystemFileMgr() { - if (!systemFileMgr) - systemFileMgr = new FileMgr(); - - return systemFileMgr; -} - - -void FileMgr::setSystemFileMgr(FileMgr *newFileMgr) { - if (systemFileMgr) - delete systemFileMgr; - systemFileMgr = newFileMgr; -} - -// --------------- end statics -------------- - - -FileDesc::FileDesc(FileMgr *parent, const char *path, int mode, int perms, bool tryDowngrade) { - this->parent = parent; - this->path = 0; - stdstr(&this->path, path); - this->mode = mode; - this->perms = perms; - this->tryDowngrade = tryDowngrade; - offset = 0; - fd = -77; -} - - -FileDesc::~FileDesc() { - if (fd > 0) - close(fd); - - if (path) - delete [] path; -} - - -int FileDesc::getFd() { - if (fd == -77) - fd = parent->sysOpen(this); -// if ((fd < -1) && (fd != -77)) // kludge to hand ce -// return 777; - return fd; -} - - -long FileDesc::seek(long offset, int whence) { - return lseek(getFd(), offset, whence); -} - - -long FileDesc::read(void *buf, long count) { - return ::read(getFd(), buf, count); -} - - -long FileDesc::write(const void *buf, long count) { - return ::write(getFd(), buf, count); -} - - -FileMgr::FileMgr(int maxFiles) { - this->maxFiles = maxFiles; // must be at least 2 - files = 0; -} - - -FileMgr::~FileMgr() { - FileDesc *tmp; - - while(files) { - tmp = files->next; - delete files; - files = tmp; - } -} - - -FileDesc *FileMgr::open(const char *path, int mode, bool tryDowngrade) { - return open(path, mode, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH, tryDowngrade); -} - - -FileDesc *FileMgr::open(const char *path, int mode, int perms, bool tryDowngrade) { - FileDesc **tmp, *tmp2; - - for (tmp = &files; *tmp; tmp = &((*tmp)->next)) { - if ((*tmp)->fd < 0) // insert as first non-system_open file - break; - } - - tmp2 = new FileDesc(this, path, mode, perms, tryDowngrade); - tmp2->next = *tmp; - *tmp = tmp2; - - return tmp2; -} - - -void FileMgr::close(FileDesc *file) { - FileDesc **loop; - - for (loop = &files; *loop; loop = &((*loop)->next)) { - if (*loop == file) { - *loop = (*loop)->next; - delete file; - break; - } - } -} - - -int FileMgr::sysOpen(FileDesc *file) { - FileDesc **loop; - int openCount = 1; // because we are presently opening 1 file, and we need to be sure to close files to accomodate, if necessary - - for (loop = &files; *loop; loop = &((*loop)->next)) { - - if ((*loop)->fd > 0) { - if (++openCount > maxFiles) { - (*loop)->offset = lseek((*loop)->fd, 0, SEEK_CUR); - ::close((*loop)->fd); - (*loop)->fd = -77; - } - } - - if (*loop == file) { - if (*loop != files) { - *loop = (*loop)->next; - file->next = files; - files = file; - } - if ((!access(file->path, 04)) || ((file->mode & O_CREAT) == O_CREAT)) { // check for at least file exists / read access before we try to open - char tries = (((file->mode & O_RDWR) == O_RDWR) && (file->tryDowngrade)) ? 2 : 1; // try read/write if possible - for (int i = 0; i < tries; i++) { - if (i > 0) { - file->mode = (file->mode & ~O_RDWR); // remove write access - file->mode = (file->mode | O_RDONLY);// add read access - } - file->fd = ::open(file->path, file->mode|O_BINARY, file->perms); - - if (file->fd >= 0) - break; - } - - if (file->fd >= 0) - lseek(file->fd, file->offset, SEEK_SET); - } - else file->fd = -1; - if (!*loop) - break; - } - } - return file->fd; -} - - -// to truncate a file at its current position -// leaving byte at current possition intact -// deleting everything afterward. -signed char FileMgr::trunc(FileDesc *file) { - - static const char *writeTest = "x"; - long size = file->seek(1, SEEK_CUR); - if (size == 1) // was empty - size = 0; - char nibble [ 32767 ]; - bool writable = file->write(writeTest, 1); - int bytes = 0; - - if (writable) { - // get tmpfilename - char *buf = new char [ strlen(file->path) + 10 ]; - int i; - for (i = 0; i < 9999; i++) { - sprintf(buf, "%stmp%.4d", file->path, i); - if (!existsFile(buf)) - break; - } - if (i == 9999) - return -2; - - int fd = ::open(buf, O_CREAT|O_RDWR, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - if (fd < 0) - return -3; - - file->seek(0, SEEK_SET); - while (size > 0) { - bytes = file->read(nibble, 32767); - bytes = (bytes < size)?bytes:size; - if (write(fd, nibble, bytes) != bytes) { break; } - size -= bytes; - } - if (size < 1) { - // zero out the file - ::close(file->fd); - file->fd = ::open(file->path, O_TRUNC, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - ::close(file->fd); - file->fd = -77; // force file open by filemgr - // copy tmp file back (dumb, but must preserve file permissions) - lseek(fd, 0, SEEK_SET); - do { - bytes = read(fd, nibble, 32767); - file->write(nibble, bytes); - } while (bytes == 32767); - } - - ::close(fd); - ::close(file->fd); - removeFile(buf); // remove our tmp file - file->fd = -77; // causes file to be swapped out forcing open on next call to getFd() - } - else { // put offset back and return failure - file->seek(-1, SEEK_CUR); - return -1; - } - return 0; -} - - -signed char FileMgr::existsFile(const char *ipath, const char *ifileName) -{ - int len = strlen(ipath) + ((ifileName)?strlen(ifileName):0) + 3; - char *ch; - char *path = new char [ len ]; - strcpy(path, ipath); - - if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/')) - path[strlen(path)-1] = 0; - - if (ifileName) { - ch = path + strlen(path); - sprintf(ch, "/%s", ifileName); - } - signed char retVal = !access(path, 04); - delete [] path; - return retVal; -} - - -signed char FileMgr::existsDir(const char *ipath, const char *idirName) -{ - char *ch; - int len = strlen(ipath) + ((idirName)?strlen(idirName):0) + 1; - if (idirName) - len += strlen(idirName); - char *path = new char [ len ]; - strcpy(path, ipath); - - if ((path[strlen(path)-1] == '\\') || (path[strlen(path)-1] == '/')) - path[strlen(path)-1] = 0; - - if (idirName) { - ch = path + strlen(path); - sprintf(ch, "/%s", idirName); - } - signed char retVal = !access(path, 04); - delete [] path; - return retVal; -} - - -int FileMgr::createParent(const char *pName) { - char *buf = new char [ strlen(pName) + 1 ]; - int retCode = 0; - - strcpy(buf, pName); - int end = strlen(buf) - 1; - while (end) { - if ((buf[end] == '/') || (buf[end] == '\\')) - break; - end--; - } - buf[end] = 0; - if (strlen(buf)>0) { - if (access(buf, 02)) { // not exists with write access? - if ((retCode = mkdir(buf -#ifndef WIN32 - , 0755 -#endif - ))) { - createParent(buf); - retCode = mkdir(buf -#ifndef WIN32 - , 0755 -#endif - ); - } - } - } - else retCode = -1; - delete [] buf; - return retCode; -} - - -int FileMgr::openFileReadOnly(const char *fName) { - int fd = ::open(fName, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - return fd; -} - - -int FileMgr::createPathAndFile(const char *fName) { - int fd; - - fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - if (fd < 1) { - createParent(fName); - fd = ::open(fName, O_CREAT|O_WRONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH); - } - return fd; -} - - -int FileMgr::copyFile(const char *sourceFile, const char *targetFile) { - int sfd, dfd, len; - char buf[4096]; - - if ((sfd = ::open(sourceFile, O_RDONLY|O_BINARY, S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) < 1) - return -1; - if ((dfd = createPathAndFile(targetFile)) < 1) - return -1; - - do { - len = read(sfd, buf, 4096); - if (write(dfd, buf, len) != len) break; - } - while(len == 4096); - ::close(dfd); - ::close(sfd); - - return 0; -} - - -int FileMgr::removeFile(const char *fName) { - return ::remove(fName); -} - -char FileMgr::getLine(FileDesc *fDesc, SWBuf &line) { - int len; - bool more = true; - char chunk[255]; - - line = ""; - - // assert we have a valid file handle - if (fDesc->getFd() < 1) - return 0; - - while (more) { - more = false; - long index = fDesc->seek(0, SEEK_CUR); - len = fDesc->read(chunk, 254); - - // assert we have a readable file (not a directory) - if (len < 1) - break; - - int start = 0; - // clean up any preceding white space if we're at the beginning of line - if (!line.length()) { - for (;start < len; start++) { - if ((chunk[start] != 13) && (chunk[start] != ' ') && (chunk[start] != '\t')) - break; - } - } - - // find the end - int end; - for (end = start; ((end < (len-1)) && (chunk[end] != 10)); end++); - - if ((chunk[end] != 10) && (len == 254)) { - more = true; - } - index += (end + 1); - - // reposition to next valid place to read - fDesc->seek(index, SEEK_SET); - - // clean up any trailing junk on line if we're at the end - if (!more) { - for (; end > start; end--) { - if ((chunk[end] != 10) && (chunk[end] != 13) && (chunk[end] != ' ') && (chunk[end] != '\t')) { - if (chunk[end] == '\\') { - more = true; - end--; - } - break; - } - } - } - - int size = (end - start) + 1; - - if (size > 0) { - // line.appendFormatted("%.*s", size, chunk+start); - line.append(chunk+start, size); - } - } - return ((len > 0) || line.length()); -} - - -char FileMgr::isDirectory(const char *path) { - struct stat stats; - if (stat(path, &stats)) - return 0; - return ((stats.st_mode & S_IFDIR) == S_IFDIR); -} - - -int FileMgr::copyDir(const char *srcDir, const char *destDir) { - DIR *dir; - struct dirent *ent; - if ((dir = opendir(srcDir))) { - rewinddir(dir); - while ((ent = readdir(dir))) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - SWBuf srcPath = (SWBuf)srcDir + (SWBuf)"/" + ent->d_name; - SWBuf destPath = (SWBuf)destDir + (SWBuf)"/" + ent->d_name; - if (!isDirectory(srcPath.c_str())) { - copyFile(srcPath.c_str(), destPath.c_str()); - } - else { - copyDir(srcPath.c_str(), destPath.c_str()); - } - } - } - closedir(dir); - } - return 0; -} - - -int FileMgr::removeDir(const char *targetDir) { - DIR *dir = opendir(targetDir); - struct dirent *ent; - if (dir) { - rewinddir(dir); - while ((ent = readdir(dir))) { - if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) { - SWBuf targetPath = (SWBuf)targetDir + (SWBuf)"/" + ent->d_name; - if (!isDirectory(targetPath.c_str())) { - FileMgr::removeFile(targetPath.c_str()); - } - else { - FileMgr::removeDir(targetPath.c_str()); - } - } - } - closedir(dir); - FileMgr::removeFile(targetDir); -/* - int status = FileMgr::removeFile(targetDir); - int stuff = errno; - char *err = strerror(errno); - int x = stuff; -*/ - } - return 0; -} - - -void FileMgr::flush() { - FileDesc **loop; - - for (loop = &files; *loop; loop = &((*loop)->next)) { - if ((*loop)->fd > 0) { - (*loop)->offset = lseek((*loop)->fd, 0, SEEK_CUR); - ::close((*loop)->fd); - (*loop)->fd = -77; - } - } -} - -long FileMgr::resourceConsumption() { - long count = 0; - FileDesc **loop; - for (loop = &files; *loop; loop = &((*loop)->next)) { - if ((*loop)->fd > 0) { - count++; - } - } - return count; -} - - -SWORD_NAMESPACE_END diff --git a/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c b/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c deleted file mode 100644 index a7b7164..0000000 --- a/.pc/12_fix_compiler_warnings.diff/src/utilfuns/zlib/untgz.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * untgz.c -- Display contents and/or extract file from - * a gzip'd TAR file - * written by "Pedro A. Aranda Guti\irrez" <paag@tid.es> - * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org> - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <errno.h> -#include <fcntl.h> -#ifdef unix -#include <unistd.h> -#include <sys/stat.h> -#include <sys/types.h> - -#else -# include <direct.h> -# include <io.h> -#endif - -#include "zlib.h" - -#ifdef WIN32 -# include <windows.h> -# ifndef F_OK -# define F_OK (0) -# endif -# ifdef _MSC_VER -# define mkdir(dirname,mode) _mkdir(dirname) -# define strdup(str) _strdup(str) -# define unlink(fn) _unlink(fn) -# define access(path,mode) _access(path,mode) -# else -# define mkdir(dirname,mode) _mkdir(dirname) -# endif -#else -# include <utime.h> -#endif - - -/* Values used in typeflag field. */ - -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ - -#define BLOCKSIZE 512 - -struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ -}; - -union tar_buffer { - char buffer[BLOCKSIZE]; - struct tar_header header; -}; - -enum { TGZ_EXTRACT = 0, TGZ_LIST }; - -void TGZnotfound OF((const char *)); - -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int ExprMatch OF((char *,char *)); - -int makedir OF((char *)); -int matchname OF((int,int,char **,char *)); - -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); - -void help OF((int)); -int main OF((int, char **)); - -char *prog; - -/* This will give a benign warning */ - -static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL }; - -/* Return the real name of the TGZ archive */ -/* or NULL if it does not exist. */ - -/* error message for the filename */ - -void TGZnotfound OF((const char *fname)) -{ - int i; - - fprintf(stderr,"%s : couldn't find ",prog); - for (i=0;TGZprefix[i];i++) - fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n", - fname, - TGZprefix[i]); - exit(1); -} - - -/* help functions */ - -int getoct(char *p,int width) -{ - int result = 0; - char c; - - while (width --) - { - c = *p++; - if (c == ' ') - continue; - if (c == 0) - break; - result = result * 8 + (c - '0'); - } - return result; -} - -char *strtime (time_t *t) -{ - struct tm *local; - static char result[32]; - - local = localtime(t); - sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", - local->tm_mday, local->tm_mon+1, local->tm_year+1900, - local->tm_hour, local->tm_min, local->tm_sec); - return result; -} - - -/* regular expression matching */ - -#define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) - -int ExprMatch(char *string,char *expr) -{ - while (1) - { - if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } - else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } - } -} - -/* recursive make directory */ -/* abort if you get an ENOENT errno somewhere in the middle */ -/* e.g. ignore error "mkdir on existing directory" */ -/* */ -/* return 1 if OK */ -/* 0 on error */ - -int makedir (char *newdir) -{ - char *buffer = strdup(newdir); - char *p; - int len = strlen(buffer); - - if (len <= 0) { - free(buffer); - return 0; - } - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mkdir(buffer, 0775) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - -int matchname (int arg,int argc,char **argv,char *fname) -{ - if (arg == argc) /* no arguments given (untgz tgzarchive) */ - return 1; - - while (arg < argc) - if (ExprMatch(fname,argv[arg++])) - return 1; - - return 0; /* ignore this for the moment being */ -} - - -/* Tar file list or extract */ - -int untar (gzFile in, const char *dest) { - union tar_buffer buffer; - int len; - int err; - int getheader = 1; - int remaining = 0; - FILE *outfile = NULL; - char fname[BLOCKSIZE]; - time_t tartime; - - while (1) { - len = gzread(in, &buffer, BLOCKSIZE); - if (len < 0) - error (gzerror(in, &err)); - /* - * Always expect complete blocks to process - * the tar information. - */ - if (len != BLOCKSIZE) - error("gzread: incomplete block read"); - - /* - * If we have to get a tar header - */ - if (getheader == 1) { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if ((len == 0) || (buffer.header.name[0]== 0)) break; - - tartime = (time_t)getoct(buffer.header.mtime,12); - strcpy(fname, dest); - if ((fname[strlen(fname)-1] != '/') && (fname[strlen(fname)-1] != '\\')) - strcat(fname, "/"); - strcat(fname, buffer.header.name); - - switch (buffer.header.typeflag) { - case DIRTYPE: - makedir(fname); - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (remaining) { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - // try creating directory - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } -/* - fprintf(stderr, - "%s %s\n", - (outfile) ? "Extracting" : "Couldn't create", - fname); -*/ - } - else - outfile = NULL; - /* - * could have no contents - */ - getheader = (remaining) ? 0 : 1; - break; - default: - break; - } - } - else { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if (outfile != NULL) { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) { - fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); - fclose(outfile); - unlink(fname); - } - } - remaining -= bytes; - if (remaining == 0) { - getheader = 1; - if (outfile != NULL) { -#ifdef WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal; - SYSTEMTIME st; - struct tm localt; - - fclose(outfile); - - localt = *localtime(&tartime); - - hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, - 0, NULL, OPEN_EXISTING, 0, NULL); - - st.wYear = (WORD)localt.tm_year+1900; - st.wMonth = (WORD)localt.tm_mon; - st.wDayOfWeek = (WORD)localt.tm_wday; - st.wDay = (WORD)localt.tm_mday; - st.wHour = (WORD)localt.tm_hour; - st.wMinute = (WORD)localt.tm_min; - st.wSecond = (WORD)localt.tm_sec; - st.wMilliseconds = 0; - SystemTimeToFileTime(&st,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,NULL,&ftm); - CloseHandle(hFile); - - outfile = NULL; -#else - struct utimbuf settime; - - settime.actime = settime.modtime = tartime; - - fclose(outfile); - outfile = NULL; - utime(fname,&settime); -#endif - } - } - } - } - return 0; -} - - -/* =========================================================== */ - -void help(int exitval) -{ - fprintf(stderr, - "untgz v 0.1\n" - " an sample application of zlib 1.0.4\n\n" - "Usage : untgz TGZfile to extract all files\n" - " untgz TGZfile fname ... to extract selected files\n" - " untgz -l TGZfile to list archive contents\n" - " untgz -h to display this help\n\n"); - exit(exitval); -} - -void error(const char *msg) -{ - fprintf(stderr, "%s: %s\n", prog, msg); -// exit(1); // don't exit on error -} - - -int untargz(int fd, const char *dest) { - gzFile f; - - f = gzdopen(fd, "rb"); - if (f == NULL) { - fprintf(stderr,"%s: Couldn't gzopen file\n", prog); - return 1; - } - - return untar(f, dest); -} diff --git a/.pc/12_fix_compiler_warnings.diff/tests/testblocks.cpp b/.pc/12_fix_compiler_warnings.diff/tests/testblocks.cpp deleted file mode 100644 index 96e2253..0000000 --- a/.pc/12_fix_compiler_warnings.diff/tests/testblocks.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/****************************************************************************** - * - * testblocks.cpp - - * - * $Id: testblocks.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#include <entriesblk.h> -#include <iostream> -#include <string> -#include <stdio.h> -#include <stdlib.h> - -using namespace std; -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -void addEntry(EntriesBlock *eb) { - string input; - string body; - char line[1024]; - std::cout << "\nEnter new Entry's text. '.' on an empty line to finish:\n"; - do { - std::cout << "> "; - fgets(line, 1000, stdin); - input = line; - if (input.compare(".")) - body.append(input); - } - while (input.compare(".")); - std::cout << "Adding new entry. Index is: " << eb->addEntry(body.c_str()) << "\n\n"; -} - - -void printEntry(EntriesBlock *eb, int index) { - if (index < eb->getCount()) { - std::cout << "Contents of entry [" << index << "]:\n"; - std::cout << eb->getEntry(index) << "\n"; - } - else std::cout << "Invalid entry number\n\n"; -} - - -void printSize(EntriesBlock *eb) { - unsigned long size; - eb->getRawData(&size); - std::cout << "Size of raw data: " << size << "\n\n"; -} - - -void removeEntry(EntriesBlock *eb, int index) { - if (index < eb->getCount()) { - std::cout << "Removing entry [" << index << "]\n"; - eb->removeEntry(index); - } - else std::cout << "Invalid entry number\n\n"; -} - - -int main(int argc, char **argv) { - - EntriesBlock *eb = new EntriesBlock(); - string input; - char line[1024]; - - std::cout << "Initial entry count should be 0: " << eb->getCount() << "\n"; - - do { - std::cout << "[" << eb->getCount() << "] > "; - fgets(line, 1000, stdin); - input = line; - if (input.length() > 0) { - switch (input[0]) { - case 'a': addEntry(eb); break; - case 'p': printEntry(eb, atoi(input.c_str()+1)); break; - case 'r': removeEntry(eb, atoi(input.c_str()+1)); break; - case 's': printSize(eb); break; - case 'q': break; - case '?': - default: - std::cout << "\n a - add a new entry\n"; - std::cout << " p <entry_index> - print entry\n"; - std::cout << " r <entry_index> - remove entry\n"; - std::cout << " s - print size of raw data\n"; - std::cout << " q - quit\n\n"; - break; - } - } - } - while (input.compare("q")); - - delete eb; - - return 0; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/cipherraw.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/cipherraw.cpp deleted file mode 100644 index a8de3e7..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/cipherraw.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * - * cipherraw.cpp - Utility to encipher a raw (uncompressed) module - * - * $Id: cipherraw.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) - #pragma warning( disable: 4996 ) -#endif - -#include <ctype.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#include <filemgr.h> -#include <swcipher.h> -#include <versekey.h> -#include <rawverse.h> -#include <swbuf.h> - -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -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; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/gbfidx.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/gbfidx.cpp deleted file mode 100644 index 8b1d1dd..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/gbfidx.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/***************************************************************************** - * - * gbfidx.cpp - This code reeks but works (at least for WEB). - * Good luck! - * - * $Id: gbfidx.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#include <fcntl.h> -#include <versekey.h> -#include <filemgr.h> - -using namespace sword; - -void writeidx(VerseKey &key1, VerseKey &key2, VerseKey &key3, long offset, short size); -char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size); -void openfiles(char *fname); -void checkparams(int argc, char **argv); - - -VerseKey key1, key2, key3; -int fp, vfp, cfp, bfp; -long chapoffset; -short chapsize; -char testmnt; - - -int main(int argc, char **argv) -{ - long pos, offset; - int num1, num2, rangemax; - char startflag = 0; - short size; - - checkparams(argc, argv); - - openfiles(argv[1]); - - testmnt = key1.getTestament(); - num1 = key1.getChapter(); - num2 = key1.getVerse(); - pos = 0; - write(bfp, &pos, 4); /* Book offset for testament intros */ - pos = 4; - write(cfp, &pos, 4); /* Chapter offset for testament intro */ - - -/* Right now just zero out intros until parsing correctly */ - pos = 0; - size = 0; - write(vfp, &pos, 4); /* Module intro */ - write(vfp, &size, 2); - write(vfp, &pos, 4); /* Testament intro */ - write(vfp, &size, 2); - - while(!findbreak(fp, &offset, &num1, &num2, &rangemax, &size)) { - if (!startflag) { - startflag = 1; - } - else { - if (num2 < key2.getVerse()) { // new chapter - if (num1 <= key2.getChapter()) { // new book - key2.setVerse(1); - key2.setChapter(1); - key2.setBook(key2.getBook()+1); - } - printf("Found Chapter Break: %d ('%s')\n", num1, (const char *)key2); - chapoffset = offset; - chapsize = size; -// continue; - } - } - key2.setVerse(1); - key2.setChapter(num1); - key2.setVerse(num2); - - key3 = key2; -// key3 += (rangemax - key3.getVerse()); - - writeidx(key1, key2, key3, offset, size); - } - close(vfp); - close(cfp); - close(bfp); - close(fp); - return 0; -} - - -/************************************************************************** - * ENT: key1 - current location of index - * key2 - minimum keyval for which this offset is valid - * key3 - maximum keyval for which this offset is valid - */ - -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); - } - } -} - - -char startchap(char *buf) -{ - if (buf[0] != '<') - return 0; - if (buf[1] != 'S') - return 0; - if (buf[2] != 'C') - return 0; -/* - if (!isdigit(buf[2])) - return 0; - for (loop = 3; loop < 7; loop++) { - if (buf[loop] == ' ') - break; - if ((!isdigit(buf[loop])) && (buf[loop] != ',') && (buf[loop] != '-')) - return 0; - } -*/ - return 1; -} - - -char startentry(char *buf) -{ - if (buf[0] != '<') - return 0; - if (buf[1] != 'S') - return 0; - if (buf[2] != 'V') - return 0; -/* - if (!isdigit(buf[2])) - return 0; - for (loop = 3; loop < 7; loop++) { - if (buf[loop] == ' ') - break; - if ((!isdigit(buf[loop])) && (buf[loop] != ',') && (buf[loop] != '-')) - return 0; - } -*/ - return 1; -} - - -char findbreak(int fp, long *offset, int *num1, int *num2, int *rangemax, short *size) -{ - char buf[7]; - int loop; - long offset2; - int ch2, vs2, rm2; - bool flag; - long chapstart = 0; - - memset(buf, ' ', 7); - - while (1) { - if (startchap(buf)) { - chapstart = lseek(fp, 0, SEEK_CUR) - 7; - memset(buf, ' ', 3); - flag = false; - for (loop = 3; loop < 6; loop++) { - if (isdigit(buf[loop])) - flag = true; - else { - buf[loop] = 0; - break; - } - } - if (flag) - *num1 = atoi(buf); - else (*num1)++; - } - if (startentry(buf)) { - memset(buf, ' ', 3); - flag = false; - for (loop = 3; loop < 6; loop++) { - if (isdigit(buf[loop])) - flag = true; - else { - buf[loop] = 0; - break; - } - if (flag) - *num2 = atoi(buf); - else (*num2)++; - } - loop++; - if (size) - *offset = lseek(fp, 0, SEEK_CUR) - (7 - loop); - else *offset = (chapstart) ? chapstart : lseek(fp, 0, SEEK_CUR) - 7; - if (size) { - ch2 = *num1; - vs2 = *num2; - if (findbreak(fp, &offset2, &ch2, &vs2, &rm2, 0)) { - *size = (short) (lseek(fp, 0, SEEK_END) - (*offset)); - } - else { - if (vs2) { - *size = (offset2 - (*offset)); - } - } - lseek(fp, *offset, SEEK_SET); - } - return 0; - } - memmove(buf, &buf[1], 6); - if (read(fp, &buf[6], 1) != 1) - return 1; - } -} - - -void openfiles(char *fname) -{ - SWBuf buf; - - if ((fp = FileMgr::openFileReadOnly(fname)) < 0) { - fprintf(stderr, "Couldn't open file: %s\n", fname); - exit(1); - } - - buf.setFormatted("%s.vss", fname); - if ((vfp = FileMgr::createPathAndFile(buf.c_str())) < 0) { - fprintf(stderr, "Couldn't open file: %s\n", buf.c_str()); - exit(1); - } - - buf.setFormatted("%s.cps", fname); - if ((cfp = FileMgr::createPathAndFile(buf.c_str())) < 0) { - fprintf(stderr, "Couldn't open file: %s\n", buf.c_str()); - exit(1); - } - - buf.setFormatted("%s.bks", fname); - if ((bfp = FileMgr::createPathAndFile(buf.c_str())) < 0) { - fprintf(stderr, "Couldn't open file: %s\n", buf.c_str()); - exit(1); - } -} - - -void checkparams(int argc, char **argv) -{ - if (argc < 2) { - fprintf(stderr, "usage: %s <file to process> [nt - for new testmt file]\n", argv[0]); - exit(1); - } - if (argc == 3) - key1 = key2 = key3 = "Matthew 1:1"; - else key1 = key2 = key3 = "Genesis 1:1"; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/genbookutil.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/genbookutil.cpp deleted file mode 100644 index 71363e3..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/genbookutil.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/****************************************************************************** - * - * genbookutil.cpp - - * - * $Id: genbookutil.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) -#endif - -#include <entriesblk.h> -#include <iostream> -#include <stdio.h> -#include <treekeyidx.h> -#include <rawgenbook.h> - -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -void printTree(TreeKeyIdx treeKey, TreeKeyIdx *target = 0, int level = 1) { - if (!target) - target = &treeKey; - - unsigned long currentOffset = target->getOffset(); - std::cout << ((currentOffset == treeKey.getOffset()) ? "==>" : ""); - for (int i = 0; i < level; i++) std::cout << "\t"; - std::cout << treeKey.getLocalName() << "/\n"; - if (treeKey.firstChild()) { - printTree(treeKey, target, level+1); - treeKey.parent(); - } - if (treeKey.nextSibling()) - printTree(treeKey, target, level); - -} - - -void printLocalName(TreeKeyIdx *treeKey) { - std::cout << "locaName: " << treeKey->getLocalName() << "\n"; -} - - -void setLocalName(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter New Node Name: "; - fgets(buf, 1000, stdin); - SWBuf name = buf; - treeKey->setLocalName(name.trim()); - treeKey->save(); -} - - -void gotoPath(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter Path: "; - fgets(buf, 1000, stdin); - SWBuf path = buf; - (*treeKey) = path.trim(); -} - - -void assurePath(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter Path: "; - fgets(buf, 1000, stdin); - SWBuf path = buf; - treeKey->assureKeyPath(path.trim()); -} - - -void viewEntryText(RawGenBook *book) { - std::cout << "\n"; - std::cout << book->renderText(); - std::cout << "\n"; -} - - -void setEntryText(RawGenBook *book) { - SWBuf body; - TreeKeyIdx *treeKey = (TreeKeyIdx *)(SWKey *)(*book); - if (treeKey->getOffset()) { - char buf[1023]; - std::cout << "Enter New Entry Text ('.' on a line by itself to end): \n"; - do { - fgets(buf, 1000, stdin); - SWBuf text = buf; - text.trim(); - if ((text[0] == '.') && (text[1] == 0)) - break; - body += text; - body += "\n"; - } while (true); - - (*book) << body.c_str(); - } - else std::cout << "Can't add entry text to root node\n"; -} - - -void appendSibbling(TreeKeyIdx *treeKey) { - if (treeKey->getOffset()) { - char buf[1023]; - std::cout << "Enter New Sibbling Name: "; - fgets(buf, 1000, stdin); - SWBuf name = buf; - treeKey->append(); - treeKey->setLocalName(name.trim()); - treeKey->save(); - } - else std::cout << "Can't add sibling to root node\n"; -} - - -void appendChild(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter New Child Name: "; - fgets(buf, 1000, stdin); - SWBuf name = buf; - treeKey->appendChild(); - treeKey->setLocalName(name.trim()); - treeKey->save(); -} - - -void deleteNode(TreeKeyIdx *treeKey) { - std::cout << "Removing entry [" << treeKey->getText() << "]\n"; - treeKey->remove(); -} - - -void removeEntry(EntriesBlock *eb, int index) { - if (index < eb->getCount()) { - std::cout << "Removing entry [" << index << "]\n"; - eb->removeEntry(index); - } - else std::cout << "Invalid entry number\n\n"; -} - - -int main(int argc, char **argv) { - - if (argc != 2) { - fprintf(stderr, "usage: %s <tree/key/data/path>\n", *argv); - exit(-1); - } - - TreeKeyIdx *treeKey = new TreeKeyIdx(argv[1]); - - if (treeKey->popError()) { - RawGenBook::createModule(argv[1]); - } - delete treeKey; - - RawGenBook *book = new RawGenBook(argv[1]); - TreeKeyIdx root = *((TreeKeyIdx *)((SWKey *)(*book))); - treeKey = (TreeKeyIdx *)(SWKey *)(*book); - - SWBuf input; - char line[1024]; - - do { - std::cout << "[" << treeKey->getText() << "] > "; - fgets(line, 1000, stdin); - input = line; - input.trim(); - if (input.length() > 0) { - switch (input[0]) { - case 'n': printLocalName(treeKey); break; - case 's': setLocalName(treeKey); break; - case 'g': gotoPath(treeKey); break; - case 'G': assurePath(treeKey); break; - case 'p': root.root(); printTree(root, treeKey); break; - case 'a': appendSibbling(treeKey); break; - case 'c': appendChild(treeKey); break; - case 'd': deleteNode(treeKey); break; - case 'j': treeKey->nextSibling(); break; - case 'k': treeKey->previousSibling(); break; - case 'h': treeKey->parent(); break; - case 'l': treeKey->firstChild(); break; - case 'r': treeKey->root(); break; - case 't': setEntryText(book); break; - case 'v': viewEntryText(book); break; - case 'q': break; - case '?': - default: - std::cout << "\n p - print tree\n"; - std::cout << " n - get local name\n"; - std::cout << " s - set local name\n"; - std::cout << " j - next sibbling\n"; - std::cout << " k - previous sibbling\n"; - std::cout << " h - parent\n"; - std::cout << " l - first child\n"; - std::cout << " r - root\n"; - std::cout << " g - goto path\n"; - std::cout << " G goto path; create if it doesn't exist\n"; - std::cout << " a - append sibbling\n"; - std::cout << " c - append child\n"; - std::cout << " d - delete node\n"; - std::cout << " v - view entry text\n"; - std::cout << " t - set entry text\n"; - std::cout << " q - quit\n\n"; - break; - } - } - } - while (input.compare("q")); - - delete treeKey; - - return 0; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/installmgr.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/installmgr.cpp deleted file mode 100644 index b705c25..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/installmgr.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/****************************************************************************** - * - * installmgr.cpp - commandline InstallMgr utility - * - * $Id: installmgr.cpp 2932 2013-07-31 14:07:01Z scribe $ - * - * Copyright 2003-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) -#endif - -#include <swmgr.h> -#include <installmgr.h> -#include <remotetrans.h> -#include <filemgr.h> -#include <iostream> -#include <map> -#include <swmodule.h> -#include <stdio.h> -#include <swlog.h> - -using namespace sword; -using std::cout; -using std::cerr; -using std::cin; -using std::map; - - -SWMgr *mgr = 0; -InstallMgr *installMgr = 0; -StatusReporter *statusReporter = 0; -SWBuf baseDir; -SWBuf confPath; - -void usage(const char *progName = 0, const char *error = 0); - -class MyInstallMgr : public InstallMgr { -public: - MyInstallMgr(const char *privatePath = "./", StatusReporter *sr = 0) : InstallMgr(privatePath, sr) {} - -virtual bool isUserDisclaimerConfirmed() const { - static bool confirmed = false; - if (!confirmed) { - cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; - cout << " -=+* WARNING *+=- -=+* WARNING *+=-\n\n\n"; - cout << "Although Install Manager provides a convenient way for installing\n"; - cout << "and upgrading SWORD components, it also uses a systematic method\n"; - cout << "for accessing sites which gives packet sniffers a target to lock\n"; - cout << "into for singling out users. \n\n\n"; - cout << "IF YOU LIVE IN A PERSECUTED COUNTRY AND DO NOT WISH TO RISK DETECTION,\n"; - cout << "YOU SHOULD *NOT* USE INSTALL MANAGER'S REMOTE SOURCE FEATURES.\n\n\n"; - cout << "Also, Remote Sources other than CrossWire may contain less than\n"; - cout << "quality modules, modules with unorthodox content, or even modules\n"; - cout << "which are not legitimately distributable. Many repositories\n"; - cout << "contain wonderfully useful content. These repositories simply\n"; - cout << "are not reviewed or maintained by CrossWire and CrossWire\n"; - cout << "cannot be held responsible for their content. CAVEAT EMPTOR.\n\n\n"; - cout << "If you understand this and are willing to enable remote source features\n"; - cout << "then type yes at the prompt\n\n"; - cout << "enable? [no] "; - - char prompt[10]; - fgets(prompt, 9, stdin); - confirmed = (!strcmp(prompt, "yes\n")); - cout << "\n"; - } - return confirmed; -} - -}; - -class MyStatusReporter : public StatusReporter { - int last; - virtual void update(unsigned long totalBytes, unsigned long completedBytes) { - int p = (totalBytes > 0) ? (int)(74.0 * ((double)completedBytes / (double)totalBytes)) : 0; - for (;last < p; ++last) { - if (!last) { - SWBuf output; - output.setFormatted("[ File Bytes: %ld", totalBytes); - while (output.size() < 75) output += " "; - output += "]"; - cout << output.c_str() << "\n "; - } - cout << "-"; - } - cout.flush(); - } - virtual void preStatus(long totalBytes, long completedBytes, const char *message) { - SWBuf output; - output.setFormatted("[ Total Bytes: %ld; Completed Bytes: %ld", totalBytes, completedBytes); - while (output.size() < 75) output += " "; - output += "]"; - cout << "\n" << output.c_str() << "\n "; - int p = (int)(74.0 * (double)completedBytes/totalBytes); - for (int i = 0; i < p; ++i) { cout << "="; } - cout << "\n\n" << message << "\n"; - last = 0; - } -}; - - -void init() { - if (!mgr) { - mgr = new SWMgr(); - - if (!mgr->config) - usage(0, "ERROR: SWORD configuration not found. Please configure SWORD before using this program."); - - SWBuf baseDir = mgr->getHomeDir(); - if (baseDir.length() < 1) baseDir = "."; - baseDir += "/.sword/InstallMgr"; - confPath = baseDir + "/InstallMgr.conf"; - statusReporter = new MyStatusReporter(); - installMgr = new MyInstallMgr(baseDir, statusReporter); - } -} - - -// clean up and exit if status is 0 or negative error code -void finish(int status) { - delete statusReporter; - delete installMgr; - delete mgr; - - installMgr = 0; - mgr = 0; - - if (status < 1) { - cout << "\n"; - exit(status); - } -} - - -void createBasicConfig(bool enableRemote, bool addCrossWire) { - - FileMgr::createParent(confPath.c_str()); - remove(confPath.c_str()); - - InstallSource is("FTP"); - is.caption = "CrossWire"; - is.source = "ftp.crosswire.org"; - is.directory = "/pub/sword/raw"; - - SWConfig config(confPath.c_str()); - config["General"]["PassiveFTP"] = "true"; - if (enableRemote) { - config["Sources"]["FTPSource"] = is.getConfEnt(); - } - config.Save(); -} - - -void initConfig() { - init(); - - bool enable = installMgr->isUserDisclaimerConfirmed(); - - createBasicConfig(enable, true); - - cout << "\n\nInitialized basic config file at [" << confPath << "]\n"; - cout << "with remote source features " << ((enable) ? "ENABLED" : "DISABLED") << "\n"; -} - - -void syncConfig() { - init(); - - if (!installMgr->isUserDisclaimerConfirmed()) { // assert disclaimer is accepted - cout << "\n\nDisclaimer not accepted. Aborting."; - return; - } - - // be sure we have at least some config file already out there - if (!FileMgr::existsFile(confPath.c_str())) { - createBasicConfig(true, false); - finish(1); // cleanup and don't exit - init(); // re-init with InstallMgr which uses our new config - } - - if (!installMgr->refreshRemoteSourceConfiguration()) - cout << "\nSync'd config file with master remote source list.\n"; - else cout << "\nFailed to sync config file with master remote source list.\n"; -} - - -void uninstallModule(const char *modName) { - init(); - SWModule *module; - ModMap::iterator it = mgr->Modules.find(modName); - if (it == mgr->Modules.end()) { - fprintf(stderr, "Couldn't find module [%s] to remove\n", modName); - finish(-2); - } - module = it->second; - installMgr->removeModule(mgr, module->getName()); - cout << "Removed module: [" << modName << "]\n"; -} - - -void listRemoteSources() { - init(); - cout << "Remote Sources:\n\n"; - for (InstallSourceMap::iterator it = installMgr->sources.begin(); it != installMgr->sources.end(); it++) { - cout << "[" << it->second->caption << "]\n"; - cout << "\tType : " << it->second->type << "\n"; - cout << "\tSource : " << it->second->source << "\n"; - cout << "\tDirectory: " << it->second->directory << "\n"; - } -} - - -void refreshRemoteSource(const char *sourceName) { - init(); - InstallSourceMap::iterator source = installMgr->sources.find(sourceName); - if (source == installMgr->sources.end()) { - fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName); - finish(-3); - } - - if (!installMgr->refreshRemoteSource(source->second)) - cout << "\nRemote Source Refreshed\n"; - else cerr << "\nError Refreshing Remote Source\n"; -} - - -void listModules(SWMgr *otherMgr = 0, bool onlyNewAndUpdates = false) { - init(); - SWModule *module; - if (!otherMgr) otherMgr = mgr; - std::map<SWModule *, int> mods = InstallMgr::getModuleStatus(*mgr, *otherMgr); - for (std::map<SWModule *, int>::iterator it = mods.begin(); it != mods.end(); it++) { - module = it->first; - SWBuf version = module->getConfigEntry("Version"); - SWBuf status = " "; - if (it->second & InstallMgr::MODSTAT_NEW) status = "*"; - if (it->second & InstallMgr::MODSTAT_OLDER) status = "-"; - if (it->second & InstallMgr::MODSTAT_UPDATED) status = "+"; - - if (!onlyNewAndUpdates || status == "*" || status == "+") { - cout << status << "[" << module->getName() << "] \t(" << version << ") \t- " << module->getDescription() << "\n"; - } - } -} - - -void remoteListModules(const char *sourceName, bool onlyNewAndUpdated = false) { - init(); - cout << "Available Modules:\n(be sure to refresh remote source (-r) first for most current list)\n\n"; - InstallSourceMap::iterator source = installMgr->sources.find(sourceName); - if (source == installMgr->sources.end()) { - fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName); - finish(-3); - } - listModules(source->second->getMgr(), onlyNewAndUpdated); -} - - -void localDirListModules(const char *dir) { - cout << "Available Modules:\n\n"; - SWMgr mgr(dir); - listModules(&mgr); -} - - -void remoteInstallModule(const char *sourceName, const char *modName) { - init(); - InstallSourceMap::iterator source = installMgr->sources.find(sourceName); - if (source == installMgr->sources.end()) { - fprintf(stderr, "Couldn't find remote source [%s]\n", sourceName); - finish(-3); - } - InstallSource *is = source->second; - SWMgr *rmgr = is->getMgr(); - SWModule *module; - ModMap::iterator it = rmgr->Modules.find(modName); - if (it == rmgr->Modules.end()) { - fprintf(stderr, "Remote source [%s] does not make available module [%s]\n", sourceName, modName); - finish(-4); - } - module = it->second; - - int error = installMgr->installModule(mgr, 0, module->getName(), is); - if (error) { - cout << "\nError installing module: [" << module->getName() << "] (write permissions?)\n"; - } else cout << "\nInstalled module: [" << module->getName() << "]\n"; -} - - -void localDirInstallModule(const char *dir, const char *modName) { - init(); - SWMgr lmgr(dir); - SWModule *module; - ModMap::iterator it = lmgr.Modules.find(modName); - if (it == lmgr.Modules.end()) { - fprintf(stderr, "Module [%s] not available at path [%s]\n", modName, dir); - finish(-4); - } - module = it->second; - int error = installMgr->installModule(mgr, dir, module->getName()); - if (error) { - cout << "\nError installing module: [" << module->getName() << "] (write permissions?)\n"; - } else cout << "\nInstalled module: [" << module->getName() << "]\n"; -} - - -void usage(const char *progName, const char *error) { - - if (error) fprintf(stderr, "\n%s: %s\n", (progName ? progName : "installmgr"), error); - - fprintf(stderr, "\nusage: %s <command> [command ...]\n" - "\n Commands (run in order they are passed):\n\n" - "\t-init\t\t\t\tcreate a basic user config file.\n" - "\t\t\t\t\t\tWARNING: overwrites existing.\n" - "\t-sc\t\t\t\tsync config with known remote repo list\n" - "\t\t\t\t\t\tNOTE: also creates if none exists\n" - "\t-s\t\t\t\tlist remote sources\n" - "\t-r <remoteSrcName>\t\trefresh remote source\n" - "\t-rl <remoteSrcName>\t\tlist available modules from remote source\n" - "\t-rd <remoteSrcName>\t\tlist new/updated modules from remote source\n" - "\t-ri <remoteSrcName> <modName>\tinstall module from remote source\n" - "\t-l\t\t\t\tlist installed modules\n" - "\t-u <modName>\t\t\tuninstall module\n" - "\t-ll <path>\t\t\tlist available modules at local path\n" - "\t-li <path> <modName>\t\tinstall module from local path\n" - "\t-d\t\t\t\tturn debug output on\n" - , (progName ? progName : "installmgr")); - finish(-1); -} - - -int main(int argc, char **argv) { - - if (argc < 2) usage(*argv); - - for (int i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-d")) { - SWLog::getSystemLog()->setLogLevel(SWLog::LOG_DEBUG); - } - else if (!strcmp(argv[i], "-init")) { - initConfig(); - } - else if (!strcmp(argv[i], "-l")) { // list installed modules - cout << "Installed Modules:\n\n"; - listModules(); - } - else if (!strcmp(argv[i], "-ll")) { // list from local directory - if (i+1 < argc) localDirListModules(argv[++i]); - else usage(*argv, "-ll requires <path>"); - } - else if (!strcmp(argv[i], "-li")) { // install from local directory - if (i+2 < argc) { - const char *path = argv[++i]; - const char *modName = argv[++i]; - localDirInstallModule(path, modName); - } - else usage(*argv, "-li requires <path> <modName>"); - } - else if (!strcmp(argv[i], "-u")) { // uninstall module - if (i+1 < argc) uninstallModule(argv[++i]); - else usage(*argv, "-u requires <modName>"); - } - else if (!strcmp(argv[i], "-s")) { // list sources - listRemoteSources(); - } - else if (!strcmp(argv[i], "-sc")) { // sync config with master - syncConfig(); - } - else if (!strcmp(argv[i], "-r")) { // refresh remote source - if (i+1 < argc) refreshRemoteSource(argv[++i]); - else usage(*argv, "-r requires <remoteSrcName>"); - } - else if (!strcmp(argv[i], "-rl")) { // list remote modules - if (i+1 < argc) remoteListModules(argv[++i]); - else usage(*argv, "-rl requires <remoteSrcName>"); - } - else if (!strcmp(argv[i], "-rd")) { // list differences between remote source and installed modules - if (i+1 < argc) remoteListModules(argv[++i], true); - else usage(*argv, "-rd requires <remoteSrcName>"); - } - else if (!strcmp(argv[i], "-ri")) { // install from remote directory - if (i+2 < argc) { - const char *source = argv[++i]; - const char *modName = argv[++i]; - remoteInstallModule(source, modName); - } - else usage(*argv, "-ri requires <remoteSrcName> <modName>"); - } - else usage(*argv, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str()); - } - - finish(0); - - return 0; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/lexdump.c b/.pc/12_fix_compiler_warnings.diff/utilities/lexdump.c deleted file mode 100644 index c55176e..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/lexdump.c +++ /dev/null @@ -1,78 +0,0 @@ -/****************************************************************************** - * - * lexdump.c - This utility outputs a specified ordinal entry from a lex - * - * $Id: lexdump.c 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4996 ) -#endif - -#include <ctype.h> -#include <stdio.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -int main(int argc, char **argv) { - char *tmpbuf; - int idxfd, datfd; - long offset; - unsigned int size; - char datbuf[255]; - - if (argc != 3) { - fprintf(stderr, "usage: %s <datapath/datafilebasename> <index>\n", argv[0]); - exit(1); - } - - tmpbuf = calloc(strlen(argv[1]) + 11,1); - sprintf(tmpbuf, "%s.idx", argv[1]); - idxfd = open(tmpbuf, O_RDONLY|O_BINARY); - sprintf(tmpbuf, "%s.dat", argv[1]); - datfd = open(tmpbuf, O_RDONLY|O_BINARY); - free(tmpbuf); - - offset = atoi(argv[2]) * 6; - lseek(idxfd, offset, SEEK_SET); - read(idxfd, &offset, 4); - read(idxfd, &size, 2); - printf("offset: %ld; size: %d\n", offset, size); - lseek(datfd, offset, SEEK_SET); - read(datfd, datbuf, 40); - datbuf[40] = 0; - printf("%s\n", datbuf); - close(datfd); - close(idxfd); - return 0; - -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/step2vpl.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/step2vpl.cpp deleted file mode 100644 index a9c4a6d..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/step2vpl.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/****************************************************************************** - * - * step2vpl.cpp - Utility to export a STEP module as VPL - * - * $Id: step2vpl.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) - #pragma warning( disable: 4996 ) -#endif - -#include <iostream> -#include <string> -#include <stdio.h> -#include <sys/stat.h> - -#include <fcntl.h> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#include <filemgr.h> -#include <lzsscomprs.h> - -using namespace std; -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -long SECTIONSLEVELSTART = 38; -long SECTIONSLEVELSIZE = 29; - -long VIEWABLEBLOCKSTART = 0; -long VIEWABLEBLOCKSIZE = 0; - -typedef struct { - short versionRecordSize; - short publisherID; - short bookID; - short setID; - char conversionProgramVerMajor; - char conversionProgramVerMinor; - char leastCompatSTEPVerMajor; - char leastCompatSTEPVerMinor; - char encryptionType; - char editionID; - short modifiedBy; -} Version; - -typedef struct { - short sectionsHeaderRecordSize; - long levelEntriesCount; // this is listed as nonGlossBlocksCount in spec! - long glossEntriesCount; - short levelEntriesSize; - long reserved; -} SectionsHeader; - -typedef struct { - short viewableHeaderRecordSize; - long viewableBlocksCount; // this is listed as nonGlossBlocksCount in spec! - long glossBlocksCount; - char compressionType; // 0 - none; 1 - LZSS - char reserved1; - short blockEntriesSize; - short reserved2; -} ViewableHeader; - -typedef struct { - short vSyncHeaderRecordSize; - short startBookNumber; - short endBookNumber; - short bookPointerEntriesSize; - short syncPointEntriesSize; - long reserved1_1; - short reserved1_2; -} VSyncHeader; - -typedef struct { - long offset; - long uncompressedSize; - long size; -} ViewableBlock; - -typedef struct { - long offset; // offset into VSYNC.IDX to first VSyncPoint - short count; // number of VSyncPoints for this book -} VSyncBooksInfo; - -typedef struct { - short chapter; - short verse; - long offset; // offset into SECTIONS.IDX -} VSyncPoint; - -typedef struct { - long parentOffset; // many of these are 0 if glossary - long previousOffset; - long nextOffset; - long viewableOffset; - short startLevel; - char level; - long nameOffset; - long outSync_1; - short outSync_2; -} SectionLevelInfo; - -void readVersion(int fd, Version *versionRecord); -void readHeaderControlWordAreaText(int fd, char **buf); -void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord); -void readVSyncHeader(int fd, VSyncHeader *vSyncHeaderRecord); -void readVSyncBooksInfo(int fd, VSyncHeader *, VSyncBooksInfo **vSyncBooksInfo); -void readViewableBlock(int fd, ViewableBlock *vb); -void readViewableBlockText(int fd, ViewableBlock *vb, char **buf); -void readSectionsHeader(int fd, SectionsHeader *sectionsHeaderRecord); -void readSectionLevelInfo(int fd, SectionLevelInfo *sli); -void readSectionName(int fd, SectionLevelInfo *sli, char **name); -void displayBook(int fdbook, int fdviewable, int fdvsync, int fdsections, VSyncBooksInfo *vSyncBooksInfo); -void extractVerseText(int fdviewable, int fdbook, SectionLevelInfo *sectionLevelInfo, char **verseText); -void cleanBuf(char *buf); - -SWCompress *compress = 0; - -int main(int argc, char **argv) { - - compress = new LZSSCompress(); - char *buf; - Version versionRecord; - VSyncHeader vSyncHeaderRecord; - VSyncBooksInfo *vSyncBooksInfo; - SectionsHeader sectionsHeaderRecord; - ViewableHeader viewableHeaderRecord; - - - if (argc < 2) { - cerr << "usage: "<< *argv << " <database to step module>\n"; - exit (-1); - } - - string bookpath = argv[1]; - string fileName; - - if ((argv[1][strlen(argv[1])-1] != '/') && - (argv[1][strlen(argv[1])-1] != '\\')) - bookpath += "/"; - - fileName = bookpath + "Book.dat"; - int fdbook = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fdbook < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-2); - } - - readVersion(fdbook, &versionRecord); - readHeaderControlWordAreaText(fdbook, &buf); - delete [] buf; - - - fileName = bookpath + "Viewable.idx"; - int fdviewable = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fdviewable < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-3); - } - - readVersion(fdviewable, &versionRecord); - readViewableHeader(fdviewable, &viewableHeaderRecord); - - VIEWABLEBLOCKSTART = lseek(fdviewable, 0, SEEK_CUR); - VIEWABLEBLOCKSIZE = viewableHeaderRecord.blockEntriesSize; - - - fileName = bookpath + "Vsync.idx"; - int fdvsync = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fdvsync < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-4); - } - - fileName = bookpath + "Sections.idx"; - int fdsections = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fdsections < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-4); - } - readVersion(fdsections, &versionRecord); - readSectionsHeader(fdsections, §ionsHeaderRecord); - SECTIONSLEVELSTART = lseek(fdsections, 0, SEEK_CUR); - SECTIONSLEVELSIZE = sectionsHeaderRecord.levelEntriesSize; - - readVersion(fdvsync, &versionRecord); - readVSyncHeader(fdvsync, &vSyncHeaderRecord); - readVSyncBooksInfo(fdvsync, &vSyncHeaderRecord, &vSyncBooksInfo); - int bookCount = vSyncHeaderRecord.endBookNumber - vSyncHeaderRecord.startBookNumber; - for (int i = 0; i <= bookCount; i++) { - displayBook(fdbook, fdviewable, fdvsync, fdsections, &vSyncBooksInfo[i]); - } - - close(fdviewable); - close(fdvsync); - close(fdsections); - close(fdbook); - -} - - - -void readVersion(int fd, Version *versionRecord) { - - read(fd, &(versionRecord->versionRecordSize), 2); - read(fd, &(versionRecord->publisherID), 2); - read(fd, &(versionRecord->bookID), 2); - read(fd, &(versionRecord->setID), 2); - read(fd, &(versionRecord->conversionProgramVerMajor), 1); - read(fd, &(versionRecord->conversionProgramVerMinor), 1); - read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1); - read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1); - read(fd, &(versionRecord->encryptionType), 1); - read(fd, &(versionRecord->editionID), 1); - read(fd, &(versionRecord->modifiedBy), 2); - - int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/; - - if (skip) { - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readSectionsHeader(int fd, SectionsHeader *sectionsHeaderRecord) { - - read(fd, &(sectionsHeaderRecord->sectionsHeaderRecordSize), 2); - read(fd, &(sectionsHeaderRecord->levelEntriesCount), 4); - read(fd, &(sectionsHeaderRecord->glossEntriesCount), 4); - read(fd, &(sectionsHeaderRecord->levelEntriesSize), 2); - read(fd, &(sectionsHeaderRecord->reserved), 4); - - int skip = sectionsHeaderRecord->sectionsHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/; - - if (skip) { - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) { - - read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2); - read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4); - read(fd, &(viewableHeaderRecord->glossBlocksCount), 4); - read(fd, &(viewableHeaderRecord->compressionType), 1); - read(fd, &(viewableHeaderRecord->reserved1), 1); - read(fd, &(viewableHeaderRecord->blockEntriesSize), 2); - read(fd, &(viewableHeaderRecord->reserved2), 2); - - int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/; - - if (skip) { - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readVSyncHeader(int fd, VSyncHeader *vSyncHeaderRecord) { - - read(fd, &(vSyncHeaderRecord->vSyncHeaderRecordSize), 2); - read(fd, &(vSyncHeaderRecord->startBookNumber), 2); - read(fd, &(vSyncHeaderRecord->endBookNumber), 2); - read(fd, &(vSyncHeaderRecord->bookPointerEntriesSize), 2); - read(fd, &(vSyncHeaderRecord->syncPointEntriesSize), 2); - read(fd, &(vSyncHeaderRecord->reserved1_1), 4); - read(fd, &(vSyncHeaderRecord->reserved1_2), 2); - - int skip = vSyncHeaderRecord->vSyncHeaderRecordSize - 16/*sizeof(VSyncHeader)*/; - - if (skip) { - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) { - unsigned long size = vb->size; - - *buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ]; - lseek(fd, vb->offset, SEEK_SET); - read(fd, *buf, vb->size); - - compress->zBuf(&size, *buf); - strcpy(*buf, compress->Buf()); -} - - -void readViewableBlock(int fd, ViewableBlock *vb) { - - read(fd, &(vb->offset), 4); - read(fd, &(vb->uncompressedSize), 4); - read(fd, &(vb->size), 4); -} - - -void readHeaderControlWordAreaText(int fd, char **buf) { - long headerControlWordAreaSize; - read(fd, &headerControlWordAreaSize, 4); - - *buf = new char [headerControlWordAreaSize + 1]; - - read(fd, *buf, headerControlWordAreaSize); - (*buf)[headerControlWordAreaSize] = 0; - -} - -void readVSyncBooksInfo(int fd, VSyncHeader *vSyncHeaderRecord, VSyncBooksInfo **vSyncBooksInfo) { - - int bookCount = vSyncHeaderRecord->endBookNumber - vSyncHeaderRecord->startBookNumber; - *vSyncBooksInfo = new VSyncBooksInfo[bookCount]; - for (int i = 0; i <= bookCount; i++) { - read(fd, &(*vSyncBooksInfo)[i].offset, 4); - read(fd, &(*vSyncBooksInfo)[i].count, 2); - } -} - -void displayBook(int fdbook, int fdviewable, int fdvsync, int fdsections, VSyncBooksInfo *vSyncBooksInfo) { - VSyncPoint vSyncPoint; - - lseek(fdvsync, vSyncBooksInfo->offset, SEEK_SET); - - for (int i = 0; i < vSyncBooksInfo->count; i++) { - - SectionLevelInfo sectionLevelInfo; - char *sectionName; - char *verseText; - - read(fdvsync, &(vSyncPoint.chapter), 2); - read(fdvsync, &(vSyncPoint.verse), 2); - read(fdvsync, &(vSyncPoint.offset), 4); - vSyncPoint.offset = SECTIONSLEVELSTART + (vSyncPoint.offset * SECTIONSLEVELSIZE); - lseek(fdsections, vSyncPoint.offset, SEEK_SET); - readSectionLevelInfo(fdsections, §ionLevelInfo); - readSectionName(fdsections, §ionLevelInfo, §ionName); - cout << sectionName << " "; - delete [] sectionName; - extractVerseText(fdviewable, fdbook, §ionLevelInfo, &verseText); - cleanBuf(verseText); - cout << verseText << "\n"; - delete [] verseText; - } -} - - -void extractVerseText(int fdviewable, int fdbook, SectionLevelInfo *sectionLevelInfo, char **verseText) { - char numberBuf[16]; - string startToken; - ViewableBlock vb; - int len = 0; - static long lastEntryOffset = -1; - static class FreeCachedEntryText { - public: - char *entryText; - FreeCachedEntryText() { entryText = 0; } - ~FreeCachedEntryText() { if (entryText) delete [] entryText; } - } _freeCachedEntryText; - - if (sectionLevelInfo->viewableOffset != lastEntryOffset) { - if (_freeCachedEntryText.entryText) - delete [] _freeCachedEntryText.entryText; - - lseek(fdviewable, sectionLevelInfo->viewableOffset, SEEK_SET); - readViewableBlock(fdviewable, &vb); - readViewableBlockText(fdbook, &vb, &(_freeCachedEntryText.entryText)); - lastEntryOffset = sectionLevelInfo->viewableOffset; - } - sprintf(numberBuf, "%d", sectionLevelInfo->startLevel); - startToken = "\\stepstartlevel"; - startToken += numberBuf; - char *start = strstr(_freeCachedEntryText.entryText, startToken.c_str()); - if (start) { - start += strlen(startToken.c_str()); - char *end = strstr(start, "\\stepstartlevel"); - if (end) - len = end - start; - else len = strlen(start); - } - *verseText = new char [ len + 1 ]; - strncpy(*verseText, start, len); - (*verseText)[len] = 0; -} - - -void readSectionName(int fd, SectionLevelInfo *sli, char **name) { - short size; - lseek(fd, sli->nameOffset, SEEK_SET); - read(fd, &size, 2); - *name = new char [ size + 1 ]; - read(fd, *name, size); - (*name)[size] = 0; -} - -void readSectionLevelInfo(int fd, SectionLevelInfo *sli) { - - read(fd, &(sli->parentOffset), 4); - read(fd, &(sli->previousOffset), 4); - read(fd, &(sli->nextOffset), 4); - read(fd, &(sli->viewableOffset), 4); - sli->viewableOffset = VIEWABLEBLOCKSTART + (VIEWABLEBLOCKSIZE * sli->viewableOffset); - read(fd, &(sli->startLevel), 2); - read(fd, &(sli->level), 1); - read(fd, &(sli->nameOffset), 4); - read(fd, &(sli->outSync_1), 4); - read(fd, &(sli->outSync_2), 2); -} - -void cleanBuf(char *buf) { - char *from = buf; - char *to = buf; - - while (*from) { - if ((*from != 10) && (*from != 13)) { - *to++ = *from++; - } - else { - from++; - } - } - *to = 0; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/stepdump.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/stepdump.cpp deleted file mode 100644 index 3b9892e..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/stepdump.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/****************************************************************************** - * - * stepdump.cpp - Utility to dump a STEP module - * - * $Id: stepdump.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) - #pragma warning( disable: 4996 ) -#endif - -#include <sys/stat.h> -#include <fcntl.h> -#include <stdio.h> - -#include <iostream> -#include <string> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#include <filemgr.h> -#include <lzsscomprs.h> - -using namespace std; -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -typedef struct { - short versionRecordSize; - short publisherID; - short bookID; - short setID; - char conversionProgramVerMajor; - char conversionProgramVerMinor; - char leastCompatSTEPVerMajor; - char leastCompatSTEPVerMinor; - char encryptionType; - char editionID; - short modifiedBy; -} Version; - -typedef struct { - short viewableHeaderRecordSize; - long viewableBlocksCount; // this is listed as nonGlossBlocksCount in spec! - long glossBlocksCount; - char compressionType; // 0 - none; 1 - LZSS - char reserved1; - short blockEntriesSize; - short reserved2; -} ViewableHeader; - -typedef struct { - long offset; - long uncompressedSize; - long size; -} ViewableBlock; - -void readVersion(int fd, Version *versionRecord); -void readHeaderControlWordAreaText(int fd, char **buf); -void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord); -void readViewableBlock(int fd, ViewableBlock *vb); -void readViewableBlockText(int fd, ViewableBlock *vb, char **buf); - -SWCompress *compress = 0; - -int main(int argc, char **argv) { - - compress = new LZSSCompress(); - char *buf; - Version versionRecord; - ViewableHeader viewableHeaderRecord; - - if (argc < 2) { - cerr << "usage: "<< *argv << " <database to step module>\n"; - exit (-1); - } - - string bookpath = argv[1]; - string fileName; - - if ((argv[1][strlen(argv[1])-1] != '/') && - (argv[1][strlen(argv[1])-1] != '\\')) - bookpath += "/"; - - fileName = bookpath + "Book.dat"; - int fd = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fd < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-2); - } - - readVersion(fd, &versionRecord); - readHeaderControlWordAreaText(fd, &buf); - delete [] buf; - - - fileName = bookpath + "Viewable.idx"; - int fdv = FileMgr::openFileReadOnly(fileName.c_str()); - - if (fdv < 1) { - cerr << "error, couldn't open file: " << fileName << "\n"; - exit (-3); - } - - readVersion(fdv, &versionRecord); - readViewableHeader(fdv, &viewableHeaderRecord); - - ViewableBlock vb; - - cout << "\n\nReading special preface viewable BLOCK 0"; - - readViewableBlock(fdv, &vb); - readViewableBlockText(fd, &vb, &buf); - delete [] buf; - - int nonGlossBlocksCount = viewableHeaderRecord.viewableBlocksCount - - viewableHeaderRecord.glossBlocksCount; - - cout << "\n\nReading " << nonGlossBlocksCount << " non-glossary viewable blocks"; - // 1 because we already read the first block above - for (int i = 1; i < nonGlossBlocksCount; i++) { - cout << "\nNon-Glossary viewable block: " << i; - readViewableBlock(fdv, &vb); - readViewableBlockText(fd, &vb, &buf); - delete [] buf; - } - - cout << "\n\nReading " << viewableHeaderRecord.glossBlocksCount << " glossary viewable blocks"; - for (int i = 0; i < viewableHeaderRecord.glossBlocksCount; i++) { - cout << "\nGlossary viewable block: " << i; - readViewableBlock(fdv, &vb); - readViewableBlockText(fd, &vb, &buf); - delete [] buf; - } - - close(fdv); - close(fd); - -} - - - -void readVersion(int fd, Version *versionRecord) { - - cout << "\n\nReading Version Record (" << 16/*sizeof(struct Version)*/ << " bytes)\n\n"; -// DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS -// read(fd, &versionRecord, sizeof(struct Version)); - - cout << "Version Record Information\n"; - read(fd, &(versionRecord->versionRecordSize), 2); - cout << "\tversionRecordSize: " << versionRecord->versionRecordSize << "\n"; - read(fd, &(versionRecord->publisherID), 2); - cout << "\tpublisherID: " << versionRecord->publisherID << "\n"; - read(fd, &(versionRecord->bookID), 2); - cout << "\tbookID: " << versionRecord->bookID << "\n"; - read(fd, &(versionRecord->setID), 2); - cout << "\tsetID: " << versionRecord->setID << "\n"; - read(fd, &(versionRecord->conversionProgramVerMajor), 1); - cout << "\tconversionProgramVerMajor: " << (int)versionRecord->conversionProgramVerMajor << "\n"; - read(fd, &(versionRecord->conversionProgramVerMinor), 1); - cout << "\tconversionProgramVerMinor: " << (int)versionRecord->conversionProgramVerMinor << "\n"; - read(fd, &(versionRecord->leastCompatSTEPVerMajor), 1); - cout << "\tleastCompatSTEPVerMajor: " << (int)versionRecord->leastCompatSTEPVerMajor << "\n"; - read(fd, &(versionRecord->leastCompatSTEPVerMinor), 1); - cout << "\tleastCompatSTEPVerMinor: " << (int)versionRecord->leastCompatSTEPVerMinor << "\n"; - read(fd, &(versionRecord->encryptionType), 1); - cout << "\tencryptionType: " << (int)versionRecord->encryptionType << "\n"; - read(fd, &(versionRecord->editionID), 1); - cout << "\teditionID: " << (int)versionRecord->editionID << "\n"; - read(fd, &(versionRecord->modifiedBy), 2); - cout << "\tmodifiedBy: " << versionRecord->modifiedBy << "\n"; - - int skip = versionRecord->versionRecordSize - 16/*sizeof(struct Version*/; - - if (skip) { - cout << "\nSkipping " << skip << " unknown bytes.\n"; - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readViewableHeader(int fd, ViewableHeader *viewableHeaderRecord) { - - cout << "\n\nReading Viewable Header Record (" << 16/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n"; - -// DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS -// read(fd, &viewableHeaderRecord, sizeof(struct ViewableHeader)); - - cout << "Viewable Header Record Information\n"; - read(fd, &(viewableHeaderRecord->viewableHeaderRecordSize), 2); - cout << "\tviewableHeaderRecordSize: " << viewableHeaderRecord->viewableHeaderRecordSize << "\n"; - read(fd, &(viewableHeaderRecord->viewableBlocksCount), 4); - cout << "\tviewableBlocksCount: " << viewableHeaderRecord->viewableBlocksCount << "\n"; - read(fd, &(viewableHeaderRecord->glossBlocksCount), 4); - cout << "\tglossBlocksCount: " << viewableHeaderRecord->glossBlocksCount << "\n"; - read(fd, &(viewableHeaderRecord->compressionType), 1); - cout << "\tcompressionType: " << (int)viewableHeaderRecord->compressionType << "(0 - none; 1 - LZSS)\n"; - read(fd, &(viewableHeaderRecord->reserved1), 1); - cout << "\treserved1: " << (int)viewableHeaderRecord->reserved1 << "\n"; - read(fd, &(viewableHeaderRecord->blockEntriesSize), 2); - cout << "\tblockEntriesSize: " << viewableHeaderRecord->blockEntriesSize << "\n"; - read(fd, &(viewableHeaderRecord->reserved2), 2); - cout << "\treserved2: " << viewableHeaderRecord->reserved2 << "\n"; - - int skip = viewableHeaderRecord->viewableHeaderRecordSize - 16/*sizeof(struct ViewableHeader)*/; - - if (skip) { - cout << "\nSkipping " << skip << " unknown bytes.\n"; - char *skipbuf = new char[skip]; - read(fd, skipbuf, skip); - delete [] skipbuf; - } -} - - -void readViewableBlockText(int fd, ViewableBlock *vb, char **buf) { - unsigned long size = vb->size; - - *buf = new char [ ((vb->size > vb->uncompressedSize) ? vb->size : vb->uncompressedSize) + 1 ]; - lseek(fd, vb->offset, SEEK_SET); - read(fd, *buf, vb->size); - - compress->zBuf(&size, *buf); - strcpy(*buf, compress->Buf()); - cout << "Viewable Block Text:\n"; - cout << *buf << "\n\n"; -} - - -void readViewableBlock(int fd, ViewableBlock *vb) { - - cout << "\n\nReading Viewable Block (" << 12/*sizeof(struct ViewableHeader)*/ << " bytes)\n\n"; - -// DO NOT USE BECAUSE OF RECORD BYTE ALIGNMENT PROBLEMS -// read(fd, &vb, sizeof(struct ViewableBlock)); - - cout << "Viewable Block Information\n"; - read(fd, &(vb->offset), 4); - cout << "\toffset: " << vb->offset << "\n"; - read(fd, &(vb->uncompressedSize), 4); - cout << "\tuncompressedSize: " << vb->uncompressedSize << "\n"; - read(fd, &(vb->size), 4); - cout << "\tsize: " << vb->size << "\n"; -} - - -void readHeaderControlWordAreaText(int fd, char **buf) { - long headerControlWordAreaSize; - read(fd, &headerControlWordAreaSize, 4); - cout << "Reading Header Control Word Area (" << headerControlWordAreaSize << " bytes)\n\n"; - - *buf = new char [headerControlWordAreaSize + 1]; - - read(fd, *buf, headerControlWordAreaSize); - (*buf)[headerControlWordAreaSize] = 0; - - cout << "headerControlWordArea:\n" << *buf << "\n"; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/treeidxutil.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/treeidxutil.cpp deleted file mode 100644 index abb9151..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/treeidxutil.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/****************************************************************************** - * - * treeidxutil.cpp - - * - * $Id: treeidxutil.cpp 2833 2013-06-29 06:40:28Z chrislit $ - * - * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) -#endif - -#include <entriesblk.h> -#include <iostream> -#include <string> -#include <stdio.h> -#include <treekeyidx.h> - -#ifndef NO_SWORD_NAMESPACE -using namespace sword; -#endif - -void printTree(TreeKeyIdx treeKey, TreeKeyIdx *target = 0, int level = 1) { - if (!target) - target = &treeKey; - - unsigned long currentOffset = target->getOffset(); - std::cout << ((currentOffset == treeKey.getOffset()) ? "==>" : ""); - for (int i = 0; i < level; i++) std::cout << "\t"; - std::cout << treeKey.getLocalName() << std::endl; - if (treeKey.firstChild()) { - printTree(treeKey, target, level+1); - treeKey.parent(); - } - if (treeKey.nextSibling()) - printTree(treeKey, target, level); - -} - - -void printLocalName(TreeKeyIdx *treeKey) { - std::cout << "locaName: " << treeKey->getLocalName() << std::endl; -} - - -void setLocalName(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter New Node Name: "; - fgets(buf, 1000, stdin); - treeKey->setLocalName(buf); - treeKey->save(); -} - - -void assurePath(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter path: "; - fgets(buf, 1000, stdin); - treeKey->assureKeyPath(buf); -} - - -void appendSibbling(TreeKeyIdx *treeKey) { - if (treeKey->getOffset()) { - char buf[1023]; - std::cout << "Enter New Sibbling Name: "; - fgets(buf, 1000, stdin); - treeKey->append(); - treeKey->setLocalName(buf); - treeKey->save(); - } - else std::cout << "Can't add sibling to root node\n"; -} - - -void appendChild(TreeKeyIdx *treeKey) { - char buf[1023]; - std::cout << "Enter New Child Name: "; - fgets(buf, 1000, stdin); - treeKey->appendChild(); - treeKey->setLocalName(buf); - treeKey->save(); -} - - -void removeEntry(EntriesBlock *eb, int index) { - if (index < eb->getCount()) { - std::cout << "Removing entry [" << index << "]\n"; - eb->removeEntry(index); - } - else std::cout << "Invalid entry number\n\n"; -} - - -int main(int argc, char **argv) { - - if (argc != 2) { - fprintf(stderr, "usage: %s <tree/key/data/path>\n", *argv); - exit(-1); - } - - TreeKeyIdx *treeKey = new TreeKeyIdx(argv[1]); - - if (treeKey->popError()) { - treeKey->create(argv[1]); - delete treeKey; - treeKey = new TreeKeyIdx(argv[1]); - } - TreeKeyIdx root = *treeKey; - - std::string input; - char line[1024]; - - do { - std::cout << "[" << treeKey->getText() << "] > "; - fgets(line, 1000, stdin); - input = line; - if (input.length() > 0) { - switch (input[0]) { - case 'n': printLocalName(treeKey); break; - case 's': setLocalName(treeKey); break; - case 'p': root.root(); printTree(root, treeKey); break; - case 'a': appendSibbling(treeKey); break; - case 'c': appendChild(treeKey); break; - case 'j': treeKey->nextSibling(); break; - case 'g': assurePath(treeKey); break; - case 'k': treeKey->previousSibling(); break; - case 'h': treeKey->parent(); break; - case 'l': treeKey->firstChild(); break; - case 'r': treeKey->root(); break; - case 'q': break; - case '?': - default: - std::cout << "\n p - print tree\n"; - std::cout << " n - get local name\n"; - std::cout << " s - set local name\n"; - std::cout << " j - next sibbling\n"; - std::cout << " k - previous sibbling\n"; - std::cout << " h - parent\n"; - std::cout << " l - first child\n"; - std::cout << " r - root\n"; - std::cout << " a - append sibbling\n"; - std::cout << " c - append child\n"; - std::cout << " u - get user data\n"; - std::cout << " d - set user data\n"; - std::cout << " g - goto path; create if it doesn't exist\n"; - std::cout << " q - quit\n\n"; - break; - } - } - } - while (input.compare("q")); - - delete treeKey; - - return 0; -} diff --git a/.pc/12_fix_compiler_warnings.diff/utilities/vpl2mod.cpp b/.pc/12_fix_compiler_warnings.diff/utilities/vpl2mod.cpp deleted file mode 100644 index c696541..0000000 --- a/.pc/12_fix_compiler_warnings.diff/utilities/vpl2mod.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/****************************************************************************** - * - * vpl2mod.cpp - Utility to import VPL formatted modules - * - * $Id: vpl2mod.cpp 2921 2013-07-28 17:21:44Z scribe $ - * - * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org) - * CrossWire Bible Society - * P. O. Box 2528 - * Tempe, AZ 85280-2528 - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation version 2. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - */ - -#ifdef _MSC_VER - #pragma warning( disable: 4251 ) - #pragma warning( disable: 4996 ) -#endif - -#include <ctype.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <stdlib.h> -#include <sys/stat.h> - -#ifndef __GNUC__ -#include <io.h> -#else -#include <unistd.h> -#endif - -#include <filemgr.h> -#include <swmgr.h> -#include <rawtext.h> -#include <swbuf.h> -#include <versekey.h> - -#ifndef NO_SWORD_NAMESPACE -using sword::FileMgr; -using sword::SWMgr; -using sword::RawText; -using sword::VerseKey; -using sword::SWBuf; -using sword::SW_POSITION; -#endif - - -char readline(int fd, char **buf) { - char ch; - if (*buf) - delete [] *buf; - *buf = 0; - int len; - - - long index = lseek(fd, 0, SEEK_CUR); - // clean up any preceding white space - while ((len = read(fd, &ch, 1)) == 1) { - if ((ch != 13) && (ch != ' ') && (ch != '\t')) - break; - else index++; - } - - - while (ch != 10) { - if ((len = read(fd, &ch, 1)) != 1) - break; - } - - int size = (lseek(fd, 0, SEEK_CUR) - index) - 1; - - *buf = new char [ size + 1 ]; - - if (size > 0) { - lseek(fd, index, SEEK_SET); - read(fd, *buf, size); - read(fd, &ch, 1); //pop terminating char - (*buf)[size] = 0; - - // clean up any trailing junk on buf - for (char *it = *buf+(strlen(*buf)-1); it > *buf; it--) { - if ((*it != 10) && (*it != 13) && (*it != ' ') && (*it != '\t')) - break; - else *it = 0; - } - } - else **buf = 0; - return !len; -} - - -char *parseVReg(char *buf) { - char stage = 0; - - while (*buf) { - switch (stage) { - case 0: - if (isalpha(*buf)) - stage++; - break; - case 1: - if (isdigit(*buf)) - stage++; - break; - case 2: - if (*buf == ':') - stage++; - break; - case 3: - if (isdigit(*buf)) - stage++; - break; - case 4: - if (*buf == ' ') { - *buf = 0; - return ++buf; - } - break; - } - buf++; - } - return (stage == 4) ? buf : 0; // if we got to stage 4 return after key buf, else return 0; -} - - -bool isKJVRef(const char *buf) { - VerseKey vk, test; - vk.setAutoNormalize(false); - vk.setIntros(true); // turn on mod/testmnt/book/chap headings - vk.setPersist(true); - // lets do some tests on the verse -------------- - vk = buf; - test = buf; - - if (vk.getTestament() && vk.getBook() && vk.getChapter() && vk.getVerse()) { // if we're not a heading -// std::cerr << (const char*)vk << " == " << (const char*)test << std::endl; - return (vk == test); - } - else return true; // no check if we're a heading... Probably bad. -} - - -void fixText(char *text) { - char *to = text; - while(*text) { - *to++ = *text++; - *to++ = *text++; - if (!*text) - break; - if (*text != ' ') - std::cerr << "problem\n"; - else text++; - } - *to = 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); - } - SWBuf 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; - } - 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; -} |