secureswitools/swisistools/source/interpretsis/main.cpp
branchRCL_3
changeset 81 42552535c1ac
parent 66 8b7f4e561641
equal deleted inserted replaced
73:79647526f98c 81:42552535c1ac
     1 /*
     1 /*
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2009 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 
       
    48 int main(int argc, const char* argv[])
    32 int main(int argc, const char* argv[])
    49 	{
    33 	{
    50 	bool pauseWhenDone = false;
    34 	bool pauseWhenDone = false;
    51 
    35 
    52 	int result= SUCCESS;
    36 	int result= SUCCESS;
    62 			return 0;
    46 			return 0;
    63 			}
    47 			}
    64 
    48 
    65 		if (options.LogFile().size() > 0)
    49 		if (options.LogFile().size() > 0)
    66 			{
    50 			{
    67 			logFile = new std::wofstream(wstring2string(options.LogFile()).c_str(), std::ios::app);
    51 			logFile = new std::wofstream(Ucs2ToUtf8(options.LogFile()).c_str(), std::ios::app);
    68 			Logger::SetStream(*logFile);
    52 			Logger::SetStream(*logFile);
    69 			}
    53 			}
    70 		else
    54 		else
    71 			{
    55 			{
    72 			Logger::SetStream(std::wcout);
    56 			Logger::SetStream(std::wcout);
   104 		e.Display();
    88 		e.Display();
   105 		result = ROM_MANAGER;
    89 		result = ROM_MANAGER;
   106     	}
    90     	}
   107 	catch  (InterpretSisError& e)
    91 	catch  (InterpretSisError& e)
   108 		{
    92 		{
   109 		LERROR(L"\t" << string2wstring(e.what()));
    93 		LERROR(L"\t" << Utf8ToUcs2(e.what()));
   110 		result =  e.GetErrorCode();
    94 		result =  e.GetErrorCode();
   111 		}
    95 		}
   112 	catch (CSISException e)
    96 	catch (CSISException e)
   113 		{
    97 		{
   114 		LERROR(L"FileContents Error - ");
    98 		LERROR(L"FileContents Error - ");
   123 		result = DB_EXCEPTION;
   107 		result = DB_EXCEPTION;
   124 		}
   108 		}
   125 #endif
   109 #endif
   126 	catch (std::exception &err)
   110 	catch (std::exception &err)
   127 		{
   111 		{
   128 		std::wstring emessage = string2wstring( err.what() );
   112 		std::wstring emessage = Utf8ToUcs2( err.what() );
   129 		LERROR( L"Error: " << emessage);
   113 		LERROR( L"Error: " << emessage);
   130 		result = STD_EXCEPTION;
   114 		result = STD_EXCEPTION;
   131 		}
   115 		}
   132 	catch (...)
   116 	catch (...)
   133 		{
   117 		{