1: /* webcpp - main.cpp
     2:  * Copyright (C)2001-2003 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: 
    20: 
    21: #ifdef HAVE_CONFIG_H 
    22: #include <config.h> 
    23: #endif 
    24: 
    25: #include "driver.h" 
    26: #include <fstream> 
    27: using namespace std;
    28: 
    29: int main(int argc, char **argv) {
    30: 
    31: 	if(argc == 2) {
    32: 		string tHelp = argv[1];
    33: 		if(tHelp == "--languages") {
    34: 			Driver::help(HELP_LANGUAGES);
    35: 			return -1;
    36: 		}
    37: 	}
    38: 
    39: 	if(argc < 3) {
    40: 		Driver::help(HELP_DEFAULT);
    41: 		return -1;
    42: 	}
    43: 
    44: 	string Arg1, Arg2, opt;
    45: 	Arg1 = argv[1];
    46: 	Arg2 = argv[2];
    47: 
    48: 	// file overwriting : (f)orce, (k)eep, ()ask
    49: 	char over;
    50: 	over = (Arg1=="-"||Arg1=="--pipe")?0x66:0x77;
    51: 
    52: 	int fileflag = Arg2.rfind(":");
    53: 	if(fileflag != -1 && fileflag != 1) {
    54: 		over = Arg2[fileflag + 1];
    55: 		Arg2.erase(fileflag,2);
    56: 		if(over == 'i' || over == 'r') {
    57: 			over = 0x77;
    58: 		}
    59: 	}
    60: 	/* process wildcards in filenames */
    61: 	if(Arg1.find("*") != -1) {
    62: 
    63: 		cerr << "multiple input files...\n";
    64: 
    65: 		ifstream batch;
    66: 		string wildcard = LIST_DIRECTORY;
    67: 		wildcard += Arg1;
    68: 		wildcard += " >webcppbatch.txt";
    69: 		system(wildcard.data());
    70: 
    71: 		//load wildcard file, then for-loop through
    72: 		//and run the engine each time
    73: 		batch.open("webcppbatch.txt");
    74: 		if(!batch) {
    75: 			cerr << "cannot create a list of files.\n";
    76: 			return -1;
    77: 		}
    78: 		string file;
    79: 		getline(batch,file);
    80: 		while(batch) {
    81: 
    82: 			Driver Webcpp;
    83: 			cerr << "\nProcessing " << file << "...";
    84: 			cerr << Webcpp.checkExt(file) << " detected.\n";
    85: 
    86: 			if(Webcpp.prep_files(file, file + ".html",over)) {
    87: 
    88: 				for(int i = 3;i < argc;i++) {
    89: 					opt = argv[i];
    90: 					if(!Webcpp.switch_parser(opt)) {
    91: 						cerr << opt << " is an invalid option\n";
    92: 						return -1;
    93: 					}
    94: 				}
    95: 				Webcpp.drive();
    96: 			} else return -1;
    97: 			getline(batch,file);
    98: 		}
    99: 		batch.close();
   100: 		Driver::makeIndex("");
   101: 		system(DELETE);
   102: 	}
   103: 	else {
   104: 		Driver Webcpp;
   105: 		cerr << Webcpp.checkExt(Arg1) << " detected.\n";
   106: 
   107: 		if(Webcpp.prep_files(Arg1,Arg2,over)) {
   108: 
   109: 			for(int i = 3;i < argc;i++) {
   110: 				opt = argv[i];
   111: 				if(!Webcpp.switch_parser(opt)) {
   112: 					cerr << opt << " is an invalid option\n";
   113: 					return -1;
   114: 				}
   115: 			}
   116: 			Webcpp.drive();
   117: 		} else return -1;
   118: 	}
   119: 	return 0;
   120: }
   121: 



w e b c p p
web c plus plus