aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/rwphtml_8cpp-source.html
blob: eca1cfdbfa4eb9b42fc59ed6dfe04f885878213c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!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>rwphtml.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>rwphtml.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/***************************************************************************</font>
00002 <font class="comment">                          rwphtml.cpp  -  description</font>
00003 <font class="comment">                             -------------------</font>
00004 <font class="comment">    begin                : Thu Jun 24 1999</font>
00005 <font class="comment">    copyright            : (C) 1999 by Torsten Uhlmann</font>
00006 <font class="comment">    email                : TUhlmann@gmx.de</font>
00007 <font class="comment"> ***************************************************************************/</font>
00008 
00009 <font class="comment">/***************************************************************************</font>
00010 <font class="comment"> *                                                                         *</font>
00011 <font class="comment"> *   This program is free software; you can redistribute it and/or modify  *</font>
00012 <font class="comment"> *   it under the terms of the GNU General Public License as published by  *</font>
00013 <font class="comment"> *   the Free Software Foundation; either version 2 of the License, or     *</font>
00014 <font class="comment"> *   (at your option) any later version.                                   *</font>
00015 <font class="comment"> *                                                                         *</font>
00016 <font class="comment"> ***************************************************************************/</font>
00017 
00018 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00019 <font class="preprocessor">#include &lt;string.h&gt;</font>
00020 <font class="preprocessor">#include &lt;ctype.h&gt;</font>
00021 <font class="preprocessor">#include &lt;rwphtml.h&gt;</font>
00022 
00023 RWPHTML::RWPHTML()
00024 {
00025 }
00026 
00027 
00028 <font class="keywordtype">char</font> RWPHTML::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)
00029 {
00030         <font class="keywordtype">char</font> *to, *from; 
00031         <font class="keywordtype">signed</font> <font class="keywordtype">char</font> greek_str[500];
00032         <font class="keywordtype">bool</font> inverse = <font class="keyword">false</font>;
00033         <font class="keywordtype">bool</font> first_letter = <font class="keyword">false</font>;
00034         <font class="keywordtype">int</font> len;
00035 
00036         len = strlen(text) + 1; <font class="comment">// shift string to right of buffer</font>
00037         <font class="keywordflow">if</font> (len &lt; maxlen) {
00038                 memmove(&amp;text[maxlen - len], text, len);
00039                 from = &amp;text[maxlen - len];
00040         } <font class="keywordflow">else</font>
00041                 from = text;    
00042         <font class="keywordflow">for</font> (to = text; *from; from++) {
00043                 <font class="keywordflow">if</font> (*from == <font class="charliteral">'\\'</font>) {
00044                         ++from;
00045                         <font class="keywordtype">int</font> i=0;
00046                         first_letter = <font class="keyword">true</font>;
00047                         greek_str[0] = <font class="charliteral">'\0'</font>;                    
00048                         <font class="keywordflow">while</font> (*from != <font class="charliteral">'\\'</font>) { <font class="comment">/* get the greek word or phrase */</font>
00049                                 greek_str[i++] = *from;
00050                                 greek_str[i + 1] = <font class="charliteral">'\0'</font>;
00051                                 from++;
00052                         } <font class="comment">/* convert to symbol font as best we can */</font>
00053                         strcpy(to,<font class="stringliteral">"&lt;I&gt; &lt;/I&gt;&lt;FONT FACE=\"symbol\"&gt;"</font>);
00054                         to += strlen(to);
00055                         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> j = 0; j &lt; i; j++) {
00056                                 <font class="keywordflow">if</font> ((first_letter)
00057                                     &amp;&amp; (greek_str[j] == <font class="charliteral">'h'</font>)) {
00058                                         <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'o'</font>) {
00059                                                 *to++ = <font class="charliteral">'o'</font>;
00060                                                 first_letter = <font class="keyword">false</font>;
00061                                                 ++j;
00062                                                 <font class="keywordflow">continue</font>;
00063                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'a'</font>) {
00064                                                 *to++ = <font class="charliteral">'a'</font>;
00065                                                 first_letter = <font class="keyword">false</font>;
00066                                                 ++j;
00067                                                 <font class="keywordflow">continue</font>;
00068                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'w'</font>) {
00069                                                 *to++ = <font class="charliteral">'w'</font>;
00070                                                 first_letter = <font class="keyword">false</font>;
00071                                                 ++j;
00072                                                 <font class="keywordflow">continue</font>;
00073                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'u'</font>) {
00074                                                 *to++ = <font class="charliteral">'u'</font>;
00075                                                 first_letter = <font class="keyword">false</font>;
00076                                                 ++j;
00077                                                 <font class="keywordflow">continue</font>;
00078                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] ==
00079                                                    -109) {
00080                                                 *to++ = <font class="charliteral">'w'</font>;
00081                                                 first_letter = <font class="keyword">false</font>;
00082                                                 ++j;
00083                                                 <font class="keywordflow">continue</font>;
00084                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] ==
00085                                                    -120) {
00086                                                 *to++ = <font class="charliteral">'h'</font>;
00087                                                 first_letter = <font class="keyword">false</font>;
00088                                                 ++j;
00089                                                 <font class="keywordflow">continue</font>;
00090                                         } <font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'i'</font>) {
00091                                                 *to++ = <font class="charliteral">'i'</font>;
00092                                                 first_letter = <font class="keyword">false</font>;
00093                                                 ++j;
00094                                                 <font class="keywordflow">continue</font>;
00095                                         }<font class="keywordflow">else</font> <font class="keywordflow">if</font> (greek_str[j + 1] == <font class="charliteral">'e'</font>) {
00096                                                 *to++ = <font class="charliteral">'e'</font>;
00097                                                 first_letter = <font class="keyword">false</font>;
00098                                                 ++j;
00099                                                 <font class="keywordflow">continue</font>;
00100                                         }
00101                                         first_letter = <font class="keyword">false</font>;
00102                                 }
00103                                 <font class="keywordflow">if</font> ((greek_str[j] == <font class="charliteral">'t'</font>)
00104                                     &amp;&amp; (greek_str[j + 1] == <font class="charliteral">'h'</font>)) {
00105                                         *to++ = <font class="charliteral">'q'</font>;
00106                                         ++j;
00107                                         <font class="keywordflow">continue</font>;
00108                                 }
00109                                 <font class="keywordflow">if</font> ((greek_str[j] == <font class="charliteral">'c'</font>)
00110                                     &amp;&amp; (greek_str[j + 1] == <font class="charliteral">'h'</font>)) {
00111                                         *to++ = <font class="charliteral">'c'</font>;
00112                                         ++j;
00113                                         <font class="keywordflow">continue</font>;
00114                                 }
00115                                 <font class="keywordflow">if</font> ((greek_str[j] == <font class="charliteral">'p'</font>)
00116                                     &amp;&amp; (greek_str[j + 1] == <font class="charliteral">'h'</font>)) {
00117                                         ++j;
00118                                         *to++ = <font class="charliteral">'f'</font>;
00119                                         <font class="keywordflow">continue</font>;
00120                                 }
00121                                 <font class="keywordflow">if</font> (greek_str[j] == -120) {
00122                                         *to++ = <font class="charliteral">'h'</font>;
00123                                         <font class="keywordflow">continue</font>;
00124                                 }
00125                                 <font class="keywordflow">if</font> (greek_str[j] == -125) {
00126                                         *to++ = <font class="charliteral">'a'</font>;
00127                                         <font class="keywordflow">continue</font>;
00128                                 }
00129                                 <font class="keywordflow">if</font> (greek_str[j] == -109) {
00130                                         <font class="keywordflow">if</font>(greek_str[j+1] == <font class="charliteral">'i'</font>) ++j;
00131                                         *to++ = <font class="charliteral">'w'</font>;
00132                                         <font class="keywordflow">continue</font>;
00133                                 }
00134                                 <font class="keywordflow">if</font> (greek_str[j] == <font class="charliteral">' '</font>)
00135                                         first_letter = <font class="keyword">true</font>;
00136                                 <font class="keywordflow">if</font> (greek_str[j] == <font class="charliteral">'s'</font>) {
00137                                         <font class="keywordflow">if</font>(isalpha(greek_str[j + 1])) *to++ = <font class="charliteral">'s'</font>;
00138                                         <font class="keywordflow">else</font> <font class="keywordflow">if</font>(!isprint(greek_str[j] )) *to++ = <font class="charliteral">'s'</font>;                                           
00139                                         <font class="keywordflow">else</font> *to++ = <font class="charliteral">'V'</font>;
00140                                         <font class="keywordflow">continue</font>;                                       
00141                                 }
00142                                 <font class="keywordflow">if</font> (greek_str[j] == <font class="charliteral">'\''</font>) {                                     
00143                                         <font class="keywordflow">continue</font>;
00144                                 }
00145                                 *to++ = greek_str[j];
00146                         }
00147                         strcpy(to,<font class="stringliteral">"&lt;/FONT&gt;&lt;I&gt; &lt;/I&gt;"</font>);
00148                         to += strlen(to);
00149                         <font class="keywordflow">continue</font>;
00150                 }
00151                 <font class="keywordflow">if</font> (*from == <font class="charliteral">'#'</font>) {     <font class="comment">// verse markings (e.g. "#Mark 1:1|")</font>
00152                         inverse = <font class="keyword">true</font>;
00153                         strcpy(to,<font class="stringliteral">"&lt;FONT COLOR=#0000FF&gt;"</font>);
00154                         to += strlen(to);                       
00155                         <font class="keywordflow">continue</font>;
00156                 }
00157                 <font class="keywordflow">if</font> ((*from == <font class="charliteral">'|'</font>) &amp;&amp; (inverse)) {
00158                         inverse = <font class="keyword">false</font>;
00159                         strcpy(to,<font class="stringliteral">"&lt;/FONT&gt;"</font>);
00160                         to += strlen(to);
00161                         <font class="keywordflow">continue</font>;
00162                 }
00163                 <font class="keywordflow">if</font> (*from == <font class="charliteral">'{'</font>) {
00164                         strcpy(to,<font class="stringliteral">"&lt;BR&gt;&lt;STRONG&gt;"</font>);
00165                         to += strlen(to);
00166                         <font class="keywordflow">if</font> ((from - &amp;text[maxlen - len]) &gt; 10) { <font class="comment">// not the beginning of the entry</font>
00167                                 strcpy(to,<font class="stringliteral">"&lt;P&gt;"</font>);
00168                                 to += strlen(to);
00169                         }
00170                         <font class="keywordflow">continue</font>;
00171                 }
00172                 <font class="keywordflow">if</font> (*from == <font class="charliteral">'}'</font>) {
00173                         strcpy(to,<font class="stringliteral">" &lt;/STRONG&gt;"</font>);
00174                         to += strlen(to);
00175                         <font class="keywordflow">continue</font>;
00176                 }
00177                 <font class="keywordflow">if</font> ((*from == <font class="charliteral">'\n'</font>) &amp;&amp; (from[1] == <font class="charliteral">'\n'</font>)) {
00178                         strcpy(to,<font class="stringliteral">"&lt;P&gt;"</font>);
00179                         to += strlen(to);
00180                         <font class="keywordflow">continue</font>;
00181                 }
00182                 *to++ = *from;
00183         }
00184         *to++ = 0;
00185         *to = 0;        
00186         <font class="keywordflow">return</font> 0;
00187 }
</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>