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

plainhtml.cpp

00001 /***************************************************************************
00002                           rwphtml.cpp  -  description
00003                              -------------------
00004     begin                : Thu Jun 24 1999
00005     copyright            : (C) 1999 by Torsten Uhlmann
00006     email                : TUhlmann@gmx.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #include <plainhtml.h>
00021 
00022 
00023 PLAINHTML::PLAINHTML()
00024 {
00025 }
00026 
00027 
00028 char PLAINHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
00029 {
00030         char *to, *from;
00031         int len;
00032         int count = 0;
00033 
00034         len = strlen(text) + 1;                                         // shift string to right of buffer
00035         if (len < maxlen) {
00036                 memmove(&text[maxlen - len], text, len);
00037                 from = &text[maxlen - len];
00038         }
00039         else    from = text;                                                    // -------------------------------
00040         for (to = text; *from; from++)
00041         {
00042                 if ((*from == '\n') && (from[1] == '\n')) // paragraph
00043                 {
00044                         *to++ = '<';
00045                         *to++ = 'P';
00046                         *to++ = '>';
00047                         from++;
00048                         continue;
00049                 } else {
00050                         if ((*from == '\n')) // && (from[1] != '\n')) // new line
00051                         {
00052                                 *to++ = '<';
00053                                 *to++ = 'B';
00054                                 *to++ = 'R';
00055                                 *to++ = '>';
00056                                 continue;
00057                         }
00058                 }
00059                 
00060                 if (*from == '{') {
00061                   *to++ = '<';
00062                 *to++ = 'F';
00063                 *to++ = 'O';
00064                         *to++ = 'N';
00065                         *to++ = 'T';
00066                         *to++ = ' ';
00067                         *to++ = 'C';
00068                         *to++ = 'O';
00069                         *to++ = 'L';
00070                         *to++ = 'O';
00071                         *to++ = 'R';
00072                         *to++ = '=';
00073                         *to++ = '#';
00074                         *to++ = '8';
00075                         *to++ = '0';
00076                         *to++ = '0';
00077                         *to++ = '0';
00078                         *to++ = '0';
00079                         *to++ = '0';
00080                         *to++ = '>';
00081 
00082                         *to++ = '<';
00083                         *to++ = 'S';
00084                         *to++ = 'M';
00085                         *to++ = 'A';
00086                         *to++ = 'L';
00087                         *to++ = 'L';
00088                         *to++ = '>';
00089                         *to++ = ' ';
00090                         *to++ = '(';
00091                         continue;
00092                 }
00093 
00094                 if (*from == '}')
00095                 {
00096                         *to++ = ')';
00097                         *to++ = ' ';
00098                         *to++ = '<';
00099                         *to++ = '/';
00100                         *to++ = 'S';
00101                         *to++ = 'M';
00102                         *to++ = 'A';
00103                         *to++ = 'L';
00104                         *to++ = 'L';
00105                         *to++ = '>';
00106                         
00107                         *to++ = '<';
00108                         *to++ = '/';
00109                 *to++ = 'F';
00110                         *to++ = 'O';
00111                         *to++ = 'N';
00112                         *to++ = 'T';
00113                         *to++ = '>';
00114                         continue;
00115                 }
00116 
00117                 if ((*from == ' ') && (count > 5000))
00118                 {
00119                         *to++ = '<';
00120                         *to++ = 'W';
00121                         *to++ = 'B';
00122                         *to++ = 'R';
00123                         *to++ = '>';
00124                         count = 0;
00125                         continue;
00126                 }
00127 
00128                 *to++ = *from;
00129                 count++;
00130         }
00131         *to++ = 0;
00132         *to = 0;
00133         return 0;
00134 }

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