#include <Readhtml.h>
Collaboration diagram for Cgi::Readhtml:
Public Member Functions | |
Readhtml (void) | |
Readhtml (char *) | |
~Readhtml (void) | |
int | getnext (char *, int) |
Private Member Functions | |
Readhtml (const Readhtml &) | |
Readhtml & | operator= (const Readhtml &) |
Private Attributes | |
char * | fn |
FILE * | fil |
char | peekc |
char * | buf |
Definition at line 27 of file Readhtml.h.
Cgi::Readhtml::Readhtml | ( | void | ) |
Cgi::Readhtml::Readhtml | ( | char * | ) |
Cgi::Readhtml::~Readhtml | ( | void | ) |
Cgi::Readhtml::Readhtml | ( | const Readhtml & | ) | [private] |
int Cgi::Readhtml::getnext | ( | char * | , | |
int | ||||
) |
Definition at line 60 of file Readhtml.cpp.
References buf, DEB, fil, MAXL, and peekc.
00061 { 00062 size_t i = 0; 00063 size_t sv = 0; 00064 00065 if (!fil) 00066 return -1; 00067 if (feof(fil)) 00068 return 0; 00069 00070 if (!peekc) 00071 do 00072 { 00073 fread(&peekc,1,1,fil); 00074 } while (!feof(fil) && (peekc == 13 || peekc == 10)); 00075 00076 // read HTML tag 00077 00078 if (peekc == '<') 00079 { 00080 if (i < MAXL - 1) 00081 buf[i++] = peekc; 00082 fread(&peekc,1,1,fil); 00083 while (!feof(fil) && peekc != '>') 00084 { 00085 if (peekc == 13 || peekc == 10 || peekc == 9) 00086 peekc = 32; 00087 if (i < MAXL - 1) 00088 buf[i++] = peekc; 00089 fread(&peekc,1,1,fil); 00090 } 00091 if (i < MAXL - 1) 00092 buf[i++] = '>'; 00093 buf[i] = 0; 00094 buf[bufl - 1] = 0; 00095 peekc = 0; 00096 while (buf[strlen(buf) - 1] == 32) 00097 buf[strlen(buf) - 1] = 0; 00098 strcpy(s,buf); 00099 // check comment 00100 if (!strncmp(buf, "<!--", 4)) 00101 { 00102 while (!strstr(buf, "-->") && !feof(fil)) 00103 { 00104 i = 0; 00105 fread(&peekc,1,1,fil); 00106 while (!feof(fil) && peekc != '>') 00107 { 00108 if (peekc == 13 || peekc == 10 || peekc == 9) 00109 peekc = 32; 00110 if (i < MAXL - 1) 00111 buf[i++] = peekc; 00112 fread(&peekc,1,1,fil); 00113 } 00114 if (i < MAXL - 1) 00115 buf[i++] = '>'; 00116 buf[i] = 0; 00117 buf[bufl - 1] = 0; 00118 peekc = 0; 00119 while (buf[strlen(buf) - 1] == 32) 00120 buf[strlen(buf) - 1] = 0; 00121 strcat(s + strlen(s),buf); 00122 } 00123 return 3; // comment 00124 } 00125 return 1; 00126 } 00127 00128 // read string 00129 // 0xc4-Auml, 0xc5-Aring, 0xd6-Ouml 00130 // 0xe4-auml, 0xe5-aring, 0xf6-ouml 00131 00132 if (peekc == 13 || peekc == 10 || peekc == 9) 00133 peekc = 32; 00134 if (peekc && peekc != 32) 00135 if (i < MAXL - 1) 00136 buf[i++] = peekc; 00137 do 00138 { 00139 fread(&peekc,1,1,fil); 00140 if (peekc == 13 || peekc == 10 || peekc == 9) 00141 peekc = 32; 00142 } while (peekc == 32 && !feof(fil)); 00143 while (!feof(fil) && peekc != '<') 00144 { 00145 if (peekc == 13 || peekc == 10 || peekc == 9) 00146 peekc = 32; 00147 if (i < MAXL - 1) 00148 buf[i++] = peekc; 00149 fread(&peekc,1,1,fil); 00150 // debug udde tecken 00151 if (peekc < 0) 00152 { 00153 buf[i] = 0; 00154 DEB(printf("%s 0x%02x\n",buf,(unsigned)peekc % 256);) 00155 sv++; 00156 } 00157 } 00158 buf[i] = 0; 00159 buf[bufl - 1] = 0; 00160 { 00161 char *s = strstr(buf, " "); 00162 while (s) 00163 { 00164 *s = ' '; 00165 memcpy(s + 1, s + 6, strlen(s + 6) + 1); 00166 // 00167 s = strstr(buf, " "); 00168 } 00169 } 00170 while (buf[strlen(buf) - 1] == 32) 00171 buf[strlen(buf) - 1] = 0; 00172 strcpy(s,buf); 00173 DEB(if (sv) 00174 printf("%s\n",buf);) 00175 if (!*s && !feof(fil)) 00176 return getnext(s, bufl); 00177 return 2; 00178 }
char* Cgi::Readhtml::fn [private] |
FILE* Cgi::Readhtml::fil [private] |
char Cgi::Readhtml::peekc [private] |
char* Cgi::Readhtml::buf [private] |