secureswitools/swisistools/source/interpretsis/main.cpp
branchRCL_3
changeset 24 5cc91383ab1e
parent 0 ba25891c3a9e
child 25 7333d7932ef7
equal deleted inserted replaced
23:cd189dac02f7 24:5cc91383ab1e
     1 /*
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 #include "commandparser.h"
    27 #include "commandparser.h"
    28 #include "interpretsis.h"
    28 #include "interpretsis.h"
    29 #include "logger.h"
    29 #include "logger.h"
    30 #include "../common/exception.h"
    30 #include "../common/exception.h"
    31 
    31 
       
    32 
       
    33 #ifndef _WIN32
       
    34 #include <ctype.h>
       
    35 
       
    36 //__ctype_b was removed from glibc. This is a workaround to fix the linking problem
       
    37 extern "C"
       
    38     {
       
    39     const unsigned short int** __ctype_b()
       
    40         {
       
    41         return __ctype_b_loc();
       
    42         }
       
    43     }
       
    44 
       
    45 #endif // _WIN32
       
    46 
       
    47 
    32 int main(int argc, const char* argv[])
    48 int main(int argc, const char* argv[])
    33 	{
    49 	{
    34 	bool pauseWhenDone = false;
    50 	bool pauseWhenDone = false;
    35 
    51 
    36 	int result= SUCCESS;
    52 	int result= SUCCESS;
    46 			return 0;
    62 			return 0;
    47 			}
    63 			}
    48 
    64 
    49 		if (options.LogFile().size() > 0)
    65 		if (options.LogFile().size() > 0)
    50 			{
    66 			{
    51 			logFile = new std::wofstream(Ucs2ToUtf8(options.LogFile()).c_str(), std::ios::app);
    67 			logFile = new std::wofstream(wstring2string(options.LogFile()).c_str(), std::ios::app);
    52 			Logger::SetStream(*logFile);
    68 			Logger::SetStream(*logFile);
    53 			}
    69 			}
    54 		else
    70 		else
    55 			{
    71 			{
    56 			Logger::SetStream(std::wcout);
    72 			Logger::SetStream(std::wcout);
    88 		e.Display();
   104 		e.Display();
    89 		result = ROM_MANAGER;
   105 		result = ROM_MANAGER;
    90     	}
   106     	}
    91 	catch  (InterpretSisError& e)
   107 	catch  (InterpretSisError& e)
    92 		{
   108 		{
    93 		LERROR(L"\t" << Utf8ToUcs2(e.what()));
   109 		LERROR(L"\t" << string2wstring(e.what()));
    94 		result =  e.GetErrorCode();
   110 		result =  e.GetErrorCode();
    95 		}
   111 		}
    96 	catch (CSISException e)
   112 	catch (CSISException e)
    97 		{
   113 		{
    98 		LERROR(L"FileContents Error - ");
   114 		LERROR(L"FileContents Error - ");
   107 		result = DB_EXCEPTION;
   123 		result = DB_EXCEPTION;
   108 		}
   124 		}
   109 #endif
   125 #endif
   110 	catch (std::exception &err)
   126 	catch (std::exception &err)
   111 		{
   127 		{
   112 		std::wstring emessage = Utf8ToUcs2( err.what() );
   128 		std::wstring emessage = string2wstring( err.what() );
   113 		LERROR( L"Error: " << emessage);
   129 		LERROR( L"Error: " << emessage);
   114 		result = STD_EXCEPTION;
   130 		result = STD_EXCEPTION;
   115 		}
   131 		}
   116 	catch (...)
   132 	catch (...)
   117 		{
   133 		{