Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

gbfplain.cpp

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

Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by doxygen1.2.15