1: /* Cfour (C++ Common Console Classes)
     2:  * Copyright (C) 2001 Jeffrey Bakker
     3:  *
     4:  * This program is free software; you can redistribute it and/or modify
     5:  * it under the terms of the GNU General Public License as published by
     6:  * the Free Software Foundation; either version 2 of the License, or
     7:  * (at your option) any later version.
     8:  *
     9:  * This program is distributed in the hope that it will be useful,
    10:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12:  * GNU General Public License for more details.
    13:  *
    14:  * You should have received a copy of the GNU General Public License
    15:  * along with this program; if not, write to the Free Software
    16:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    17:  *
    18:  *
    19:  *  Author:              Jeffrey Bakker
    20:  *  Filename:            cfdatapair.h
    21:  *  File version:        1.1
    22:  *
    23:  *  ===========================================================================
    24:  *
    25:  *  Created on: Sept 2nd, 2001
    26:  *
    27:  *  Modified on: April 1st, 2002
    28:  *
    29:  *             - Added translateML() which takes data markup format,
    30:  *               and modifies name and value.
    31:  *             - Added info_ml(), changed info() to info_nv().
    32:  *             - Added a constructor which takes a string in markup format.
    33:  *             - Overloaded insertion and extraction operators to convert
    34:  *               data between pairs and maarkup like a stream call.
    35:  *             - Made getName() and getValue() as const methods.
    36:  *
    37:  *  ===========================================================================
    38:  *
    39:  *  Remark:
    40:  *
    41:  *  This is the class defintion for CFdataPair, a class which provides methods
    42:  *  and data members for storing pairs of data.
    43:  *
    44:  *  ===========================================================================
    45:  * _______. ..
    46:  */
    47: 
    48: 
    49: #ifndef _C4_DATA_PAIR  
    50: #define _C4_DATA_PAIR  
    51: 
    52: #include <string>  
    53: using namespace std;
    54: 
    55: class CFdatapair {
    56: 
    57:  public:
    58: 
    59:   void operator<<(string  mldata);//{translateML(mldata);}
    60:   void operator>>(string& mldata);//{mldata = info_ml();}
    61:   //---------------------------------------------------------------------------
    62:   CFdatapair();                   // default constructor
    63:   CFdatapair(string mldata);      // create datapair with markup data
    64:   CFdatapair(string n, string v); // create datapair with name and value
    65:   //---------------------------------------------------------------------------
    66:   string getname()  const;        // return the name
    67:   string getvalue() const;        // return the value
    68:   void setname (string n);        // change the name
    69:   void setvalue(string v);        // change the value
    70:   //---------------------------------------------------------------------------
    71:   string info_nv()  const;        // return the name/value in printable format
    72:   string info_ml()  const;        // return the name/value in markup format
    73:   //---------------------------------------------------------------------------
    74:   void translateML(string mldata);// change the name/value using markup data
    75:   void swap();                    // swap the name and value
    76:   //---------------------------------------------------------------------------
    77:  protected:
    78: 
    79:   string name;
    80:   string value;
    81:   //---------------------------------------------------------------------------
    82: };
    83: 
    84: #endif  // _C4_DATA_PAIR  
    85: 
    86: 
    87: 
    88: /* Cfour (C++ Common Classes Collection)
    89:  * Copyright (C) 2001, (C) 2002 Jeffrey Bakker
    90:  *
    91:  * This program is free software; you can redistribute it and/or modify
    92:  * it under the terms of the GNU General Public License as published by
    93:  * the Free Software Foundation; either version 2 of the License, or
    94:  * (at your option) any later version.
    95:  *
    96:  * This program is distributed in the hope that it will be useful,
    97:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    98:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    99:  * GNU General Public License for more details.
   100:  *
   101:  * You should have received a copy of the GNU General Public License
   102:  * along with this program; if not, write to the Free Software
   103:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   104:  *
   105:  *
   106:  *  Author:              Jeffrey Bakker
   107:  *  Filename:            cffile.h
   108:  *  File version:        1.2.3
   109:  *
   110:  *  CHANGELOG ==================================================================
   111:  *  ============================================================================
   112:  *
   113:  *  Created on:  August 21st, 2001
   114:  *
   115:  *
   116:  *  Modified on: September 2nd, 2001
   117:  *
   118:  *             - Added a new read(), rline(), and write() methods for reading
   119:  *               and writing to and from a file.
   120:  *
   121:  *  Modified on: November 7th, 2001
   122:  *
   123:  *             - Added a new isIredir(), and isOredir(), toggleImode(), and
   124:  *               toggleOmode() methods and booleans data iredir & oredir for
   125:  *               I/O redirection.
   126:  *
   127:  *  Modified on: November 8th, 2001
   128:  *
   129:  *             - Overloaded the insertion and extraction operators.
   130:  *             - The read() and write() methods are now template methods.
   131:  *
   132:  *  Modified on: December 30th, 2001
   133:  *
   134:  *             - Added void setIFptr(long), void setOFptr (long),
   135:  *               long getIFptr(), and long getOFptr() methods for
   136:  *               get/setting the location of the in/out file pointers.
   137:  *             - Added CFfile::READ and CFfile::WRITE constants to send
   138:  *               as file modes to the constructor and open method.
   139:  *
   140:  *  Modified on: March 30th, 2002
   141:  *
   142:  *             - Extraction and insertion operator now return CFfile&, for
   143:  *               concatenating multiple stream commands into a single call
   144:  *               to the stream object. eg. IO << "this" << that << 2 << 'y';
   145:  *             - Added rfile() method, which reads the contents of the
   146:  *               currently open input file into a string.
   147:  *             - Defined ENDL and DOSENDL as "\n" and "\r\n".
   148:  *
   149:  *  Modified on: March 31st, 2002
   150:  *
   151:  *             - Added an overloaded openW() method, which takes a bool
   152:  *               parameter for overwriting or aborting on existing files.
   153:  *             - Redone read() and write() using the conditional operator
   154:  *               rather than using if/else.
   155:  *             - Replaced read/write mode constants with #defines, and
   156:  *               added more modes.
   157:  *             - All templated methods are now implemented in the header
   158:  *               file to fix unresolved symbols when linking with the
   159:  *               microsoft compiler.
   160:  *
   161:  *  Modified on: April 12th, 2002
   162:  *
   163:  *             - Improved and added more whitespace defines, and set the file
   164:  *               open method defines to Hex format.
   165:  *             - The read() and write() methods now use positive logic.
   166:  *
   167:  *  Modified on: April 30th, 2002
   168:  *
   169:  *             - Added members bool oopen, iopen, bool isOopen(), and
   170:  *               bool isIopen() to check if the file streams are in use.
   171:  *
   172:  *  ============================================================================
   173:  *  ============================================================================
   174:  *
   175:  *  Remark:
   176:  *
   177:  *  This is the definition of the CFfile class. The CFfile class contains file
   178:  *  I/O methods which automates file checking while opening I/O streams. You
   179:  *  can now safely open and close files, error free.
   180:  *
   181:  *  The extraction and insertion operators have been overloaded, in an attempt
   182:  *  to turn this class into a stream class which wraps the fstream and the
   183:  *  iostream classes nicely and conveniently together.
   184:  *
   185:  *  The class has also been designed to easily switch between file I/O to
   186:  *  STDIN/STDOUT, enabling the ability to write programs which provide the
   187:  *  "piping" functionality from the command line.
   188:  *
   189:  *  For specific details on the methods, see the documentation at the top of
   190:  *  the file "cffile.cpp".
   191:  *
   192:  *  ============================================================================
   193:  * _______. ..
   194:  */
   195: 
   196: 
   197: #ifndef _C4_FILE_H 
   198: #define _C4_FILE_H 
   199: 
   200: #define C4_FILE_VER "1.2.3" 
   201: 
   202: 
   203: // whitespace defines ----------------------------------------------------------
   204: #if     defined(WIN32) 
   205: #define ENDL    "\r\n" 
   206: #elif   defined(UNIX) 
   207: #define ENDL    "\n" 
   208: #else   // other OS 
   209: #define ENDL    "\n" 
   210: #endif  // defined(WIN32/UNIX) 
   211: 
   212: #define NIXENDL "\n" 
   213: #define DOSENDL "\r\n" 
   214: #define BIG_TAB "\t\t" 
   215: #define SPACE_4 "    " 
   216: #define SPACE_8 "        " 
   217: 
   218: // file open modes ----------
   219: #define MODE_READ        0x72 
   220: #define MODE_WRITE       0x77 
   221: #define PROMPT_OVERWRITE 0x77 
   222: #define FORCE_OVERWRITE  0x66 
   223: #define NEVER_OVERWRITE  0x6B 
   224: //--------------------------..
   225: 
   226: #include <iostream> 
   227: #include <fstream> 
   228: #include <string> 
   229: using namespace std;
   230: 
   231: 
   232: class CFfile {
   233: 
   234:  public:
   235:   // (Con/De)structors ---------------------------------------------------------
   236:   CFfile();
   237:   CFfile(string filename, char io);
   238:   CFfile(string filein, string fileout);
   239:   ~CFfile();
   240:   // Initialize bool data members ----------------------------------------------
   241:   void init_switches();
   242:   //----------------------------------------------------------------------------
   243:   // Operator overloading ------------------------------------------------------
   244:   template <class T> CFfile& operator<<(T var)  {write(var);return *this;}
   245:   template <class T> CFfile& operator>>(T& var) {read (var);return *this;}
   246:   //----------------------------------------------------------------------------
   247:   // File open methods ---------------------------------------------------------
   248:   bool exists(string fname);      // check if a file exists
   249:   bool openR(string INfile);      // opens file for reading
   250:   bool openW(string OUTfile);     // opens file for writing
   251:   bool openW(string fn, bool ow); // open, specify overwrite
   252:   bool open(string fn, char io);  // open, specify mode
   253: 
   254:   bool isIopen() {return iopen;}  // is infile open?
   255:   bool isOopen() {return oopen;}  // is outfile open?
   256:   //----------------------------------------------------------------------------
   257:   // File pointer location methods ---------------------------------------------
   258:   void setIFptr(long location);   // set the infile pointer location
   259:   void setOFptr(long location);   // set the outfile pointer location
   260:   long getIFptr();                // get the infile pointer location
   261:   long getOFptr();                // get the outfile pointer location
   262:   //----------------------------------------------------------------------------
   263:   // I/O redirection methods ---------------------------------------------------
   264:   bool isIredir() const;          // returns the input mode
   265:   bool isOredir() const;          // returns the output mode
   266:   void toggleImode();             // toggles input mode (FILE or STDIN)
   267:   void toggleOmode();             // toggles output mode (FILE or STDIN)
   268:   //----------------------------------------------------------------------------
   269:   // Read/Write methods --------------------------------------------------------
   270:   template <class T> void read(T &buffer) {(iredir?  cin:ifile) >> buffer;}
   271:   template <class T> void write(T buffer) {(oredir? cout:ofile) << buffer;}
   272:   // Special purpose read methods ----------------------------------------------
   273:   void rline(string &buffer);                // read a line to the string
   274:   void rfile(string &buffer);                // read a file to the string
   275:   void backup(string fname, string bname);   // copy a file
   276:   // File close methods --------------------------------------------------------
   277:   void closeR();   // close the input file
   278:   void closeW();   // close the output file
   279:   void close();    // close all
   280:   //----------------------------------------------------------------------------
   281:   // These are public, so you can still use them raw ---------------------------
   282:   ifstream ifile;  // input file stream
   283:   ofstream ofile;  // output file stream
   284:   //----------------------------------------------------------------------------
   285:  protected:
   286:   // I/O redirection switches --------------------------------------------------
   287:   bool iredir;
   288:   bool oredir;
   289:   bool iopen;
   290:   bool oopen;
   291: };
   292: 
   293: #endif  // _C4_FILE_H  
   294: 
   295: #ifndef _DEFLANGS_H 
   296: #define _DEFLANGS_H 
   297: 
   298: #define ADA_FILE     0x64 
   299: #define ASM_FILE     0x61 
   300: #define ASP_FILE     0x41 
   301: #define BASIC_FILE   0x62 
   302: #define BATCH_FILE   0x75 
   303: #define C_FILE       0x63 
   304: #define CG_FILE      0x67 
   305: #define CLIPS_FILE   0x6E 
   306: #define CPP_FILE     0x2B 
   307: #define CSHARP_FILE  0x23 
   308: #define EMF_FILE     0x4D 
   309: #define U4EA_FILE    0x45 
   310: #define FORTRAN_FILE 0x66 
   311: #define HASKELL_FILE 0x6B 
   312: #define HTML_FILE    0x68 
   313: #define JAVA_FILE    0x6A 
   314: #define JSCRIPT_FILE 0x78 
   315: #define MODULA_FILE  0x6D 
   316: #define OBJC_FILE    0x6F 
   317: #define PASCAL_FILE  0x6C 
   318: #define PERL_FILE    0x65 
   319: #define PHP_FILE     0x70 
   320: #define PB6_FILE     0x77 
   321: #define PYTHON_FILE  0x79 
   322: #define RENDER_FILE  0x52 
   323: #define RUBY_FILE    0x55 
   324: #define SHELL_FILE   0x73 
   325: #define SQL_FILE     0x71 
   326: #define TCL_FILE     0x72 
   327: #define TEXT_FILE    0x74 
   328: #define USCRIPT_FILE 0x54 
   329: #define VHDL_FILE    0x76 
   330: 
   331: #include "langada.h" 
   332: #include "langasm.h" 
   333: #include "langasp.h" 
   334: #include "langbasic.h" 
   335: #include "langbatch.h" 
   336: #include "langc.h" 
   337: #include "langcg.h" 
   338: #include "langclips.h" 
   339: #include "langcpp.h" 
   340: #include "langcsharp.h" 
   341: #include "langemf.h" 
   342: #include "langeuphoria.h" 
   343: #include "langfortran.h" 
   344: #include "langhaskell.h" 
   345: #include "langhtml.h" 
   346: #include "langjava.h" 
   347: #include "langjscript.h" 
   348: #include "langmodula.h" 
   349: #include "langobjc.h" 
   350: #include "langpascal.h" 
   351: #include "langperl.h" 
   352: #include "langphp.h" 
   353: #include "langpbuilder.h" 
   354: #include "langpython.h" 
   355: #include "langrenderman.h" 
   356: #include "langruby.h" 
   357: #include "langshell.h" 
   358: #include "langsql.h" 
   359: #include "langtcl.h" 
   360: #include "langtext.h" 
   361: #include "languscript.h" 
   362: #include "langvhdl.h" 
   363: 
   364: #endif //_DEFLANGS_H 
   365: /* webcpp - driver.h
   366:  * Copyright (C)2001-2003 Jeffrey Bakker
   367: 
   368:  * This program is free software; you can redistribute it and/or modify
   369:  * it under the terms of the GNU General Public License as published by
   370:  * the Free Software Foundation; either version 2 of the License, or
   371:  * (at your option) any later version.
   372: 
   373:  * This program is distributed in the hope that it will be useful,
   374:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   375:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   376:  * GNU General Public License for more details.
   377: 
   378:  * You should have received a copy of the GNU General Public License
   379:  * along with this program; if not, write to the Free Software
   380:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   381:    ___________________________________ .. .
   382:  */
   383: 
   384: #ifndef DRIVER_H 
   385: #define DRIVER_H 
   386: 
   387: #if     defined(WIN32) 
   388: #define LIST_DIRECTORY "dir /s /b " 
   389: #define DIRECTORY_SLASH "\\" 
   390: #define DELETE "del webcppbatch.txt" 
   391: #define CYCLE_SPEED CLK_TCK 
   392: #else 
   393: #define LIST_DIRECTORY "ls " 
   394: #define DIRECTORY_SLASH "/" 
   395: #define DELETE "rm -f webcppbatch.txt" 
   396: #define CYCLE_SPEED CLOCKS_PER_SEC 
   397: #endif  //defined(WIN32/UNIX) 
   398: 
   399: #define HELP_LANGUAGES 'L' 
   400: #define HELP_DEFAULT   'D' 
   401: 
   402: #include "engine.h" 
   403: 
   404: class Driver {
   405:  public:
   406: 	Driver();
   407: 	~Driver();
   408: 	static void help(char mode);
   409: 	bool switch_parser(string arg);
   410: 	char getExt(string filename);
   411: 	string checkExt(string filename);
   412: 	static void makeIndex(string prefix);
   413: 	bool prep_files(string ifile, string ofile, char over);
   414: 	string getTitle();
   415: 	void drive();
   416: 	void clean();
   417: 
   418:  protected:
   419: 	Engine *lang;
   420: 	string iFile;
   421: 	string oFile;
   422: };
   423: 
   424: #endif //DRIVER_H 
   425: /* webcpp - engine.h
   426:  * Copyright (C)2001-2003 Jeffrey Bakker
   427: 
   428:  * This program is free software; you can redistribute it and/or modify
   429:  * it under the terms of the GNU General Public License as published by
   430:  * the Free Software Foundation; either version 2 of the License, or
   431:  * (at your option) any later version.
   432: 
   433:  * This program is distributed in the hope that it will be useful,
   434:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   435:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   436:  * GNU General Public License for more details.
   437: 
   438:  * You should have received a copy of the GNU General Public License
   439:  * along with this program; if not, write to the Free Software
   440:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   441:    ___________________________________ .. .
   442:  */
   443: 
   444: #ifndef _ENGINE_H 
   445: #define _ENGINE_H 
   446: 
   447: #define DBL_QUOTES   0x22 
   448: #define SIN_QUOTES   0x27 
   449: #define BCK_QUOTES   0x60 
   450: 
   451: #define Yes          true 
   452: #define No           false 
   453: 
   454: #include "cffile.h" 
   455: #include "theme.h" 
   456: #include <vector> 
   457: #include <string> 
   458: using namespace std;
   459: 
   460: class Engine {
   461: 
   462:  public:
   463: 	virtual ~Engine() {IO.close();}
   464: 	
   465: 	void init_switches();
   466: 
   467: 	void pre_parse();
   468: 	void makeMargin();
   469: 	void makeAnchor();
   470: 
   471: 	bool abortParse();
   472: 	bool abortColour(int index);
   473: 
   474: 	bool isInsideIt(int index, string start, string end);
   475: 	bool isInsideTag(int index);
   476: 	bool isNotWord(int index);
   477: 	void eraseTags(int start, int fin);
   478: 
   479: 	void parsePreProc();
   480: 
   481: 	void parseSymbol();
   482: 	bool colourSymbol(int start, int end);
   483: 	bool isSymbol(char c);
   484: 
   485: 	void parseLabel();
   486: 	void colourLabel(int start, int end);
   487: 
   488: 	void parseNum();
   489: 	bool colourNum(int start, int end);
   490: 
   491: 	void parseString(char quotetype, bool &inside);
   492: 	void colourString(int   index, bool &inside, string cssclass);
   493: 
   494: 	void parseBigComment(string start, string end, bool &inside);
   495: 
   496: 	void parseKeys();
   497: 	void colourKeys(int index, string key, string cssclass);
   498: 	bool isKey(int start, int end) const;
   499: 	int  noCaseFind(string search, int index);
   500: 	
   501: 	void parseVariable(string var);
   502: 	void colourVariable(int index);
   503: 	
   504: 	void parseComment(string cmnt);
   505: 	void colourComment(int index);
   506: 	void parseCharZeroComment(char zchar);
   507: 
   508: 	void loadKeys();
   509: 	void doParsing();
   510: 
   511: 	void begHtml(string name);
   512: 	void endHtml();
   513: 
   514: 	void hyperTagMe();
   515: 	void hyperLinkMe();
   516: 	void hyperNameMe();
   517: 	void hyperIncludeMe();
   518: 	
   519: 	int  getLineCount() {return lncount;}
   520: 
   521: 	virtual
   522: 	void fill() = 0;
   523: 
   524: 	void toggleBigtab() {opt_bigtab = !opt_bigtab;}
   525: 	void toggleWebcpp() {opt_webcpp = !opt_webcpp;}
   526: 	void toggleHypinc() {opt_hypinc = !opt_hypinc;}
   527: 	void toggleFollow() {opt_follow = !opt_follow;}
   528: 	void toggleAnchor() {opt_anchor = !opt_anchor;}
   529: 	void toggleNumber() {opt_number = !opt_number;}
   530: 	void toggleExtcss() {opt_extcss = !opt_extcss;}
   531: 
   532: 	void setTabWidth(string width);
   533: 
   534:  //options
   535:  protected:
   536: 	bool opt_bigtab;
   537: 	bool opt_webcpp;
   538: 	bool opt_hypinc;
   539: 	bool opt_follow;
   540: 	bool opt_number;
   541: 	bool opt_extcss;
   542: 	bool opt_anchor;
   543: 	
   544:  //parsing rules
   545:  protected:
   546: 	bool doStrings;
   547: 	bool doSymbols;
   548: 	bool doNumbers;
   549: 	bool doKeywords;
   550: 	bool doCaseKeys;
   551: 	bool doLabels;
   552: 	bool doPreProc;
   553: 	bool doScalars;
   554: 	bool doArrays;
   555: 	bool doHashes;
   556: 	bool doHtmlTags;
   557: 	bool doCComnt;
   558: 	bool doHskComnt;
   559: 	bool doHtmComnt;
   560: 	bool doPasComnt;
   561: 	bool doBigComnt;
   562: 	bool doCinComnt;
   563: 	bool doAdaComnt;
   564: 	bool doUnxComnt;
   565: 	bool doAsmComnt;
   566: 	bool doRemComnt;
   567: 	bool doFtnComnt;
   568: 	bool doTclComnt;
   569: 	bool doAspComnt;
   570: 	bool doBatComnt;
   571: 
   572:  //theme file I/O engine
   573:  public:
   574: 	CFfile IO;
   575: 	Theme  Scs2;
   576: //    vector<string> incref;
   577: 
   578:  //internal data
   579:  protected:
   580: 	int lncount;
   581: 	int tabwidth;
   582: 	string tw;
   583: 	string buffer;
   584: 	vector<string> keys;
   585: 	vector<string> types;
   586: 
   587: 	bool inDblQuotes;
   588: 	bool inSinQuotes;
   589: 	bool inBckQuotes;
   590: 	bool inHtmTags;
   591: 	bool inComment;
   592: 	bool endComment;
   593: };
   594: 
   595: #endif  // _ENGINE_H 
   596: // The Ada95 Language definition file for Web C Plus Plus
   597: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   598: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   599: 
   600: #ifndef LANG_DEF_Ada95 
   601: #define LANG_DEF_Ada95 
   602: 
   603: #include "engine.h" 
   604: 
   605: class LangAda95 : public Engine {
   606: 
   607:  public:
   608: 	LangAda95();
   609: 	~LangAda95() {IO.close();}
   610: 	virtual void fill();
   611: 
   612: };
   613: 
   614: #endif //LANG_DEF_Ada95 
   615: // Author: Jeffrey Bakker  |  Date May14th 2002  |  langasm.h
   616: 
   617: // the Assembly Language definition file for Web C Plus Plus
   618: // Webcpp Copyright (C) 2002 Jeffrey Bakker
   619: 
   620: 
   621: #ifndef LANG_ASM_DEF_H 
   622: #define LANG_ASM_DEF_H 
   623: 
   624: #include "engine.h" 
   625: 
   626: class LangAssembler: public Engine {
   627: 
   628:  public:
   629: 	LangAssembler();
   630: 	virtual ~LangAssembler() {IO.close();}
   631: 	virtual void fill();
   632: };
   633: 
   634: #endif // LANG_ASM_DEF_H 
   635: // the ASP Language definition file for Web C Plus Plus
   636: // Author: Matt Runion <mrunion@yahoo.com>
   637: 
   638: #ifndef LANG_DEF_ASP 
   639: #define LANG_DEF_ASP 
   640: 
   641: #include "langhtml.h" 
   642: 
   643: class LangAsp :public LangHtml {
   644:  public:
   645: 	LangAsp();
   646: 	~LangAsp() {IO.close();}
   647: 	virtual void fill();
   648: };
   649: 
   650: #endif //LANG_DEF_ASP 
   651: // The Basic Language definition file for Web C Plus Plus
   652: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   653: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   654: 
   655: #ifndef LANG_DEF_Basic 
   656: #define LANG_DEF_Basic 
   657: 
   658: #include "engine.h" 
   659: 
   660: class LangBasic : public Engine {
   661: 
   662:  public:
   663: 	LangBasic();
   664: 	~LangBasic() {IO.close();}
   665: 	virtual void fill();
   666: 
   667: };
   668: 
   669: #endif //LANG_DEF_Basic 
   670: // The DOS Batch Language definition file for Web C Plus Plus
   671: // Generated by Daniel Lin <dan@dlin.d2g.com> using genlang.cgi
   672: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   673: 
   674: #ifndef LANG_DEF_BATCH 
   675: #define LANG_DEF_BATCH 
   676: 
   677: #include "engine.h" 
   678: 
   679: class LangBatch : public Engine {
   680: 
   681:  public:
   682: 	LangBatch();
   683: 	~LangBatch() {IO.close();}
   684: 	virtual void fill();
   685: 
   686: };
   687: 
   688: #endif //LANG_DEF_BATCH 
   689: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langc.h
   690: 
   691: // the C Language definition file for Web C Plus Plus
   692: // Webcpp Copyright (C) 2002 Jeffrey Bakker
   693: 
   694: 
   695: #ifndef _LANG_C_DEF_H 
   696: #define _LANG_C_DEF_H 
   697: 
   698: #include "engine.h"
 
   699: 
   700: class LangC : public Engine {
   701: 
   702:  public:
   703: 	LangC();
   704: 	virtual ~LangC() {IO.close();}
   705: 	virtual void fill();
   706: };
   707: 
   708: #endif  // _LANG_C_DEF_H 
   709: 
   710: // The Cg Language definition file for Web C Plus Plus
   711: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   712: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   713: 
   714: #ifndef LANG_DEF_NVIDIA_CG_SHADING_LANGUAGE 
   715: #define LANG_DEF_NVIDIA_CG_SHADING_LANGUAGE 
   716: 
   717: #include "engine.h" 
   718: 
   719: class LangCg : public Engine {
   720: 
   721:  public:
   722: 	LangCg();
   723: 	~LangCg() {IO.close();}
   724: 	virtual void fill();
   725: 
   726: };
   727: 
   728: #endif //LANG_DEF_NVIDIA_CG_SHADING_LANGUAGE 
   729: // The CLIPS Language definition file for Web C Plus Plus
   730: // Generated by Walter Maner<maner@cs.bgsu.edu> using genlang.cgi
   731: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   732: 
   733: #ifndef LANG_DEF_NASA_CLIPS 
   734: #define LANG_DEF_NASA_CLIPS 
   735: 
   736: #include "engine.h" 
   737: 
   738: class LangClips : public Engine {
   739: 
   740:  public:
   741: 	LangClips();
   742: 	~LangClips() {IO.close();}
   743: 	virtual void fill();
   744: 
   745: };
   746: 
   747: #endif //LANG_DEF_NASA_CLIPS 
   748: 
   749: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langcpp.h
   750: 
   751: // the C++ Language definition file for Web C Plus Plus
   752: // Webcpp Copyright (C) 2002 Jeffrey Bakker
   753: 
   754: #ifndef _LANG_CPP_DEF_H 
   755: #define _LANG_CPP_DEF_H 
   756: 
   757: #include "langc.h"
 
   758: 
   759: class LangCPlusPlus : public LangC {
   760: 
   761:  public:
   762: 	LangCPlusPlus();
   763: 	virtual ~LangCPlusPlus() {IO.close();}
   764: 	virtual void fill();
   765: };
   766: 
   767: #endif  // _LANG_CPP_DEF_H 
   768: // The CSharp Language definition file for Web C Plus Plus
   769: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   770: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   771: 
   772: #ifndef LANG_DEF_CSharp 
   773: #define LANG_DEF_CSharp 
   774: 
   775: #include "engine.h" 
   776: 
   777: class LangCSharp : public Engine {
   778: 
   779:  public:
   780: 	LangCSharp();
   781: 	~LangCSharp() {IO.close();}
   782: 	virtual void fill();
   783: 
   784: };
   785: 
   786: #endif //LANG_DEF_CSharp 
   787: 
   788: // The emf Language definition file for Web C Plus Plus
   789: // Generated by Dr. Detlef Groth<dgroth@gmx.de> using genlang.cgi
   790: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   791: 
   792: #ifndef LANG_DEF_EMF 
   793: #define LANG_DEF_EMF 
   794: 
   795: #include "engine.h" 
   796: 
   797: class LangEmf : public Engine {
   798: 
   799:  public:
   800: 	LangEmf();
   801: 	~LangEmf() {IO.close();}
   802: 	virtual void fill();
   803: 
   804: };
   805: 
   806: #endif //LANG_DEF_EMF 
   807: 
   808: // The Euphoria Language definition file for Web C Plus Plus
   809: // Generated by George Lewis <ghlewis@hotmail.com> using genlang.cgi
   810: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   811: 
   812: #ifndef LANG_DEF_EUPHORIA 
   813: #define LANG_DEF_EUPHORIA 
   814: 
   815: #include "engine.h" 
   816: 
   817: class LangEuphoria : public Engine {
   818: 
   819:  public:
   820: 	LangEuphoria();
   821: 	~LangEuphoria() {IO.close();}
   822: 	virtual void fill();
   823: 
   824: };
   825: 
   826: #endif //LANG_DEF_EUPHORIA 
   827: // The Fortran Language definition file for Web C Plus Plus
   828: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   829: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   830: 
   831: #ifndef LANG_DEF_Fortran 
   832: #define LANG_DEF_Fortran 
   833: 
   834: #include "engine.h" 
   835: 
   836: class LangFortran : public Engine {
   837: 
   838:  public:
   839: 	LangFortran();
   840: 	~LangFortran() {IO.close();}
   841: 	virtual void fill();
   842: 
   843: };
   844: 
   845: #endif //LANG_DEF_Fortran 
   846: // The Haskell Language definition file for Web C Plus Plus
   847: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   848: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   849: 
   850: #ifndef LANG_DEF_Haskell 
   851: #define LANG_DEF_Haskell 
   852: 
   853: #include "engine.h" 
   854: 
   855: class LangHaskell : public Engine {
   856: 
   857:  public:
   858: 	LangHaskell();
   859: 	~LangHaskell() {IO.close();}
   860: 	virtual void fill();
   861: 
   862: };
   863: 
   864: #endif //LANG_DEF_Haskell 
   865: 
   866: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langhtml.h
   867: 
   868: // the HyperText Markup Language definition file for Web C Plus Plus
   869: // Webcpp Copyright (C) 2002 Jeffrey Bakker
   870: 
   871: #ifndef LANG_HTML_DEF_H 
   872: #define LANG_HTML_DEF_H 
   873: 
   874: #include "engine.h" 
   875: 
   876: class LangHtml: public Engine {
   877: 
   878:  public:
   879: 	LangHtml();
   880: 	~LangHtml() {IO.close();}
   881: 
   882: 	virtual void fill();
   883: };
   884: 
   885: #endif  // LANG_HTML_DEF_H 
   886: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langjava.h
   887: 
   888: // the Java Language definition file for Web C Plus Plus
   889: // Webcpp Copyright (C) 2002 Jeffrey Bakker
   890: 
   891: #ifndef LANG_JAVA_DEF_H 
   892: #define LANG_JAVA_DEF_H 
   893: 
   894: 
   895: 
   896: #include "engine.h" 
   897: 
   898: class LangJava: public Engine {
   899: 
   900:  public:
   901: 	LangJava();
   902: 	virtual ~LangJava() {IO.close();}
   903: 	virtual void fill();
   904: };
   905: 
   906: #endif  // LANG_JAVA_DEF_H 
   907: 
   908: // The javascript Language definition file for Web C Plus Plus
   909: // Generated by forrest johnston<forrest.johnston@attbi.com> using genlang.cgi
   910: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   911: 
   912: #ifndef LANG_DEF_JSCRIPT 
   913: #define LANG_DEF_JSCRIPT 
   914: 
   915: #include "engine.h" 
   916: 
   917: class LangJScript : public Engine {
   918: 
   919:  public:
   920: 	LangJScript();
   921: 	~LangJScript() {IO.close();}
   922: 	virtual void fill();
   923: 
   924: };
   925: 
   926: #endif //LANG_DEF_JSCRIPT 
   927: // The Modula2 Language definition file for Web C Plus Plus
   928: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   929: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   930: 
   931: #ifndef LANG_DEF_Modula2 
   932: #define LANG_DEF_Modula2 
   933: 
   934: #include "engine.h" 
   935: 
   936: class LangModula2 : public Engine {
   937: 
   938:  public:
   939: 	LangModula2();
   940: 	~LangModula2() {IO.close();}
   941: 	virtual void fill();
   942: 
   943: };
   944: 
   945: #endif //LANG_DEF_Modula2 
   946: // The ObjectiveC Language definition file for Web C Plus Plus
   947: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   948: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   949: 
   950: #ifndef LANG_DEF_ObjectiveC 
   951: #define LANG_DEF_ObjectiveC 
   952: 
   953: #include "langc.h" 
   954: 
   955: class LangObjectiveC : public LangC {
   956: 
   957:  public:
   958: 	LangObjectiveC();
   959: 	~LangObjectiveC() {IO.close();}
   960: 	virtual void fill();
   961: 
   962: };
   963: 
   964: #endif //LANG_DEF_ObjectiveC 
   965: // The Pascal Language definition file for Web C Plus Plus
   966: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
   967: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   968: 
   969: #ifndef LANG_DEF_Pascal 
   970: #define LANG_DEF_Pascal 
   971: 
   972: #include "engine.h" 
   973: 
   974: class LangPascal : public Engine {
   975: 
   976:  public:
   977: 	LangPascal();
   978: 	~LangPascal() {IO.close();}
   979: 	virtual void fill();
   980: 
   981: };
   982: 
   983: #endif //LANG_DEF_Pascal 
   984: 
   985: // The Power Builder 6.x Language definition file for Web C Plus Plus
   986: // Generated by Philippe Torche<philippe.torche@swissonline.ch> using genlang.cgi
   987: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
   988: 
   989: #ifndef LANG_DEF_POWER_BUILDER 
   990: #define LANG_DEF_POWER_BUILDER 
   991: 
   992: #include "engine.h" 
   993: 
   994: class LangPBuilder : public Engine {
   995: 
   996:  public:
   997: 	LangPBuilder();
   998: 	~LangPBuilder() {IO.close();}
   999: 	virtual void fill();
  1000: 
  1001: };
  1002: 
  1003: #endif //LANG_DEF_POWER_BUILDER 
  1004: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langperl.h
  1005: 
  1006: // the PERL 5 Language definition file for Web C Plus Plus
  1007: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  1008: 
  1009: #ifndef LANG_PERL_DEF_H 
  1010: #define LANG_PERL_DEF_H 
  1011: 
  1012: #include "engine.h" 
  1013: 
  1014: class LangPerl: public Engine {
  1015: 
  1016:  public :
  1017: 	LangPerl();
  1018: 	virtual ~LangPerl() {IO.close();}
  1019: 	virtual void fill();
  1020: };
  1021: 
  1022: #endif  // LANG_PERL_DEF_H 
  1023: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langphp.h
  1024: 
  1025: // the PHP Language definition file for Web C Plus Plus
  1026: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  1027: 
  1028: #ifndef LANG_PHP_DEF_H 
  1029: #define LANG_PHP_DEF_H 
  1030: 
  1031: #include "engine.h" 
  1032: 
  1033: class LangPhp :public Engine {
  1034:  public:
  1035: 	LangPhp();
  1036: 	~LangPhp() {IO.close();}
  1037: 	virtual void fill();
  1038: };
  1039: 
  1040: #endif  // LANG_PHP_DEF_H 
  1041: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langpython.h
  1042: 
  1043: // the Python Language definition file for Web C Plus Plus
  1044: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  1045: 
  1046: #ifndef LANG_PYTHON_DEF_H 
  1047: #define LANG_PYTHON_DEF_H 
  1048: 
  1049: #include "engine.h" 
  1050: 
  1051: class LangPython : public Engine {
  1052: 
  1053:  public:
  1054: 	LangPython();
  1055: 	~LangPython() {IO.close();}
  1056: 
  1057: 	virtual void fill();
  1058: };
  1059: 
  1060: #endif  // LANG_PYTHON_DEF_H 
  1061: 
  1062: // The RenderMan Shading Language Language definition file for Web C Plus Plus
  1063: // Generated by Mark Williams <markdjwilliams@hotmail.com> using genlang.cgi
  1064: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  1065: 
  1066: #ifndef LANG_DEF_RENDERMAN_SHADING_LANGUAGE 
  1067: #define LANG_DEF_RENDERMAN_SHADING_LANGUAGE 
  1068: 
  1069: #include "engine.h" 
  1070: 
  1071: class LangRenderMan : public Engine {
  1072: 
  1073:  public:
  1074: 	LangRenderMan();
  1075: 	~LangRenderMan() {IO.close();}
  1076: 	virtual void fill();
  1077: 
  1078: };
  1079: 
  1080: #endif //LANG_DEF_RENDERMAN_SHADING_LANGUAGE 
  1081: 
  1082: // The Ruby Language definition file for Web C Plus Plus
  1083: // Generated by Jeffrey Bakker <jefskey@yahoo.com> using genlang.cgi
  1084: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  1085: 
  1086: #ifndef LANG_DEF_RUBY 
  1087: #define LANG_DEF_RUBY 
  1088: 
  1089: #include "engine.h" 
  1090: 
  1091: class LangRuby : public Engine {
  1092: 
  1093:  public:
  1094: 	LangRuby();
  1095: 	~LangRuby() {IO.close();}
  1096: 	virtual void fill();
  1097: 
  1098: };
  1099: 
  1100: #endif //LANG_DEF_RUBY 
  1101: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langshell.h
  1102: 
  1103: // the Bourne shell Syntax definition file for Web C Plus Plus
  1104: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  1105: 
  1106: #ifndef LANG_SHELL_DEF_H 
  1107: #define LANG_SHELL_DEF_H 
  1108: 
  1109: #include "engine.h" 
  1110: 
  1111: class LangShell: public Engine {
  1112: 
  1113:  public :
  1114: 	LangShell();
  1115: 	virtual ~LangShell() {IO.close();}
  1116: 	virtual void fill();
  1117: };
  1118: 
  1119: #endif  // LANG_SHELL_DEF_H 
  1120: // The SQL Language definition file for Web C Plus Plus
  1121: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  1122: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  1123: 
  1124: #ifndef LANG_DEF_SQL 
  1125: #define LANG_DEF_SQL 
  1126: 
  1127: #include "engine.h" 
  1128: 
  1129: class LangSQL : public Engine {
  1130: 
  1131:  public:
  1132: 	LangSQL();
  1133: 	~LangSQL() {IO.close();}
  1134: 	virtual void fill();
  1135: 
  1136: };
  1137: 
  1138: #endif //LANG_DEF_SQL 
  1139: // The Tcl Language definition file for Web C Plus Plus
  1140: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  1141: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  1142: 
  1143: #ifndef LANG_DEF_Tcl 
  1144: #define LANG_DEF_Tcl 
  1145: 
  1146: #include "engine.h" 
  1147: 
  1148: class LangTcl : public Engine {
  1149: 
  1150:  public:
  1151: 	LangTcl();
  1152: 	~LangTcl() {IO.close();}
  1153: 	virtual void fill();
  1154: 
  1155: };
  1156: 
  1157: #endif //LANG_DEF_Tcl 
  1158: #include "engine.h" 
  1159: 
  1160: #ifndef _LANG_DEF_TEXT_H 
  1161: #define _LANG_DEF_TEXT_H 
  1162: 
  1163: class LangText :public Engine {
  1164:  public:
  1165: 	LangText();
  1166: 	~LangText() {IO.close();}
  1167: 	virtual void fill();
  1168: };
  1169: 
  1170: #endif // _LANG_DEF_TEXT_H 
  1171: // Author: Jeffrey Bakker  |  Date: January 29th 2003  |  languscript.h

  1172: 
  1173: // the UnrealScript Language definition file for Web C Plus Plus

  1174: // Webcpp Copyright (C) 2002 Jeffrey Bakker

  1175: 
  1176: #ifndef _LANG_UNREALSCRIPT_DEF_H
 
  1177: #define _LANG_UNREALSCRIPT_DEF_H
 
  1178: 
  1179: #include "langc.h"
 
  1180: 
  1181: class LangUScript : public LangC {
  1182: 
  1183:  public:
  1184: 	LangUScript();
  1185: 	virtual ~LangUScript() {IO.close();}
  1186: 	virtual void fill();
  1187: };
  1188: 
  1189: #endif  // _LANG_UNREALSCRIPT_DEF_H
 
  1190: // The VHDL Language definition file for Web C Plus Plus
  1191: // Generated by Thomas Hedler<thomas.hedler@fen-net.de> using genlang.cgi
  1192: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  1193: 
  1194: #ifndef LANG_DEF_VHDL 
  1195: #define LANG_DEF_VHDL 
  1196: 
  1197: #include "engine.h" 
  1198: 
  1199: class LangVHDL : public Engine {
  1200: 
  1201:  public:
  1202: 	LangVHDL();
  1203: 	~LangVHDL() {IO.close();}
  1204: 	virtual void fill();
  1205: 
  1206: };
  1207: 
  1208: #endif //LANG_DEF_VHDL 
  1209: /* webcpp - theme.h
  1210:  * Copyright (C)2001-2003 Jeffrey Bakker
  1211: 
  1212:  * This program is free software; you can redistribute it and/or modify
  1213:  * it under the terms of the GNU General Public License as published by
  1214:  * the Free Software Foundation; either version 2 of the License, or
  1215:  * (at your option) any later version.
  1216: 
  1217:  * This program is distributed in the hope that it will be useful,
  1218:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1219:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1220:  * GNU General Public License for more details.
  1221: 
  1222:  * You should have received a copy of the GNU General Public License
  1223:  * along with this program; if not, write to the Free Software
  1224:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1225:    ___________________________________ .. .
  1226:  */
  1227: 
  1228: 
  1229: #ifndef _THEME_H_ 
  1230: #define _THEME_H_ 
  1231: 
  1232: #define BGCOLOR  0 
  1233: #define PREPROC  1 
  1234: #define NORTEXT  2 
  1235: #define SYMBOLS  3 
  1236: #define KEYWORD  4 
  1237: #define KEYTYPE  5 
  1238: #define INTEGER  6 
  1239: #define FLOATPT  7 
  1240: #define DBLQUOT  8 
  1241: #define SINQUOT  9 
  1242: #define COMMENT 10 
  1243: 
  1244: // use Cfour engines
  1245: #include "cffile.h" 
  1246: #include "cfdatapair.h" 
  1247: 
  1248: #include <vector> 
  1249: using namespace std;
  1250: 
  1251: class Theme : public CFfile {
  1252: 
  1253:  public:
  1254: 	Theme();
  1255: 	~Theme();
  1256: 
  1257: 	void	typical();
  1258: 	bool	setFile(string filename);
  1259: 	void	setPicture(string picture);
  1260: 	void	setColour(string hexcode,int num);
  1261: 	bool	verifyFormat(string data);
  1262: 
  1263: 	string	getColour(string name);
  1264: 	string	getThemeName();
  1265: 	string	getImageFile();
  1266: 	string	getCSSdata();
  1267: 
  1268: 	bool	writeCSS(string cssfile);
  1269: 	bool	load();
  1270: 
  1271:  protected:
  1272: 	vector<CFdatapair> ScsVec;
  1273: 	string	Colours2[11];
  1274: 	string	SCSfile;
  1275: 	string	Picture;
  1276: 	bool	format2;
  1277: };
  1278: 
  1279: #endif  // _THEME_H_ 
  1280: /* Cfour (C++ Common Console Classes)
  1281:  * Copyright (C) 2001 Jeffrey Bakker
  1282:  *
  1283:  * This program is free software; you can redistribute it and/or modify
  1284:  * it under the terms of the GNU General Public License as published by
  1285:  * the Free Software Foundation; either version 2 of the License, or
  1286:  * (at your option) any later version.
  1287:  *
  1288:  * This program is distributed in the hope that it will be useful,
  1289:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1290:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1291:  * GNU General Public License for more details.
  1292:  *
  1293:  * You should have received a copy of the GNU General Public License
  1294:  * along with this program; if not, write to the Free Software
  1295:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1296:  *
  1297:  *
  1298:  *  Author:              Jeffrey Bakker
  1299:  *  Filename:            cfdatapair.cpp
  1300:  *  File version:        1.1
  1301:  *
  1302:  *  ===========================================================================
  1303:  *
  1304:  *  Created on: Sept 2nd, 2001
  1305:  *
  1306:  *  Modified on: April 1st, 2002
  1307:  *
  1308:  *             - Added translateML() which takes data markup format,
  1309:  *               and modifies name and value.
  1310:  *             - Added info_ml(), changed info() to info_nv().
  1311:  *             - Added a constructor which takes a string in markup format.
  1312:  *             - Overloaded insertion and extraction operators to convert
  1313:  *               data between pairs and maarkup like a stream call.
  1314:  *             - Made getName() and getValue() as const methods.
  1315:  *
  1316:  *  ===========================================================================
  1317:  *
  1318:  *  Remark:
  1319:  *
  1320:  *  This is the class implementaion for CFdataPair, a class which provides
  1321:  *  methods and data members for storing pairs of data.
  1322:  *
  1323:  *  ===========================================================================
  1324:  * _______. ..
  1325:  */
  1326: 
  1327: 
  1328: #include "cfdatapair.h"  
  1329: 
  1330: // overloaded stream operators ------------------------------------------------
  1331: void CFdatapair::operator<<(string  mldata) {translateML(mldata);}
  1332: void CFdatapair::operator>>(string& mldata) {mldata = info_ml();}
  1333: // Constructors ---------------------------------------------------------------
  1334: CFdatapair::CFdatapair()                   {name = "name"; value = "value";}
  1335: CFdatapair::CFdatapair(string mldata)      {translateML(mldata);}
  1336: CFdatapair::CFdatapair(string n, string v) {name = n; value = v;}
  1337: // set methods ----------------------------------------------------------------
  1338: void CFdatapair::setname(string n)  {name  = n;} // changes the name
  1339: void CFdatapair::setvalue(string v) {value = v;} // changes the value
  1340: // get methods ----------------------------------------------------------------
  1341: string CFdatapair::getname()  const {return name;}  // returns the name
  1342: string CFdatapair::getvalue() const {return value;} // returns the value
  1343: //-----------------------------------------------------------------------------
  1344: string CFdatapair::info_nv()  const { // return the name and value in a string
  1345: 
  1346:  return name + ": " + value;
  1347: } //---------------------------------------------------------------------------
  1348: string CFdatapair::info_ml()  const { // return name and value in markup format
  1349: 
  1350:  return ("<" + name + ">" + value + "</" + name + ">");
  1351: } //---------------------------------------------------------------------------
  1352: // swaps the name/value -------------------------------------------------------
  1353: void CFdatapair::swap() {
  1354:  string temp;
  1355:  temp  = name;
  1356:  name  = value;
  1357:  value = temp;
  1358: } //---------------------------------------------------------------------------
  1359: // convert XML-Style string data into name/value pair ------------------------- 
  1360: void CFdatapair::translateML(string mldata) {
  1361: 
  1362:  string ntmp, vtmp;
  1363:  int    open, close;
  1364:  
  1365:  open  = mldata.find("<",0);
  1366:  close = mldata.find(">",open);
  1367:  ntmp  = mldata.substr(open+1,(close - open) -1);
  1368: // ntmp  = mldata.substr(open+1,close-1);
  1369: 
  1370:  open  = mldata.find("</",close);
  1371:  vtmp  = mldata.substr(close+1,(open - close -1));
  1372: 
  1373:  name  = ntmp;
  1374:  value = vtmp;
  1375: }
  1376: //-----------------------------------------------------------------------------
  1377: 
  1378: 
  1379: 
  1380: /* Cfour (C++ Common Classes Collection)
  1381:  * Copyright (C) 2001, (C) 2002 Jeffrey Bakker
  1382:  *
  1383:  * This program is free software; you can redistribute it and/or modify
  1384:  * it under the terms of the GNU General Public License as published by
  1385:  * the Free Software Foundation; either version 2 of the License, or
  1386:  * (at your option) any later version.
  1387:  *
  1388:  * This program is distributed in the hope that it will be useful,
  1389:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1390:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1391:  * GNU General Public License for more details.
  1392:  *
  1393:  * You should have received a copy of the GNU General Public License
  1394:  * along with this program; if not, write to the Free Software
  1395:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1396:  *
  1397:  *
  1398:  *  Author:              Jeffrey Bakker
  1399:  *  Filename:            cffile.cpp
  1400:  *  File version:        1.2.3
  1401:  *
  1402: 
  1403:  *  CHANGELOG =================================================================
  1404:  *  ===========================================================================
  1405:  *
  1406:  *  Created on:  August 21st, 2001
  1407:  *
  1408:  *
  1409:  *  Modified on: September 2nd, 2001
  1410:  *
  1411:  *             - Added a new read(), rline(), and write() methods for reading
  1412:  *               and writing to and from a file.
  1413:  *
  1414:  *  Modified on: November 7th, 2001
  1415:  *
  1416:  *             - Added a new isIredir(), and isOredir(), toggleImode(), and
  1417:  *               toggleOmode() methods and most cout's were changed to cerr
  1418:  *               for I/O redirection.
  1419:  *
  1420:  *  Modified on: November 8th, 2001
  1421:  *
  1422:  *             - Added template operaor<< and operator>> overloading.
  1423:  *             - The read() and write() methods are now template methods.
  1424:  *
  1425:  *  Modified on: December 28th, 2001
  1426:  *
  1427:  *             - Constructor CFfile(string,char) now calls open(string,char).
  1428:  *             - Added 'r' and 'w' to the io mode switch statement in open().
  1429:  *             - Updated documentation
  1430:  *
  1431:  *  Modified on: March 30th, 2002
  1432:  *
  1433:  *             - Extraction and insertion operator now return CFfile&, for
  1434:  *               concatenating multiple stream commands into a single call
  1435:  *               to the stream object. eg. IO << "this" << that << 2 << 'y';
  1436:  *             - Added rfile() method, which reads the contents of the
  1437:  *               currently open input file into a string.
  1438:  *             - Added an overloaded openW() method, which takes a bool
  1439:  *               parameter for overwriting or aborting on existing files.
  1440:  *
  1441:  *  Modified on: March 31st, 2002
  1442:  *
  1443:  *             - All templated methods are now implemented in the header
  1444:  *               file to fix unresolved symbols when linking with the
  1445:  *               microsoft compiler.
  1446:  *
  1447:  *  Modified on: April 30th, 2002
  1448:  *
  1449:  *             - Add code in constructors and the openX() methods to interact
  1450:  *               with iopen and oopen, to verify open file streams. 
  1451:  *
  1452:  *  ===========================================================================
  1453:  *  ===========================================================================
  1454:  *
  1455:  *  Remark:
  1456:  *
  1457:  *  This is the implementation of the CFfile class. In here, you will find
  1458:  *  the inner workings of the CFfile class. The documentation below will show
  1459:  *  how to use the methods.
  1460:  *
  1461:  *  ===========================================================================
  1462:  *  BEGIN METHOD DOCUMENTATION ================================================
  1463:  *  ===========================================================================
  1464:  *
  1465:  *  template <class T> CFfile& operator<<():
  1466:  *
  1467:  *   Description: overloaded operator allows output stream of many data types.
  1468:  *
  1469:  *  ===========================================================================
  1470:  *
  1471:  *  template <class T> CFfile& operator>>():
  1472:  *
  1473:  *   Description: overloaded operator allows input stream of many data types.
  1474:  *
  1475:  *  ===========================================================================
  1476:  *
  1477:  *  CFfile():
  1478:  *
  1479:  *   Description: default constructor.
  1480:  *
  1481:  *  ===========================================================================
  1482:  *
  1483:  *  CFfile(string filename, char io):
  1484:  *
  1485:  *   Description: Overloaded constructor that takes a filename and anI/O mode.
  1486:  *                This constructor calls open(string,char).
  1487:  *
  1488:  *   Input:
  1489:  *
  1490:  *    Parameter 1
  1491:  *    - Name:        filename
  1492:  *    - Type:        string
  1493:  *    - Description: the name of the file to open
  1494:  *
  1495:  *
  1496:  *    Parameter 2
  1497:  *    - Name:        io
  1498:  *    - Type:        char
  1499:  *    - Description: the mode in which to open the file ('i/r' or 'o/w').
  1500:  *
  1501:  *  ===========================================================================
  1502:  *
  1503:  *  bool open(string filename, char io):
  1504:  *
  1505:  *   Description: Depending on the mode selected, it passes the filename to
  1506:  *                openR(string) or openW(string).
  1507:  *
  1508:  *   Input:
  1509:  *
  1510:  *    Parameter 1
  1511:  *    - Name:        filename
  1512:  *    - Type:        string
  1513:  *    - Description: the name of the file to open
  1514:  *
  1515:  *
  1516:  *    Parameter 2
  1517:  *    - Name:        io
  1518:  *    - Type:        char
  1519:  *    - Description: the mode in which to open the file ('i/r' or 'o/w').
  1520:  *
  1521:  *   Output:
  1522:  *    - returns true if file opened correctly, false otherwise.
  1523:  *
  1524:  *  ===========================================================================
  1525:  *
  1526:  *  bool openR(string filename):
  1527:  *
  1528:  *   Description: This opens the specified file for reading and returns true,
  1529:  *                if the file exists. If not, it will return false.
  1530:  *
  1531:  *   Input:
  1532:  *
  1533:  *    Parameter 1
  1534:  *    - Name:        filename
  1535:  *    - Type:        string
  1536:  *    - Description: the name of the file to open
  1537:  *
  1538:  *   Output:
  1539:  *    - returns true if file opened correctly, false otherwise.
  1540:  *
  1541:  *  ===========================================================================
  1542:  *
  1543:  *  bool openW(string filename):
  1544:  *
  1545:  *   Description: This opens the specified file for writing. If the file
  1546:  *                already exists, it asks the user whether to overwrite.
  1547:  *
  1548:  *   Input:
  1549:  *
  1550:  *    Parameter 1
  1551:  *    - Name:        filename
  1552:  *    - Type:        string
  1553:  *    - Description: the name of the file to open
  1554:  *
  1555:  *   Output:
  1556:  *    - returns true if file opened correctly, false otherwise.
  1557:  *
  1558:  *  ===========================================================================
  1559:  *
  1560:  *  void rline(T &buffer):
  1561:  *
  1562:  *   Description: reads a whole line from the file into the buffer.
  1563:  *
  1564:  *   Input:
  1565:  *
  1566:  *    Parameter 1
  1567:  *    - Name:        buffer
  1568:  *    - Type:        address of string
  1569:  *    - Description: the string in which to store the data
  1570:  *
  1571:  *  ===========================================================================
  1572:  *
  1573:  *  void rfile(T &buffer):
  1574:  *
  1575:  *   Description: reads the currently open input file into the buffer.
  1576:  *
  1577:  *   Input:
  1578:  *
  1579:  *    Parameter 1
  1580:  *    - Name:        buffer
  1581:  *    - Type:        address of string
  1582:  *    - Description: the string in which to store the data
  1583:  *
  1584:  *  ===========================================================================
  1585:  *
  1586:  *  template <class T> void read(T &buffer):
  1587:  *
  1588:  *   Description: reads a string from the file into the buffer.
  1589:  *
  1590:  *   Input:
  1591:  *
  1592:  *    Parameter 1
  1593:  *    - Name:        buffer
  1594:  *    - Type:        address of any data type
  1595:  *    - Description: the string in which to store the data
  1596:  *
  1597:  *  ===========================================================================
  1598:  *
  1599:  *  template <class T> void write(T buffer):
  1600:  *
  1601:  *   Description: writes from the string buffer to the file.
  1602:  *
  1603:  *   Input:
  1604:  *
  1605:  *    Parameter 1
  1606:  *    - Name:        buffer
  1607:  *    - Type:        any data type
  1608:  *    - Description: the string in which to write from
  1609:  *
  1610:  *  ===========================================================================
  1611:  *
  1612:  *  void backup(string fname, string bname):
  1613:  *
  1614:  *   Description: creates a backup of a file.
  1615:  *
  1616:  *
  1617:  *   Input:
  1618:  *
  1619:  *    Parameter 1
  1620:  *    - Name:        fname
  1621:  *    - Type:        string
  1622:  *    - Description: the name of the file to copy from
  1623:  *
  1624:  *
  1625:  *    Parameter 2
  1626:  *    - Name:        bname
  1627:  *    - Type:        string
  1628:  *    - Description: the name of the backup file
  1629:  *
  1630:  *  ===========================================================================
  1631:  *
  1632:  *  bool exists(string fname):
  1633:  *
  1634:  *   Description: checks whether or not a file exists
  1635:  *
  1636:  *   Input:
  1637:  *
  1638:  *    Parameter 1
  1639:  *    - Name:        fname
  1640:  *    - Type:        string
  1641:  *    - Description: the name of the file to check
  1642:  *
  1643:  *   Output:
  1644:  *    - returns true if file exists, false otherwise.
  1645:  *
  1646:  *  ===========================================================================
  1647:  *
  1648:  *  void closeR():
  1649:  *
  1650:  *   Description: closes the input stream _if_ it is open.
  1651:  *
  1652:  *  ===========================================================================
  1653:  *
  1654:  *  void closeW():
  1655:  *
  1656:  *   Description: closes the output stream _if_ it is open.
  1657:  *
  1658:  *  ===========================================================================
  1659:  *
  1660:  *  void close():
  1661:  *
  1662:  *   Description: calls closeR() and closeW().
  1663:  *
  1664:  *  ===========================================================================
  1665:  *  END METHOD DOCUMENTATION ==================================================
  1666:  * _______. ..
  1667:  */
  1668: 
  1669: 
  1670: #include "cffile.h"  
  1671: #include <iostream>  
  1672: #include <cctype>  
  1673: using namespace std;
  1674: 
  1675: // constructors ---------------------------------------------------------------
  1676: CFfile::CFfile() {
  1677:  init_switches();
  1678: } //---------------------------------------------------------------------------
  1679: CFfile::CFfile(string filename, char io) {
  1680:  init_switches();
  1681:  open(filename,io);
  1682: } //---------------------------------------------------------------------------
  1683: CFfile::CFfile(string in, string out) {
  1684:  init_switches();
  1685:  openR(in);
  1686:  openW(out);
  1687: }
  1688: // destructor -----------------------------------------------------------------
  1689: CFfile::~CFfile() {
  1690:  close();
  1691: }
  1692: // bool member initialization -------------------------------------------------
  1693: void CFfile::init_switches() {
  1694:  iredir = false;
  1695:  oredir = false;
  1696:  iopen  = false;
  1697:  oopen  = false;
  1698: }
  1699: // open methods ---------------------------------------------------------------
  1700: bool CFfile::open(string filename, char io)  {
  1701: 
  1702:  io = tolower(io);
  1703:  switch (io) {
  1704:   case 'i':
  1705:   case 'r': return openR(filename);
  1706:   case 'o':
  1707:   case 'w': return openW(filename);
  1708:   case 'f': return openW(filename,true);
  1709:   case 'k': return openW(filename,false);
  1710:   default : cerr << "\nInvalid I/O mode.\n"; return false;
  1711:  }
  1712: 
  1713:  return true;
  1714: } // --------------------------------------------------------------------------
  1715: bool CFfile::openR(string INfile)  {
  1716: 
  1717:  if (exists(INfile)) {
  1718:   ifile.open(INfile.data());
  1719:   iopen = true;
  1720:   return true;
  1721:  } else {
  1722:   cerr << ENDL << INfile << " cannot be opened.\n";
  1723:   return false;
  1724:  }
  1725: } // --------------------------------------------------------------------------
  1726: bool CFfile::openW(string OUTfile) {
  1727: 
  1728:  if (exists(OUTfile)) {
  1729:   char write;
  1730:   do {
  1731:    cerr << ENDL << OUTfile << " already exists. Overwrite? (Y/N) ";
  1732:    cin  >> write;
  1733:    if (write == 'N' || write == 'n') {return false;}
  1734:   } while (!(write == 'Y' || write == 'y'));
  1735:  }
  1736:  ofile.open(OUTfile.data());
  1737:  oopen = true;
  1738:  return true;
  1739: } // --------------------------------------------------------------------------
  1740: bool CFfile::openW(string OUTfile, bool overwrite) {
  1741: 
  1742:  if (exists(OUTfile)) {
  1743:   if(!overwrite) {return false;}
  1744:  }
  1745:  ofile.open(OUTfile.data());
  1746:  oopen = true;
  1747:  return true;
  1748: }
  1749: // ----------------------------------------------------------------------------
  1750: // close methods --------------------------------------------------------------
  1751: void CFfile::closeR() {  // safely close the stream
  1752:  if(ifile){
  1753:   ifile.close();
  1754:   iopen = false;
  1755:  }
  1756: }
  1757: void CFfile::closeW() {  // safely close the stream
  1758:  if(ofile){
  1759:   ofile.close();
  1760:   oopen = false;
  1761:  }
  1762: }
  1763: void CFfile::close()  {  // safely close all streams
  1764:  closeR();
  1765:  closeW();
  1766: }
  1767: // ----------------------------------------------------------------------------
  1768: // checks if a file exists ----------------------------------------------------
  1769: bool CFfile::exists(string fname) {
  1770: 
  1771:  ifstream chk;
  1772:  chk.open(fname.data());
  1773: 
  1774:  if(!chk) {
  1775:   chk.close();
  1776:   return false;
  1777:  }
  1778:  chk.close();
  1779:  return true;
  1780: } //---------------------------------------------------------------------------
  1781: // check input/output modes for redirection -----------------------------------
  1782: bool CFfile::isIredir() const {return iredir;}    // is Input redirected?
  1783: bool CFfile::isOredir() const {return oredir;}    // is Output redirected?
  1784: // toggle input/output modes for redirection ----------------------------------
  1785: void CFfile::toggleImode() {iredir = !iredir;}
  1786: void CFfile::toggleOmode() {oredir = !oredir;}
  1787: 
  1788: // return the location of the pointer in the file -----------------------------
  1789: long CFfile::getIFptr() {return ifile.tellg();}
  1790: long CFfile::getOFptr() {return ofile.tellp();}
  1791: // set the location of the ponter in the file ---------------------------------
  1792: void CFfile::setIFptr(long location) {ifile.seekg(location);}
  1793: void CFfile::setOFptr(long location) {ofile.seekp(location);}
  1794: 
  1795: // readline to string ---------------------------------------------------------
  1796: void CFfile::rline(string &buffer)  {
  1797:  if(!iredir) {getline(ifile,buffer);}
  1798:  else getline(cin,buffer);
  1799: }
  1800: // readfile to string ---------------------------------------------------------
  1801: void CFfile::rfile(string &buffer)  {
  1802: 
  1803:  long save_pos = getIFptr(); // save current position in file
  1804:  setIFptr(0);                // set position to the start of the file
  1805: 
  1806:  string line;
  1807:  while(ifile) {
  1808:   rline(line);
  1809:   buffer += line + ENDL;  
  1810:  }
  1811: 
  1812:  setIFptr(save_pos);         // restore previous position in file
  1813: } //---------------------------------------------------------------------------
  1814: // backup a file --------------------------------------------------------------
  1815: void CFfile::backup(string fname, string bname) {
  1816: 
  1817:  ifstream bin;
  1818:  ofstream bout;
  1819:  string linebuf;
  1820: 
  1821:  bin.open(fname.data());
  1822:  bout.open(bname.data());
  1823: 
  1824:  getline(bin,linebuf);
  1825:  while (bin) {
  1826:   bout << linebuf;
  1827:   getline(bin,linebuf);
  1828:   if (bin) bout << ENDL;
  1829:  }
  1830:  bin.close();
  1831:  bout.close();
  1832: } // --------------------------------------------------------------------------
  1833: //-----------------------------------------------------------------------------
  1834: 
  1835: /* webcpp - driver.cpp
  1836:  * Copyright (C)2001-2003 Jeffrey Bakker
  1837: 
  1838:  * This program is free software; you can redistribute it and/or modify
  1839:  * it under the terms of the GNU General Public License as published by
  1840:  * the Free Software Foundation; either version 2 of the License, or
  1841:  * (at your option) any later version.
  1842: 
  1843:  * This program is distributed in the hope that it will be useful,
  1844:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1845:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1846:  * GNU General Public License for more details.
  1847: 
  1848:  * You should have received a copy of the GNU General Public License
  1849:  * along with this program; if not, write to the Free Software
  1850:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1851:    ___________________________________ .. .
  1852:  */
  1853: 
  1854: 
  1855: #include "deflangs.h" 
  1856: #include "driver.h" 
  1857: 
  1858: #include <ctime> 
  1859: #include <iomanip> 
  1860: using namespace std;
  1861: 
  1862: Driver::Driver() {lang = NULL;}
  1863: Driver::~Driver(){clean();}
  1864: 
  1865: // toggle/set an option --------------------------------------------------------
  1866: bool Driver::switch_parser(string arg) {
  1867: 
  1868: 	if (arg.substr(0,3) == "-x=") {
  1869: 		cerr << checkExt("." + arg.substr(3)) << " type forced.\n";
  1870: 		prep_files(iFile,oFile,0x66);
  1871: 	} else if (arg.substr(0,3) == "-c=") {
  1872: 		lang->Scs2.setFile(arg.substr(3));
  1873: 	} else if (arg.substr(0,3) == "-C=") {
  1874: 		lang->toggleExtcss();
  1875: 		lang->Scs2.setFile(arg.substr(3));
  1876: 	} else if (arg.substr(0,3) == "-i=") {
  1877: 		lang->Scs2.setPicture(arg.substr(3));
  1878: 	} else if (arg.substr(0,3) == "-t=") {
  1879: 		lang->toggleBigtab();
  1880: 		lang->setTabWidth(arg.substr(3));
  1881: 	} else if (arg.substr(0,3) == "-w=") {
  1882: 		lang->toggleNumber();
  1883: 		lang->toggleAnchor();
  1884: 		lang->toggleHypinc();
  1885: 		lang->toggleWebcpp();
  1886: 		lang->Scs2.setFile(arg.substr(3));
  1887: 	} else if (arg.substr(0,3) == "-W=") {
  1888: 		lang->toggleNumber();
  1889: 		lang->toggleAnchor();
  1890: 		lang->toggleHypinc();
  1891: 		lang->toggleWebcpp();
  1892: 		lang->toggleExtcss();
  1893: 		lang->Scs2.setFile(arg.substr(3));
  1894: 	} else if (arg == "--external-css" || arg == "-X") {
  1895: 		lang->toggleExtcss();
  1896: 	} else if (arg == "--superinclude" || arg == "-H") {
  1897: 		lang->toggleHypinc();
  1898: 		lang->toggleFollow();
  1899: 	} else if (arg == "--hyperinclude" || arg == "-h") {
  1900: 		lang->toggleHypinc();
  1901: 	} else if (arg == "--anchor-lines" || arg == "-a") {
  1902: 		lang->toggleAnchor();
  1903: 	} else if (arg == "--line-numbers" || arg == "-l") {
  1904: 		lang->toggleNumber();
  1905: 	} else if (arg == "--tabs-spaces"  || arg == "-t") {
  1906: 		lang->toggleBigtab();
  1907: 	} else if (arg == "--made-with"    || arg == "-m") {
  1908: 		lang->toggleWebcpp();
  1909: 	} else if (arg == "--the-works"    || arg == "-w") {
  1910: 		lang->toggleNumber();
  1911: 		lang->toggleAnchor();
  1912: 		lang->toggleHypinc();
  1913: 		lang->toggleWebcpp();
  1914: 	} else {
  1915: 		help(HELP_DEFAULT);
  1916: 		return false;
  1917: 	}
  1918: 
  1919: 	return true;
  1920: }
  1921: // print help ----------------------------------------------------------------
  1922: void Driver::help(char mode) {
  1923: 
  1924: 	string Usage;
  1925: 
  1926: 	Usage = "\
  1927: Usage: $ webcpp <infile> <outfile> [options...]\n\
  1928: \n\
  1929: Options:\n\
  1930:   -c=<scheme>        Use a webcpp colour scheme.\n\
  1931:   -w=<scheme>        The works, same as -m -l -a -h -c=<scheme>.\n\
  1932:   -i=<filename>      Use an image for the background.\n\
  1933:   -t=<width>         Convert tabs to spaces using the specified width.\n\
  1934:   -x=<extension>     Force the filetype for syntax highlighting.\n\
  1935: \n\
  1936:   -X,--external-css  Generate an external stylesheet.\n\
  1937:   -l,--line-numbers  Print the line numbers in the left margin.\n\
  1938:   -a,--anchor-lines  Create anchors to line numbers.\n\
  1939:   -h,--hyperinclude  Create hyperlinks to #include statements.\n\
  1940:   -H,--superinclude  Hyperinclude that recursively generates files.\n\
  1941:   -t,--tabs-spaces   Convert tabs to spaces, default width is 8.\n\
  1942:   -m,--made-with     Show made with webcpp footer.\n\
  1943:   -A,--auto          Automatic naming in place of the output file.\n\
  1944:   - ,--pipe          Use STDIN or STDOUT in place of the filename.\n\
  1945: \n\
  1946:  Type `webcpp --languages` to see supported languages and filetypes.\n";
  1947: 
  1948: 
  1949: 	string Langs = "\
  1950: Ada95\t\t*.adb,*.ads,*.ali\n\
  1951: Assembly\t*.asm,*.s\n\
  1952: Asp\t\t*.asp,*.asa\n\
  1953: Basic\t\t*.bas\n\
  1954: C#\t\t*.cs\n\
  1955: C Source\t*.c,*.rc\n\
  1956: C++ Source\t*.cc,*.cpp,*.cxx\n\
  1957: C/C++ Header\t*.h,*.hh,*.hpp,*.hxx\n\
  1958: Objective-C\t*.m\n\
  1959: DOS Batch\t*.bat,*.cmd\n\
  1960: EMF\t\t*.emf\n\
  1961: Euphoria\t*.e,*.eu,*.ex\n\
  1962: Fortran\t\t*.f,*.f77,*.f90,*.for,*.ftn\n\
  1963: Haskell\t\t*.hs,*.lhs\n\
  1964: Java\t\t*.java\n\
  1965: JavaScript\t*.js\n\
  1966: Markup\t\t*.htm,*.html,*.shtml,*.sgml,*.xml\n\
  1967: Modula2\t\t*.def,*.mod\n\
  1968: Nasa CLIPS\t*.clp\n\
  1969: NVidia Cg\t*.cg\n\
  1970: Pascal\t\t*.pas\n\
  1971: Perl\t\t*.cgi,*.pl,*.plx,*.plex,*.pm\n\
  1972: PHP\t\t*.inc,*.php,*.php3,*.php4\n\
  1973: Power Builder\t*.pbl,*.pbr\n\
  1974: Python\t\t*.py,*.pyw\n\
  1975: RenderMan\t*.rib,*.sl\n\
  1976: Ruby\t\t*.rb\n\
  1977: SQL\t\t*.sql\n\
  1978: Tcl\t\t*.tcl,*.tk\n\
  1979: Unix shell\t*.sh\n\
  1980: UnrealScript\t*.uc\n\
  1981: VHDL\t\t*.v,*.vhd,*.vhdl\n\
  1982: Don't see your favorite language listed here?\n\
  1983: Try http://webcpp.sourceforge.net/languages.php\n";
  1984: 
  1985: 	cerr	<< "Web C Plus Plus v0.8.0  "
  1986: 		<< "Copyright (C)2001-2003 Jeffrey Bakker\n"
  1987: 		<< "Released February 6th 2003, "
  1988: 		<< "Compiled " << __DATE__ << " at " << __TIME__ << "\n\n"
  1989: 		<< ((mode == HELP_LANGUAGES)?Langs:Usage);
  1990: 
  1991: }
  1992: // determines the filetype for syntax highlighting ----------------------------
  1993: char Driver::getExt(string filename)
  1994: {
  1995: 	int dot;
  1996: 	char ext;
  1997: 
  1998: 	string extension = "";
  1999: 	dot = filename.rfind(".");
  2000: 
  2001: 	if(dot != -1) {
  2002: 		extension = filename.substr(dot+1, filename.size() - dot);
  2003: 	}
  2004: 	for(int i=0; i < extension.size(); i++) {
  2005: 		extension[i]=tolower(extension[i]);
  2006: 	}
  2007: 
  2008: 	if     (extension ==  "adb") {ext =     ADA_FILE;}
  2009: 	else if(extension ==  "ads") {ext =     ADA_FILE;}
  2010: 	else if(extension ==  "ali") {ext =     ADA_FILE;}
  2011: 	else if(extension ==  "asm") {ext =     ASM_FILE;}
  2012: 	else if(extension ==  "asp") {ext =     ASP_FILE;}
  2013: 	else if(extension ==  "asa") {ext =     ASP_FILE;}
  2014: 	else if(extension ==    "s") {ext =     ASM_FILE;}
  2015: 	else if(extension ==  "bas") {ext =   BASIC_FILE;}
  2016: 	else if(extension ==  "bat") {ext =   BATCH_FILE;}
  2017: 	else if(extension ==  "cmd") {ext =   BATCH_FILE;}
  2018: 	else if(extension ==    "c") {ext =       C_FILE;}
  2019: 	else if(extension ==   "rc") {ext =       C_FILE;}
  2020: 	else if(extension ==   "cc") {ext =     CPP_FILE;}
  2021: 	else if(extension ==  "cpp") {ext =     CPP_FILE;}
  2022: 	else if(extension ==  "coo") {ext =     CPP_FILE;}
  2023: 	else if(extension ==  "c++") {ext =     CPP_FILE;}
  2024: 	else if(extension ==  "cxx") {ext =     CPP_FILE;}
  2025: 	else if(extension ==    "h") {ext =     CPP_FILE;}
  2026: 	else if(extension ==   "hh") {ext =     CPP_FILE;}
  2027: 	else if(extension ==  "hpp") {ext =     CPP_FILE;}
  2028: 	else if(extension ==  "hxx") {ext =     CPP_FILE;}
  2029: 	else if(extension ==   "cg") {ext =      CG_FILE;}
  2030: 	else if(extension ==  "clp") {ext =   CLIPS_FILE;}
  2031: 	else if(extension ==   "cs") {ext =  CSHARP_FILE;}
  2032: 	else if(extension ==    "m") {ext =    OBJC_FILE;}
  2033: 	else if(extension ==  "emf") {ext =     EMF_FILE;}
  2034: 	else if(extension ==    "e") {ext =    U4EA_FILE;}
  2035: 	else if(extension ==   "eu") {ext =    U4EA_FILE;}
  2036: 	else if(extension ==   "ex") {ext =    U4EA_FILE;}
  2037: 	else if(extension ==    "f") {ext = FORTRAN_FILE;}
  2038: 	else if(extension ==  "for") {ext = FORTRAN_FILE;}
  2039: 	else if(extension ==  "ftn") {ext = FORTRAN_FILE;}
  2040: 	else if(extension ==  "f77") {ext = FORTRAN_FILE;}
  2041: 	else if(extension ==  "f90") {ext = FORTRAN_FILE;}
  2042: 	else if(extension ==   "hs") {ext = HASKELL_FILE;}
  2043: 	else if(extension ==  "lhs") {ext = HASKELL_FILE;}
  2044: 	else if(extension == "shtm") {ext =    HTML_FILE;}
  2045: 	else if(extension == "html") {ext =    HTML_FILE;}
  2046: 	else if(extension ==  "htm") {ext =    HTML_FILE;}
  2047: 	else if(extension ==  "xml") {ext =    HTML_FILE;}
  2048: 	else if(extension == "sgml") {ext =    HTML_FILE;}
  2049: 	else if(extension == "java") {ext =    JAVA_FILE;}
  2050: 	else if(extension ==   "js") {ext = JSCRIPT_FILE;}
  2051: 	else if(extension ==  "def") {ext =  MODULA_FILE;}
  2052: 	else if(extension ==  "mod") {ext =  MODULA_FILE;}
  2053: 	else if(extension ==  "pas") {ext =  PASCAL_FILE;}
  2054: 	else if(extension ==  "cgi") {ext =    PERL_FILE;}
  2055: 	else if(extension == "plex") {ext =    PERL_FILE;}
  2056: 	else if(extension ==  "plx") {ext =    PERL_FILE;}
  2057: 	else if(extension ==   "pl") {ext =    PERL_FILE;}
  2058: 	else if(extension ==   "pm") {ext =    PERL_FILE;}
  2059: 	else if(extension ==  "inc") {ext =     PHP_FILE;}
  2060: 	else if(extension == "php4") {ext =     PHP_FILE;}
  2061: 	else if(extension == "php3") {ext =     PHP_FILE;}
  2062: 	else if(extension ==  "php") {ext =     PHP_FILE;}
  2063: 	else if(extension ==  "pbl") {ext =     PB6_FILE;}
  2064: 	else if(extension ==  "pbr") {ext =     PB6_FILE;}
  2065: 	else if(extension ==  "pyw") {ext =  PYTHON_FILE;}
  2066: 	else if(extension ==   "py") {ext =  PYTHON_FILE;}
  2067: 	else if(extension ==   "sl") {ext =  RENDER_FILE;}
  2068: 	else if(extension ==  "rib") {ext =  RENDER_FILE;}
  2069: 	else if(extension ==   "rb") {ext =    RUBY_FILE;}
  2070: 	else if(extension ==  "sql") {ext =     SQL_FILE;}
  2071: 	else if(extension ==   "sh") {ext =   SHELL_FILE;}
  2072: 	else if(extension ==  "tcl") {ext =     TCL_FILE;}
  2073: 	else if(extension ==   "tk") {ext =     TCL_FILE;}
  2074: 	else if(extension ==   "uc") {ext = USCRIPT_FILE;}
  2075: 	else if(extension ==    "v") {ext =    VHDL_FILE;}
  2076: 	else if(extension == "vhdl") {ext =    VHDL_FILE;}
  2077: 	else if(extension ==  "vhd") {ext =    VHDL_FILE;}
  2078: 
  2079: 	else ext = TEXT_FILE;
  2080: 	return ext;
  2081: }
  2082: // determines the language for syntax highlighting ----------------------------
  2083: string Driver::checkExt(string filename) {
  2084: 
  2085:  clean();
  2086: 
  2087:  char filetype = getExt(filename);
  2088: 
  2089:  switch(filetype) {
  2090:   case (ADA_FILE)     : lang = new LangAda95;      return "Ada file";
  2091:   case (ASM_FILE)     : lang = new LangAssembler;  return "Assembly file";
  2092:   case (ASP_FILE)     : lang = new LangAsp;        return "ASP file";
  2093:   case (BASIC_FILE)   : lang = new LangBasic;      return "Basic file";
  2094:   case (BATCH_FILE)   : lang = new LangBatch;      return "DOS Batch file";
  2095:   case (C_FILE)       : lang = new LangC;          return "'C' file";
  2096:   case (CPP_FILE)     : lang = new LangCPlusPlus;  return "C++ file";
  2097:   case (CG_FILE)      : lang = new LangCg;         return "NVIDIA Cg file";
  2098:   case (CLIPS_FILE)   : lang = new LangClips;      return "NASA CLIPS file";
  2099:   case (CSHARP_FILE)  : lang = new LangCSharp;     return "C-Sharp file";
  2100:   case (OBJC_FILE)    : lang = new LangObjectiveC; return "Objective-C file";
  2101:   case (EMF_FILE)     : lang = new LangEmf;        return "MicroEmacs macro file";
  2102:   case (U4EA_FILE)    : lang = new LangEuphoria;   return "Euphoria file";
  2103:   case (FORTRAN_FILE) : lang = new LangFortran;    return "Fortran file";
  2104:   case (HASKELL_FILE) : lang = new LangHaskell;    return "Haskell file";
  2105:   case (HTML_FILE)    : lang = new LangHtml;       return "Markup file";
  2106:   case (JAVA_FILE)    : lang = new LangJava;       return "Java file";
  2107:   case (JSCRIPT_FILE) : lang = new LangJScript;    return "Java script";
  2108:   case (MODULA_FILE)  : lang = new LangModula2;    return "Modula file";
  2109:   case (PASCAL_FILE)  : lang = new LangPascal;     return "Pascal file";
  2110:   case (PERL_FILE)    : lang = new LangPerl;       return "Perl script";
  2111:   case (PHP_FILE)     : lang = new LangPhp;        return "PHP script";
  2112:   case (PB6_FILE)     : lang = new LangPBuilder;   return "Power Builder file";
  2113:   case (PYTHON_FILE)  : lang = new LangPython;     return "Python script";
  2114:   case (RUBY_FILE)    : lang = new LangRuby;       return "Ruby script";
  2115:   case (RENDER_FILE)  : lang = new LangRenderMan;  return "RenderMan file";
  2116:   case (SQL_FILE)     : lang = new LangSQL;        return "SQL script";
  2117:   case (SHELL_FILE)   : lang = new LangShell;      return "UNIX shell script";
  2118:   case (TCL_FILE)     : lang = new LangTcl;        return "Tcl script";
  2119:   case (USCRIPT_FILE) : lang = new LangUScript;    return "UnrealScript";
  2120:   case (VHDL_FILE)    : lang = new LangVHDL;       return "VHDL file";
  2121:   default             : lang = new LangText;       return "Text file";
  2122:  }
  2123: }
  2124: //-----------------------------------------------------------------------------
  2125: // prepare input and output files ---------------------------------------------
  2126: bool Driver::prep_files(string ifile, string ofile, char over) {
  2127: 
  2128: 	if(ofile == "--auto" || ofile == "-A") {ofile = ifile + ".html";}
  2129: 
  2130: 	iFile = ifile;
  2131: 	oFile = ofile;
  2132: 
  2133: 	if(ifile == "-" || ifile == "--pipe") {lang->IO.toggleImode();}
  2134: 	else if(!lang->IO.openR(ifile))    {return false;}
  2135: 
  2136: 	if(ofile == "-" || ofile == "--pipe") {lang->IO.toggleOmode();}
  2137: 	else if(!lang->IO.open(ofile,over)) {return false;}
  2138: 	//over?FORCE_OVERWRITE:MODE_WRITE)
  2139: 	return true;
  2140: }
  2141: // returns the filename without the full path ---------------------------------
  2142: string Driver::getTitle() {
  2143: 
  2144: 	int slash = iFile.rfind(DIRECTORY_SLASH);
  2145: 	if(slash == -1) {
  2146: 		return iFile;
  2147: 	}
  2148: 	return iFile.substr(slash+1);
  2149: }
  2150: // run the webcpp engine ------------------------------------------------------
  2151: void Driver::drive() {
  2152: 
  2153: 	clock_t time_beg,time_end,time_dif;
  2154: 	time_beg = clock();
  2155: 
  2156: 	// get the filesize
  2157: 	ifstream Count;
  2158: 	string tmp;
  2159: 	int percent = 0;
  2160: 
  2161: 	Count.open(iFile.data());
  2162: 	while (Count) {
  2163: 		getline(Count,tmp);
  2164: 		percent++;
  2165: 	}
  2166: 	percent--;
  2167: 	Count.close();
  2168: 	// to compare against progress
  2169: 
  2170: 	lang->begHtml(getTitle());
  2171: 	lang->doParsing();
  2172: 	while(lang->IO.ifile && cin) {
  2173: 		lang->doParsing();
  2174: 
  2175: 		if( ((lang->getLineCount()*100)/percent) < 101 ) {
  2176: 
  2177: 			cerr << '\r';
  2178: 
  2179: 			if(!lang->IO.isIredir()) {
  2180: 
  2181: 				cerr	<< ((lang->getLineCount() * 100) / percent)
  2182: 					<< "% Complete ";
  2183: 			}
  2184: 			cerr << "@ line " << lang->getLineCount()-1;
  2185: 		}
  2186: 	}
  2187: 	lang->endHtml();
  2188: 
  2189: 	time_end = clock();
  2190: 	time_dif = time_end - time_beg;
  2191: 
  2192: 	cerr << " took " << setprecision(3)
  2193: 			 << (double) time_dif / CYCLE_SPEED << " seconds.\n";
  2194: 
  2195: 	lang->IO.close();
  2196: }
  2197: //-----------------------------------------------------------------------------
  2198: void Driver::makeIndex(string prefix) {
  2199: 
  2200: 	CFfile Index;
  2201: 	if(!Index.openR("webcppbatch.txt")){return;}
  2202: 	if(!Index.openW(prefix + "files.html",true)){return;}
  2203: 
  2204: 	string file;
  2205: 	Theme theme;
  2206: 
  2207: 	Index	<< "<html>\n<head>\n<title>source index</title>\n"
  2208: 		<< "<style type=\"text/css\">\n\n"
  2209: 		<< theme.getCSSdata() << "</style>\n"
  2210: 		<< "</head>\n<body>\n\n";
  2211: 
  2212: 	getline(Index.ifile,file);
  2213: 	while(Index.ifile) {
  2214: 
  2215: 		file = "<a href=\"" + file + ".html\">" + file + "</a>";
  2216: 
  2217: 		Index << file << "<br>\n";
  2218: 		getline(Index.ifile,file);
  2219: 	}
  2220: 
  2221: 	Index << "\n</body>\n</html>";
  2222: }
  2223: //-----------------------------------------------------------------------------
  2224: void Driver::clean() {
  2225: 
  2226: 	if( lang != NULL ) {
  2227: 		delete lang;
  2228: 		lang = NULL;
  2229: 	}
  2230: }
  2231: //-----------------------------------------------------------------------------
  2232: /* webcpp - engine.cpp
  2233:  * Copyright (C)2001-2003 Jeffrey Bakker
  2234: 
  2235:  * This program is free software; you can redistribute it and/or modify
  2236:  * it under the terms of the GNU General Public License as published by
  2237:  * the Free Software Foundation; either version 2 of the License, or
  2238:  * (at your option) any later version.
  2239: 
  2240:  * This program is distributed in the hope that it will be useful,
  2241:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2242:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2243:  * GNU General Public License for more details.
  2244: 
  2245:  * You should have received a copy of the GNU General Public License
  2246:  * along with this program; if not, write to the Free Software
  2247:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2248:    ___________________________________ .. .
  2249:  */
  2250: 
  2251: //--build=i386-linux --host=i386-linux --target=i386-linux
  2252: 
  2253: #include <cctype> 
  2254: #include <cstdlib> 
  2255: #include "engine.h" 
  2256: using namespace std;
  2257: 
  2258: #define DEBUG_DO_PARSING false 
  2259: 
  2260: #define PARSE_DBL_QUO_STRING parseString(DBL_QUOTES,inDblQuotes) 
  2261: #define PARSE_SIN_QUO_STRING parseString(SIN_QUOTES,inSinQuotes) 
  2262: #define PARSE_BCK_QUO_STRING parseString(BCK_QUOTES,inBckQuotes) 
  2263: 
  2264: #define PARSE_A_MARKUP_COMNT parseBigComment("&lt;!-", "--&gt;", inComment) 
  2265: #define PARSE_PAS_MOD2_COMNT parseBigComment("(*", "*)", inComment) 
  2266: #define PARSE_CLASSICC_COMNT parseBigComment("/*", "*/", inComment) 
  2267: #define PARSE_HASKL_98_COMNT parseBigComment("{-", "-", inComment) 
  2268: #define PARSE_HTML_TAGS      parseBigComment("&lt;", "&gt;", inHtmTags) 
  2269: 
  2270: #define PARSE_A_MS_ASP_COMNT parseComment("'") 
  2271: #define PARSE_A_ADA_95_COMNT parseComment("--") 
  2272: #define PARSE_C_INLINE_COMNT parseComment("//") 
  2273: #define PARSE_UNIXHASH_COMNT parseComment("#") 
  2274: #define PARSE_ASSEMBLY_COMNT parseComment(";") 
  2275: #define PARSE_DBLCOLON_COMNT parseComment("::") 
  2276: #define PARSE_REMINDER_COMNT \ 
  2277: parseComment("REM"); \
  2278: parseComment("rem")
  2279: 
  2280: #define PARSE_ZEROHASH_COMNT parseCharZeroComment('#') 
  2281: #define PARSE_ZFORTRAN_COMNT \ 
  2282: parseCharZeroComment('C'); \
  2283: parseCharZeroComment('c'); \
  2284: parseCharZeroComment('*'); \
  2285: parseCharZeroComment('!')
  2286: 
  2287: #define PARSE_ASSEMBLY_MACRO parseVariable("%") 
  2288: #define PARSE_SCALAR_VARIABL parseVariable("$") 
  2289: #define PARSE_ARRAYS_VARIABL parseVariable("@") 
  2290: #define PARSE_HASHED_VARIABL parseVariable("%") 
  2291: 
  2292: #define PRE_PARSE_CODE       pre_parse() 
  2293: #define PARSE_PREPROCESSOR   parsePreProc() 
  2294: #define PARSE_LABELS         parseLabel() 
  2295: #define PARSE_KEYWORDS       parseKeys() 
  2296: #define PARSE_NUMBERS        parseNum() 
  2297: 
  2298: 
  2299: // initialize data members ----------------------------------------------------
  2300: void Engine::init_switches() {
  2301: 
  2302: 	// command line options
  2303: 	opt_bigtab  = false;
  2304: 	opt_webcpp  = false;
  2305: 	opt_hypinc  = false;
  2306: 	opt_follow  = false;
  2307: 	opt_number  = false;
  2308: 	opt_extcss  = false;
  2309: 	opt_anchor  = false;
  2310: 
  2311: 	// abort switches
  2312: 	inHtmTags   = false;
  2313: 	inDblQuotes = false;
  2314: 	inSinQuotes = false;
  2315: 	inBckQuotes = false;
  2316: 	inComment   = false;
  2317: 	endComment  = false;
  2318: 
  2319: 	// common language
  2320: 	doStrings   = Yes;
  2321: 	doNumbers   = Yes;
  2322: 	doKeywords  = Yes;
  2323: 	doCaseKeys  = Yes;
  2324: 	doSymbols   = No;
  2325: 	doLabels    = No;
  2326: 	doPreProc   = No;
  2327: 	doScalars   = No;
  2328: 	doArrays    = No;
  2329: 	doHashes    = No;
  2330: 	doHtmlTags  = No;
  2331: 	doHtmComnt  = No;
  2332: 	doHskComnt  = No;
  2333: 	doPasComnt  = No;
  2334: 	doBigComnt  = No;
  2335: 	doCinComnt  = No;
  2336: 	doUnxComnt  = No;
  2337: 	doAsmComnt  = No;
  2338: 	doRemComnt  = No;
  2339: 	doAdaComnt  = No;
  2340: 	doFtnComnt  = No;
  2341: 	doTclComnt  = No;
  2342: 	doAspComnt  = No;
  2343: 	doBatComnt  = No;
  2344: 
  2345: 	lncount  = 1;
  2346: 	tabwidth = 8;
  2347: 	tw = "8";
  2348: 	
  2349: 	IO.init_switches();
  2350: }
  2351: // set the width of the tabs --------------------------------------------------
  2352: void Engine::setTabWidth(string width) {
  2353: 
  2354: 	tabwidth = atoi(width.data());
  2355: 	if(tabwidth == 0) {
  2356:         	tabwidth = 8;
  2357: 		tw = "8";
  2358: 	}
  2359: 	tw = width;
  2360: }
  2361: // format the plain text for proper display in HTML ---------------------------
  2362: void Engine::pre_parse() {
  2363: 
  2364: 	// the virtual Nth character factoring in for escapes
  2365: 	int i_esc = 0;
  2366: 
  2367: 	for (int i=0; i < (int)buffer.size(); i++) {
  2368: 
  2369: 		// escape from HTML escapes
  2370: 		if (buffer[i] == '&') {buffer.replace(i,1,"&amp;");i_esc+=4;}
  2371: 		else
  2372: 		if (buffer[i] == '<') {buffer.replace(i,1, "&lt;");i_esc+=3;}
  2373: 		else
  2374: 		if (buffer[i] == '>') {buffer.replace(i,1, "&gt;");i_esc+=3;}
  2375: 		// escape from accidental HTML tags
  2376: 
  2377: 		if (opt_bigtab)
  2378: 		// convert tabs into spaces
  2379: 		if (buffer[i] == '\t') {
  2380: 
  2381: 			int j;
  2382: 			buffer.erase(i,1);
  2383: 
  2384: 			// factor in the number of escapes
  2385: 			if((i-i_esc) % tabwidth == 0) {
  2386: 
  2387: 				for(j=0; j < tabwidth; j++) {
  2388: 
  2389: 					buffer.insert(i," ");
  2390: 				}
  2391: 				i+=tabwidth-1;
  2392: 			}else{
  2393: 				int spaces = tabwidth - ((i-i_esc) % tabwidth);
  2394: 
  2395: 				for(j=0; j < spaces; j++) {
  2396: 
  2397: 					buffer.insert(i," ");
  2398: 				}
  2399: 				i+=spaces-1;
  2400: 			}
  2401: 		}
  2402: 		// for browsers that don't display tabs properly
  2403: 	}
  2404: }
  2405: // erases tags (use for inside of inline comments) ----------------------------
  2406: void Engine::eraseTags(int start, int fin) {
  2407: 
  2408: 	if(fin ==  0) {fin = buffer.size();}
  2409: 	if(fin == -1) {fin = buffer.size();}
  2410: 
  2411: 	int erase1, erase2;
  2412: 	int offset1, offset2;
  2413: 	string srchstr;
  2414: 
  2415: 	srchstr = "<font CLASS=";
  2416: 	offset1 = 20;
  2417: 	offset2 = 7;
  2418: 
  2419: 	// erase all the colours previously made
  2420: 	while(buffer.find(srchstr,start) != -1 &&
  2421: 	      buffer.find(srchstr,start) < fin) {
  2422: 
  2423: 		//erasing opening font tags
  2424: 		erase1 = buffer.find(srchstr,start);
  2425: 		if(erase1 != -1 && erase1 < fin) {
  2426: 			buffer.erase(erase1,offset1);
  2427: 		}
  2428: 		//erasing closing font tags
  2429: 		erase2 = buffer.find("</font>",start);
  2430: 		if(erase2 != -1 && erase2 < fin) {
  2431: 			buffer.erase(erase2,offset2);
  2432: 		}
  2433: 	}
  2434: 	inDblQuotes = false;
  2435: 	inSinQuotes = false;
  2436: 	inBckQuotes = false;
  2437: }
  2438: // anchors the line (for hyperlinking capabilities) ---------------------------
  2439: void Engine::makeAnchor() {
  2440: 
  2441: 	IO << "<a name=\"line" << lncount << "\"/>";
  2442: }
  2443: // prints the line number in the margin ---------------------------------------
  2444: void Engine::makeMargin() {
  2445: 
  2446: 	string space = "";
  2447: 
  2448: 	// setting margin alignment
  2449: 	if(lncount < 100000)	{space += " ";}
  2450: 	if(lncount < 10000)	{space += " ";}
  2451: 	if(lncount < 1000)	{space += " ";}
  2452: 	if(lncount < 100)	{space += " ";}
  2453: 	if(lncount < 10)	{space += " ";}
  2454: 
  2455: 	IO	<< space	<< "<font CLASS=comment>"
  2456: 		<< lncount	<< ":</font> ";
  2457: }
  2458: //-----------------------------------------------------------------------------
  2459: // check if parsing needs to be aborted ---------------------------------------
  2460: bool Engine::abortParse() {
  2461: 
  2462: //	if(doHtmlTags && inHtmTags)
  2463: //			{return true;}
  2464: 
  2465: 	if(endComment)	{return true;}
  2466: 	if(inDblQuotes)	{return true;}
  2467: 	if(!doAspComnt)	{
  2468: 	if(inSinQuotes)	{return true;}
  2469: 	}
  2470: 	if(inBckQuotes)	{return true;}
  2471: 	if(inComment)	{return true;}
  2472: 
  2473: 	return false;
  2474: }
  2475: // check if colouring needs to be aborted -------------------------------------
  2476: bool Engine::abortColour(int index) {
  2477: 
  2478: 	if(doHtmComnt
  2479: 	&& ( isInsideIt(index,"&lt;","&gt;")
  2480: 	&&   isInsideIt(index,"&gt;","&lt;") ))	{return true;}
  2481: 	if(isInsideIt(index,"/*","*/"))		{return true;}
  2482: 	if(isInsideIt(index,"(*","*)"))		{return true;}
  2483: 	if(isInsideIt(index,"&lt;!","&gt;"))	{return true;}
  2484: 	if(isInsideIt(index,"\"","\""))		{return true;}
  2485: 	if(!doAspComnt) {
  2486: 		if(isInsideIt(index,"'","'"))	{return true;}
  2487: 	}
  2488: 	if(isInsideIt(index,"`","`"))		{return true;}
  2489: 
  2490: 	return false;
  2491: }
  2492: // check if the index is inside the specified boundaries ----------------------
  2493: bool Engine::isInsideIt(int index, string start, string end) {
  2494: 
  2495: 	// count the number of starts and ends
  2496: 	// and return true for an odd number
  2497: 	
  2498: 	if(buffer.find(start,0) == -1) {return false;}
  2499: 
  2500: 	int l = 0;
  2501: 	int r = 0;
  2502: 	int idx;
  2503: 
  2504: 	idx = buffer.find(end,index);
  2505: 	while(idx < buffer.size()) { // idx < string::npos && idx != -1
  2506: 		if(idx != -1 && buffer[idx-1] != '\\'){r++;}
  2507: 		idx = buffer.find(end,idx+1);
  2508: 	}
  2509: 
  2510: 	idx = buffer.rfind(start,index);
  2511: 	while(idx > 0) {
  2512: 		if(idx != -1 && buffer[idx-1] != '\\'){l++;}
  2513: 		idx = buffer.rfind(start,idx-1);
  2514: 	}
  2515: 
  2516: 	if(r % 2 == 1 && l % 2 == 1) {return true;}
  2517: 
  2518: 	return false;
  2519: }
  2520: // for HTML highlighting ------------------------------------------------------
  2521: bool Engine::isInsideTag(int index) {
  2522: 
  2523: 	return false;
  2524: }
  2525: // number accuracy ------------------------------------------------------------
  2526: bool Engine::isNotWord(int index) {
  2527: 
  2528: 	if(isalpha(buffer[index+1]))		{return false;}
  2529: 
  2530: 	while(index > 0) {
  2531: 
  2532: 		if(isalpha(buffer[index]))	{return false;}
  2533: 		if(buffer[index] == '_')	{return false;}
  2534: 		if(buffer[index] == '#')	{return false;}
  2535: 
  2536: 		if(ispunct(buffer[index]) ||
  2537: 		   isspace(buffer[index]))	{return true;}
  2538: 		index--;
  2539: 	}
  2540: 	return true;
  2541: }
  2542: // parse for preprocessor directives ------------------------------------------
  2543: void Engine::parsePreProc() {
  2544: 
  2545: 	if(abortParse())     {return;}
  2546: 	if(buffer[0] != '#') {return;}
  2547: 
  2548: 	if(opt_hypinc) {
  2549: 		hyperIncludeMe();
  2550: 	}
  2551: 
  2552: 	buffer += " ";
  2553: 	buffer.insert(0, "<font CLASS=preproc>");
  2554: 
  2555: 	int end;
  2556: 	for(int i=8;i<buffer.size();i++) {
  2557: 		if(isspace(buffer[i])) {end = i;i=buffer.size();}
  2558: 	}
  2559: 	buffer.insert(end, "</font>");
  2560: }
  2561: // define symbol characters ---------------------------------------------------
  2562: bool Engine::isSymbol(char c) {
  2563: 
  2564: 	switch(c) {
  2565: 
  2566: //			case '*':
  2567: 			case '!':
  2568: 			case '|':
  2569: //			case '&':
  2570: //			case '<':
  2571: //			case '>':
  2572: //			case '{':
  2573: //			case '}':
  2574: //			case '[':
  2575: //			case ']':
  2576: //			case '(':
  2577: //			case ')':
  2578: //			case ':':
  2579: 			case '-':
  2580: 			case '=':
  2581: 			case '+': return true;
  2582: 			default : return false;
  2583: 	}
  2584: }
  2585: // parse for symbols ----------------------------------------------------------
  2586: void Engine::parseSymbol() {
  2587: 
  2588: 	if(abortParse()) {return;}
  2589: 
  2590: 	int	end;
  2591: 	int	insert = 0;
  2592: 
  2593: 	for(int i=0; i < buffer.size(); i++) {
  2594: 
  2595: 		if(isSymbol(buffer[i])) {
  2596: 
  2597: 			end = i;
  2598: 			while(isSymbol(buffer[end+1])) {end++;}
  2599: 
  2600: 			if(colourSymbol(i,end)) {
  2601: 
  2602: 				insert += 27;
  2603: 				i = end + insert;
  2604: 			}
  2605: 		}
  2606: 	}
  2607: // currently enabled for:
  2608: // C,C++,Cg,C#,Objective C,Java,Perl,PHP,Python,UScript
  2609: }
  2610: // colour the symbols ---------------------------------------------------------
  2611: bool Engine::colourSymbol(int s, int f) {
  2612: 
  2613: 	if(abortColour(s)) {return false;}
  2614: 	if(!isNotWord(s))  {return false;}
  2615: 
  2616: 	buffer.insert(s,"<font CLASS=symbols>");
  2617: 	buffer.insert(f+21,"</font>");
  2618: 
  2619: 	return true;
  2620: }
  2621: // parse labels ---------------------------------------------------------------
  2622: void Engine::parseLabel() {
  2623: 
  2624: 	if(abortParse()) {return;}
  2625: 
  2626: 	if(buffer.find("/*") != -1) {return;} //prevent comment loop
  2627: 	if(buffer.find("(*") != -1) {return;}
  2628: 
  2629: 
  2630: 	int end, beg;
  2631: 	
  2632: 	end = buffer.size()-1;
  2633: 	beg = buffer.rfind(" ",end);
  2634: 
  2635: 	if(beg == -1) {beg = 0;}
  2636: 	if(buffer[end] == ':') {
  2637: 		colourLabel(beg,end);
  2638: 	}
  2639: }
  2640: // colourize the labels -------------------------------------------------------
  2641: void Engine::colourLabel(int beg, int end) {
  2642: 
  2643: 	if(abortColour(beg)) {return;}
  2644: 	buffer.insert(beg,"<font CLASS=preproc>");
  2645: 	buffer.insert(end+21,"</font>");
  2646: }
  2647: //-----------------------------------------------------------------------------
  2648: // parse the buffer for numbers -----------------------------------------------
  2649: void Engine::parseNum()
  2650: {
  2651: 	if(buffer[0] == '#') {return;}
  2652: 	if(abortParse())     {return;}
  2653: 
  2654: 	vector<int>	nums;
  2655: 	vector<int>	ends;
  2656: 	int  end, insert;
  2657: 
  2658: 	// grab indexes of all numbers into the vector
  2659: 	for(int i=0; i < buffer.size(); i++) {
  2660: 
  2661: 		if(isdigit(buffer[i]) && !isalpha(buffer[i-1])) {
  2662: 			end = i;
  2663: 
  2664: 			while(isdigit(buffer[end+1]) ||
  2665: 				  (buffer[end+1] == '.'  &&
  2666: 				  isdigit(buffer[end+2])))
  2667: 			{end++;}
  2668: 
  2669: 			nums.push_back(i);
  2670: 			ends.push_back(end);
  2671: 			i=end;
  2672: 		}
  2673: 	}
  2674: 	// now colour each number
  2675: 	for(int j=0; j < (int)ends.size(); j++) {
  2676: 
  2677: 		if(j == 0) {insert = 0;}
  2678: 		else       {insert += 27;}
  2679: 
  2680: 		if(!colourNum(nums[j]+insert, ends[j]+insert)) {
  2681: 			insert -= 27;
  2682: 		}
  2683: 	}
  2684: 
  2685: }
  2686: // insert number highlighting tags --------------------------------------------
  2687: bool Engine::colourNum(int s, int f) {
  2688: 
  2689: 	if(abortColour(s)) {return false;}
  2690: 	if(!isNotWord(s))  {return false;}
  2691: 
  2692: 	string cssclass;
  2693: 	int fpt;
  2694: 
  2695: 	fpt = buffer.find(".",s);
  2696: 
  2697: 	if(fpt != -1 && fpt < f) {
  2698: 
  2699:  		cssclass = "<font CLASS=floatpt>";
  2700: 	} else
  2701:         	cssclass = "<font CLASS=integer>";
  2702: 
  2703: 
  2704: 	// insert the font tags
  2705: 	buffer.insert(s,	cssclass);
  2706: 	buffer.insert(f+21,	"</font>");
  2707: 	
  2708: 	return true;
  2709: }
  2710: //-----------------------------------------------------------------------------
  2711: // parse the buffer for strings -----------------------------------------------
  2712: void Engine::parseString(char quotetype, bool &inside) {
  2713: 
  2714: 	if(doAdaComnt && !doRemComnt && quotetype == SIN_QUOTES) {return;}
  2715: 	if(doAspComnt && quotetype == SIN_QUOTES) {return;}
  2716: 
  2717: 	string quote, escap1, escap2, cssclass;
  2718: 	int index,offset;
  2719: 	index = 0;
  2720: 
  2721: // Support for 3 different string types
  2722: 	if       (quotetype == DBL_QUOTES) {	
  2723: 		if(inSinQuotes || inBckQuotes) {return;}
  2724: 
  2725: 		quote  = "\"";
  2726: 		
  2727: 		// Asp uses single ticks for comments and this
  2728: 		// screws up if a double-quoted line is commented out
  2729: 		if (!doAspComnt) {
  2730: 			escap1 = "'";
  2731: 		} else {
  2732: 			escap1 = "`";
  2733: 		}
  2734: 		escap2 = "`";
  2735: 
  2736: 		cssclass = "dblquot";
  2737: 
  2738: 	} else if(quotetype == SIN_QUOTES) {
  2739: 		if(inDblQuotes || inBckQuotes) {return;}
  2740: 
  2741: 		quote  = "'";
  2742: 		escap1 = "\"";
  2743: 		escap2 = "`";
  2744: 
  2745: 		cssclass = "sinquot";
  2746: 
  2747: 	} else if(quotetype == BCK_QUOTES) {
  2748: 		if(inDblQuotes || inSinQuotes) {return;}
  2749: 
  2750: 		quote  = "`";
  2751: 		escap1 = "\"";
  2752: 		escap2 = "'";
  2753: 
  2754: 		cssclass = "preproc";
  2755: 	}
  2756: // Double, single, and back quoted ///
  2757: 
  2758: 
  2759: 	index = buffer.find(quote,index);
  2760: 	if(index == -1) {return;}
  2761: 
  2762: 	while (index < string::npos) {
  2763: 
  2764: 		if(buffer[index -1] == '\\') {
  2765: 			if(buffer[index -2] == '\'' && buffer[index +1] == '\'') {
  2766: 				index = buffer.find(quote,index+1);
  2767: 			}
  2768: 		}
  2769: 		if(index == -1) {return;}
  2770: 
  2771: 		while(isInsideIt(index,escap1,escap1)){
  2772: 			index = buffer.find(quote,index +1);
  2773: 			if(index == -1) {return;}
  2774: 		}
  2775: 		while(isInsideIt(index,escap2,escap2)){
  2776: 			index = buffer.find(quote,index +1);
  2777: 			if(index == -1) {return;}
  2778: 		}
  2779: 
  2780: 		while(doHtmComnt && isInsideIt(index,"&gt;","&lt;") ) {
  2781: 			index = buffer.find(quote,index +1);
  2782: 			if(index == -1) {return;}
  2783: 		}
  2784: 
  2785: 		// keep escape characters in mind
  2786: 		while	(buffer[index -1] == '\\' &&
  2787: 			(buffer[index -2] != '\\' ||
  2788: 			(buffer[index -3] == '\\' &&
  2789: 			 buffer[index -4] != '\\'))) {
  2790: 
  2791: 			index = buffer.find(quote,index +1);
  2792: 			if(index == -1) {return;}
  2793: 		}
  2794: 
  2795: 		if(index != -1 	&& !inComment) {
  2796: 
  2797: 			colourString(index, inside, cssclass);
  2798: 		}
  2799: 
  2800: 		if(inside) {offset = index + 21;}
  2801: 		else       {offset = index +  7;}
  2802: 
  2803: 		index = buffer.find(quote,offset);
  2804: 		if(index == -1)          {return;}
  2805: 		if(index > buffer.size()){return;}
  2806: 	}
  2807: }
  2808: // insert string highlighting tags --------------------------------------------
  2809: void Engine::colourString(int index, bool &inside, string cssclass) {
  2810: 
  2811: 	if(index > buffer.size()){return;}
  2812: 
  2813: 	string fntag = "<font CLASS=" + cssclass + ">";
  2814: 
  2815: 	// open tag
  2816: 	if(!inside) {
  2817: 		buffer.insert(index,   fntag);
  2818: 	} else {
  2819: 		buffer.insert(index+1, "</font>");
  2820: 	}
  2821: 	// or close tag
  2822: 	// depending on whether or not inside
  2823: 
  2824: 	inside = !inside;
  2825: }
  2826: // parse for multi-line comments ----------------------------------------------
  2827: void Engine::parseBigComment(string start, string end, bool &inside) {
  2828: 
  2829: 	string search, escap, css;
  2830: 	int index,offset;
  2831: 	bool erase;
  2832: 
  2833: 	index = 0;
  2834: 	erase = true;
  2835: 	css = "comment";
  2836: 
  2837: 	if(inside) {search = end;}
  2838: 	else {search = start;}
  2839: 	
  2840: 	index = buffer.find(search,index);
  2841: 	if(index == -1) {return;}
  2842: 	if(doCinComnt && start == "/*" && buffer.find("//") < index) {return;}
  2843: 	if(doUnxComnt && start == "/*" && buffer.find("#")  < index) {return;}
  2844: 
  2845: 	if(start == "&lt;" && end == "&gt;" && doHtmlTags) {
  2846: 
  2847: 		if(buffer.find("&lt;!-") == index || inHtmTags)
  2848: 			if(!inside)
  2849: 				return;
  2850: 		erase = false;
  2851:         	css = "preproc";
  2852: 	}
  2853: 
  2854: 	while (index < string::npos) {
  2855: 
  2856: 		if(inside) {search = end;}
  2857: 		else {search = start;}		
  2858: 
  2859: 		index = buffer.find(search,index);
  2860: 		if(index == -1) {return;}
  2861: 
  2862: 		if(buffer[index -1] == '\\') {
  2863: 			if(buffer[index -2] == '\'' && buffer[index +1] == '\'') {
  2864: 				index = buffer.find(search,index+1);
  2865: 			}
  2866: 		}
  2867: 		if(index == -1) {return;}
  2868: 		if(!isInsideIt(index, "\"", "\"") &&
  2869: 		   !isInsideIt(index, "'", "'")   &&
  2870: 		   !isInsideIt(index, "`", "`")) {
  2871: 			if(inside) {
  2872: 				index += end.size()-1;
  2873: 		                if(buffer.find(end) == -1) {endComment = true;}
  2874: 			}
  2875: 			else if(erase)eraseTags(index,0);
  2876: 			colourString(index, inside, css);
  2877: 		}
  2878: 
  2879: 		if(inside) {
  2880: 			offset = index + 21;
  2881: 			search = end;
  2882: 		}
  2883: 		else {
  2884: 			offset = index +  7;
  2885: 			search = start;
  2886: 		}
  2887: 
  2888: 		index = buffer.find(search,offset);
  2889: 		if(index == -1)          {return;}
  2890: 		if(index > buffer.size()){return;}
  2891: 	}
  2892: }
  2893: // parse for keywords ---------------------------------------------------------
  2894: void Engine::parseKeys() {
  2895: 
  2896: 	if(buffer[0] == '#') {return;}
  2897: 	if(abortParse())     {return;}
  2898: 
  2899: 	int i, index, offset = 20;
  2900: 	string cmpkey;
  2901: 
  2902: 	for(i=0; i < (int)keys.size(); i++) {
  2903: 
  2904: 		cmpkey	= keys[i];
  2905: 		index	= noCaseFind(cmpkey,0);
  2906: 
  2907: 		while(index < buffer.size() && index != -1) {
  2908: 
  2909: 			if(isKey(index-1, (index) + keys[i].size())) {
  2910: 				colourKeys(index, keys[i], "keyword");
  2911: 			}
  2912: 			index = noCaseFind(cmpkey,(index+cmpkey.size()+offset));
  2913: 		}
  2914: 	}
  2915: 
  2916: 	for(i=0; i < (int)types.size(); i++) {
  2917: 
  2918: 		cmpkey	= types[i];
  2919: 		index	= noCaseFind(cmpkey,0);
  2920: 
  2921: 		while(index < buffer.size() && index != -1) {
  2922: 
  2923: 			if(isKey(index-1, (index) + types[i].size())) {
  2924: 				colourKeys(index, types[i], "keytype");
  2925: 			}
  2926: 			index = noCaseFind(cmpkey,(index+cmpkey.size()+offset));
  2927: 		}
  2928: 	}
  2929: }
  2930: // checks for case sensitive keys ---------------------------------------------
  2931: int Engine::noCaseFind(string search, int index) {
  2932: 
  2933: 	if(doCaseKeys) {
  2934: 		return buffer.find(search,index);
  2935: 	}
  2936: 	if(search == "class") {
  2937: 		return buffer.find(search,index);
  2938: 	}
  2939: 
  2940: 	string tmp;
  2941: 	tmp = buffer;
  2942: 
  2943: 	for(int i=0; i < tmp.size(); i++) {
  2944: 		tmp[i] = toupper(tmp[i]);
  2945: 	}
  2946: 	for(int j=0; j < search.size(); j++) {
  2947: 		search[j] = toupper(search[j]);
  2948: 	}
  2949: 
  2950: 	return tmp.find(search,index);
  2951: }
  2952: // asserts word boundaries for keywords ---------------------------------------
  2953: bool Engine::isKey(int before, int after) const {
  2954: 
  2955: 	if(buffer[before] == '#')   {return false;}
  2956: 	if(buffer[before] == '_')   {return false;}
  2957: 	if(buffer[after]  == '_')   {return false;}
  2958: 	if(isalnum(buffer[before])) {return false;}
  2959: 	if(isalnum(buffer[after]))  {return false;}
  2960: 
  2961: 	if(ispunct(buffer[before]) || isspace(buffer[before])) {
  2962: 		if(ispunct(buffer[after]) || isspace(buffer[after])) {
  2963: 			return true;
  2964: 		}
  2965: 	}
  2966: 	return true;
  2967: }
  2968: // colourize the keywords -----------------------------------------------------
  2969: void Engine::colourKeys(int index, string key, string cssclass) {
  2970: 
  2971: 	if(abortColour(index)) {
  2972: 		return;
  2973: 	}
  2974: 	buffer.insert(index, "<font CLASS=" + cssclass + ">");
  2975: 	buffer.insert(index+key.size()+20, "</font>");
  2976: }
  2977: //-----------------------------------------------------------------------------
  2978: // parse for variables --------------------------------------------------------
  2979: void Engine::parseVariable(string var) {
  2980: 
  2981: 	int index;
  2982: 	int test;
  2983: 
  2984: 	index = buffer.find(var,0);
  2985: 	test  = buffer.find("#",0);
  2986: 	if(test != -1 && test < index) {return;}
  2987: 
  2988: 	while(index < string::npos) {
  2989: 
  2990: 		if(index != -1) {colourVariable(index);}
  2991: 		index = buffer.find(var,index +22);
  2992: 	}
  2993: }
  2994: // colourize the variables ----------------------------------------------------
  2995: void Engine::colourVariable(int index) {
  2996: 
  2997: 	int end = 0;
  2998: 	buffer.insert(index, "<font CLASS=preproc>");
  2999: 
  3000: 	int i = index+21;
  3001: 
  3002: 	// search for a variable name delimiter
  3003: 	while(!end && i < buffer.size()) {
  3004: 
  3005: 		if(!isalnum(buffer[i])) {
  3006: 			if(buffer[i] == '_')   {i++;}
  3007: 			if(isspace(buffer[i])) {end = i;}
  3008: 			if(ispunct(buffer[i])) {end = i;}
  3009: 			if(buffer[i] ==  '=')  {end = i;}
  3010: 			if(buffer[i] ==  ',')  {end = i;}
  3011: 			if(buffer[i] ==  '{')  {end = i;}
  3012: 			if(buffer[i] ==  '[')  {end = i;}
  3013: 			if(buffer[i] ==  '(')  {end = i;}
  3014: 			if(buffer[i] == '\'')  {end = i;}
  3015: 			if(buffer[i] == '\n')  {end = i;}
  3016: 		}
  3017: 		if(i == buffer.size() -1)  {end = i+1;}
  3018: 		else i++;
  3019: 	}
  3020: 
  3021: 	if(buffer[end -1] == '\"')     {end--;}
  3022: 	if(buffer[end -1] == ')')      {end--;}
  3023: 
  3024: 	buffer.insert(end, "</font>");
  3025: }
  3026: //-----------------------------------------------------------------------------
  3027: // check for comments ---------------------------------------------------------
  3028: void Engine::parseComment(string cmnt) {
  3029: 
  3030:   if(inComment) {return;}
  3031: 
  3032: 	int index = buffer.find(cmnt,0);
  3033: 	if(index == -1) {return;}
  3034: 
  3035: // do not misktake HTML attributes for UNIX comments
  3036: 	if(cmnt == "#" && index != -1 && buffer[index -1] != '\\') {
  3037: 		if(index != 0) {
  3038: 			while(buffer[index -1] == '=' && index < string::npos) {
  3039: 				index = buffer.find("#",index+1);
  3040: 			}
  3041: 		}
  3042: 	}	
  3043: //-----------------------------------------------//
  3044: 
  3045: 	if(buffer[index -1] == '$')  {return;}
  3046: 	if(buffer[index -1] == '\\') {return;}
  3047: 
  3048: 	colourComment(index);
  3049: }
  3050: // colour an inline comment ---------------------------------------------------
  3051: void Engine::colourComment(int index) {
  3052: 
  3053: 	if(abortColour(index)) {
  3054: 		return;
  3055: 	}
  3056: 	if(doCinComnt) {
  3057: 		if(buffer.rfind("http:",index) == index -5) {
  3058: 			return;
  3059: 		}
  3060: 	}
  3061: 
  3062: 	// no highlighting inside of comments
  3063: 	eraseTags(index,0);
  3064: 
  3065: 	// insert the font tags
  3066: 	buffer.insert(index, "<font CLASS=comment>");
  3067: 	buffer.insert(buffer.size(), "</font>");
  3068: }
  3069: //-----------------------------------------------------------------------------
  3070: void Engine::parseCharZeroComment(char zchar) {
  3071: 
  3072: 	if(buffer[0] == zchar) {colourComment(0);}
  3073: }
  3074: // here is where the parsing rules apply --------------------------------------
  3075: void Engine::doParsing() {
  3076: 
  3077: 	if(opt_anchor) {
  3078: 		makeAnchor();
  3079: 	}
  3080: 	if(opt_number) {
  3081: 		makeMargin();
  3082: 	}
  3083: 
  3084: 	IO.rline(buffer);
  3085: 
  3086: 	// preformat HTML escapes
  3087: 	PRE_PARSE_CODE;
  3088: 
  3089: 	if(doSymbols) parseSymbol();
  3090: 
  3091: 	if(DEBUG_DO_PARSING) cerr << endl << 0 << ": buffer is: " << buffer << endl;
  3092: 
  3093: 	if(doLabels)   PARSE_LABELS;
  3094: 
  3095: 	if(doStrings)
  3096: 	{
  3097: 		PARSE_DBL_QUO_STRING;
  3098: 		PARSE_SIN_QUO_STRING;
  3099: 		PARSE_BCK_QUO_STRING;
  3100: 	}
  3101: 
  3102: 	if(DEBUG_DO_PARSING) cerr << 1 << ": buffer is: " << buffer << endl;
  3103: 
  3104: 	if(doPreProc)  PARSE_PREPROCESSOR;
  3105: 
  3106: 	if(doPasComnt) PARSE_PAS_MOD2_COMNT;
  3107: 	if(doHtmComnt) PARSE_A_MARKUP_COMNT;
  3108: 	if(doBigComnt) PARSE_CLASSICC_COMNT;
  3109: 	if(doHskComnt) PARSE_HASKL_98_COMNT;
  3110: 	if(doHtmlTags) PARSE_HTML_TAGS;
  3111: 
  3112: 	if(doKeywords) PARSE_KEYWORDS;
  3113: 
  3114: 	if(DEBUG_DO_PARSING) cerr << 2 << ": buffer is: " << buffer << endl;
  3115: 
  3116: 	if(doScalars)  PARSE_SCALAR_VARIABL;
  3117: 	if(doArrays)   PARSE_ARRAYS_VARIABL;
  3118: 	if(doHashes)   PARSE_HASHED_VARIABL;
  3119: 
  3120: 	if(DEBUG_DO_PARSING) cerr << 3 << ": buffer is: " << buffer << endl;
  3121: 
  3122: 	if(doNumbers)  PARSE_NUMBERS;
  3123: 
  3124: 	if(DEBUG_DO_PARSING) cerr << 4 << ": buffer is: " << buffer << endl;
  3125: 
  3126: 	if(doAdaComnt) {PARSE_A_ADA_95_COMNT;}
  3127: 	if(doAspComnt) {PARSE_A_MS_ASP_COMNT;}
  3128: 	if(doCinComnt) {PARSE_C_INLINE_COMNT;}
  3129: 	if(doUnxComnt) {PARSE_UNIXHASH_COMNT;}
  3130: 	if(doAsmComnt) {PARSE_ASSEMBLY_COMNT;}
  3131: 	if(doBatComnt) {PARSE_DBLCOLON_COMNT;}
  3132: 	if(doRemComnt) {PARSE_REMINDER_COMNT;}
  3133: 	if(doFtnComnt) {PARSE_ZFORTRAN_COMNT;}
  3134:  	if(doTclComnt) {PARSE_ZEROHASH_COMNT;}
  3135: 
  3136: 	if(DEBUG_DO_PARSING) cerr << 5 << ": buffer is: " << buffer << endl;
  3137: 
  3138: 	hyperTagMe();
  3139: 	hyperNameMe();
  3140: 	hyperLinkMe();
  3141: 
  3142: 	if(DEBUG_DO_PARSING) cerr << 6 << ": buffer is: " << buffer << endl;
  3143: 
  3144: 	IO << buffer << "\n";
  3145: 
  3146: 	endComment = inComment;
  3147: 
  3148: 	lncount++;
  3149: 	buffer = "";
  3150: }
  3151: //-----------------------------------------------------------------------------
  3152: // write the initial HTML tags ------------------------------------------------
  3153: void Engine::begHtml(string name) {
  3154: 
  3155: 	string gen;
  3156: 	string style;
  3157: 	string openht;
  3158: 
  3159: 	gen = "<!--\n\
  3160: This file was generated by Web C Plus Plus software v0.8.0\n\
  3161: Webcpp Copyright (C)2001, (C)2002, (C)2003 Jeffrey Bakker under the GNU GPL\n\
  3162: Get webcpp at http://webcpp.sf.net\n-->\n\n";
  3163: 
  3164: 	if(opt_extcss) {
  3165: 
  3166: 		Scs2.writeCSS(Scs2.getThemeName() + ".css");
  3167: 
  3168: 		style = "<link rel=\"stylesheet\" type=\"text/css\" href=\""
  3169:               + Scs2.getThemeName() + ".css\"/>\n";
  3170: 
  3171: 	} else {
  3172: 	
  3173: 		style = "<style type=\"text/css\">\n\n"
  3174: 			  + Scs2.getCSSdata() + "</style>\n";
  3175: 	}
  3176: 
  3177: 	openht = "<html>\n<head>\n<title>" + name + "</title>\n"
  3178:            + style + "</head>\n<body>\n<pre>\n\n";
  3179: 
  3180: 	if(IO.isOredir()) {
  3181: 		IO << "Content-Type: text/html\n\n";  // cgi-ready
  3182: 	}
  3183: 	IO << gen << openht;
  3184: }
  3185: // write the closing HTML tags ------------------------------------------------
  3186: void Engine::endHtml() {
  3187: 
  3188: 	IO << "\n\n</pre>\n\n";
  3189: 	if(opt_webcpp) {
  3190: 
  3191: 		string made;
  3192: 		made = "<hr size=4>\n\
  3193: <table cellpadding=3 cellspacing=3 bgcolor=#000000><tr>\n\
  3194: <td bgcolor=#ff0000><tt><font size=+2 color=#000000>w</font></tt></td>\n\
  3195: <td bgcolor=#ffbb00><tt><font size=+2 color=#000000>e</font></tt></td>\n\
  3196: <td bgcolor=#ffff00><tt><font size=+2 color=#000000>b</font></tt></td>\n\
  3197: <td bgcolor=#00ff00><tt><font size=+2 color=#000000>c</font></tt></td>\n\
  3198: <td bgcolor=#0000ff><tt><font size=+2 color=#000000>p</font></tt></td>\n\
  3199: <td bgcolor=#bb00ff><tt><font size=+2 color=#000000>p</font></tt></td>\n\
  3200: </tr><tr><td colspan=6>\n\
  3201: <a href=\"http://webcpp.sf.net\"><center><b>\
  3202: <font color=#ffffff>web c plus plus</font></b></center>\n\
  3203: </a></td></tr>\n\
  3204: </table>";
  3205: 
  3206: 		IO << made;
  3207: 	}
  3208: 
  3209: 	IO << "\n\n</body>\n</html>\n";
  3210: }
  3211: // place HTML tags without being stripped -------------------------------------
  3212: void Engine::hyperTagMe() {
  3213: 
  3214: 	int index;
  3215: 	index = buffer.find("TagMe:",0);
  3216: 	if(index == -1) {return;}
  3217: 	if(abortColour(index)) {
  3218: 		return;
  3219: 	}
  3220: 	buffer.erase(index,6);
  3221: 
  3222: 	for(int i=index; i < buffer.size(); i++) {
  3223: 		if	(buffer.substr(i,4) == "&lt;") buffer.replace(i,4, "<");
  3224: 		else if	(buffer.substr(i,4) == "&gt;") buffer.replace(i,4, ">");
  3225: 	}
  3226: }
  3227: // hyperlink a line of code ---------------------------------------------------
  3228: void Engine::hyperLinkMe() {
  3229: 
  3230: 	int index;
  3231: 	index = buffer.find("LinkMe:",0);
  3232: 	if(index == -1) {return;}
  3233: 	if(abortColour(index)) {
  3234: 		return;
  3235: 	}
  3236: 	string link;
  3237: 	link = buffer.substr(index+7);
  3238: 	buffer.erase(index, buffer.size() - index);
  3239: 
  3240: 	buffer.insert(0, "<a href=\"" + link + "\">");
  3241: 	buffer += "</a>";
  3242: }
  3243: // anchor a line of code ------------------------------------------------------
  3244: void Engine::hyperNameMe() {
  3245: 
  3246: 	int index;
  3247: 	index = buffer.find("NameMe:",0);
  3248: 	if(index == -1) {return;}
  3249: 	if(abortColour(index)) {
  3250: 		return;
  3251: 	}
  3252: 	string name;
  3253: 	name = buffer.substr(index+7);
  3254: 	buffer.erase(index, buffer.size() - index);
  3255: 
  3256: 	buffer.insert(0, "<a name=\"" + name + "\">");
  3257: 	buffer += "</a>";
  3258: }
  3259: // automatically hyperlink included C/C++ files -------------------------------
  3260: void Engine::hyperIncludeMe() {
  3261: 
  3262: 	int incl, insr;
  3263: 
  3264: 	incl = buffer.find("#include",0);
  3265: 	if(incl == -1) {return;}
  3266: 
  3267: 	insr = buffer.find("\"",incl+1);
  3268: 	if(insr == -1) {return;}
  3269: 
  3270: 	string cmd;
  3271: 	string link;
  3272: 	link = buffer.substr(insr);
  3273: 	link = link.substr(0,link.find("\"</font>"));
  3274: 
  3275: 	if(opt_follow) {
  3276: 		// follow and process the include file
  3277: 
  3278: 		cmd = "webcpp " + link.substr(1) + " -A:k -H";
  3279: 		// retain switches from the current file
  3280: 		if(opt_bigtab) {
  3281: 			cmd += " -t";
  3282: 			if(tabwidth != 8) {
  3283: 				cmd += "=";
  3284: 				cmd += tw;
  3285: 			}
  3286: 		}
  3287: 		if(opt_webcpp) cmd += " -m";
  3288: 		if(opt_number) cmd += " -l";
  3289: 		if(opt_anchor) cmd += " -a";
  3290: 		if(opt_extcss) cmd += " -X";
  3291: 
  3292: 		if(Scs2.getThemeName() != "typical") {
  3293: 			cmd += " -c=" + Scs2.getThemeName();
  3294: 		}
  3295: 		if(Scs2.getImageFile() != "") {
  3296: 			cmd += " -i=" + Scs2.getImageFile();
  3297: 		}
  3298: 		cerr << "\nHyperInclude found " + link.substr(1) + "\n";
  3299: 		cerr << cmd << "\n";
  3300: 		system(cmd.data());
  3301: 	}
  3302: 	// make the hyperlink
  3303: 	link = "<a href=" + link + ".html\">";
  3304: 	buffer.insert(insr, link);
  3305: 	buffer.insert(buffer.size(),"</a>");
  3306: 
  3307: /*
  3308: 	string path;
  3309: 	int dir_idx = IO.ifile.rfind("/");
  3310: 	if(dir_idx != -1) {
  3311: 
  3312: 		path = IO.ifile.substr(0,dir_idx +1);
  3313: 		link = path + link;
  3314: 	}
  3315: */
  3316: }
  3317: //-----------------------------------------------------------------------------
  3318: // The Ada95 Language definition file for Web C Plus Plus
  3319: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3320: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3321: 
  3322: #include "langada.h" 
  3323: 
  3324: LangAda95 ::LangAda95() {
  3325: 
  3326: 	fill();
  3327: 	init_switches();
  3328: 
  3329: 	doLabels   = Yes;
  3330: 	doAdaComnt = Yes;
  3331: }
  3332: 
  3333: void LangAda95 ::fill() {
  3334: 
  3335: 	string K[] = {
  3336: 	"abort","abs","abstract","accept","access","aliased","all","and","array",
  3337: 	"at","begin","body","case","constant","declare","delay","delta","digits",
  3338: 	"do","else","elsif","end","entry","exception","exit","for","function",
  3339: 	"generic","goto","if","in","is","limited","loop","mod","new","not","null",
  3340: 	"of","or","others","out","package","pragma","private","procedure",
  3341: 	"protected","raise","range","record","rem","renames","requeue","return",
  3342: 	"reverse","select","separate","subtype","tagged","task","terminate",
  3343: 	"then","type","until","use","when","while","with","xor"
  3344: 	};
  3345: 	for(int k=0;k < 69;k++) {keys.push_back(K[k]);}
  3346: }
  3347: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langasm.cpp
  3348: 
  3349: // the Assembler Language definition file for Web C Plus Plus
  3350: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  3351: 
  3352: #include "langasm.h" 
  3353: 
  3354: LangAssembler::LangAssembler() {
  3355: 
  3356: 	fill();
  3357: 	init_switches();
  3358: 
  3359: 	doCaseKeys  = No;
  3360: 	doLabels    = Yes;
  3361: 	doPreProc   = Yes;
  3362: 	doBigComnt  = Yes;
  3363: 	doAsmComnt  = Yes;
  3364: }
  3365: 
  3366: void LangAssembler::fill() {
  3367: 
  3368: 	string K[] = {
  3369: "aam","aas","adc","add","and","align","assume","bne","bpl","br","call","cmp",
  3370: "cbw","clc","cwd","daa","das","db","dd","dec","dq","dt","dup","dw","endp",
  3371: "ends","end","equ","far","global","idiv","div","in","inc","int","jae","ja",
  3372: "jb","jcxz","jmp","jne","jns","jle","je","jl","jg","jng","jnl","jns","jnz",
  3373: "jz","lodsb","local","loop","leave","lea","main","mov","imul","mul","near",
  3374: "neg","not","or","org","out","pusha","push","popa","pop","proc","iret","rep",
  3375: "ret","rol","seg","section","segment","shld","shl","shr","stosd","stosw",
  3376: "sbb","sub","test","xchg","xor"
  3377: 	};
  3378: 
  3379: 	for(int k=0;k < 88;k++) {keys.push_back(K[k]);}
  3380: 
  3381: 	string T[] = {
  3382: "ah","al","ax",
  3383: "bh","bl","bx",
  3384: "ch","cl","cx",
  3385: "dh","dl","dx",
  3386: "eax","ebx","ecx","edx",
  3387: "ss","ds","cs","es"
  3388: 	};
  3389: 	for(int t=0;t < 20;t++) {types.push_back(T[t]);}
  3390: }
  3391: // the ASP Language definition file for Web C Plus Plus
  3392: // Author: Matt Runion <mrunion@yahoo.com>
  3393: 
  3394: 
  3395: #include "langasp.h" 
  3396: 
  3397: LangAsp::LangAsp()  {
  3398: 	
  3399: 	fill();
  3400: 	init_switches();
  3401: 
  3402: 	//doHtmTags  = Yes;
  3403: 	//doHtmComnt = Yes;
  3404: 	doAspComnt = Yes;
  3405: 	doCaseKeys = No;
  3406: }
  3407: 
  3408: void LangAsp::fill(){
  3409: 
  3410: 	// ASP keywords
  3411: 	string K[] = {
  3412: 	"and","response","write","case","select","continue","date","dim","server",
  3413: 	"createobject","do","if","else","end","empty","then","next","set",
  3414: 	"default","movenext","open","close","activeconnection","false","true","BOF",
  3415: 	"EOF","each","for","sub","function","len","cstr","include",
  3416: 	"cdbl","cdate","is","null","object","redirect","request","querystring","exit",
  3417: 	"clng","redim","session","form","not","nothing","loop","while",
  3418: 
  3419: 	"public", "let", "boolean", "integer", "property",
  3420: 	"get", "long", "as", "byval", "byref", "double",
  3421: 	"event", "private", "enum", "optional", "option",
  3422: 	"explicit", "on", "error", "goto"
  3423: 
  3424: 	};
  3425: 	for(int k=0;k < 71;k++) {keys.push_back(K[k]);}
  3426: }
  3427: // The Basic Language definition file for Web C Plus Plus
  3428: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3429: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3430: 
  3431: #include "langbasic.h" 
  3432: 
  3433: LangBasic ::LangBasic() {
  3434: 
  3435: 	fill();
  3436: 	init_switches();
  3437: 
  3438: 	doCaseKeys = No;
  3439: 	doLabels   = Yes;
  3440: 	doAsmComnt = Yes;
  3441: 	doRemComnt = Yes;
  3442: }
  3443: 
  3444: void LangBasic ::fill() {
  3445: 
  3446: 	string K[] = {
  3447: 	"ABS","AND","ASC","BYE","CHR","CLS","DATA","DEL","DIM","END","FOR","GOSUB",
  3448: 	"GOTO","IF","INPUT","LEN","LET","LIST","LOAD","LOCATE","LOG","MERGE","MID",
  3449: 	"MOD","NEW","NEXT","NOT","ON","OR","POKE","PRINT","RAND","READ","RENUM",
  3450: 	"RESTORE","RETURN","RND","RUN","SAVE","SGN","SIN","SQR","SQRT","STOP",
  3451: 	"STR","TO","VAL","WEND","WHILE","XOR"
  3452: 	};
  3453: 	for(int k=0;k < 50;k++) {keys.push_back(K[k]);}
  3454: }
  3455: // The DOS Batch Language definition file for Web C Plus Plus
  3456: // Generated by Daniel Lin <dan@dlin.d2g.com> using genlang.cgi
  3457: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3458: 
  3459: #include "langbatch.h" 
  3460: 
  3461: LangBatch::LangBatch() {
  3462: 
  3463: 	fill();
  3464: 	init_switches();
  3465: 
  3466: //	doStrings   = No;
  3467: //	doNumbers   = No;
  3468: 	doCaseKeys  = No;
  3469: //	doLabels    = Yes;
  3470: 	doHashes    = Yes;
  3471:   doRemComnt  = Yes;
  3472:   doBatComnt  = Yes;
  3473: }
  3474: 
  3475: void LangBatch::fill() {
  3476: 	string K[] = {
  3477: "assoc","at","attrib","break","cacls","call","cd","chcp","chdir","chkdsk",
  3478: "chkntfs","cls","cmd","color","comp","compact","control","convert","copy",
  3479: "date","del","dir","diskcomp","diskcopy","doskey","echo","endlocal",
  3480: "erase","exit","fc","find","findstr","for","format","ftype","goto",
  3481: "graftabl","help","if","label","md","mkdir","more","move","net","path",
  3482: "pause","popd","print","prompt","pushd","rd","recover","ren","rename",
  3483: "replace","rmdir","rundll32","set","setlocal","share","shift","sort",
  3484: "start","subst","time","title","tree","type","ver","verify","vol","xcopy"
  3485: 	};
  3486: 	for(int k=0;k < 73;k++) {keys.push_back(K[k]);}
  3487: }
  3488: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langc.cpp
  3489: 
  3490: // the C Language definition file for Web C Plus Plus
  3491: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  3492: 
  3493: #include "langc.h" 
  3494: 
  3495: LangC::LangC() {
  3496: 
  3497: 	fill();
  3498: 	init_switches();
  3499: 
  3500: 	doSymbols   = Yes;
  3501: 	doLabels    = Yes;
  3502: 	doPreProc   = Yes;
  3503: 	doBigComnt  = Yes;
  3504: 	doCinComnt  = Yes;
  3505: }
  3506: 
  3507: void LangC::fill() {
  3508: 
  3509: 	string K[] = {
  3510: 		"break","case","const","continue","default","do",
  3511: 		"else","enum","extern","for","if","return","sizeof",
  3512: 		"struct","switch","typedef","union","while"
  3513: 	};
  3514: 	for(int k=0;k < 18;k++) {keys.push_back(K[k]);}
  3515: 
  3516: 	string T[] = {
  3517: 		"auto","char","double","float","int","long","register","short",
  3518: 		"signed","static","unsigned","void","volatile"
  3519: 	};
  3520: 	for(int t=0;t < 13;t++) {types.push_back(T[t]);}
  3521: }
  3522: // The Cg Language definition file for Web C Plus Plus
  3523: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3524: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3525: 
  3526: #include "langcg.h" 
  3527: 
  3528: LangCg ::LangCg() {
  3529: 
  3530: 	fill();
  3531: 	init_switches();
  3532: 
  3533: 	doSymbols   = Yes;
  3534: 	doPreProc   = Yes;
  3535: 	doCinComnt  = Yes;
  3536: 	doBigComnt  = Yes;
  3537: }
  3538: 
  3539: void LangCg ::fill() {
  3540: 
  3541: 	string K[] = {
  3542: "break",
  3543: "case",
  3544: "const",
  3545: "continue",
  3546: "default",
  3547: "discard",
  3548: "do",
  3549: "else",
  3550: "enum",
  3551: "extern",
  3552: "false",
  3553: "for",
  3554: "function",
  3555: "goto",
  3556: "if",
  3557: "return",
  3558: "struct",
  3559: "switch",
  3560: "true",
  3561: "typedef",
  3562: "uniform",
  3563: "while"
  3564: 	};
  3565: 	for(int k=0;k < 22;k++) {keys.push_back(K[k]);}
  3566: 
  3567: 	string T[] = {
  3568: "bool",
  3569: "float4x4",
  3570: "float4",
  3571: "float3x3",
  3572: "float3",
  3573: "float2x2",
  3574: "float2",
  3575: "float",
  3576: "in",
  3577: "inout",
  3578: "int",
  3579: "out",
  3580: "static",
  3581: "void",
  3582: "volatile",
  3583: 	};
  3584: 	for(int t=0;t < 15;t++) {types.push_back(T[t]);}
  3585: }
  3586: // The CLIPS Language definition file for Web C Plus Plus
  3587: // Generated by Walter Maner<maner@cs.bgsu.edu> using genlang.cgi
  3588: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3589: 
  3590: #include "langclips.h" 
  3591: 
  3592: LangClips ::LangClips() {
  3593: 
  3594: 	fill();
  3595: 	init_switches();
  3596: 
  3597: 
  3598: 	doAsmComnt  = Yes;
  3599: }
  3600: 
  3601: void LangClips ::fill() {
  3602: 
  3603: 	string K[] = {
  3604: "FALSE",
  3605: "TRUE",
  3606: "abs",
  3607: "acos",
  3608: "acosh",
  3609: "acoth",
  3610: "acsc",
  3611: "acsch",
  3612: "agenda",
  3613: "and",
  3614: "apropos",
  3615: "asec",
  3616: "asech",
  3617: "asin",
  3618: "asinh",
  3619: "assert",
  3620: "assert-string",
  3621: "atan",
  3622: "atanh",
  3623: "auto-focus",
  3624: "batch",
  3625: "bind",
  3626: "bsave",
  3627: "cardinality",
  3628: "clear",
  3629: "clear-focus-on-stack",
  3630: "close",
  3631: "cos",
  3632: "cosh",
  3633: "cot",
  3634: "coth",
  3635: "create$",
  3636: "crlf",
  3637: "csc",
  3638: "csch",
  3639: "declare",
  3640: "default",
  3641: "deffacts",
  3642: "deffunction",
  3643: "defmodule",
  3644: "defrule",
  3645: "deftemplate",
  3646: "deg-grad",
  3647: "deg-rad",
  3648: "delete$",
  3649: "dependencies",
  3650: "dependents",
  3651: "div",
  3652: "dribble-off",
  3653: "dribble-on",
  3654: "duplicate",
  3655: "else",
  3656: "eq",
  3657: "evenp",
  3658: "exists",
  3659: "exit",
  3660: "exp",
  3661: "explode$",
  3662: "fact-index",
  3663: "facts",
  3664: "first$",
  3665: "float",
  3666: "floatp",
  3667: "focus",
  3668: "forall",
  3669: "format",
  3670: "gensym",
  3671: "gensym*",
  3672: "get-current-module",
  3673: "get-dynamic-constraint-checking",
  3674: "get-fact-duplication",
  3675: "get-focus",
  3676: "get-static-constraint-checking",
  3677: "grad-deg",
  3678: "halt",
  3679: "if",
  3680: "implode$",
  3681: "insert$",
  3682: "integer",
  3683: "integerp",
  3684: "length$",
  3685: "lexemep",
  3686: "list-deffacts",
  3687: "list-defmodules",
  3688: "list-defrules",
  3689: "list-deftemplates",
  3690: "list-focus-stack",
  3691: "load",
  3692: "load-facts",
  3693: "log",
  3694: "log10",
  3695: "logical",
  3696: "lowcase",
  3697: "matches",
  3698: "max",
  3699: "member",
  3700: "member$",
  3701: "min",
  3702: "mod",
  3703: "modify",
  3704: "multifieldp",
  3705: "multislot",
  3706: "neq",
  3707: "not",
  3708: "nth$",
  3709: "numberp",
  3710: "oddp",
  3711: "open",
  3712: "or",
  3713: "pi",
  3714: "pop-focus-stack",
  3715: "ppdeffacts",
  3716: "ppdefmodule",
  3717: "ppdefrule",
  3718: "ppdeftemplate",
  3719: "printout",
  3720: "rad-deg",
  3721: "random",
  3722: "range",
  3723: "read",
  3724: "readline",
  3725: "refresh",
  3726: "remove",
  3727: "remove-break",
  3728: "rename",
  3729: "replace$",
  3730: "reset",
  3731: "rest$",
  3732: "retract",
  3733: "round",
  3734: "run",
  3735: "salience",
  3736: "save",
  3737: "save-facts",
  3738: "sec",
  3739: "sech",
  3740: "seed",
  3741: "set-break",
  3742: "set-current-module",
  3743: "set-dynamic-constraint-checking",
  3744: "set-fact-duplication",
  3745: "set-static-constraint-checking",
  3746: "setgen",
  3747: "show-breaks",
  3748: "sin",
  3749: "sinh",
  3750: "slot",
  3751: "sqrt",
  3752: "str-cat",
  3753: "stringp",
  3754: "sub-string",
  3755: "subseq$",
  3756: "subsetp",
  3757: "sym-cat",
  3758: "symbolp",
  3759: "system",
  3760: "tan",
  3761: "tanh",
  3762: "test",
  3763: "then",
  3764: "time",
  3765: "type",
  3766: "undeffacts",
  3767: "undefrule",
  3768: "undeftemplate",
  3769: "unwatch",
  3770: "upcase",
  3771: "watch",
  3772: "while"
  3773: 	};
  3774: 	for(int k=0;k < 169;k++) {keys.push_back(K[k]);}
  3775: }
  3776: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langcpp.cpp
  3777: 
  3778: // the C++ Language definition file for Web C Plus Plus
  3779: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  3780: 
  3781: #include "langcpp.h" 
  3782: 
  3783: LangCPlusPlus::LangCPlusPlus() {
  3784: 
  3785: 	fill();
  3786: 	init_switches();
  3787: 
  3788: 	doSymbols   = Yes;
  3789: 	doLabels    = Yes;
  3790: 	doPreProc   = Yes;
  3791: 	doBigComnt  = Yes;
  3792: 	doCinComnt  = Yes;
  3793: }
  3794: 
  3795: void LangCPlusPlus::fill() {
  3796: 
  3797: 	string K[] = {
  3798: 		"asm","catch","class","const_cast","delete","dynamic_cast",
  3799: 		"explicit","false","friend","inline","namespace","new",
  3800: 		"operator","private","protected","public","reinterpret_cast",
  3801: 		"static_cast","template","this","throw","true","try","typeid",
  3802: 		"typename","using","virtual","wchar_t"
  3803: 	};
  3804: 	for(int k=0;k < 28;k++) {keys.push_back(K[k]);}
  3805: 
  3806: 	string T[] = {
  3807: 		"bool","mutable"
  3808: 	};
  3809: 	for(int t=0;t < 2;t++) {types.push_back(T[t]);}
  3810: }
  3811: // The CSharp Language definition file for Web C Plus Plus
  3812: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3813: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3814: 
  3815: #include "langcsharp.h" 
  3816: 
  3817: LangCSharp ::LangCSharp() {
  3818: 
  3819: 	fill();
  3820: 	init_switches();
  3821: 
  3822: 	doSymbols  = Yes;
  3823: 	doLabels   = Yes;
  3824: 	doPreProc  = Yes;
  3825: 	doBigComnt = Yes;
  3826: 	doCinComnt = Yes;
  3827: }
  3828: 
  3829: void LangCSharp ::fill() {
  3830: 
  3831: 	string K[] = {
  3832: 		"abstract","as","base","break","case","catch","checked",
  3833: 		"class","const","continue","default","do","else","enum",
  3834: 		"event","explicit","extern","false","finally","fixed",
  3835: 		"for","foreach","get","goto","if","implicit","in","interface",
  3836: 		"internal","is","lock","namespace","new","null","operator",
  3837: 		"override","params","private","protected","public","return",
  3838: 		"sealed","set","sizeof","stackalloc","struct","switch","this",
  3839: 		"throw","true","try","typeof","unchecked","unsafe","using",
  3840: 		"value","virtual","while"
  3841: 	};
  3842: 	for(int k=0;k < 58;k++) {keys.push_back(K[k]);}
  3843: 
  3844: 	string T[] = {
  3845: 		"bool","byte","char","decimal","delegate","double","float",
  3846: 		"int","long","object","readonly","ref","sbyte","short","static",
  3847: 		"string","uint","ulong","out","ushort","void","volatile"
  3848: 	};
  3849: 	for(int t=0;t < 22;t++) {types.push_back(T[t]);}
  3850: }
  3851: 
  3852: // The emf Language definition file for Web C Plus Plus
  3853: // Generated by Dr. Detlef Groth<dgroth@gmx.de> using genlang.cgi
  3854: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3855: 
  3856: #include "langemf.h" 
  3857: 
  3858: LangEmf ::LangEmf() {
  3859: 
  3860: 	fill();
  3861: 	init_switches();
  3862: 
  3863: 
  3864: 	doNumbers   = No;
  3865: 	doLabels    = Yes;
  3866: 	doScalars   = Yes;
  3867: 	doArrays    = Yes;
  3868: 	doHashes    = Yes;
  3869: 	doAsmComnt  = Yes;
  3870: }
  3871: 
  3872: void LangEmf ::fill() {
  3873: 
  3874: 	string K[] = {
  3875: "!done",
  3876: "!nmacro",
  3877: "!abort",
  3878: "!bell",
  3879: "!continue",
  3880: "!ehelp",
  3881: "!elif",
  3882: "!else",
  3883: "!emacro",
  3884: "!end",
  3885: "!endif",
  3886: "!force",
  3887: "!goto",
  3888: "!if",
  3889: "!jump",
  3890: "!repeat",
  3891: "!return",
  3892: "!tgoto",
  3893: "!tjump",
  3894: "!until",
  3895: "!while",
  3896: "define-macro"
  3897: 	};
  3898: 	for(int k=0;k < 22;k++) {keys.push_back(K[k]);}
  3899: }
  3900: // The Euphoria Language definition file for Web C Plus Plus
  3901: // Generated by George Lewis <ghlewis@hotmail.com> using genlang.cgi
  3902: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3903: 
  3904: #include "langeuphoria.h" 
  3905: 
  3906: LangEuphoria ::LangEuphoria() {
  3907: 
  3908: 	fill();
  3909: 	init_switches();
  3910: 
  3911: 
  3912: 	doAdaComnt  = Yes;
  3913: }
  3914: 
  3915: void LangEuphoria ::fill() {
  3916: 
  3917: 	string K[] = {
  3918:   "by","constant","do","else","elsif","end","exit","for","function","global",
  3919:   "if","include","not","or","procedure","return","then","to","type","while",
  3920:   "with","without","xor","and"
  3921: 	};
  3922: 
  3923: 	for(int k=0;k < 24;k++) {keys.push_back(K[k]);}
  3924: }
  3925: // The Fortran Language definition file for Web C Plus Plus
  3926: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3927: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3928: 
  3929: #include "langfortran.h" 
  3930: 
  3931: LangFortran ::LangFortran() {
  3932: 
  3933: 	fill();
  3934: 	init_switches();
  3935: 
  3936: 	doCaseKeys = No;
  3937: 	doPreProc  = Yes;
  3938: 	doFtnComnt = Yes;
  3939: }
  3940: 
  3941: void LangFortran ::fill() {
  3942: 
  3943: 	string K[] = {
  3944: 		"ACCEPT","ASSIGN","AUTOMATIC","Assignment","BACKSPACE","BLOCK",
  3945: 		"BYTECALL","CLOSE","COMMON","CONTINUE","DATA","DECODE",
  3946: 		"DIMENSION","DO","ELSE","ENCODE","END","ENDIF","ENTRY",
  3947: 		"EQUIVALENCE","EXTERNAL","FILE","FORMAT","FUNCTION","GO","IF",
  3948: 		"IMPLICIT","INCLUDE","INQUIRE","INTRINSIC","MAP","NAMELIST",
  3949: 		"OPEN","OPTIONS","PARAMETER","PAUSE","POINTER","PRINT",
  3950: 		"PROGRAM","READ","RECORD","RETURN","REWIND","SAVE","STATIC",
  3951: 		"STOP","STRUCTURE","SUBROUTINE","THEN","TO","TYPE","UNION",
  3952: 		"UNTIL","VIRTUAL","WHILE","WRITE"
  3953: 	};
  3954: 	for(int k=0;k < 56;k++) {keys.push_back(K[k]);}
  3955: 
  3956: 	string T[] = {
  3957: 		"BYTE","CHARACTER","COMPLEX","DOUBLE","INTEGER","LOGICAL",
  3958: 		"REAL","PRECISION","VOLATILE"
  3959: 	};
  3960: 	for(int t=0;t < 9;t++) {types.push_back(T[t]);}
  3961: }
  3962: 
  3963: // The Haskell Language definition file for Web C Plus Plus
  3964: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  3965: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  3966: 
  3967: #include "langhaskell.h" 
  3968: 
  3969: LangHaskell ::LangHaskell() {
  3970: 
  3971: 	fill();
  3972: 	init_switches();
  3973: 
  3974: 
  3975: 	doAdaComnt  = Yes;
  3976: 	doHskComnt  = Yes;
  3977: }
  3978: 
  3979: void LangHaskell ::fill() {
  3980: 
  3981: 	string K[] = {
  3982:   "abstract","case","concrete","data","do","in","interface","let","module",
  3983:   "native","of","open","private","public","sig","struct","type","use"
  3984: 	};
  3985: 	for(int k=0;k < 18;k++) {keys.push_back(K[k]);}
  3986: }
  3987: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langhtml.cpp
  3988: 
  3989: // the HyperText Markup Language definition file for Web C Plus Plus
  3990: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  3991: 
  3992: #include "langhtml.h" 
  3993: 
  3994: LangHtml::LangHtml() {
  3995: 	
  3996: 	fill();
  3997: 	init_switches();
  3998: 
  3999: 	doNumbers   = Yes;
  4000: 	doCaseKeys  = No;
  4001: 	doHtmlTags  = Yes;
  4002: 	doHtmComnt  = Yes;
  4003: }
  4004: 
  4005: void LangHtml::fill() {
  4006: 
  4007: 	string T[] = {
  4008: "?",
  4009: "?PHP",
  4010: "?XML",
  4011: "!DOCTYPE",
  4012: "A",
  4013: "ABBR",
  4014: "ACRONYM",
  4015: "ACTION",
  4016: "ADDRESS",
  4017: "ALIGN",
  4018: "ALINK",
  4019: "ALT",
  4020: "APPLET",
  4021: "AREA",
  4022: "B",
  4023: "BACKGROUND",
  4024: "BASE",
  4025: "BASEFONT",
  4026: "BDO",
  4027: "BGCOLOR",
  4028: "BIG",
  4029: "BLOCKQUOTE",
  4030: "BODY",
  4031: "BORDER",
  4032: "BR",
  4033: "BUTTON",
  4034: "CAPTION",
  4035: "CELLPADDING",
  4036: "CELLSPACING",
  4037: "CENTER",
  4038: "CHECKED",
  4039: "CITE",
  4040: "CODE",
  4041: "COL",
  4042: "COLGROUP",
  4043: "COLOR",
  4044: "COLS",
  4045: "COLSPAN",
  4046: "CONTENT",
  4047: "DD",
  4048: "DEL",
  4049: "DFN",
  4050: "DIR",
  4051: "DIV",
  4052: "DL",
  4053: "DT",
  4054: "EM",
  4055: "ENCODING",
  4056: "FACE",
  4057: "FIELDSET",
  4058: "FORM",
  4059: "FRAME",
  4060: "FRAMESET",
  4061: "H1",
  4062: "H2",
  4063: "H3",
  4064: "H4",
  4065: "H5",
  4066: "H6",
  4067: "HEAD",
  4068: "HEIGHT",
  4069: "HIDDEN",
  4070: "HR",
  4071: "HREF",
  4072: "HTML",
  4073: "I",
  4074: "IFRAME",
  4075: "IMG",
  4076: "INPUT",
  4077: "INS",
  4078: "ISINDEX",
  4079: "KBD",
  4080: "LABEL",
  4081: "LANGUAGE",
  4082: "LEGEND",
  4083: "LI",
  4084: "LINK",
  4085: "MAP",
  4086: "MENU",
  4087: "META",
  4088: "METHOD",
  4089: "NAME",
  4090: "NOFRAMES",
  4091: "NOSCRIPT",
  4092: "NOSHADE",
  4093: "OBJECT",
  4094: "OL",
  4095: "OPTGROUP",
  4096: "OPTION",
  4097: "P",
  4098: "PARAM",
  4099: "PRE",
  4100: "Q",
  4101: "REL",
  4102: "ROWS",
  4103: "S",
  4104: "SAMP",
  4105: "SCRIPT",
  4106: "SELECT",
  4107: "SELECTED",
  4108: "SIZE",
  4109: "SMALL",
  4110: "SPAN",
  4111: "SRC",
  4112: "STRIKE",
  4113: "STRING",
  4114: "STYLE",
  4115: "SUB",
  4116: "SUBMIT",
  4117: "SUP",
  4118: "TABLE",
  4119: "TBODY",
  4120: "TD",
  4121: "TEXT",
  4122: "TEXTAREA",
  4123: "TFOOT",
  4124: "TH",
  4125: "THEAD",
  4126: "TITLE",
  4127: "TR",
  4128: "TT",
  4129: "TYPE",
  4130: "U",
  4131: "UL",
  4132: "VALIGN",
  4133: "VALUE",
  4134: "VAR",
  4135: "VERSION",
  4136: "VLINK",
  4137: "WIDTH"
  4138: 	};
  4139: 	for(int t=0;t < 128;t++) {types.push_back(T[t]);}
  4140: }
  4141: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langjava.cpp
  4142: 
  4143: // the Java Language definition file for Web C Plus Plus
  4144: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  4145: 
  4146: 
  4147: #include "langjava.h" 
  4148: 
  4149: LangJava::LangJava() {
  4150: 	
  4151: 	fill();
  4152: 	init_switches();
  4153: 
  4154: 	doSymbols   = Yes;
  4155: 	doLabels    = Yes;
  4156: 	doBigComnt  = Yes;
  4157: 	doCinComnt  = Yes;
  4158: }
  4159: 
  4160: void LangJava::fill() {
  4161: 
  4162: 	// add Java keywords --------------------------------------------------
  4163: 	string K[] = {
  4164: 		"abstract","break","case","catch","class","const",
  4165: 		"continue","default","do","else","extends","final","false",
  4166: 		"for","if","implements","import","instanceof","interface",
  4167: 		"native","new","null","package","private","protected","public",
  4168: 		"register","return","super","switch","synchronized","this",
  4169: 		"true","throws","throw","transient","try","while"
  4170: 	};
  4171: 	for(int k=0;k < 38;k++) {keys.push_back(K[k]);}
  4172: 
  4173: 	string T[] = {
  4174: 		"boolean","byte","char","double","float","int","long","short",
  4175: 		"static","void","volatile"
  4176: 	};
  4177: 	for(int t=0;t < 11;t++) {types.push_back(T[t]);}
  4178: }
  4179: 
  4180: // The javascript Language definition file for Web C Plus Plus
  4181: // Generated by forrest johnston<forrest.johnston@attbi.com> using genlang.cgi
  4182: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4183: 
  4184: #include "langjscript.h" 
  4185: 
  4186: LangJScript ::LangJScript() {
  4187: 
  4188: 	fill();
  4189: 	init_switches();
  4190: 
  4191: 
  4192: 	doCinComnt  = Yes;
  4193: 	doBigComnt  = Yes;
  4194: }
  4195: 
  4196: void LangJScript ::fill() {
  4197: 
  4198: 	string K[] = {
  4199: "break",
  4200: "case",
  4201: "continue",
  4202: "default",
  4203: "delete",
  4204: "do",
  4205: "else",
  4206: "export",
  4207: "for",
  4208: "function",
  4209: "if",
  4210: "import",
  4211: "in",
  4212: "new",
  4213: "return",
  4214: "switch",
  4215: "this",
  4216: "typeof",
  4217: "var",
  4218: "void",
  4219: "while",
  4220: "with"
  4221: 	};
  4222: 	for(int k=0;k < 22;k++) {keys.push_back(K[k]);}
  4223: }
  4224: 
  4225: // The Modula2 Language definition file for Web C Plus Plus
  4226: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  4227: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4228: 
  4229: #include "langmodula.h" 
  4230: 
  4231: LangModula2 ::LangModula2() {
  4232: 
  4233: 	fill();
  4234: 	init_switches();
  4235: 
  4236: 	doPasComnt = Yes;
  4237: }
  4238: 
  4239: void LangModula2 ::fill() {
  4240: 
  4241: 	string K[] = {
  4242: 		"AND","BEGIN","BY","CASE","CONST","DEFINITION","DIV",
  4243: 		"DO","ELSE","ELSIF","END","EXIT","EXPORT","FALSE","FOR","FROM",
  4244: 		"IF","IMPLEMENTATION","IMPORT","IN","LOOP","MOD","MODULE",
  4245: 		"NOT","OF","OR","POINTER","PROCEDURE","QUALIFIED","REPEAT",
  4246: 		"RETURN","SET","THEN","TO","TRUE","TYPE","UNTIL","VAR","WHILE",
  4247: 		"WITH"
  4248: 	};
  4249: 	for(int k=0;k < 40;k++) {keys.push_back(K[k]);}
  4250: 
  4251: 	string T[] = {
  4252: 		"ACHAR","ARRAY","BITSET","BOOLEAN","CARDINAL","CHAR","INTEGER",
  4253: 		"LONGCARD","LONGCOMPLEX","LONGINT","LONGREAL","REAL","RECORD",
  4254: 		"SHORTCARD","SHORTINT","UCHAR"
  4255: 	};
  4256: 	for(int t=0;t < 16;t++) {types.push_back(T[t]);}
  4257: }
  4258: // The ObjectiveC Language definition file for Web C Plus Plus
  4259: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  4260: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4261: 
  4262: #include "langobjc.h" 
  4263: 
  4264: LangObjectiveC ::LangObjectiveC() {
  4265: 
  4266: 	fill();
  4267: 	init_switches();
  4268: 
  4269: 	doSymbols  = Yes;
  4270: 	doLabels   = Yes;
  4271: 	doPreProc  = Yes;
  4272: 	doArrays   = Yes;
  4273: 	doBigComnt = Yes;
  4274: 	doCinComnt = Yes;
  4275: }
  4276: 
  4277: void LangObjectiveC ::fill() {
  4278: 
  4279: 	string K[] = {
  4280: 		"Class","IMP","Nil","SEL","STR","bycopy","byref","id",
  4281: 		"nil","self","super"
  4282: 	};
  4283: 	for(int k=0;k < 11;k++) {keys.push_back(K[k]);}
  4284: 
  4285: 	string T[] = {
  4286: 		"BOOL","in","inout","out","oneway"
  4287: 	};
  4288: 	for(int t=0;t < 5;t++) {types.push_back(T[t]);}
  4289: }
  4290: // The Pascal Language definition file for Web C Plus Plus
  4291: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  4292: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4293: 
  4294: #include "langpascal.h" 
  4295: 
  4296: LangPascal ::LangPascal() {
  4297: 
  4298: 	fill();
  4299: 	init_switches();
  4300: 
  4301: 	doCaseKeys = No;
  4302: 	doHashes   = Yes;
  4303: 	doPasComnt = Yes;
  4304: }
  4305: 
  4306: void LangPascal ::fill() {
  4307: 
  4308: 	string K[] = {
  4309: 		"abs","and","arctan","begin","case","const","cos","dispose",
  4310: 		"div","do","downto","else","end","eof","eoln","exp","false",
  4311: 		"file","for","forward","function","goto","if","in","input",
  4312: 		"label","ln","maxint","mod","new","nil","not","odd","of","or",
  4313: 		"ord","output","pack","packed","page","pred","procedure",
  4314: 		"program","read","readln","repeat","reset","rewrite","round",
  4315: 		"set","sin","sqr","sqrt","succ","text","then","to","true",
  4316: 		"trunc","type","until","var","while","with","write","writeln"
  4317: 	};
  4318: 	for(int k=0;k < 66;k++) {keys.push_back(K[k]);}
  4319: 
  4320: 	string T[] = {
  4321: 		"array","boolean","byte","char","double","extended","integer",
  4322: 		"longint","real","record","string","word"
  4323: 	};
  4324: 	for(int t=0;t < 12;t++) {types.push_back(T[t]);}
  4325: }
  4326: 
  4327: // The Power Builder 6.x Language definition file for Web C Plus Plus
  4328: // Generated by Philippe Torche<philippe.torche@swissonline.ch> using genlang.cgi
  4329: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4330: 
  4331: #include "langpbuilder.h" 
  4332: 
  4333: LangPBuilder::LangPBuilder() {
  4334: 
  4335: 	fill();
  4336: 	init_switches();
  4337: 
  4338: 
  4339: 	doCaseKeys  = No;
  4340: 	doCinComnt  = Yes;
  4341: 	doBigComnt  = Yes;
  4342: }
  4343: 
  4344: void LangPBuilder::fill() {
  4345: 
  4346: 	string K[] = {
  4347:     "_debug","alias","and","autoinstantiate","blob","boolean","call","case",
  4348:     "char","character","choose","close","commit","connect","constant",
  4349:     "continue","create","cursor","date","datetime","dec","decimal","declare",
  4350:     "delete","describe","descriptor","destroy","disconnect","do","double",
  4351:     "dynamic","else","elseif","end","enumerated","event","execute","exit",
  4352:     "external","false","fetch","first","for","forward","from","function",
  4353:     "global","goto","halt","if","immediate","indirect","insert","int",
  4354:     "integer","into","intrinsic","is","last","library","long","loop","next",
  4355:     "not","of","on","open","or","parent","post","prepare","prior","private",
  4356:     "privateread","privatewrite","procedure","protected","protectedread",
  4357:     "protectedwrite","prototypes","public","readonly","real","ref","return",
  4358:     "rollback","rpcfunc","select","selectblob","shared","static","step",
  4359:     "string","subroutine","super","system","systemread","systemwrite","then",
  4360:     "this","time","to","trigger","true","type","uint","ulong","unsignedint",
  4361:     "unsignedinteger","unsignedlong","until","update","updateblob","using",
  4362:     "variables","while","with","within"
  4363: 	};
  4364: 	for(int k=0;k < 118;k++) {keys.push_back(K[k]);}
  4365: }
  4366: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langperl.cpp
  4367: 
  4368: // the PERL 5 Language definition file for Web C Plus Plus
  4369: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  4370: 
  4371: #include "langperl.h" 
  4372: 
  4373: LangPerl::LangPerl() {
  4374: 	
  4375: 	fill();
  4376: 	init_switches();
  4377: 
  4378: 	doSymbols  = Yes;
  4379: 	doLabels   = Yes;
  4380: 	doScalars  = Yes;
  4381: 	doArrays   = Yes;
  4382: 	doHashes   = Yes;
  4383: 	doUnxComnt = Yes;
  4384: }
  4385: 
  4386: void LangPerl::fill() {
  4387: 
  4388: 	// PERL 5 keywords
  4389: 	string K[] = {
  4390: 		"and","bless","chdir","chomp","chop","chr","case","delete",
  4391: 		"die","do","each","else","elsif","exit","foreach","for",
  4392: 		"function","if","in","join","keys","last","local","my","next",
  4393: 		"no","null","or","package","pack","printf","print","push",
  4394: 		"read","redo","require","return","seek","select","shift",
  4395: 		"splice","split","sub","tell","tied","then","undef","unless",
  4396: 		"untie","until","use","vars","warn","while","xor"
  4397: 	};
  4398: 	for(int k=0;k < 55;k++) {keys.push_back(K[k]);}
  4399: 
  4400: 	// filesystem operations
  4401: 	string T[] = {
  4402: 		"close","closedir","flock","mkdir","open","opendir","readdir",
  4403: 		"rewinddir","rmdir","unlink"
  4404: 	};
  4405: 	for(int t=0;t < 10;t++) {types.push_back(T[t]);}
  4406: }
  4407: 
  4408: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langphp.cpp
  4409: 
  4410: // the PHP Language definition file for Web C Plus Plus
  4411: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  4412: 
  4413: #include "langphp.h" 
  4414: 
  4415: LangPhp::LangPhp()  {
  4416: 	
  4417: 	fill();
  4418: 	init_switches();
  4419: 
  4420: 	doSymbols  = Yes;
  4421: 	doScalars  = Yes;
  4422: 	doBigComnt = Yes;
  4423: 	doCinComnt = Yes;
  4424: 	doUnxComnt = Yes;
  4425: }
  4426: 
  4427: void LangPhp::fill(){
  4428: 
  4429: 	// PHP keywords
  4430: 	string K[] = {
  4431: 	"and","array","break","case","class","continue","date","declare","die",
  4432: 	"double","do","if","elseif","else","empty","endif","endfor","endforeach",
  4433: 	"endswitch","endwhile","echo","exit","extends","false","fclose","fgets",
  4434: 	"fopen","foreach","for","fputs","function","global","header","include",
  4435: 	"int","list","new","NULL","object","print","require","return","static",
  4436: 	"string","switch","this","ticks","true","unset","var","while"
  4437: 	};
  4438: 	for(int k=0;k < 51;k++) {keys.push_back(K[k]);}
  4439: }
  4440: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langpython.cpp
  4441: 
  4442: // the Python Language definition file for Web C Plus Plus
  4443: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  4444: 
  4445: #include "langpython.h" 
  4446: 
  4447: LangPython::LangPython() {
  4448: 	
  4449: 	fill();
  4450: 	init_switches();
  4451: 
  4452: 	doSymbols  = Yes;
  4453: 	doUnxComnt = Yes;
  4454: }
  4455: 
  4456: void LangPython::fill() {
  4457: 
  4458: 	string K[] = {
  4459: 	"and","assert","break","class","continue","def","del","elif","else","except",
  4460: 	"exec","finally","for","from","global","if","import","input","in","is",
  4461: 	"lambda","not","or","pass","print","raise","range","return","try","while"
  4462: 	};
  4463: 	for(int k=0;k < 30;k++) {keys.push_back(K[k]);}
  4464: }
  4465: // The RenderMan Shading Language Language definition file for Web C Plus Plus
  4466: // Generated by Mark Williams <markdjwilliams@hotmail.com> using genlang.cgi
  4467: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4468: 
  4469: #include "langrenderman.h" 
  4470: 
  4471: LangRenderMan ::LangRenderMan() {
  4472: 
  4473: 	fill();
  4474: 	init_switches();
  4475: 
  4476: 	doCaseKeys = No;
  4477: 	doPreProc  = Yes;
  4478: 	doCinComnt = Yes;
  4479: 	doBigComnt = Yes;
  4480: 	doUnxComnt = Yes;
  4481: }
  4482: 
  4483: void LangRenderMan ::fill() {
  4484: 
  4485: 	string K[] = {
  4486: "break",
  4487: "color",
  4488: "continue",
  4489: "displacement",
  4490: "else",
  4491: "environment",
  4492: "extern",
  4493: "float",
  4494: "for",
  4495: "if",
  4496: "illuminance",
  4497: "illuminate",
  4498: "imager",
  4499: "light",
  4500: "matrix",
  4501: "normal",
  4502: "output",
  4503: "point",
  4504: "return",
  4505: "shadow",
  4506: "solar",
  4507: "string",
  4508: "surface",
  4509: "texture",
  4510: "transformation",
  4511: "uniform",
  4512: "varying",
  4513: "vector",
  4514: "vertex",
  4515: "void",
  4516: "volume",
  4517: "while"
  4518: 	};
  4519: 	for(int k=0;k < 32;k++) {keys.push_back(K[k]);}
  4520: }
  4521: // The Ruby Language definition file for Web C Plus Plus
  4522: // Generated by Jeffrey Bakker <jefskey@yahoo.com> using genlang.cgi
  4523: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4524: 
  4525: #include "langruby.h" 
  4526: 
  4527: LangRuby ::LangRuby() {
  4528: 
  4529: 	fill();
  4530: 	init_switches();
  4531: 
  4532: 
  4533: 	doScalars  = Yes;
  4534: 	doArrays   = Yes;
  4535: 	doHashes   = Yes;
  4536: 	doUnxComnt = Yes;
  4537: }
  4538: 
  4539: void LangRuby ::fill() {
  4540: 
  4541: 	string K[] = {
  4542: "BEGIN",
  4543: "END",
  4544: "alias",
  4545: "and",
  4546: "begin",
  4547: "break",
  4548: "case",
  4549: "class",
  4550: "def",
  4551: "defined",
  4552: "do",
  4553: "else",
  4554: "elsif",
  4555: "end",
  4556: "ensure",
  4557: "false",
  4558: "for",
  4559: "if",
  4560: "in",
  4561: "module",
  4562: "next",
  4563: "nil",
  4564: "not",
  4565: "or",
  4566: "redo",
  4567: "rescue",
  4568: "retry",
  4569: "return",
  4570: "self",
  4571: "super",
  4572: "then",
  4573: "true",
  4574: "undef",
  4575: "unless",
  4576: "until",
  4577: "when",
  4578: "while",
  4579: "yield",
  4580: 	};
  4581: 	for(int k=0;k < 38;k++) {keys.push_back(K[k]);}
  4582: }
  4583: 
  4584: // Author: Jeffrey Bakker  |  Date: May14th 2002  |  langshell.cpp
  4585: 
  4586: // the Bourne shell Syntax definition file for Web C Plus Plus
  4587: // Webcpp Copyright (C) 2002 Jeffrey Bakker
  4588: 
  4589: #include "langshell.h" 
  4590: 
  4591: LangShell::LangShell() {
  4592: 	
  4593: 	fill();
  4594: 	init_switches();
  4595: 
  4596: 	doScalars  = Yes;
  4597: 	doUnxComnt = Yes;
  4598: }
  4599: 
  4600: void LangShell::fill() {
  4601: 
  4602: 	string K[] = {
  4603: 	// add shell keywords -------------------------------------------------
  4604: 		"case","done","do","elif","else","esac","exit","for","fi",
  4605: 		"function","if","in","then","until","while"
  4606: 	};
  4607: 	for(int k=0;k < 15;k++) {keys.push_back(K[k]);}
  4608: 
  4609: 	string T[] = {
  4610: 	// add UNIX commands --------------------------------------------------
  4611: 	"alias","ar","awk","bg","cat","cc","cd","chgrp","chmod","clear","cmp",
  4612: 	"compress","cp","date","dialog","diff","echo","export","fg","find","finger",
  4613: 	"ftp","g++","gcc","grep","gunzip","gzip","jobs","killall","kill","ln","ls",
  4614: 	"less","make","merge","mkdir","more","mv","ping","ps","pwd","read","rm",
  4615: 	"rmdir","sed","set","sort","sleep","tail","tar","test","time","touch",
  4616: 	"uncompress","wc","which","whoami","who"
  4617: 	};
  4618: 	for(int t=0;t < 58;t++) {types.push_back(T[t]);}
  4619: }
  4620: // The SQL Language definition file for Web C Plus Plus
  4621: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  4622: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4623: 
  4624: #include "langsql.h" 
  4625: 
  4626: LangSQL ::LangSQL() {
  4627: 
  4628: 	fill();
  4629: 	init_switches();
  4630: 
  4631: 	doCaseKeys  = No;
  4632: 	doRemComnt  = Yes;
  4633: 	doAdaComnt  = Yes;
  4634: 	doBigComnt  = Yes;
  4635: }
  4636: 
  4637: void LangSQL ::fill() {
  4638: 
  4639: 	string K[] = {
  4640:     "*","ALTER","AND","AS","AVERAGE","BEGIN","BY","CLOSE","COMMIT","COUNT",
  4641:     "CREATE","CURSOR","DATABASE","DEALLOCATE","DECLARE","DIVIDE","DROP",
  4642:     "EXECUTE","FETCH","FROM","FULL","GRANT","GROUP","HAVING","INDEX","INNER",
  4643:     "INTERSECT","IS","LEFT","MAXIMUM","MINIMUM","NOT","NULL","ON","OR","ORDER",
  4644:     "OUTER","PROCEDURE","REVOKE","RIGHT","ROLLBACK","SELECT","SET","SUM",
  4645:     "TABLE","TRANSACTION","TRIGGER","UNION","USER","VIEW","WHERE"
  4646: 	};
  4647: 	for(int k=0;k < 51;k++) {keys.push_back(K[k]);}
  4648: }
  4649: // The Tcl Language definition file for Web C Plus Plus
  4650: // Generated by Jeffrey Bakker<jefskey@yahoo.com> using genlang.cgi
  4651: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4652: 
  4653: #include "langtcl.h" 
  4654: 
  4655: LangTcl ::LangTcl() {
  4656: 
  4657: 	fill();
  4658: 	init_switches();
  4659: 
  4660: 
  4661: 	doScalars  = Yes;
  4662: //	doTclComnt = Yes;
  4663: 	doUnxComnt = Yes;
  4664: }
  4665: 
  4666: void LangTcl ::fill() {
  4667: 
  4668: 	string K[] = {
  4669:   "append","array","break","case","catch","cd","close","concat","continue",
  4670:   "eof","error","eval","exec","exit","expr","file","flush","for","foreach",
  4671:   "format","gets","glob","global","history","if","incr","info","join",
  4672:   "lappened","lindex","linsert","list","llength","lrange","lreplace","lsearch",
  4673:   "lsort","open","pid","proc","puts","pwd","read","regexp","regsub","rename",
  4674:   "return","scan","seek","set","source","split","string","switch","tell",
  4675:   "time","trace","unknown","unset","uplevel","upvar","while"
  4676: 	};
  4677: 	for(int k=0;k < 62;k++) {keys.push_back(K[k]);}
  4678: }
  4679: #include "langtext.h" 
  4680: 
  4681: LangText::LangText() {
  4682: 
  4683: 	init_switches();
  4684: 
  4685: 	doStrings   = No;
  4686: 	doNumbers   = No;
  4687: 	doKeywords  = No;
  4688: //	doCaseKeys  = No;
  4689: 	doRemComnt  = No;
  4690: }
  4691: 
  4692: void LangText::fill() {
  4693: 	// no keywords
  4694: }
  4695: // Author: Jeffrey Bakker  |  Date: January 29th 2003  |  languscript.cpp

  4696: 
  4697: // the UnrealScript Language definition file for Web C Plus Plus

  4698: // Webcpp Copyright (C) 2003 Jeffrey Bakker

  4699: 
  4700: #include "languscript.h"
 
  4701: 
  4702: LangUScript::LangUScript() {
  4703: 
  4704: 	fill();
  4705: 	init_switches();
  4706: 
  4707: 	doCaseKeys  = No;
  4708: 	doSymbols   = Yes;
  4709: 	doLabels    = Yes;
  4710: 	doBigComnt  = Yes;
  4711: 	doCinComnt  = Yes;
  4712: }
  4713: 
  4714: void LangUScript::fill() {
  4715: 
  4716: 	string K[] = {
  4717: "abstract","class","event","expands","extends","foreach","function","global",
  4718: "local","None","Self","state","Super","until","var"
  4719: 	};
  4720: 	for(int k=0;k < 15;k++) {keys.push_back(K[k]);}
  4721: 
  4722: 	string T[] = {
  4723: "Vector","Plane","Rotation","Coords","Color","Region","Texture",
  4724: "actor","bool","byte","name","string",
  4725: "config","native","private","transient"
  4726: 	};
  4727: 	for(int t=0;t < 16;t++) {types.push_back(T[t]);}
  4728: }
  4729: // The VHDL Language definition file for Web C Plus Plus
  4730: // Generated by Thomas Hedler<thomas.hedler@fen-net.de> using genlang.cgi
  4731: // genlang.cgi Copyright (C) 2002 Jeffrey Bakker
  4732: 
  4733: // Very High Speed Integrated Circuit Hardware Description Language
  4734: 
  4735: #include "langvhdl.h" 
  4736: 
  4737: LangVHDL ::LangVHDL() {
  4738: 
  4739: 	fill();
  4740: 	init_switches();
  4741: 
  4742: 
  4743: 	doCaseKeys  = No;
  4744: 	doLabels    = Yes;
  4745: 	doAdaComnt  = Yes;
  4746: }
  4747: 
  4748: void LangVHDL ::fill() {
  4749: 	string K[] = {
  4750:     "ABS","ACCESS","AFTER","ALIAS","ALL","AND","ARCHITECTURE","ARRAY","ASSERT",
  4751:     "ATTRIBUTE","BEGIN","BLOCK","BODY","BUFFER","BUS","CASE","COMPONENT",
  4752:     "CONFIGURATION","CONSTANT","DISCONNECT","DOWNTO","ELSE","ELSIF","END",
  4753:     "ENTITY","EXIT","FILE","FOR","FUNCTION","GENERATE","GENERIC","GUARDED",
  4754:     "IF","IN","INOUT","IS","LABEL","LIBRARY","LINKAGE","LOOP","MAP","MOD",
  4755:     "NAND","NEW","NEXT","NOR","NOT","NULL","OF","ON","OPEN","OR","OTHERS",
  4756:     "OUT","PACKAGE","PORT","PROCEDURE","PROCESS","RANGE","RECORD","REGISTER",
  4757:     "REM","REPORT","RETURN","SELECT","SEVERITY","SIGNAL","SUBTYPE","THEN","TO",
  4758:     "TRANSPORT","TYPE","UNITS","UNTIL","USE","VARIABLE","WAIT","WHEN","WHILE",
  4759:     "WITH","XOR"
  4760: 	};
  4761: 	for(int k=0;k < 81;k++) {keys.push_back(K[k]);}
  4762: }
  4763: /* webcpp - main.cpp
  4764:  * Copyright (C)2001-2003 Jeffrey Bakker
  4765: 
  4766:  * This program is free software; you can redistribute it and/or modify
  4767:  * it under the terms of the GNU General Public License as published by
  4768:  * the Free Software Foundation; either version 2 of the License, or
  4769:  * (at your option) any later version.
  4770: 
  4771:  * This program is distributed in the hope that it will be useful,
  4772:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4773:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4774:  * GNU General Public License for more details.
  4775: 
  4776:  * You should have received a copy of the GNU General Public License
  4777:  * along with this program; if not, write to the Free Software
  4778:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  4779:    ___________________________________ .. .
  4780:  */
  4781: 
  4782: 
  4783: #ifdef HAVE_CONFIG_H 
  4784: #include <config.h> 
  4785: #endif 
  4786: 
  4787: #include "driver.h" 
  4788: #include <fstream> 
  4789: using namespace std;
  4790: 
  4791: int main(int argc, char **argv) {
  4792: 
  4793: 	if(argc == 2) {
  4794: 		string tHelp = argv[1];
  4795: 		if(tHelp == "--languages") {
  4796: 			Driver::help(HELP_LANGUAGES);
  4797: 			return -1;
  4798: 		}
  4799: 	}
  4800: 
  4801: 	if(argc < 3) {
  4802: 		Driver::help(HELP_DEFAULT);
  4803: 		return -1;
  4804: 	}
  4805: 
  4806: 	string Arg1, Arg2, opt;
  4807: 	Arg1 = argv[1];
  4808: 	Arg2 = argv[2];
  4809: 
  4810: 	// file overwriting : (f)orce, (k)eep, ()ask
  4811: 	char over;
  4812: 	over = (Arg1=="-"||Arg1=="--pipe")?0x66:0x77;
  4813: 
  4814: 	int fileflag = Arg2.rfind(":");
  4815: 	if(fileflag != -1 && fileflag != 1) {
  4816: 		over = Arg2[fileflag + 1];
  4817: 		Arg2.erase(fileflag,2);
  4818: 		if(over == 'i' || over == 'r') {
  4819: 			over = 0x77;
  4820: 		}
  4821: 	}
  4822: 	/* process wildcards in filenames */
  4823: 	if(Arg1.find("*") != -1) {
  4824: 
  4825: 		cerr << "multiple input files...\n";
  4826: 
  4827: 		ifstream batch;
  4828: 		string wildcard = LIST_DIRECTORY;
  4829: 		wildcard += Arg1;
  4830: 		wildcard += " >webcppbatch.txt";
  4831: 		system(wildcard.data());
  4832: 
  4833: 		//load wildcard file, then for-loop through
  4834: 		//and run the engine each time
  4835: 		batch.open("webcppbatch.txt");
  4836: 		if(!batch) {
  4837: 			cerr << "cannot create a list of files.\n";
  4838: 			return -1;
  4839: 		}
  4840: 		string file;
  4841: 		getline(batch,file);
  4842: 		while(batch) {
  4843: 
  4844: 			Driver Webcpp;
  4845: 			cerr << "\nProcessing " << file << "...";
  4846: 			cerr << Webcpp.checkExt(file) << " detected.\n";
  4847: 
  4848: 			if(Webcpp.prep_files(file, file + ".html",over)) {
  4849: 
  4850: 				for(int i = 3;i < argc;i++) {
  4851: 					opt = argv[i];
  4852: 					if(!Webcpp.switch_parser(opt)) {
  4853: 						cerr << opt << " is an invalid option\n";
  4854: 						return -1;
  4855: 					}
  4856: 				}
  4857: 				Webcpp.drive();
  4858: 			} else return -1;
  4859: 			getline(batch,file);
  4860: 		}
  4861: 		batch.close();
  4862: 		Driver::makeIndex("");
  4863: 		system(DELETE);
  4864: 	}
  4865: 	else {
  4866: 		Driver Webcpp;
  4867: 		cerr << Webcpp.checkExt(Arg1) << " detected.\n";
  4868: 
  4869: 		if(Webcpp.prep_files(Arg1,Arg2,over)) {
  4870: 
  4871: 			for(int i = 3;i < argc;i++) {
  4872: 				opt = argv[i];
  4873: 				if(!Webcpp.switch_parser(opt)) {
  4874: 					cerr << opt << " is an invalid option\n";
  4875: 					return -1;
  4876: 				}
  4877: 			}
  4878: 			Webcpp.drive();
  4879: 		} else return -1;
  4880: 	}
  4881: 	return 0;
  4882: }
  4883: /* webcpp - theme.cpp
  4884:  * Copyright (C)2001-2003 Jeffrey Bakker
  4885: 
  4886:  * This program is free software; you can redistribute it and/or modify
  4887:  * it under the terms of the GNU General Public License as published by
  4888:  * the Free Software Foundation; either version 2 of the License, or
  4889:  * (at your option) any later version.
  4890: 
  4891:  * This program is distributed in the hope that it will be useful,
  4892:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4893:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4894:  * GNU General Public License for more details.
  4895: 
  4896:  * You should have received a copy of the GNU General Public License
  4897:  * along with this program; if not, write to the Free Software
  4898:  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  4899:    ___________________________________ .. .
  4900:  */
  4901: 
  4902: 
  4903: /*
  4904: Finished
  4905: 
  4906: Asm
  4907: Asp
  4908: C
  4909: C#
  4910: C++
  4911: CG
  4912: Fortran
  4913: HTML
  4914: Java
  4915: Modula*
  4916: Objective C
  4917: Pascal
  4918: Shell
  4919: 
  4920: */
  4921: 
  4922: #include "theme.h" 
  4923: #include <cctype> 
  4924: using namespace std;
  4925: 
  4926: // (de)construction -----------------------------------------------------------
  4927: Theme::~Theme() {
  4928: 
  4929: 	close();
  4930: }
  4931: Theme::Theme()  {
  4932: 
  4933: 	typical();
  4934: 
  4935: 	format2 = true;
  4936: 	Picture = "\0";
  4937: } //---------------------------------------------------------------------------
  4938: // set file -------------------------------------------------------------------
  4939: bool Theme::setFile(string filename) {
  4940: 
  4941: 	SCSfile = filename;
  4942: 
  4943: 	if(filename.rfind(".Scs2") == -1) {
  4944: 
  4945: 		if(filename.rfind(".scs") != -1) {
  4946: 			format2 = false;
  4947: 		}
  4948: 		else
  4949: 		filename += ".Scs2";
  4950: 	}
  4951: 	if( openR(filename) ) {
  4952: 
  4953: 		return load();
  4954: 	}
  4955: 	return false;
  4956: }
  4957: // set background picture -----------------------------------------------------
  4958: void Theme::setPicture(string picture) {
  4959: 
  4960: 	Picture = picture;
  4961: }
  4962: // get the name of the theme --------------------------------------------------
  4963: string Theme::getThemeName() {
  4964: 
  4965: 	return SCSfile;
  4966: }
  4967: // get background picture -----------------------------------------------------
  4968: string Theme::getImageFile() {
  4969: 
  4970: 	return Picture;
  4971: }
  4972: // loading a theme ------------------------------------------------------------
  4973: bool Theme::load() {
  4974: 
  4975: 	// load an Scs2-format file
  4976: 	if(format2) {
  4977: 
  4978: 		string     Scs2buf;
  4979: 		CFdatapair ScsXml;
  4980: 
  4981: 		// check for xml tag
  4982: 		getline(ifile,Scs2buf);
  4983: 		if(Scs2buf.find("<?xml version=\"1.0\"") == -1)
  4984: 		{return false;}
  4985: 		// check for the document type
  4986: 		getline(ifile,Scs2buf);
  4987: 		if(Scs2buf.find("<!DOCTYPE SyntaxColourScheme2") == -1)
  4988: 		{return false;}
  4989: 		// check for Scs2 data section
  4990: 		getline(ifile,Scs2buf);
  4991: 		if(Scs2buf.find("<SyntaxColourScheme2>") == -1)
  4992: 		{return false;}
  4993: 
  4994: 		// load the Scs2 data which may be in random order
  4995: 		getline(ifile,Scs2buf);
  4996: 		while(ifile) {
  4997: 
  4998: //			cerr << "\nScs2: " << Scs2buf << endl;
  4999: 
  5000: 			ScsXml << Scs2buf;
  5001: 			ScsVec.push_back(Scs2buf);
  5002: 			getline(ifile,Scs2buf);
  5003: 		}
  5004: 
  5005: //		for(int j=0; j < ScsVec.size(); j++) {
  5006: 
  5007: //			cerr << endl << ScsVec[j].info_nv() << endl;
  5008: //		}
  5009: 
  5010: 		// sort the Scs2 data
  5011: 		Colours2[BGCOLOR] = getColour("bgcolor");
  5012: 		Colours2[PREPROC] = getColour("preproc");
  5013: 		Colours2[NORTEXT] = getColour("nortext");
  5014: 		Colours2[SYMBOLS] = getColour("symbols");
  5015: 		Colours2[KEYWORD] = getColour("keyword");
  5016: 		Colours2[KEYTYPE] = getColour("keytype");
  5017: 		Colours2[INTEGER] = getColour("integer");
  5018: 		Colours2[FLOATPT] = getColour("floatpt");
  5019: 		Colours2[DBLQUOT] = getColour("dblquot");
  5020: 		Colours2[SINQUOT] = getColour("sinquot");
  5021: 		Colours2[COMMENT] = getColour("comment");
  5022: 		// use a background image, if found
  5023: 		Picture = getColour("background");
  5024: 
  5025: 		// check the format of all the colours
  5026: 		for(int i=BGCOLOR; i <= COMMENT; i++) {
  5027: 
  5028: 			if(Colours2[i] == "\0") {
  5029: 				typical();
  5030: 				return false;
  5031: 			}
  5032: 
  5033: 			if(Colours2[i][0] != '#') {
  5034: 				Colours2[i].insert(0,"#");
  5035: 			}
  5036: 
  5037: 			// verify data is in the right format
  5038: 			if(!verifyFormat(Colours2[i])) {
  5039: 				typical();
  5040: 				return false;
  5041: 			}
  5042: 			// if not, use the defulat scheme
  5043: 		}
  5044: 		return true;
  5045: 	}
  5046: 	// load an original SCS-format file
  5047: 	for(int i=BGCOLOR; i <= COMMENT; i++) {
  5048: 
  5049: 		ifile >> Colours2[i];
  5050: 
  5051: 		// convert old Scs to Scs2 format
  5052: 		if(i == NORTEXT) {
  5053:                 	Colours2[SYMBOLS] = Colours2[NORTEXT];
  5054: 			i++;
  5055: 		}
  5056: 		else
  5057: 		if(i == KEYWORD) {
  5058:                 	Colours2[KEYTYPE] = Colours2[KEYWORD];
  5059: 			i++;
  5060: 		}
  5061: 		else
  5062: 		if(i == INTEGER) {
  5063:                 	Colours2[FLOATPT] = Colours2[INTEGER];
  5064: 			i++;
  5065: 		}
  5066: 		else
  5067: 		if(i == DBLQUOT) {
  5068:                 	Colours2[SINQUOT] = Colours2[DBLQUOT];
  5069: 			i++;
  5070: 		}
  5071: 		// they will look exactly the same as the old style
  5072: 
  5073: 		if(!verifyFormat(Colours2[i])) {
  5074: 			typical();
  5075: 			return false;
  5076: 		}
  5077: 	}
  5078: 	return true;
  5079: }
  5080: 
  5081: 
  5082: string	Theme::getColour(string Name) {
  5083: 
  5084: 	for(int i=0; i < ScsVec.size(); i++) {
  5085: 
  5086: 		if(ScsVec[i].getname() == Name)
  5087: 			return ScsVec[i].getvalue();
  5088: 	}
  5089: //	cerr << "\nScs2: " << Name << " was not found!\n";
  5090: 	return "\0";
  5091: }
  5092: // write a stylesheet ---------------------------------------------------------
  5093: bool Theme::writeCSS(string cssfile) {
  5094: 
  5095: 	if(!openW(cssfile,true)) {return false;}
  5096: 	ofile << getCSSdata();
  5097: 	closeW();
  5098: 	return true;
  5099: }
  5100: // set a colour in the theme --------------------------------------------------
  5101: void Theme::setColour(string colour, int num) {
  5102: 
  5103: 	Colours2[num] = colour;
  5104: }
  5105: // set default theme ----------------------------------------------------------
  5106: void Theme::typical() {
  5107: 
  5108: 	SCSfile = "typical";
  5109: 
  5110: 	setColour("#f1f1f1",BGCOLOR);
  5111: 	setColour("#a900a9",PREPROC); //a900a9
  5112: 	setColour("#000000",NORTEXT);
  5113: 	setColour("#0077dd",SYMBOLS);
  5114: 	setColour("#224fff",KEYWORD);
  5115: 	setColour("#ff9933",KEYTYPE); //224fff  //ff9933
  5116: 	setColour("#ff0032",INTEGER);
  5117: 	setColour("#ff23a6",FLOATPT);
  5118: 	setColour("#00b800",DBLQUOT);
  5119: 	setColour("#00b86b",SINQUOT);
  5120: 	setColour("#666666",COMMENT);
  5121: }
  5122: // enforces proper colour format ----------------------------------------------
  5123: bool Theme::verifyFormat(string hexData) {
  5124: 
  5125: 	// make sure string is the right length
  5126: 	if (hexData.size() != 7) {
  5127: 		 cerr << hexData << "\a is an invalid colour.\n";
  5128: 		 return false;
  5129: 	}
  5130: 
  5131: 	// string must start with '#'
  5132: 	if (hexData[0] != '#') {
  5133: 		cerr << hexData << "\a is an invalid colour.\n";
  5134: 		return false;
  5135: 	}
  5136: 
  5137: 	// change string to uppercase
  5138: 	for (int i=1; i < 7; i++) {hexData[i] = toupper(hexData[i]);}
  5139: 
  5140: 	// enforce range from #000000 to #FFFFFF
  5141: 	for (int j=1; j < 7; j++) {
  5142: 
  5143: 		if (hexData[j] < '0' || hexData[j] > 'F') {
  5144: 			cerr << hexData << "\a is an invalid colour.\n";
  5145: 			return false;
  5146: 		}
  5147: 		if (ispunct(hexData[j]) || isspace(hexData[j])) {
  5148: 			cerr << hexData << "\a is an invalid colour.\n";
  5149: 			return false;
  5150: 		}
  5151: 	}
  5152: 
  5153: 	return true;
  5154: } //---------------------------------------------------------------------------
  5155: string Theme::getCSSdata() {
  5156: 
  5157: 	string CSS;
  5158: 
  5159: 	CSS =
  5160: 
  5161: "/*\nWebcpp v0.8.0 compatible StyleSheet\nhttp://webcpp.sf.net\n"
  5162: "Theme: "  +  SCSfile  + "\n*/\n\n"
  5163: "body\n{\nbackground-color: "  + Colours2[BGCOLOR] +
  5164: 
  5165: ( (Picture == "\0")
  5166: ? "\n}\n\n": ";\nbackground-image: url(\"" + Picture +
  5167: "\");\nbackground-attachment: fixed\n}\n\n" ) +
  5168: 
  5169: "a:link    {color:"        + Colours2[DBLQUOT] + "}\n"
  5170: "a:visited {color:"        + Colours2[COMMENT] + "}\n"
  5171: "a:active  {color:"        + Colours2[KEYWORD] + "}\n"
  5172: "a:hover   {color:"        + Colours2[PREPROC] + "}\n\n"
  5173: "pre\n{\ncolor: "          + Colours2[NORTEXT] + "\n}\n\n"
  5174: "font\n{\nfont-size:100%\n}\n\n"
  5175: "font.symbols\n{\ncolor: " + Colours2[SYMBOLS] + "\n}\n\n"
  5176: "font.preproc\n{\ncolor: " + Colours2[PREPROC] + "\n}\n\n"
  5177: "font.integer\n{\ncolor: " + Colours2[INTEGER] + "\n}\n\n"
  5178: "font.floatpt\n{\ncolor: " + Colours2[FLOATPT] + "\n}\n\n"
  5179: "font.dblquot\n{\ncolor: " + Colours2[DBLQUOT] + "\n}\n\n"
  5180: "font.sinquot\n{\ncolor: " + Colours2[SINQUOT] + "\n}\n\n"
  5181: "font.keyword\n{\ncolor: " + Colours2[KEYWORD] + ";\nfont-weight: bold\n}\n\n"
  5182: "font.keytype\n{\ncolor: " + Colours2[KEYTYPE] + ";\nfont-weight: bold\n}\n\n"
  5183: "font.comment\n{\ncolor: " + Colours2[COMMENT] + ";\nfont-style: italic\n}\n\n";
  5184: 
  5185: 	return CSS;
  5186: }
  5187: //-----------------------------------------------------------------------------
  5188: 



w e b c p p
web c plus plus