|
1 /* |
|
2 * Copyright (c) 2007-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 * Commandline handler for imgcheck Tool, responsible to parse the |
|
16 * commandline options and preserve the data for later use |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent |
|
24 @released |
|
25 */ |
|
26 |
|
27 #include "cmdlinehandler.h" |
|
28 |
|
29 /** |
|
30 Constructor initializes the iOptionMap with short and long option names as key and |
|
31 the value pair says whether the respective option can have value or not. |
|
32 |
|
33 @internalComponent |
|
34 @released |
|
35 */ |
|
36 CmdLineHandler::CmdLineHandler() |
|
37 :iDebuggableFlagVal(false),iXmlFileName(GXmlFileName), iNoImage(true), iCommmandFlag(0), iValidations(0), iSuppressions(0) |
|
38 { |
|
39 iOptionMap[KLongHelpOption] = ENone; |
|
40 iOptionMap[KLongAllOption] = ENone; |
|
41 iOptionMap[KLongXmlOption] = ENone; |
|
42 iOptionMap[KLongOutputOption] = ESingle; //option can have only 1 value |
|
43 iOptionMap[KLongQuietOption] = ENone; |
|
44 iOptionMap[KLongVerboseOption] = ENone; |
|
45 iOptionMap[KLongSuppressOption]= EMultiple; //This value should be updated, while introducing new validations |
|
46 iOptionMap[KLongVidValOption]= EMultiple; |
|
47 iOptionMap[KShortHelpOption] = ENone; |
|
48 iOptionMap[KShortAllOption] = ENone; |
|
49 iOptionMap[KShortXmlOption] = ENone; |
|
50 iOptionMap[KShortOutputOption] = ESingle; //option can have only 1 value |
|
51 iOptionMap[KShortQuietOption] = ENone; |
|
52 iOptionMap[KShortVerboseOption] = ENone; |
|
53 iOptionMap[KShortSuppressOption] = EMultiple; |
|
54 iOptionMap[KShortNoCheck] = ENone; |
|
55 iOptionMap[KLongSidAllOption] = ENone; |
|
56 iOptionMap[KLongEnableDepCheck] = ENone; |
|
57 iOptionMap[KLongEnableSidCheck] = ENone; |
|
58 iOptionMap[KLongEnableVidCheck] = ENone; |
|
59 iOptionMap[KLongEnableDbgFlagCheck] = EOptional; |
|
60 iOptionMap[KLongE32InputOption] = ENone; |
|
61 iOptionMap[KLongNoCheck] = ENone; |
|
62 iSuppressVal[KSuppressDependency] = EDep; |
|
63 iSuppressVal[KSuppressSid] = ESid; |
|
64 iSuppressVal[KSuppressVid] = EVid; |
|
65 |
|
66 Version(); |
|
67 Usage(); |
|
68 } |
|
69 |
|
70 /** |
|
71 Destructor. |
|
72 |
|
73 @internalComponent |
|
74 @released |
|
75 */ |
|
76 CmdLineHandler::~CmdLineHandler() |
|
77 { |
|
78 iOptionMap.clear(); |
|
79 iImageNameList.clear(); |
|
80 iSuppressVal.clear(); |
|
81 iVidValList.clear(); |
|
82 } |
|
83 |
|
84 /** |
|
85 Function to parse the command line options. |
|
86 Responsible to |
|
87 1. Parse the input values. |
|
88 2. Print the usage note. |
|
89 3. Identify the valdations to be carried out. |
|
90 4. Type of report needs to be generated. |
|
91 |
|
92 @internalComponent |
|
93 @released |
|
94 |
|
95 @param aArgc - argument count |
|
96 @param aArgv[] - argument values |
|
97 */ |
|
98 ReturnType CmdLineHandler::ProcessCommandLine(unsigned int aArgc, char* aArgv[]) |
|
99 { |
|
100 if(aArgc < 2) |
|
101 { |
|
102 std::cout << PrintVersion().c_str() << std::endl; |
|
103 std::cout << PrintUsage().c_str() << std::endl; |
|
104 return EQuit; |
|
105 } |
|
106 ArgumentList argumentList(&aArgv[0], aArgv + aArgc); |
|
107 int argCount = argumentList.size(); |
|
108 |
|
109 iInputCommand = KToolName; |
|
110 |
|
111 for( int i = 1; i < argCount; i++ ) //Skip tool name |
|
112 { |
|
113 String name = argumentList.at(i); |
|
114 iInputCommand += " "; |
|
115 iInputCommand += name; |
|
116 int longOptionFlag = 0; |
|
117 if(IsOption(name, longOptionFlag)) |
|
118 { |
|
119 String optionName; |
|
120 bool optionValue = false; |
|
121 StringList optionValueList; |
|
122 ParseOption(name, optionName, optionValueList, optionValue); |
|
123 char shortOption = KNull; |
|
124 if(Validate(ReaderUtil::ToLower(optionName), optionValue, optionValueList.size())) |
|
125 { |
|
126 if(longOptionFlag) |
|
127 { |
|
128 shortOption = optionName.at(2); |
|
129 } |
|
130 else |
|
131 { |
|
132 shortOption = optionName.at(1); |
|
133 } |
|
134 } |
|
135 |
|
136 switch(shortOption) |
|
137 { |
|
138 case 'q': |
|
139 iCommmandFlag |= QuietMode; |
|
140 break; |
|
141 case 'a': |
|
142 iCommmandFlag |= KAll; |
|
143 break; |
|
144 case 'x': |
|
145 iCommmandFlag |= KXmlReport; |
|
146 break; |
|
147 case 'o': |
|
148 iXmlFileName.assign(optionValueList.front()); |
|
149 NormaliseName(); |
|
150 break; |
|
151 case 's': |
|
152 if((optionName == KShortSuppressOption) || (optionName == KLongSuppressOption)) |
|
153 { |
|
154 String value; |
|
155 while(optionValueList.size() > 0) |
|
156 { |
|
157 value = optionValueList.front(); |
|
158 if(iSuppressVal[value]) |
|
159 { |
|
160 if(iValidations > 0) //Is any check enabled? |
|
161 { |
|
162 if(iValidations & iSuppressVal[value]) |
|
163 { |
|
164 iValidations ^= iSuppressVal[value]; //Consider only 3 LSB's |
|
165 } |
|
166 } |
|
167 else //Is this valid value? |
|
168 { |
|
169 iSuppressions |= iSuppressVal[value]; |
|
170 } |
|
171 } |
|
172 else |
|
173 { |
|
174 throw ExceptionReporter(UNKNOWNSUPPRESSVAL,(char*)(optionValueList.front().c_str())); |
|
175 } |
|
176 optionValueList.pop_front(); |
|
177 } |
|
178 } |
|
179 else if(optionName == KLongEnableSidCheck) |
|
180 { |
|
181 iValidations |= KMarkEnable; |
|
182 iValidations |= ESid; |
|
183 } |
|
184 else if(optionName == KLongSidAllOption) |
|
185 { |
|
186 iCommmandFlag |= KSidAll; |
|
187 } |
|
188 break; |
|
189 case 'd': |
|
190 if(optionName == KLongEnableDbgFlagCheck) |
|
191 { |
|
192 iValidations |= KMarkEnable; |
|
193 iValidations |= EDbg; |
|
194 if(optionValueList.size() > 0) |
|
195 { |
|
196 if(optionValueList.front() == String("true")) |
|
197 { |
|
198 iDebuggableFlagVal = true; |
|
199 } |
|
200 else if (optionValueList.front() == String("false")) |
|
201 { |
|
202 iDebuggableFlagVal = false; |
|
203 } |
|
204 else |
|
205 { |
|
206 throw ExceptionReporter(UNKNOWNDBGVALUE); |
|
207 } |
|
208 } |
|
209 } |
|
210 else if (optionName == KLongEnableDepCheck) |
|
211 { |
|
212 iValidations |= KMarkEnable; |
|
213 iValidations |= EDep; |
|
214 } |
|
215 break; |
|
216 |
|
217 case 'e': |
|
218 if (optionName == KLongE32InputOption) |
|
219 { |
|
220 iCommmandFlag |= KE32Input; |
|
221 } |
|
222 break; |
|
223 |
|
224 case 'v': |
|
225 if(optionName == KLongVidValOption) |
|
226 { |
|
227 StringListToUnIntList(optionValueList, iVidValList); |
|
228 } |
|
229 else if(optionName == KLongEnableVidCheck) |
|
230 { |
|
231 iValidations |= KMarkEnable; |
|
232 iValidations |= EVid; |
|
233 } |
|
234 else |
|
235 { |
|
236 iCommmandFlag |= KVerbose; |
|
237 /**Initialize ExceptionImplementation class with verbose mode flag |
|
238 to print all status information to standard output*/ |
|
239 ExceptionImplementation::Instance(iCommmandFlag); |
|
240 } |
|
241 break; |
|
242 case 'n': |
|
243 iCommmandFlag |= KNoCheck; |
|
244 break; |
|
245 case 'h': |
|
246 std::cout << PrintVersion().c_str() << std::endl; |
|
247 std::cout << PrintUsage().c_str() << std::endl; |
|
248 return EQuit; //Don't proceed further |
|
249 } |
|
250 } |
|
251 else |
|
252 { |
|
253 if(!AlreadyReceived(name)) |
|
254 { |
|
255 iImageNameList.push_back(name); |
|
256 } |
|
257 else |
|
258 { |
|
259 ExceptionReporter(IMAGENAMEALREADYRECEIVED, (char*)name.c_str()).Report(); |
|
260 } |
|
261 |
|
262 iNoImage = false; |
|
263 } |
|
264 } //While loop ends here |
|
265 if((iCommmandFlag || iValidations || iSuppressions) && iNoImage) |
|
266 { |
|
267 PrintVersion(); |
|
268 PrintUsage(); |
|
269 } |
|
270 //Always log the version information into log file |
|
271 ExceptionImplementation::Instance(iCommmandFlag)->Log(iVersion); |
|
272 ValidateArguments(); |
|
273 ValidateE32NoCheckArguments(); |
|
274 if(iCommmandFlag & KE32Input) |
|
275 { |
|
276 ValidateImageNameList(); |
|
277 } |
|
278 return ESuccess; |
|
279 } |
|
280 |
|
281 /** |
|
282 Function identify whether the passed string is an option or not. |
|
283 |
|
284 @internalComponent |
|
285 @released |
|
286 |
|
287 @param aName - a string received as part of command line |
|
288 @param aLongOptionFlag - this flag is set if the option is long else |
|
289 it is assumed as short option. |
|
290 |
|
291 @return - returns true or false |
|
292 */ |
|
293 bool CmdLineHandler::IsOption(const String& aName, int& aLongOptionFlag) |
|
294 { |
|
295 unsigned int prefixCount = 0; |
|
296 while(aName.at(prefixCount) == KShortOptionPrefix) |
|
297 { |
|
298 if(aName.length() == ++prefixCount) |
|
299 { |
|
300 throw ExceptionReporter(UNKNOWNOPTION, (char*)aName.c_str()); |
|
301 } |
|
302 } |
|
303 |
|
304 switch(prefixCount) |
|
305 { |
|
306 case 0: //argument can be an image |
|
307 return false; |
|
308 case 1: // '-' |
|
309 return true; |
|
310 case 2: // '--' |
|
311 aLongOptionFlag = 1; |
|
312 return true; |
|
313 default: |
|
314 throw ExceptionReporter(UNKNOWNPREFIX, (char*)aName.c_str()); |
|
315 } |
|
316 } |
|
317 |
|
318 /** |
|
319 Function to do syntax validation on the received option. |
|
320 1. Identifies whether the received option is valid or not. |
|
321 2. Identifies whether the option can have vaue or not. |
|
322 3. Throws an error if no value received for an option which should have value. |
|
323 4. Throws an error if more number of values received. |
|
324 5. Throws an error if an unwanted value received. |
|
325 6. Throws an error if the option is not a valid one. |
|
326 |
|
327 @internalComponent |
|
328 @released |
|
329 |
|
330 @param aOption - a string received as part of command line. |
|
331 @param aOptionValue - Whether option value received or not. |
|
332 @param aNoOfVal - Number of values received for this option. |
|
333 |
|
334 @return - returns true if it is a valid option |
|
335 */ |
|
336 bool CmdLineHandler::Validate(const String& aOption, bool aOptionValue, unsigned int aNoOfVal) |
|
337 { |
|
338 if(iOptionMap.find(aOption) != iOptionMap.end()) |
|
339 { |
|
340 if(iOptionMap[aOption]) //Option can have value? |
|
341 { |
|
342 if((aNoOfVal == ENone) && (iOptionMap[aOption] != EOptional)) //No values received? |
|
343 { |
|
344 throw ExceptionReporter(VALUEEXPECTED, (char*)aOption.c_str()); |
|
345 } |
|
346 |
|
347 if((iOptionMap[aOption] == ESingle) && (ESingle < aNoOfVal)) //Received values are more than expected |
|
348 { |
|
349 throw ExceptionReporter(UNEXPECTEDNUMBEROFVALUE,(char*)aOption.c_str()); |
|
350 } |
|
351 } |
|
352 else |
|
353 { |
|
354 if(aOptionValue) //Is option value received? Any character after the option considered as value. |
|
355 { |
|
356 throw ExceptionReporter(VALUENOTEXPECTED, (char*)aOption.c_str()); |
|
357 } |
|
358 } |
|
359 return true; |
|
360 } |
|
361 throw ExceptionReporter(UNKNOWNOPTION, (char*)aOption.c_str()); |
|
362 } |
|
363 |
|
364 /** |
|
365 Function to split the option name and option values. |
|
366 1. Ignore's the '=' symbol which is following the option. But this is an error, if that |
|
367 option does not expecting any value. |
|
368 2. Parses the value received with options. |
|
369 |
|
370 @internalComponent |
|
371 @released |
|
372 |
|
373 @param aFullName - Option with its value |
|
374 @param aOptionName - Option name put into this parameter |
|
375 @param aOptionValues - Option values put into this parameter |
|
376 @param aOptionValue - Set this flag if any value received with the option. |
|
377 */ |
|
378 void CmdLineHandler::ParseOption(const String& aFullName, String& aOptionName, StringList& aOptionValues, bool& aOptionValue) |
|
379 { |
|
380 unsigned int optionEndLocation = aFullName.find("="); |
|
381 if(optionEndLocation != String::npos) |
|
382 { |
|
383 aOptionValue = true; |
|
384 aOptionName = aFullName.substr(0, optionEndLocation++); |
|
385 if(aFullName.length() == optionEndLocation) |
|
386 { |
|
387 throw ExceptionReporter(VALUEEXPECTED, (char*)aOptionName.c_str()); |
|
388 } |
|
389 String sub = aFullName.substr(optionEndLocation); |
|
390 char* optionValues = (char*)sub.c_str(); |
|
391 //Get all the values; use (,) as delimiter |
|
392 char* value = strtok(optionValues,","); |
|
393 while(value != KNull) |
|
394 { |
|
395 String str(value); |
|
396 aOptionValues.push_back(ReaderUtil::ToLower(str)); |
|
397 value = strtok(KNull,","); |
|
398 } |
|
399 return; |
|
400 } |
|
401 aOptionName = aFullName; |
|
402 } |
|
403 |
|
404 /** |
|
405 Function to initialize the usage. |
|
406 |
|
407 @internalComponent |
|
408 @released |
|
409 */ |
|
410 void CmdLineHandler::Usage(void) |
|
411 { |
|
412 iUsage.assign("imgcheck [options] <img1> [<img2 .. imgN>] \n" |
|
413 "imgcheck --e32input [options] (<file> | <directory>) \n" |
|
414 "\n" |
|
415 "options: \n" |
|
416 " -a, --all, Report all executable's status\n" |
|
417 " -q, --quiet, Command line display off\n" |
|
418 " -x, --xml, Generate XML report\n" |
|
419 " -o=xxx, --output=xxx Override default XML file name\n" |
|
420 " -v, --verbose, Verbose mode output\n" |
|
421 " -h, --help, Display this message\n" |
|
422 " -s=val1[,val2][...], --suppress=val1[,val2][...] \n" |
|
423 " Suppress one or more check,\n" |
|
424 " Possible values are dep, sid and vid\n" |
|
425 " --vidlist=val1[,val2][...] \n" |
|
426 " One or more VID value(s) \n" |
|
427 " --dep Enable dependency check\n" |
|
428 " --vid Enable VID check\n" |
|
429 " --sid Enable SID check, only EXEs are considered by default\n" |
|
430 " --sidall Include DLL also into SID check\n" |
|
431 " --dbg[=val] Enable Debug flag check,\n" |
|
432 " Optionally over ride the default value 'false'\n" |
|
433 " --e32input Switches the tool to filesystem mode\n" |
|
434 " -n, --nocheck Don't report any check(s) status\n"); |
|
435 } |
|
436 |
|
437 /** |
|
438 Function to return the usage. |
|
439 |
|
440 @internalComponent |
|
441 @released |
|
442 */ |
|
443 const String& CmdLineHandler::PrintUsage(void) const |
|
444 { |
|
445 return iUsage; |
|
446 } |
|
447 |
|
448 /** |
|
449 Function to prepare the version information. |
|
450 |
|
451 @internalComponent |
|
452 @released |
|
453 */ |
|
454 void CmdLineHandler::Version(void) |
|
455 { |
|
456 iVersion.append(gToolDesc); |
|
457 iVersion.append(gMajorVersion); |
|
458 iVersion.append(gMinorVersion); |
|
459 iVersion.append(gMaintenanceVersion); |
|
460 iVersion.append(gCopyright); |
|
461 } |
|
462 |
|
463 /** |
|
464 Function to return the version information. |
|
465 |
|
466 @internalComponent |
|
467 @released |
|
468 */ |
|
469 const String& CmdLineHandler::PrintVersion(void) const |
|
470 { |
|
471 return iVersion; |
|
472 } |
|
473 |
|
474 /** |
|
475 Function to return the image name one by one. |
|
476 |
|
477 @internalComponent |
|
478 @released |
|
479 |
|
480 @return - returns image name |
|
481 */ |
|
482 String CmdLineHandler::NextImageName(void) |
|
483 { |
|
484 String imageName = iImageNameList.front(); |
|
485 iImageNameList.pop_front(); |
|
486 return imageName; |
|
487 } |
|
488 |
|
489 /** |
|
490 Function to return the iCommmandFlag. |
|
491 |
|
492 @internalComponent |
|
493 @released |
|
494 |
|
495 @return - returns iCommmandFlag value. |
|
496 */ |
|
497 const unsigned int CmdLineHandler::ReportFlag(void) const |
|
498 { |
|
499 return iCommmandFlag; |
|
500 } |
|
501 |
|
502 /** |
|
503 Function to return the iXmlFileName. |
|
504 |
|
505 @internalComponent |
|
506 @released |
|
507 |
|
508 @return - returns iXmlFileName value. |
|
509 */ |
|
510 const String& CmdLineHandler::XmlReportName(void) const |
|
511 { |
|
512 return iXmlFileName; |
|
513 } |
|
514 |
|
515 |
|
516 /** |
|
517 Function to append the XML extension to the received XML name. |
|
518 |
|
519 @internalComponent |
|
520 @released |
|
521 */ |
|
522 void CmdLineHandler::NormaliseName(void) |
|
523 { |
|
524 if (iXmlFileName.find(KXmlExtension) == String::npos) |
|
525 { |
|
526 iXmlFileName.append(KXmlExtension); |
|
527 } |
|
528 } |
|
529 |
|
530 /** |
|
531 Function to validate the arguements to ensure that the tool is invoked with proper |
|
532 arguments. |
|
533 |
|
534 @internalComponent |
|
535 @released |
|
536 */ |
|
537 void CmdLineHandler::ValidateArguments(void) const |
|
538 { |
|
539 unsigned int validations = EnabledValidations(); |
|
540 validations = (validations & KMarkEnable) ? iValidations ^ KMarkEnable:validations; //disable MSB |
|
541 |
|
542 if( iCommmandFlag & QuietMode && !(iCommmandFlag & KXmlReport)) |
|
543 { |
|
544 throw ExceptionReporter(QUIETMODESELECTED); |
|
545 } |
|
546 |
|
547 if(!(iCommmandFlag & KXmlReport) && (iXmlFileName != GXmlFileName)) |
|
548 { |
|
549 ExceptionReporter(XMLOPTION).Report(); |
|
550 } |
|
551 |
|
552 if((iVidValList.size() > 0) && (validations & EVid) == 0) |
|
553 { |
|
554 ExceptionReporter(SUPPRESSCOMBINEDWITHVIDVAL).Report(); |
|
555 } |
|
556 |
|
557 if((iCommmandFlag & KSidAll) && ((validations & ESid)==0)) |
|
558 { |
|
559 ExceptionReporter(SIDALLCOMBINEDWITHSID).Report(); |
|
560 } |
|
561 |
|
562 if( validations == ENone) |
|
563 { |
|
564 throw ExceptionReporter(ALLCHECKSSUPPRESSED); |
|
565 } |
|
566 |
|
567 if(iNoImage) |
|
568 { |
|
569 throw ExceptionReporter(NOIMAGE); |
|
570 } |
|
571 } |
|
572 |
|
573 /** |
|
574 Function to return number of images received through command line. |
|
575 |
|
576 @internalComponent |
|
577 @released |
|
578 */ |
|
579 unsigned int CmdLineHandler::NoOfImages(void) const |
|
580 { |
|
581 return iImageNameList.size(); |
|
582 } |
|
583 |
|
584 /** |
|
585 Function to return Validations needs to be performed. |
|
586 1. If any validation is enabled, then only enabled validations are carried. |
|
587 2. If any validation is suppressed, then all validations are carried execept the suppressed ones. |
|
588 |
|
589 @internalComponent |
|
590 @released |
|
591 |
|
592 @return - returns the enabled Validations |
|
593 */ |
|
594 const unsigned int CmdLineHandler::EnabledValidations(void) const |
|
595 { |
|
596 if(iValidations > 0) |
|
597 { |
|
598 return iValidations; |
|
599 } |
|
600 return (iSuppressions ^ EAllValidation); //Enable unsuppressed options |
|
601 } |
|
602 |
|
603 /** |
|
604 Function to convert strings to integers. |
|
605 1. If any validation is enabled, then only enabled validations are carried. |
|
606 2. If any validation is suppressed, then all validations are carried execept the suppressed ones. |
|
607 3. Throws an error if the value is not a decimal or hexadecimal one. |
|
608 |
|
609 @internalComponent |
|
610 @released |
|
611 |
|
612 @param aStrList - List VID values received at command line |
|
613 @param aUnIntList - Received values are validated and put into this container. |
|
614 */ |
|
615 void CmdLineHandler::StringListToUnIntList(StringList& aStrList, UnIntList& aUnIntList) |
|
616 { |
|
617 String tempString; |
|
618 Long64 intValue = 0; |
|
619 while(aStrList.size() > 0) |
|
620 { |
|
621 tempString = aStrList.front(); |
|
622 if(tempString.length() >= 2) //Hex number should start with '0x' |
|
623 { |
|
624 //is this an Hexadecimal number? |
|
625 if((tempString.at(0) == '0') && (tempString.at(1) == 'x')) |
|
626 { |
|
627 tempString = tempString.substr(2); |
|
628 unsigned int location = 0; |
|
629 if(!tempString.empty()) |
|
630 { |
|
631 while(location < tempString.length()) //Ignore proceeding zeros. |
|
632 { |
|
633 if(tempString.at(location) == '0') |
|
634 { |
|
635 location++; |
|
636 continue; |
|
637 } |
|
638 break; |
|
639 } |
|
640 } |
|
641 else |
|
642 { |
|
643 throw ExceptionReporter(INVALIDVIDVALUE,(char*)aStrList.front().c_str()); |
|
644 } |
|
645 tempString = tempString.substr(location); |
|
646 if(tempString.empty() && location != 0) |
|
647 { |
|
648 tempString = '0'; |
|
649 } |
|
650 unsigned int strLength = tempString.length(); |
|
651 if(strLength <= KHexEightByte && strLength > 0) |
|
652 { |
|
653 if(tempString.find_first_not_of(KHexNumber) == String::npos) |
|
654 { |
|
655 aUnIntList.push_back(ReaderUtil::HexStrToInt(tempString)); |
|
656 aStrList.pop_front(); |
|
657 continue; |
|
658 } |
|
659 } |
|
660 else |
|
661 { |
|
662 throw ExceptionReporter(DATAOVERFLOW,(char*)tempString.c_str()); |
|
663 } |
|
664 } |
|
665 } |
|
666 //is this an Decimal number? |
|
667 if(tempString.find_first_not_of(KDecNumber) == String::npos) |
|
668 { |
|
669 intValue = ReaderUtil::DecStrToInt(tempString); |
|
670 if(intValue <= KDecHighValue) |
|
671 { |
|
672 aUnIntList.push_back(intValue); |
|
673 } |
|
674 else |
|
675 { |
|
676 throw ExceptionReporter(DATAOVERFLOW,(char*)tempString.c_str()); |
|
677 } |
|
678 } |
|
679 else |
|
680 { |
|
681 throw ExceptionReporter(INVALIDVIDVALUE,(char*)tempString.c_str()); |
|
682 } |
|
683 aStrList.pop_front(); |
|
684 } |
|
685 } |
|
686 |
|
687 |
|
688 |
|
689 /** |
|
690 Function to return vid value list. |
|
691 |
|
692 @internalComponent |
|
693 @released |
|
694 |
|
695 @return - returns vid value list. |
|
696 */ |
|
697 UnIntList& CmdLineHandler::VidValueList() |
|
698 { |
|
699 return iVidValList; |
|
700 } |
|
701 |
|
702 /** |
|
703 Function to return input command string. |
|
704 |
|
705 @internalComponent |
|
706 @released |
|
707 |
|
708 @return - returns iInputCommand. |
|
709 */ |
|
710 const String& CmdLineHandler::Command() const |
|
711 { |
|
712 return iInputCommand; |
|
713 } |
|
714 |
|
715 /** |
|
716 Function identifies whether the image is already received or not. |
|
717 |
|
718 @internalComponent |
|
719 @released |
|
720 |
|
721 @return - returns true if the image is already received. |
|
722 - returns false if the image is not received already. |
|
723 */ |
|
724 bool CmdLineHandler::AlreadyReceived(String& aName) |
|
725 { |
|
726 StringList::iterator nameBegin = iImageNameList.begin(); |
|
727 StringList::iterator nameEnd = iImageNameList.end(); |
|
728 while(nameBegin != nameEnd) |
|
729 { |
|
730 if(aName == *nameBegin) |
|
731 { |
|
732 return true; |
|
733 } |
|
734 ++nameBegin; |
|
735 } |
|
736 return false; |
|
737 } |
|
738 |
|
739 /** |
|
740 Function to return debug flag value. |
|
741 |
|
742 @internalComponent |
|
743 @released |
|
744 |
|
745 @return - returns iDebuggableFlagVal. |
|
746 */ |
|
747 bool CmdLineHandler::DebuggableFlagVal() |
|
748 { |
|
749 return iDebuggableFlagVal; |
|
750 } |
|
751 |
|
752 /** |
|
753 Function to validate the e32 input. |
|
754 |
|
755 @internalComponent |
|
756 @released |
|
757 |
|
758 */ |
|
759 void CmdLineHandler::ValidateImageNameList(void) |
|
760 { |
|
761 if(iImageNameList.size() > 1) |
|
762 { |
|
763 throw ExceptionReporter(ONLYSINGLEDIRECTORYEXPECTED); |
|
764 } |
|
765 } |
|
766 |
|
767 |
|
768 /** |
|
769 Function to validate the e32 and no check option arguments. |
|
770 |
|
771 @internalComponent |
|
772 @released |
|
773 |
|
774 */ |
|
775 void CmdLineHandler::ValidateE32NoCheckArguments(void) |
|
776 { |
|
777 if((iCommmandFlag & KE32Input) && !iValidations) |
|
778 { |
|
779 throw ExceptionReporter(NOVALIDATIONSENABLED); |
|
780 } |
|
781 |
|
782 if((iCommmandFlag & KE32Input) && (iValidations & (EDep | ESid))) |
|
783 { |
|
784 ExceptionReporter(INCORRECTVALUES).Report(); |
|
785 } |
|
786 } |