|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifdef _MSC_VER |
|
19 #pragma warning (disable: 4786) |
|
20 #endif // _MSC_VER |
|
21 |
|
22 |
|
23 #include <iostream> |
|
24 #include <string> |
|
25 #include <fstream> |
|
26 #include <wchar.h> |
|
27 #include <openssl/err.h> |
|
28 #include <stdio.h> |
|
29 |
|
30 #include "utility_interface.h" |
|
31 #include "options.h" |
|
32 #include "siscontents.h" |
|
33 #include "siscontroller.h" |
|
34 #include "dumpsis.h" |
|
35 |
|
36 enum DumpsisException |
|
37 { |
|
38 EDumpsisExecutionSuccessful, |
|
39 EDumpsisExecutionError, |
|
40 EDumpsisUnknownError |
|
41 }; |
|
42 |
|
43 void DisplayFileCapList(CDumpSis& dumpsis, Options& aOptions) |
|
44 { |
|
45 TFileCapTestList fileList; |
|
46 dumpsis.GetCapVerifiedFileList(fileList); |
|
47 int fileCount = fileList.size(); |
|
48 |
|
49 if(fileCount != 0 && aOptions.CreateECI() && !aOptions.Verbose()) |
|
50 { |
|
51 std::wcout << L"[FILELIST]" << std::endl; |
|
52 } |
|
53 |
|
54 for(int i = 0; i < fileCount; ++i) |
|
55 { |
|
56 std::wcout << std::endl; |
|
57 const CSISFileDescription* fdesc = fileList[i].iFileDesc; |
|
58 std::wstring str = fdesc->Target().GetString(); |
|
59 std::wcout << L"File" << i+1; |
|
60 if(aOptions.CreateECI() && !aOptions.Verbose()) |
|
61 { |
|
62 std::wcout << L"=" << str; |
|
63 std::wcout << L"@" << fdesc->Capabilities() << std::endl; |
|
64 } |
|
65 else |
|
66 { |
|
67 std::wcout << L":" << str; |
|
68 std::vector<std::wstring> capList; |
|
69 fdesc->GetCapabilityList(capList); |
|
70 std::wcout << std::endl; |
|
71 for(int j = 0; j < capList.size(); ++j) |
|
72 { |
|
73 std::wcout << L"\t" << capList[j] << std::endl; |
|
74 } |
|
75 } |
|
76 } |
|
77 if(!aOptions.Verbose()) |
|
78 { |
|
79 for(int i = 0; i < fileCount; ++i) |
|
80 { |
|
81 if(fileList[i].iActualCap < 0) |
|
82 { |
|
83 continue; |
|
84 } |
|
85 if(aOptions.CreateECI() && fileList[i].iFileDesc->Capabilities() == 0) |
|
86 { |
|
87 std::wcout << L"0" << std::endl; |
|
88 } |
|
89 else if(!aOptions.CreateECI()) |
|
90 { |
|
91 std::wcout << std::endl; |
|
92 std::wcout << L"Executable" << i+1; |
|
93 if(fileList[i].iActualCap) |
|
94 { |
|
95 std::wcout << L": capabilities matched with the SIS file header capabilities"; |
|
96 } |
|
97 else |
|
98 { |
|
99 std::wcout << L": capabilities mismatched with the SIS file header capabilities"; |
|
100 } |
|
101 std::wcout << std::endl << std::endl; |
|
102 } |
|
103 } |
|
104 } |
|
105 } |
|
106 |
|
107 int main(int argc, char *argv[]) |
|
108 { |
|
109 wchar_t **argv1 = CommandLineArgs(argc,argv); |
|
110 |
|
111 Options* options = NULL; |
|
112 int retVal = EDumpsisExecutionSuccessful; |
|
113 try |
|
114 { |
|
115 options = new Options (argc, argv1); |
|
116 |
|
117 SISLogger::SetStream(std::wcout); |
|
118 |
|
119 CDumpSis dumpsis(options->SISFileName(), options->Verbose()); |
|
120 |
|
121 CDumpSis::TExtractionLevel extractionLevel = CDumpSis::ENone; |
|
122 |
|
123 if(options->ExtractFiles()) |
|
124 { |
|
125 extractionLevel = (options->Verbose())? CDumpSis::EEverything : CDumpSis::EAllButCerts; |
|
126 } |
|
127 else |
|
128 { |
|
129 extractionLevel = CDumpSis::EAllDataFiles; |
|
130 } |
|
131 |
|
132 dumpsis.ExtractFiles(options->ExtractDirectory(), extractionLevel); |
|
133 |
|
134 if(options->Listexe()) |
|
135 { |
|
136 DisplayFileCapList(dumpsis, *options); |
|
137 } |
|
138 } |
|
139 catch (CmdLineException err) |
|
140 { |
|
141 Options::DisplayError (err); |
|
142 retVal = EDumpsisExecutionError; |
|
143 } |
|
144 catch(CSISException oops) |
|
145 { |
|
146 switch(oops.ErrorCategory()) |
|
147 { |
|
148 case CSISException::EFileProblem: |
|
149 std::cerr << "cannot open specified SIS file for reading" << std::endl; |
|
150 break; |
|
151 case CSISException::EFileFormat: |
|
152 case CSISException::EMemory: |
|
153 case CSISException::EIllegal: |
|
154 std::cerr << "error whilst parsing file contents" << std::endl; |
|
155 break; |
|
156 case CSISException::ELegacyFormat: |
|
157 std::cerr << "This is an old format (pre 9.x) SIS file, which is no longer supported" << std::endl; |
|
158 break; |
|
159 case CSISException::ECompress: |
|
160 std::cerr << "error while decompressing" << std::endl; |
|
161 break; |
|
162 default: |
|
163 std::cerr << "unknown error reading SIS file" << std::endl; |
|
164 break; |
|
165 } |
|
166 retVal = EDumpsisExecutionError; |
|
167 } |
|
168 catch (std::exception &err) |
|
169 { |
|
170 std::cerr << "Error: " << err.what() << std::endl; |
|
171 retVal = EDumpsisExecutionError; |
|
172 } |
|
173 catch (...) |
|
174 { |
|
175 retVal = EDumpsisUnknownError; |
|
176 std::cerr << "Unknown error"; |
|
177 } |
|
178 |
|
179 if ((NULL != options) && (options->PauseOnExit())) |
|
180 { |
|
181 std::cout << argv[0] << " Finished" << std::endl; |
|
182 getchar (); |
|
183 } |
|
184 delete options; |
|
185 |
|
186 return retVal; |
|
187 } |