aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/rawfiles_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api-documentation/html/rawfiles_8cpp-source.html')
-rw-r--r--doc/api-documentation/html/rawfiles_8cpp-source.html305
1 files changed, 305 insertions, 0 deletions
diff --git a/doc/api-documentation/html/rawfiles_8cpp-source.html b/doc/api-documentation/html/rawfiles_8cpp-source.html
new file mode 100644
index 0000000..7384a23
--- /dev/null
+++ b/doc/api-documentation/html/rawfiles_8cpp-source.html
@@ -0,0 +1,305 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+<title>rawfiles.cpp Source File</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.2.15 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
+<hr><h1>rawfiles.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
+00002 <font class="comment"> * rawfiles.cpp - code for class 'RawFiles'- a module that produces HTML HREFs</font>
+00003 <font class="comment"> * pointing to actual text desired. Uses standard</font>
+00004 <font class="comment"> * files: ot and nt using indexs ??.bks ??.cps ??.vss</font>
+00005 <font class="comment"> */</font>
+00006
+00007
+00008 <font class="preprocessor">#include &lt;ctype.h&gt;</font>
+00009 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
+00010 <font class="preprocessor">#include &lt;fcntl.h&gt;</font>
+00011
+00012 <font class="preprocessor">#ifndef __GNUC__</font>
+00013 <font class="preprocessor"></font><font class="preprocessor">#include &lt;io.h&gt;</font>
+00014 <font class="preprocessor">#else</font>
+00015 <font class="preprocessor"></font><font class="preprocessor">#include &lt;unistd.h&gt;</font>
+00016 <font class="preprocessor">#endif</font>
+00017 <font class="preprocessor"></font>
+00018 <font class="preprocessor">#include &lt;string.h&gt;</font>
+00019 <font class="preprocessor">#include &lt;utilfuns.h&gt;</font>
+00020 <font class="preprocessor">#include &lt;rawverse.h&gt;</font>
+00021 <font class="preprocessor">#include &lt;rawfiles.h&gt;</font>
+00022 <font class="preprocessor">#include &lt;filemgr.h&gt;</font>
+00023
+00024 <font class="preprocessor">#ifndef O_BINARY // O_BINARY is needed in Borland C++ 4.53</font>
+00025 <font class="preprocessor"></font><font class="preprocessor">#define O_BINARY 0 // If it hasn't been defined than we probably</font>
+00026 <font class="preprocessor"></font><font class="preprocessor">#endif // don't need it.</font>
+00027 <font class="preprocessor"></font>
+00028
+00029 <font class="comment">/******************************************************************************</font>
+00030 <font class="comment"> * RawFiles Constructor - Initializes data for instance of RawFiles</font>
+00031 <font class="comment"> *</font>
+00032 <font class="comment"> * ENT: iname - Internal name for module</font>
+00033 <font class="comment"> * idesc - Name to display to user for module</font>
+00034 <font class="comment"> * idisp - Display object to use for displaying</font>
+00035 <font class="comment"> */</font>
+00036
+00037 RawFiles::RawFiles(<font class="keyword">const</font> <font class="keywordtype">char</font> *ipath, <font class="keyword">const</font> <font class="keywordtype">char</font> *iname, <font class="keyword">const</font> <font class="keywordtype">char</font> *idesc, <a class="code" href="class_s_w_display.html">SWDisplay</a> *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, <font class="keyword">const</font> <font class="keywordtype">char</font>* ilang) : RawVerse(ipath, O_RDWR), <a class="code" href="class_s_w_com.html">SWCom</a>(iname, idesc, idisp, enc, dir, mark, ilang)
+00038 {
+00039 }
+00040
+00041
+00042 <font class="comment">/******************************************************************************</font>
+00043 <font class="comment"> * RawFiles Destructor - Cleans up instance of RawFiles</font>
+00044 <font class="comment"> */</font>
+00045
+00046 RawFiles::~RawFiles()
+00047 {
+00048 }
+00049
+00050
+00051 <font class="comment">/******************************************************************************</font>
+00052 <font class="comment"> * RawFiles::operator char * - Returns the correct verse when char * cast</font>
+00053 <font class="comment"> * is requested</font>
+00054 <font class="comment"> *</font>
+00055 <font class="comment"> * RET: string buffer with verse</font>
+00056 <font class="comment"> */</font>
+00057
+00058 <font class="keywordtype">char</font> *RawFiles::getRawEntry() {
+00059 FileDesc *datafile;
+00060 <font class="keywordtype">long</font> start = 0;
+00061 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size = 0;
+00062 <font class="keywordtype">char</font> *tmpbuf;
+00063 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0;
+00064
+00065 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00066 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
+00067 <font class="preprocessor">#endif</font>
+00068 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this-&gt;key);
+00069 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00070 <font class="preprocessor"></font> }
+00071 <font class="keywordflow">catch</font> ( ... ) {}
+00072 <font class="preprocessor">#endif</font>
+00073 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
+00074 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this-&gt;key);
+00075
+00076 findoffset(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), &amp;start, &amp;size);
+00077
+00078 <font class="keywordflow">if</font> (entrybuf)
+00079 <font class="keyword">delete</font> [] entrybuf;
+00080
+00081 <font class="keywordflow">if</font> (size) {
+00082 tmpbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ (size + 2) + strlen(path) + 5 ];
+00083 sprintf(tmpbuf,<font class="stringliteral">"%s/"</font>,path);
+00084 gettext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), start, (size + 2), tmpbuf+strlen(tmpbuf));
+00085 datafile = FileMgr::systemFileMgr.open(tmpbuf, O_RDONLY|O_BINARY);
+00086 <font class="keyword">delete</font> [] tmpbuf;
+00087 <font class="keywordflow">if</font> (datafile-&gt;getFd() &gt; 0) {
+00088 size = lseek(datafile-&gt;getFd(), 0, SEEK_END);
+00089 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ size * FILTERPAD ];
+00090 memset(entrybuf, 0, size * FILTERPAD);
+00091 lseek(datafile-&gt;getFd(), 0, SEEK_SET);
+00092 read(datafile-&gt;getFd(), entrybuf, size);
+00093 <font class="comment">// preptext(entrybuf);</font>
+00094 }
+00095 <font class="keywordflow">else</font> {
+00096 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [2];
+00097 entrybuf[0] = 0;
+00098 entrybuf[1] = 0;
+00099 }
+00100 FileMgr::systemFileMgr.close(datafile);
+00101 }
+00102 <font class="keywordflow">else</font> {
+00103 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [2];
+00104 entrybuf[0] = 0;
+00105 entrybuf[1] = 0;
+00106 }
+00107
+00108 <font class="keywordflow">if</font> (key != this-&gt;key)
+00109 <font class="keyword">delete</font> key;
+00110
+00111 <font class="keywordflow">return</font> entrybuf;
+00112 }
+00113
+00114
+00115 <font class="comment">/******************************************************************************</font>
+00116 <font class="comment"> * RawFiles::operator &lt;&lt; (char *)- Update the modules current key entry with</font>
+00117 <font class="comment"> * provided text</font>
+00118 <font class="comment"> *</font>
+00119 <font class="comment"> * RET: *this</font>
+00120 <font class="comment"> */</font>
+00121
+00122 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawFiles::operator &lt;&lt;(<font class="keyword">const</font> <font class="keywordtype">char</font> *inbuf) {
+00123 FileDesc *datafile;
+00124 <font class="keywordtype">long</font> start;
+00125 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size;
+00126 <font class="keywordtype">char</font> *tmpbuf;
+00127 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0;
+00128
+00129 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00130 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
+00131 <font class="preprocessor">#endif</font>
+00132 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this-&gt;key);
+00133 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00134 <font class="preprocessor"></font> }
+00135 <font class="keywordflow">catch</font> ( ... ) {}
+00136 <font class="preprocessor">#endif</font>
+00137 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
+00138 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this-&gt;key);
+00139
+00140 findoffset(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), &amp;start, &amp;size);
+00141
+00142 <font class="keywordflow">if</font> (size) {
+00143 tmpbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ (size + 2) + strlen(path) + 1 ];
+00144 sprintf(tmpbuf, <font class="stringliteral">"%s/"</font>, path);
+00145 gettext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), start, (size + 2), tmpbuf+strlen(tmpbuf));
+00146 }
+00147 <font class="keywordflow">else</font> {
+00148 tmpbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ 16 + strlen(path) + 1 ];
+00149 sprintf(tmpbuf, <font class="stringliteral">"%s/%s"</font>, path, getnextfilename());
+00150 settext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), tmpbuf+strlen(path)+1);
+00151 }
+00152 datafile = FileMgr::systemFileMgr.open(tmpbuf, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
+00153 <font class="keyword">delete</font> [] tmpbuf;
+00154 <font class="keywordflow">if</font> (datafile-&gt;getFd() &gt; 0) {
+00155 write(datafile-&gt;getFd(), inbuf, strlen(inbuf));
+00156 }
+00157 FileMgr::systemFileMgr.close(datafile);
+00158
+00159 <font class="keywordflow">if</font> (key != this-&gt;key)
+00160 <font class="keyword">delete</font> key;
+00161
+00162 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00163 }
+00164
+00165
+00166 <font class="comment">/******************************************************************************</font>
+00167 <font class="comment"> * RawFiles::operator &lt;&lt; (SWKey *)- Link the modules current key entry with</font>
+00168 <font class="comment"> * another module entry</font>
+00169 <font class="comment"> *</font>
+00170 <font class="comment"> * RET: *this</font>
+00171 <font class="comment"> */</font>
+00172
+00173 <a class="code" href="class_s_w_module.html">SWModule</a> &amp;RawFiles::operator &lt;&lt;(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *inkey) {
+00174
+00175 <font class="keywordtype">long</font> start;
+00176 <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> size;
+00177 <font class="keywordtype">char</font> *tmpbuf;
+00178 <font class="keyword">const</font> <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0;
+00179
+00180 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00181 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
+00182 <font class="preprocessor">#endif</font>
+00183 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, inkey);
+00184 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00185 <font class="preprocessor"></font> }
+00186 <font class="keywordflow">catch</font> ( ... ) {}
+00187 <font class="preprocessor">#endif</font>
+00188 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
+00189 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this-&gt;key);
+00190
+00191 findoffset(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), &amp;start, &amp;size);
+00192
+00193 <font class="keywordflow">if</font> (size) {
+00194 tmpbuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [ size + 2];
+00195 gettext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), start, size + 2, tmpbuf);
+00196
+00197 <font class="keywordflow">if</font> (key != inkey)
+00198 <font class="keyword">delete</font> key;
+00199 key = 0;
+00200
+00201 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00202 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
+00203 <font class="preprocessor">#endif</font>
+00204 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, inkey);
+00205 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00206 <font class="preprocessor"></font> }
+00207 <font class="keywordflow">catch</font> ( ... ) {}
+00208 <font class="preprocessor">#endif</font>
+00209 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
+00210 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this-&gt;key);
+00211 settext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), tmpbuf);
+00212 }
+00213
+00214 <font class="keywordflow">if</font> (key != inkey)
+00215 <font class="keyword">delete</font> key;
+00216
+00217 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
+00218 }
+00219
+00220
+00221 <font class="comment">/******************************************************************************</font>
+00222 <font class="comment"> * RawFiles::deleteEntry - deletes this entry</font>
+00223 <font class="comment"> *</font>
+00224 <font class="comment"> * RET: *this</font>
+00225 <font class="comment"> */</font>
+00226
+00227 <font class="keywordtype">void</font> RawFiles::deleteEntry() {
+00228
+00229 <a class="code" href="class_verse_key.html">VerseKey</a> *key = 0;
+00230
+00231 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00232 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
+00233 <font class="preprocessor">#endif</font>
+00234 <font class="preprocessor"></font> key = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, this-&gt;key);
+00235 <font class="preprocessor">#ifndef _WIN32_WCE</font>
+00236 <font class="preprocessor"></font> }
+00237 <font class="keywordflow">catch</font> ( ... ) {}
+00238 <font class="preprocessor">#endif</font>
+00239 <font class="preprocessor"></font> <font class="keywordflow">if</font> (!key)
+00240 key = <font class="keyword">new</font> <a class="code" href="class_verse_key.html">VerseKey</a>(this-&gt;key);
+00241
+00242 settext(key-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(), key-&gt;<a class="code" href="class_verse_key.html#a34">Index</a>(), <font class="stringliteral">""</font>);
+00243
+00244 <font class="keywordflow">if</font> (key != this-&gt;key)
+00245 <font class="keyword">delete</font> key;
+00246 }
+00247
+00248
+00249 <font class="comment">/******************************************************************************</font>
+00250 <font class="comment"> * RawFiles::getnextfilename - generates a valid filename in which to store</font>
+00251 <font class="comment"> * an entry</font>
+00252 <font class="comment"> *</font>
+00253 <font class="comment"> * RET: filename</font>
+00254 <font class="comment"> */</font>
+00255
+00256 <font class="keywordtype">char</font> *RawFiles::getnextfilename() {
+00257 <font class="keyword">static</font> <font class="keywordtype">char</font> incfile[255];
+00258 <font class="keywordtype">long</font> number;
+00259 FileDesc *datafile;
+00260
+00261 sprintf(incfile, <font class="stringliteral">"%s/incfile"</font>, path);
+00262 datafile = FileMgr::systemFileMgr.open(incfile, O_RDONLY|O_BINARY);
+00263 <font class="keywordflow">if</font> (read(datafile-&gt;getFd(), &amp;number, 4) != 4)
+00264 number = 0;
+00265 number++;
+00266 FileMgr::systemFileMgr.close(datafile);
+00267
+00268 datafile = FileMgr::systemFileMgr.open(incfile, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
+00269 write(datafile-&gt;getFd(), &amp;number, 4);
+00270 FileMgr::systemFileMgr.close(datafile);
+00271 sprintf(incfile, <font class="stringliteral">"%.7ld"</font>, number-1);
+00272 <font class="keywordflow">return</font> incfile;
+00273 }
+00274
+00275
+00276 <font class="keywordtype">char</font> RawFiles::createModule (<font class="keyword">const</font> <font class="keywordtype">char</font> *path) {
+00277 <font class="keywordtype">char</font> *incfile = <font class="keyword">new</font> <font class="keywordtype">char</font> [ strlen (path) + 16 ];
+00278 <font class="keyword">static</font> <font class="keywordtype">long</font> zero = 0;
+00279 FileDesc *datafile;
+00280
+00281 sprintf(incfile, <font class="stringliteral">"%s/incfile"</font>, path);
+00282 datafile = FileMgr::systemFileMgr.open(incfile, O_CREAT|O_WRONLY|O_BINARY|O_TRUNC);
+00283 <font class="keyword">delete</font> [] incfile;
+00284 write(datafile-&gt;getFd(), &amp;zero, 4);
+00285 FileMgr::systemFileMgr.close(datafile);
+00286
+00287 <font class="keywordflow">return</font> RawVerse::createModule (path);
+00288 }
+00289
+00290
+00291
+</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:00 2002 for The Sword Project by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border=0
+width=110 height=53></a>1.2.15 </small></address>
+</body>
+</html>