| 347 | }; |
| 348 | |
| 349 | int main(int argc, char **argv) |
| 350 | { |
| 351 | if (argc < 3) { |
| 352 | ERROR("Incorrect number of args(%d)!\n", argc); |
| 353 | usage(argv[0]); |
| 354 | return 1; |
| 355 | } |
| 356 | |
| 357 | const char *prog_name = argv[0]; |
| 358 | const char *image_name = argv[1]; |
| 359 | const char *cmd = argv[2]; |
| 360 | size_t i; |
| 361 | |
| 362 | for (i = 0; i < ARRAY_SIZE(commands); i++) { |
| 363 | if (strcmp(cmd, commands[i].name)) |
| 364 | continue; |
| 365 | |
| 366 | int c; |
| 367 | int option_index; |
| 368 | |
| 369 | while (1) { |
| 370 | c = getopt_long(argc, argv, commands[i].optstring, |
| 371 | long_options, &option_index); |
| 372 | |
| 373 | if (c == -1) |
| 374 | break; |
| 375 | |
| 376 | if (strchr(commands[i].optstring, c) == NULL) { |
| 377 | ERROR("Invalid option '%c'\n", c); |
| 378 | usage(prog_name); |
| 379 | return 1; |
| 380 | } |
| 381 | |
| 382 | switch (c) { |
| 383 | case 'o': |
| 384 | params.output_dir = optarg; |
| 385 | break; |
| 386 | case 'n': |
| 387 | params.partition_name = optarg; |
| 388 | break; |
| 389 | case 'h': |
| 390 | case '?': |
| 391 | default: |
| 392 | usage(prog_name); |
| 393 | return 1; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | break; |
| 398 | } |
| 399 | |
| 400 | if (i == ARRAY_SIZE(commands)) { |
| 401 | ERROR("No command match %s\n", cmd); |
| 402 | usage(prog_name); |
| 403 | return 1; |
| 404 | } |
| 405 | |
| 406 | if (fpt_parse(image_name)) |
nothing calls this directly
no test coverage detected