Revision d7238092
Host/Source/SerialBoot/main.c | ||
---|---|---|
380 | 380 |
strcpy(choosenID, &argv[paramIdx][2]); |
381 | 381 |
/* Transform ascii numbers in string to an integer */ |
382 | 382 |
flashingTargetID = 0; |
383 |
int idx=0; |
|
384 |
while (choosenID[idx] != 0x00) { |
|
385 |
if (flashingTargetID > 25 || ((int)choosenID[idx])-48 < 0 || ((int)choosenID[idx])-48 > 9) { |
|
386 |
flashingTargetID = 0; |
|
387 |
printf("given flashing id too high\n"); |
|
388 |
return SB_FALSE; |
|
389 |
} |
|
390 |
flashingTargetID *= 10; |
|
391 |
if (flashingTargetID >= 250 && ((int)choosenID[idx])-48 > 5) { |
|
392 |
printf("given flashing id too high\n"); |
|
393 |
return SB_FALSE; |
|
383 |
if (choosenID[0] == '0' && (choosenID[1] < '0' || choosenID[1] > '9')) { // if the ID is something like "0x..." or "0o..." |
|
384 |
switch (choosenID[1]) { |
|
385 |
case 'x': |
|
386 |
case 'X': |
|
387 |
flashingTargetID = strtoul(&choosenID[2], NULL, 16); |
|
388 |
break; |
|
389 |
case 'o': |
|
390 |
case 'O': |
|
391 |
flashingTargetID = strtoul(&choosenID[2], NULL, 8); |
|
392 |
break; |
|
393 |
case 'b': |
|
394 |
case 'B': |
|
395 |
flashingTargetID = strtoul(&choosenID[2], NULL, 2); |
|
396 |
break; |
|
397 |
case 'd': |
|
398 |
case 'D': |
|
399 |
flashingTargetID = strtoul(&choosenID[2], NULL, 10); |
|
400 |
break; |
|
401 |
default: |
|
402 |
printf("could not interprete target ID\n"); |
|
403 |
return SB_FALSE; |
|
404 |
break; |
|
394 | 405 |
} |
395 |
flashingTargetID += ((int)choosenID[idx])-48;
|
|
396 |
idx++;
|
|
406 |
} else {
|
|
407 |
flashingTargetID = strtoul(choosenID, NULL, 10);
|
|
397 | 408 |
} |
398 | 409 |
flashingTargetIDs[countFlashingPrograms] = flashingTargetID; |
399 | 410 |
} |
Also available in: Unified diff