~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to src/modules/comments/hrefcom/hrefcom.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *  hrefcom.cpp - code for class 'HREFCom'- a module that produces HTML HREFs
 
3
 *                      pointing to actual text desired.  Uses standard
 
4
 *                      files:  ot and nt using indexs ??.bks ??.cps ??.vss
 
5
 */
 
6
 
 
7
 
 
8
#include <ctype.h>
 
9
#include <stdio.h>
 
10
#include <fcntl.h>
 
11
 
 
12
#ifndef __GNUC__
 
13
#include <io.h>
 
14
#else
 
15
#include <unistd.h>
 
16
#endif
 
17
 
 
18
#include <utilfuns.h>
 
19
#include <rawverse.h>
 
20
#include <hrefcom.h>
 
21
 
 
22
SWORD_NAMESPACE_START
 
23
 
 
24
 /******************************************************************************
 
25
 * HREFCom Constructor - Initializes data for instance of HREFCom
 
26
 *
 
27
 * ENT: iname - Internal name for module
 
28
 *      iprefix - string to prepend to each HREF (e.g. "file://mods/com/jfb/")
 
29
 *      idesc - Name to display to user for module
 
30
 *      idisp    - Display object to use for displaying
 
31
 */
 
32
 
 
33
HREFCom::HREFCom(const char *ipath, const char *iprefix, const char *iname, const char *idesc, SWDisplay *idisp) : RawVerse(ipath), SWCom(iname, idesc, idisp)
 
34
{
 
35
        prefix   = 0;
 
36
        stdstr(&prefix, iprefix);
 
37
}
 
38
 
 
39
 
 
40
/******************************************************************************
 
41
 * HREFCom Destructor - Cleans up instance of HREFCom
 
42
 */
 
43
 
 
44
HREFCom::~HREFCom()
 
45
{
 
46
        if (prefix)
 
47
                delete [] prefix;
 
48
}
 
49
 
 
50
 
 
51
/******************************************************************************
 
52
 * HREFCom::operator char *     - Returns the correct verse when char * cast
 
53
 *                                      is requested
 
54
 *
 
55
 * RET: string buffer with verse
 
56
 */
 
57
 
 
58
SWBuf &HREFCom::getRawEntryBuf() {
 
59
        long  start;
 
60
        unsigned short size;
 
61
        VerseKey *key = 0;
 
62
 
 
63
#ifndef _WIN32_WCE
 
64
        try {
 
65
#endif
 
66
                key = SWDYNAMIC_CAST(VerseKey, this->key);
 
67
#ifndef _WIN32_WCE
 
68
        }
 
69
        catch ( ... ) {}
 
70
#endif
 
71
        if (!key)
 
72
                key = new VerseKey(this->key);
 
73
 
 
74
        findOffset(key->Testament(), key->Index(), &start, &size);
 
75
        entrySize = size;        // support getEntrySize call
 
76
 
 
77
        SWBuf tmpbuf;
 
78
 
 
79
        readText(key->Testament(), start, size, tmpbuf);
 
80
        entryBuf = prefix;
 
81
        entryBuf += tmpbuf.c_str();
 
82
        prepText(entryBuf);
 
83
 
 
84
        if (key != this->key)
 
85
                delete key;
 
86
 
 
87
        return entryBuf;
 
88
}
 
89
 
 
90
SWORD_NAMESPACE_END