|         |      1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). | 
|         |      2 // All rights reserved. | 
|         |      3 // This component and the accompanying materials are made available | 
|         |      4 // under the terms of "Eclipse Public License v1.0" | 
|         |      5 // which accompanies this distribution, and is available | 
|         |      6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". | 
|         |      7 // | 
|         |      8 // Initial Contributors: | 
|         |      9 // Nokia Corporation - initial contribution. | 
|         |     10 // | 
|         |     11 // Contributors: | 
|         |     12 // | 
|         |     13 // Description: | 
|         |     14 // DST TZ Database Compiler  | 
|         |     15 //  | 
|         |     16 // | 
|         |     17  | 
|         |     18 #include "TZCompiler.h" | 
|         |     19 #include <direct.h> | 
|         |     20 #include "TzGlobals.h" | 
|         |     21 #include "TzHelpers.h" | 
|         |     22 #include "tzscanner.h" | 
|         |     23  | 
|         |     24 #pragma warning(disable: 4786) | 
|         |     25  | 
|         |     26 using namespace std; | 
|         |     27 //============================================================================ | 
|         |     28 // main | 
|         |     29 // TZCompiler application entry point.  CTzCompiler does all the real work. | 
|         |     30 //============================================================================ | 
|         |     31 int main(int argc, char* argv[]) | 
|         |     32 	{ | 
|         |     33 	 | 
|         |     34 	if (argc > 1) | 
|         |     35 		{ | 
|         |     36 		TzGlobals::iIniFilePath = argv[1]; | 
|         |     37 		} | 
|         |     38 	else | 
|         |     39 		{ | 
|         |     40 		//Read the ini file to set up default parameters | 
|         |     41 		char buffer[KMaxPathLength]; | 
|         |     42 		getcwd(buffer,KMaxPathLength); | 
|         |     43 		std::string filePath(buffer); | 
|         |     44 		filePath += "\\TZCompiler.ini"; | 
|         |     45 		ifstream file(filePath.c_str()); | 
|         |     46 		if(!file) | 
|         |     47 			{ | 
|         |     48 			cerr << "Aborting - Configuration file (TZCompiler.ini) not found" << endl; | 
|         |     49 			return TzGlobals::ETzAbortNoConfigFile; | 
|         |     50 			} | 
|         |     51 		TzGlobals::iIniFilePath = filePath; | 
|         |     52 		} | 
|         |     53  | 
|         |     54 	CTzCpScanner* theScanner = new CTzCpScanner(); | 
|         |     55 	CTZDocument* theTzDocument = new CTZDocument(*theScanner); | 
|         |     56 	theScanner->SetDocument(theTzDocument); | 
|         |     57 	CTzCompiler* theCompiler = new CTzCompiler(*theTzDocument); | 
|         |     58 	try | 
|         |     59 		{ | 
|         |     60 		theCompiler->CompileL(); | 
|         |     61 		// uncomment following line for diagnostic | 
|         |     62 		//theTzDocument->DisplayData(); | 
|         |     63 		cerr << "Success" << endl; | 
|         |     64 		} | 
|         |     65  | 
|         |     66 	//Fatal errors - abort compilation | 
|         |     67 	catch (TzGlobals::TzFaults aExceptionCode) | 
|         |     68 		{ | 
|         |     69 		switch (aExceptionCode) | 
|         |     70 			{ | 
|         |     71 			case TzGlobals::ETzAbortNoInputFiles: | 
|         |     72 				cerr << "Aborting - Input files not found." << endl; | 
|         |     73 				break; | 
|         |     74 			case TzGlobals::ETzAbortCreateDatabaseFile: | 
|         |     75 				cerr << "Aborting - Could not create database file." << endl; | 
|         |     76 				break; | 
|         |     77 			case TzGlobals::ETzAbortScannerSyntaxError: | 
|         |     78 				cerr << "Aborting - Syntax errors in source files" << endl; | 
|         |     79 				break; | 
|         |     80 			case TzGlobals::ETzAbortScannerFileIOError: | 
|         |     81 				cerr << "Aborting - Could not open source file for reading"; | 
|         |     82 				break; | 
|         |     83 			default: | 
|         |     84 				cerr << "Aborting - Fatal Error" << endl; | 
|         |     85 				break; | 
|         |     86 			} | 
|         |     87 		return aExceptionCode; | 
|         |     88 		} | 
|         |     89  | 
|         |     90 	delete theCompiler; | 
|         |     91 	delete theTzDocument; | 
|         |     92 	return TzGlobals::ETzNone; | 
|         |     93 	} | 
|         |     94  | 
|         |     95 //============================================================================ | 
|         |     96 // End of file | 
|         |     97 //============================================================================ | 
|         |     98  |