Parse the argument given in the command line of the application */
| 624 | |
| 625 | /* Parse the argument given in the command line of the application */ |
| 626 | static int |
| 627 | eal_parse_args(int argc, char **argv) |
| 628 | { |
| 629 | int opt, ret; |
| 630 | char **argvopt; |
| 631 | int option_index; |
| 632 | char *prgname = argv[0]; |
| 633 | const int old_optind = optind; |
| 634 | const int old_optopt = optopt; |
| 635 | char * const old_optarg = optarg; |
| 636 | struct internal_config *internal_conf = |
| 637 | eal_get_internal_configuration(); |
| 638 | |
| 639 | argvopt = argv; |
| 640 | optind = 1; |
| 641 | |
| 642 | while ((opt = getopt_long(argc, argvopt, eal_short_options, |
| 643 | eal_long_options, &option_index)) != EOF) { |
| 644 | |
| 645 | /* getopt didn't recognise the option */ |
| 646 | if (opt == '?') { |
| 647 | eal_usage(prgname); |
| 648 | ret = -1; |
| 649 | goto out; |
| 650 | } |
| 651 | |
| 652 | /* eal_log_level_parse() already handled this option */ |
| 653 | if (opt == OPT_LOG_LEVEL_NUM) |
| 654 | continue; |
| 655 | |
| 656 | ret = eal_parse_common_option(opt, optarg, internal_conf); |
| 657 | /* common parser is not happy */ |
| 658 | if (ret < 0) { |
| 659 | eal_usage(prgname); |
| 660 | ret = -1; |
| 661 | goto out; |
| 662 | } |
| 663 | /* common parser handled this option */ |
| 664 | if (ret == 0) |
| 665 | continue; |
| 666 | |
| 667 | switch (opt) { |
| 668 | case OPT_HELP_NUM: |
| 669 | eal_usage(prgname); |
| 670 | exit(EXIT_SUCCESS); |
| 671 | |
| 672 | case OPT_HUGE_DIR_NUM: |
| 673 | { |
| 674 | char *hdir = strdup(optarg); |
| 675 | if (hdir == NULL) |
| 676 | RTE_LOG(ERR, EAL, "Could not store hugepage directory\n"); |
| 677 | else { |
| 678 | /* free old hugepage dir */ |
| 679 | free(internal_conf->hugepage_dir); |
| 680 | internal_conf->hugepage_dir = hdir; |
| 681 | } |
| 682 | break; |
| 683 | } |
no test coverage detected