<!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>gbfplain.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> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center> <hr><h1>gbfplain.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font> 00002 <font class="comment"> *</font> 00003 <font class="comment"> * gbfplain - SWFilter decendant to strip out all GBF tags or convert to</font> 00004 <font class="comment"> * ASCII rendered symbols.</font> 00005 <font class="comment"> */</font> 00006 00007 00008 <font class="preprocessor">#include <stdlib.h></font> 00009 <font class="preprocessor">#include <string.h></font> 00010 <font class="preprocessor">#include <gbfplain.h></font> 00011 00012 00013 GBFPlain::GBFPlain() { 00014 } 00015 00016 00017 <font class="keywordtype">char</font> GBFPlain::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module) 00018 { 00019 <font class="keywordtype">char</font> *to, *from, token[2048]; 00020 <font class="keywordtype">int</font> tokpos = 0; 00021 <font class="keywordtype">bool</font> intoken = <font class="keyword">false</font>; 00022 <font class="keywordtype">int</font> len; 00023 00024 len = strlen(text) + 1; <font class="comment">// shift string to right of buffer</font> 00025 <font class="keywordflow">if</font> (len < maxlen) { 00026 memmove(&text[maxlen - len], text, len); 00027 from = &text[maxlen - len]; 00028 } 00029 <font class="keywordflow">else</font> from = text; <font class="comment">// -------------------------------</font> 00030 00031 <font class="keywordflow">for</font> (to = text; *from; from++) { 00032 <font class="keywordflow">if</font> (*from == <font class="charliteral">'<'</font>) { 00033 intoken = <font class="keyword">true</font>; 00034 tokpos = 0; 00035 token[0] = 0; 00036 token[1] = 0; 00037 token[2] = 0; 00038 <font class="keywordflow">continue</font>; 00039 } 00040 <font class="keywordflow">if</font> (*from == <font class="charliteral">'>'</font>) { 00041 intoken = <font class="keyword">false</font>; 00042 <font class="comment">// process desired tokens</font> 00043 <font class="keywordflow">switch</font> (*token) { 00044 <font class="keywordflow">case</font> <font class="charliteral">'W'</font>: <font class="comment">// Strongs</font> 00045 <font class="keywordflow">switch</font>(token[1]) { 00046 <font class="keywordflow">case</font> <font class="charliteral">'G'</font>: <font class="comment">// Greek</font> 00047 <font class="keywordflow">case</font> <font class="charliteral">'H'</font>: <font class="comment">// Hebrew</font> 00048 <font class="keywordflow">case</font> <font class="charliteral">'T'</font>: <font class="comment">// Tense</font> 00049 *to++ = <font class="charliteral">' '</font>; 00050 *to++ = <font class="charliteral">'<'</font>; 00051 <font class="keywordflow">for</font> (<font class="keywordtype">char</font> *tok = token + 2; *tok; tok++) 00052 *to++ = *tok; 00053 *to++ = <font class="charliteral">'>'</font>; 00054 *to++ = <font class="charliteral">' '</font>; 00055 <font class="keywordflow">continue</font>; 00056 } 00057 <font class="keywordflow">break</font>; 00058 <font class="keywordflow">case</font> <font class="charliteral">'R'</font>: 00059 <font class="keywordflow">switch</font>(token[1]) { 00060 <font class="keywordflow">case</font> <font class="charliteral">'F'</font>: <font class="comment">// footnote begin</font> 00061 *to++ = <font class="charliteral">' '</font>; 00062 *to++ = <font class="charliteral">'['</font>; 00063 <font class="keywordflow">continue</font>; 00064 <font class="keywordflow">case</font> <font class="charliteral">'f'</font>: <font class="comment">// footnote end</font> 00065 *to++ = <font class="charliteral">']'</font>; 00066 *to++ = <font class="charliteral">' '</font>; 00067 <font class="keywordflow">continue</font>; 00068 } 00069 <font class="keywordflow">break</font>; 00070 <font class="keywordflow">case</font> <font class="charliteral">'C'</font>: 00071 <font class="keywordflow">switch</font>(token[1]) { 00072 <font class="keywordflow">case</font> <font class="charliteral">'A'</font>: <font class="comment">// ASCII value</font> 00073 *to++ = (char)atoi(&token[2]); 00074 <font class="keywordflow">continue</font>; 00075 <font class="keywordflow">case</font> <font class="charliteral">'G'</font>: 00076 *to++ = <font class="charliteral">'>'</font>; 00077 <font class="keywordflow">continue</font>; 00078 <font class="comment">/* Bug in WEB</font> 00079 <font class="comment"> case 'L':</font> 00080 <font class="comment"> *to++ = '<';</font> 00081 <font class="comment"> continue;</font> 00082 <font class="comment">*/</font> 00083 <font class="keywordflow">case</font> <font class="charliteral">'L'</font>: <font class="comment">// Bug in WEB. Use above entry when fixed</font> 00084 <font class="keywordflow">case</font> <font class="charliteral">'N'</font>: <font class="comment">// new line</font> 00085 *to++ = <font class="charliteral">'\n'</font>; 00086 <font class="keywordflow">continue</font>; 00087 <font class="keywordflow">case</font> <font class="charliteral">'M'</font>: <font class="comment">// new paragraph</font> 00088 *to++ = <font class="charliteral">'\n'</font>; 00089 *to++ = <font class="charliteral">'\n'</font>; 00090 <font class="keywordflow">continue</font>; 00091 } 00092 <font class="keywordflow">break</font>; 00093 } 00094 <font class="keywordflow">continue</font>; 00095 } 00096 <font class="keywordflow">if</font> (intoken) { 00097 <font class="keywordflow">if</font> (tokpos < 2045) 00098 token[tokpos++] = *from; 00099 token[tokpos+2] = 0; 00100 } 00101 <font class="keywordflow">else</font> *to++ = *from; 00102 } 00103 *to++ = 0; 00104 *to = 0; 00105 <font class="keywordflow">return</font> 0; 00106 } </pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 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>