Examines the command line like no tomorrow :-) * * Huge code, I am sorry for that. * On the other hand, cross-platformness of popt is catastrophical * and usage of boost is also too much for this simple purpose. */
| 413 | * and usage of boost is also too much for this simple purpose. |
| 414 | */ |
| 415 | int parse_commandline(int argc, char ** argv, Parameters * params) |
| 416 | { |
| 417 | int actions = 0, expectations = 0; |
| 418 | const int long_str = 63; |
| 419 | int return_value = TEST_NOTHING; |
| 420 | |
| 421 | int i; |
| 422 | for (i = 1; i < argc; i++) |
| 423 | { |
| 424 | actions = 0; |
| 425 | /* Find out what to do and what to expect */ |
| 426 | if (argv[i][0] == '-') |
| 427 | {/* Ho, an option was passed... */ |
| 428 | if (argv[i][1] == '-') |
| 429 | {/* Deal with long options */ |
| 430 | if(strncmp(argv[i], "--extension", long_str)) |
| 431 | { |
| 432 | expectations |= EXPECT_EXTENSION; |
| 433 | } |
| 434 | else if (strncmp(argv[i], "--quantile", long_str)) |
| 435 | { |
| 436 | expectations |= EXPECT_QUANTILE; |
| 437 | } |
| 438 | else if (strncmp(argv[i], "--help", long_str)) |
| 439 | { |
| 440 | actions |= ACTION_HELP; |
| 441 | } |
| 442 | else if (strncmp(argv[i], "--verbose", long_str)) |
| 443 | { |
| 444 | actions |= ACTION_VERBOSE; |
| 445 | } |
| 446 | else if (strncmp(argv[i], "--test-alpha", long_str)) |
| 447 | { |
| 448 | actions |= ACTION_TEST_ALPHA; |
| 449 | } |
| 450 | else if (strncmp(argv[i], "--preserve", long_str)) |
| 451 | { |
| 452 | actions |= ACTION_PRESERVE_TESTFILE; |
| 453 | } |
| 454 | else if (strncmp(argv[i], "--use-resolution", long_str)) |
| 455 | { |
| 456 | expectations |= EXPECT_RESOLUTION; |
| 457 | } |
| 458 | else if (strncmp(argv[i], "--are-same", long_str)) |
| 459 | { |
| 460 | expectations |= EXPECT_IMAGES; |
| 461 | } |
| 462 | else if (strncmp(argv[i], "--image-complies", long_str)) |
| 463 | { |
| 464 | expectations |= EXPECT_FILENAME; |
| 465 | } |
| 466 | |
| 467 | } |
| 468 | else /* if not (argv[i][1] == '-') */ |
| 469 | {/* Deal with short options */ |
| 470 | int j; |
| 471 | for (j = 1; j < strlen(argv[i]); j++) |
| 472 | switch(argv[i][j]) |