secureswitools/swisistools/source/interpretsislib/rommanager.cpp
changeset 60 245df5276b97
parent 0 ba25891c3a9e
child 81 42552535c1ac
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-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 "parameterlist.h"
    27 #include "parameterlist.h"
    28 #include "stringutils.h"
    28 #include "stringutils.h"
    29 #include "is_utils.h"
    29 #include "is_utils.h"
    30 
    30 
    31 // String constants
    31 // String constants
       
    32 #ifndef __TOOLS2_LINUX__
    32 const std::wstring KRomManagerSysBinPath 			= L"z:\\sys\\bin\\";
    33 const std::wstring KRomManagerSysBinPath 			= L"z:\\sys\\bin\\";
    33 const std::string KRomManagerRomDrive               = "Z:\\";
    34 const std::string KRomManagerRomDrive               = "Z:\\";
       
    35 #else
       
    36 const std::wstring KRomManagerSysBinPath 			= L"z:/sys/bin/";
       
    37 const std::string KRomManagerRomDrive               = "Z:/";
       
    38 #endif
    34 const std::string KRomManagerRomLogProcessingFile   = "Processing file ";
    39 const std::string KRomManagerRomLogProcessingFile   = "Processing file ";
    35 const std::string KRomManagerRomLogReadingResource  = "Reading resource ";
    40 const std::string KRomManagerRomLogReadingResource  = "Reading resource ";
    36 const std::string KRomManagerRomLogReadingResource2 = " to rom linear address";
    41 const std::string KRomManagerRomLogReadingResource2 = " to rom linear address";
    37 const std::string KRomManagerRomLogUids             = "Uids:                    ";
    42 const std::string KRomManagerRomLogUids             = "Uids:                    ";
    38 const std::string KRomManagerRomLogSecureId         = "Secure ID:               ";
    43 const std::string KRomManagerRomLogSecureId         = "Secure ID:               ";
   144 RomManagerLogFiles::RomManagerLogFiles( const std::list<std::wstring>& aLogFileNames )
   149 RomManagerLogFiles::RomManagerLogFiles( const std::list<std::wstring>& aLogFileNames )
   145 :   iLogFileNames( aLogFileNames )
   150 :   iLogFileNames( aLogFileNames )
   146     {
   151     {
   147     for( std::list<std::wstring>::const_iterator it = aLogFileNames.begin() ; it != aLogFileNames.end(); it++ )
   152     for( std::list<std::wstring>::const_iterator it = aLogFileNames.begin() ; it != aLogFileNames.end(); it++ )
   148         {
   153         {
   149     	std::string narrowLogFileName = Ucs2ToUtf8( *it );
   154     	std::string narrowLogFileName = wstring2string( *it );
   150     	std::string narrowUpperCaseLogFileName = StringUtils::ToUpper( narrowLogFileName );
   155     	std::string narrowUpperCaseLogFileName = StringUtils::ToUpper( narrowLogFileName );
   151 
   156 
   152         // Get the base name
   157         // Get the base name
   153         int dotPos = narrowUpperCaseLogFileName.find( ".LOG" );
   158         int dotPos = narrowUpperCaseLogFileName.find( ".LOG" );
   154         if ( dotPos == std::string::npos )
   159         if ( dotPos == std::string::npos )
   186     {
   191     {
   187     bool exists = false;
   192     bool exists = false;
   188 
   193 
   189     // Get filename & convert it to uppercase, since our map key is
   194     // Get filename & convert it to uppercase, since our map key is
   190     // also in upper case form.
   195     // also in upper case form.
   191     std::string narrowFileName = Ucs2ToUtf8( aFileName );
   196     std::string narrowFileName = wstring2string( aFileName );
   192     narrowFileName = StringUtils::ToUpper( narrowFileName );
   197     narrowFileName = StringUtils::ToUpper( narrowFileName );
   193 
   198 
   194     // Do we have a corresponding entry?
   199     // Do we have a corresponding entry?
   195     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   200     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   196     if ( entry != NULL )
   201     if ( entry != NULL )
   208 
   213 
   209 	std::wstring searchNameWild = StringUtils::ToUpper(aSearchNameWild);
   214 	std::wstring searchNameWild = StringUtils::ToUpper(aSearchNameWild);
   210 
   215 
   211 	for ( ; curr != end ; ++curr)
   216 	for ( ; curr != end ; ++curr)
   212 		{
   217 		{
   213 		std::wstring romFile = Utf8ToUcs2(curr->first);
   218 		std::wstring romFile = string2wstring(curr->first);
   214 		if (StringUtils::WildcardCompare(searchNameWild,romFile))
   219 		if (StringUtils::WildcardCompare(searchNameWild,romFile))
   215 			{
   220 			{
   216 			aAdornedFileNamesFound.push_back(romFile);
   221 			aAdornedFileNamesFound.push_back(romFile);
   217 			}
   222 			}
   218 		}
   223 		}
   231 			if (romEntry->Type() == RomEntry::ETypeBinary)
   236 			if (romEntry->Type() == RomEntry::ETypeBinary)
   232 				{
   237 				{
   233 				TUint32 romSid = romEntry->SecurityInfo().iSecureId;
   238 				TUint32 romSid = romEntry->SecurityInfo().iSecureId;
   234 				if (romSid != 0 && romSid == aSid)
   239 				if (romSid != 0 && romSid == aSid)
   235 					{
   240 					{
   236 					aFile = Utf8ToUcs2(romEntry->RomFileName());
   241 					aFile = string2wstring(romEntry->RomFileName());
   237 					return true;
   242 					return true;
   238 					}
   243 					}
   239 				}
   244 				}
   240 			}
   245 			}
   241 		}
   246 		}
   246     {
   251     {
   247     TInt err = -1;
   252     TInt err = -1;
   248 
   253 
   249     // Get filename & convert it to uppercase, since our map key is
   254     // Get filename & convert it to uppercase, since our map key is
   250     // also in upper case form.
   255     // also in upper case form.
   251     std::string narrowFileName = Ucs2ToUtf8( aFileName );
   256     std::string narrowFileName = wstring2string( aFileName );
   252     narrowFileName = StringUtils::ToUpper( narrowFileName );
   257     narrowFileName = StringUtils::ToUpper( narrowFileName );
   253 
   258 
   254     // Do we have a corresponding entry?
   259     // Do we have a corresponding entry?
   255     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   260     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   256     if ( entry != NULL )
   261     if ( entry != NULL )
   267     }
   272     }
   268 
   273 
   269 
   274 
   270 void RomManagerLogFiles::ReadObyFile( const std::string& aFileName )
   275 void RomManagerLogFiles::ReadObyFile( const std::string& aFileName )
   271     {
   276     {
   272 	std::wstring fileName = Utf8ToUcs2( aFileName );
   277 	std::wstring fileName = string2wstring( aFileName );
   273     if ( FileExists( fileName ) )
   278     if ( FileExists( fileName ) )
   274         {
   279         {
   275     	std::ifstream stream;
   280     	std::ifstream stream;
   276 	    stream.open( aFileName.c_str(), std::ios::binary );
   281 	    stream.open( aFileName.c_str(), std::ios::binary );
   277         //
   282         //
   568 		stream << "Unknown error";
   573 		stream << "Unknown error";
   569 		break;
   574 		break;
   570 	}
   575 	}
   571     //
   576     //
   572     stream << std::endl;
   577     stream << std::endl;
   573     std::wstring finalMessage = Utf8ToUcs2( stream.str() );
   578     std::wstring finalMessage = string2wstring( stream.str() );
   574     //
   579     //
   575 	LERROR( finalMessage );
   580 	LERROR( finalMessage );
   576     }
   581     }