00001 #ifndef gWEB_X_H
00002 #define gWEB_X_H
00003
00004 #include "gconfig.h"
00005 #include "gnet.h"
00006
00007 #if defined(DEBUG) || defined(DEBUG_WEB)
00008 #define cCHR_HTM_PARSED_DEFAULT 0xA1 // Acc.UniCode4: 00A1;INVERTED EXCLAMATION MARK
00009
00010 #else
00011 #define cCHR_HTM_PARSED_DEFAULT 0x7F // must not be dumped
00012 #endif //DEBUG
00013 #define cCHR_HTM_INFO_DEFAULT 0xB7 // Acc.UniCode4: 00B7;MIDDLE DOT
00014
00015 #ifdef DEBUG_WEB
00016 #define DBGPRINT_WEB(args...) printf(args)
00017 #else
00018 #define DBGPRINT_WEB(args...) ;
00019 #endif //DEBUG_WEB
00020
00021
00022
00023
00024 class gIntCoord : public gInt {
00025 public:
00026 gIntCoord () ;
00027 gIntCoord (int ax, int ay) ;
00028 gIntCoord (int ax, int ay, int az) ;
00029 virtual ~gIntCoord () {
00030 }
00031
00032
00033 short iAux;
00034
00035
00036 virtual int GetX () {
00037 return c;
00038 }
00039
00040 virtual int GetY () {
00041 return y;
00042 }
00043
00044 virtual int GetZ () {
00045 return z;
00046 }
00047
00048
00049 virtual void Reset () {
00050 c = 0;
00051 y = z = 0;
00052 }
00053
00054 virtual bool SetX (int ax) {
00055 return SetInt( ax );
00056 }
00057
00058 virtual bool SetY (int ay) {
00059 y = ay;
00060 return true;
00061 }
00062
00063 virtual bool SetZ (int az) {
00064 z = az;
00065 return true;
00066 }
00067
00068
00069 gIntCoord& operator= (gIntCoord& copy) ;
00070
00071
00072 gStorage* NewObject () ;
00073 virtual t_uchar* ToString (t_uchar* uBuf) ;
00074
00075
00076 virtual void Show (bool doShowAll=true) ;
00077
00078 protected:
00079 int y, z;
00080
00081 private:
00082
00083 gIntCoord (gIntCoord& ) ;
00084 };
00085
00086 class gTagCoord : public gIntCoord {
00087 public:
00088 gTagCoord () ;
00089 virtual ~gTagCoord () ;
00090
00091
00092 t_int16 opId;
00093 int depth;
00094
00095
00096 virtual bool IsOk () {
00097 return c>=0 && GetY()>0 && GetZ()>0;
00098 }
00099 virtual t_int16 GetTagId () {
00100 return (t_int16)c;
00101 }
00102
00103
00104 virtual void Reset () ;
00105
00106 virtual bool SetTagId (t_int16 id) {
00107 SetX( id );
00108 return id>=0;
00109 }
00110 virtual bool SetZ (int az) ;
00111
00112 private:
00113
00114 gTagCoord (gTagCoord& ) ;
00115 gTagCoord& operator= (gTagCoord& ) ;
00116 };
00117
00118
00119
00120 struct sCoordText {
00121 sCoordText () {
00122 }
00123 ~sCoordText () {
00124 }
00125
00126 gList coordL;
00127 gList textL;
00128
00129
00130 bool IsOk () ;
00131 unsigned N () ;
00132 char* Str (unsigned idx) ;
00133 gIntCoord& GetCoord (unsigned idx) ;
00134 unsigned FindCoordX (int x) ;
00135 unsigned FindCoordX (int x, gList& foundL, gList& foundTxtL) ;
00136
00137
00138 bool Add (int x, int y, gString& s) {
00139 return Add( x, y, s.Str() );
00140 }
00141 bool Add (int x, int y, char* s);
00142 bool Add (int x, int y, int z, gString& s) ;
00143 bool Add (int x, int y, int z, char* s);
00144
00145 bool AddCoord (int x, int y, int z=0) ;
00146 bool AddCoordToList (int x, int y, int z, gList& resL) ;
00147
00148 bool AddText (gString& s) ;
00149 bool AddText (char* s) ;
00150
00151 void Delete () ;
00152
00153 void Report (FILE* fRep, bool doShowAll=true) ;
00154 };
00155
00156
00157
00158 class gUnweb : public gFileFetch {
00159 public:
00160 gUnweb (char* fName, bool doVerbose) ;
00161 gUnweb (gString& sInput, bool doVerbose) ;
00162 virtual ~gUnweb () ;
00163
00164
00165 enum eTagCaseChange {
00166 e_CaseUnchange,
00167 e_CaseConvUpper,
00168 e_CaseConvDown
00169 };
00170
00171 enum eDumpMask {
00172 e_ShowNonscript = 1,
00173 e_ShowScript = 2,
00174 e_ShowAll = e_ShowNonscript | e_ShowScript
00175 };
00176
00177
00178 int firstHtmlError, firstHtmlErrLNr;
00179 int lastHtmlError, lastHtmlErrLNr;
00180 int nHtmlErrors;
00181 eDumpMask showKind;
00182
00183 sCoordText coordComments;
00184 sCoordText coordSerial;
00185 sCoordText coordParseErr;
00186
00187
00188 virtual bool IsVerbose () {
00189 return isVerbose;
00190 }
00191 virtual FILE* VerboseStream () ;
00192
00193 virtual bool IsBufferOk () ;
00194 virtual char* Str (unsigned idx) ;
00195
00196 virtual bool HasProcessed () {
00197 return nHtmlErrors!=-1;
00198 }
00199 virtual bool HasErrors () {
00200 return nHtmlErrors>0;
00201 }
00202
00203
00204
00205 unsigned FindStringKey (gString& s, char* sub, unsigned startPos, unsigned endPos) ;
00206 unsigned FindStringKey (gString& s, char* sub) ;
00207 unsigned FindStringKey (char* s, char* sub, unsigned startPos, unsigned endPos) ;
00208 unsigned FindStringKey (char* s, char* sub) ;
00209
00210
00211 bool SetVerboseStream (FILE* aFRepErr) ;
00212
00213 void SetTagCaseChange (eTagCaseChange aTagCaseCh) {
00214 tagCaseCh = aTagCaseCh;
00215 }
00216 void SetChrHtmParsed (t_uchar c) ;
00217
00218 int Dump (FILE* fRepErr) ;
00219
00220
00221 protected:
00222 bool isVerbose;
00223 eTagCaseChange tagCaseCh;
00224
00225 int thisConsolidateData (gList& iL, unsigned lowL, unsigned highL, short step) ;
00226 int thisConsolidateDataCoord (sCoordText& cErr, sCoordText& coord) ;
00227
00228 int thisCutCommentsInTxt (sCoordText& coordCmt, sCoordText& zRes) ;
00229
00230 int thisPreProcess (FILE* fRepErr, gList& iL, gList& oL) ;
00231 int thisPreJoin (FILE* fRepErr, gList& iL, gList& sL, gList& oL) ;
00232 int thisPreStripComments (FILE* fRepErr, gList& iL, sCoordText& zRes) ;
00233
00234 int thisStrMove (gString& s, unsigned startPos, unsigned endPos, gList& oL) ;
00235 int thisStripReplace (gString& s, char* resStr) ;
00236 int thisStrSetParse (gString& s, unsigned startPos, unsigned endPos, gString& sResult) ;
00237
00238 int thisPostProcess (FILE* fRepErr, gList& headL, gList& iL, gList& oL, sCoordText& coord) ;
00239
00240 int thisAddTxt (int x, int y, char* s, sCoordText& coord) ;
00241 int thisAddTxt (int x, int y, gString& sTxt, sCoordText& coord) ;
00242 int thisAddCmd (int x, int y, char* s, sCoordText& coord) ;
00243 int thisAddCmd (int x, int y, gString& sCmd, sCoordText& coord) ;
00244
00245 int thisTxtCheck (int x, int y, gString& s, sCoordText& cErr) ;
00246
00247 private:
00248 short scriptLevel;
00249 t_uchar cCHR_HTM_PARSED;
00250 t_uchar cCHR_HTM_INFO;
00251 char sCHR_HTM_PARSED[10];
00252
00253
00254 gList stripL;
00255
00256
00257
00258 gUnweb (gUnweb& ) ;
00259 gUnweb& operator= (gUnweb& ) ;
00260 };
00261
00262 #endif //gWEB_X_H
00263