diff options
Diffstat (limited to 'src/modules/comments/hrefcom')
-rw-r--r-- | src/modules/comments/hrefcom/Makefile | 5 | ||||
-rw-r--r-- | src/modules/comments/hrefcom/Makefile.am | 2 | ||||
-rw-r--r-- | src/modules/comments/hrefcom/hrefcom.cpp | 95 |
3 files changed, 102 insertions, 0 deletions
diff --git a/src/modules/comments/hrefcom/Makefile b/src/modules/comments/hrefcom/Makefile new file mode 100644 index 0000000..35d6648 --- /dev/null +++ b/src/modules/comments/hrefcom/Makefile @@ -0,0 +1,5 @@ + +root := ../../../.. + +all: + make -C ${root} diff --git a/src/modules/comments/hrefcom/Makefile.am b/src/modules/comments/hrefcom/Makefile.am new file mode 100644 index 0000000..dba4294 --- /dev/null +++ b/src/modules/comments/hrefcom/Makefile.am @@ -0,0 +1,2 @@ +hrefcomdir = $(top_srcdir)/src/modules/comments/hrefcom +libsword_la_SOURCES += $(hrefcomdir)/hrefcom.cpp diff --git a/src/modules/comments/hrefcom/hrefcom.cpp b/src/modules/comments/hrefcom/hrefcom.cpp new file mode 100644 index 0000000..3716dbf --- /dev/null +++ b/src/modules/comments/hrefcom/hrefcom.cpp @@ -0,0 +1,95 @@ +/****************************************************************************** + * + * hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML + * HREFs pointing to actual text desired. Uses standard + * files: ot and nt using indexs ??.bks ??.cps ??.vss + * + * $Id: hrefcom.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 <ctype.h> +#include <stdio.h> +#include <fcntl.h> + +#include <utilstr.h> +#include <rawverse.h> +#include <hrefcom.h> +#include <swbuf.h> +#include <versekey.h> + +SWORD_NAMESPACE_START + + /****************************************************************************** + * HREFCom Constructor - Initializes data for instance of HREFCom + * + * ENT: iname - Internal name for module + * iprefix - string to prepend to each HREF (e.g. "file://mods/com/jfb/") + * idesc - Name to display to user for module + * idisp - Display object to use for displaying + */ + +HREFCom::HREFCom(const char *ipath, const char *iprefix, const char *iname, const char *idesc, SWDisplay *idisp) : RawVerse(ipath), SWCom(iname, idesc, idisp) +{ + prefix = 0; + stdstr(&prefix, iprefix); +} + + +/****************************************************************************** + * HREFCom Destructor - Cleans up instance of HREFCom + */ + +HREFCom::~HREFCom() +{ + if (prefix) + delete [] prefix; +} + + +/****************************************************************************** + * HREFCom::operator char * - Returns the correct verse when char * cast + * is requested + * + * RET: string buffer with verse + */ + +SWBuf &HREFCom::getRawEntryBuf() const { + long start; + unsigned short size; + VerseKey *key = 0; + + key = &getVerseKey(); + + findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size); + entrySize = size; // support getEntrySize call + + SWBuf tmpbuf; + + readText(key->getTestament(), start, size, tmpbuf); + entryBuf = prefix; + entryBuf += tmpbuf.c_str(); + prepText(entryBuf); + + if (key != this->key) + delete key; + + return entryBuf; +} + +SWORD_NAMESPACE_END |