src/dpdk/lib/librte_eal/freebsd/eal.c
static int
eal_parse_args(int argc, char **argv)
{
	int opt, ret;
	char **argvopt;
	int option_index;
	char *prgname = argv[0];
	const int old_optind = optind;
	const int old_optopt = optopt;
	const int old_optreset = optreset;
	char * const old_optarg = optarg;
	struct internal_config *internal_conf =
		eal_get_internal_configuration();

	argvopt = argv;
	optind = 1;
	optreset = 1;

	while ((opt = getopt_long(argc, argvopt, eal_short_options,
				  eal_long_options, &option_index)) != EOF) {

		/* getopt didn't recognise the option */
		if (opt == '?') {
			eal_usage(prgname);
			ret = -1;
			goto out;
		}

		ret = eal_parse_common_option(opt, optarg, internal_conf);
		/* common parser is not happy */
		if (ret < 0) {
			eal_usage(prgname);
			ret = -1;
			goto out;
		}
		/* common parser handled this option */
		if (ret == 0)
			continue;

		switch (opt) {
		case OPT_MBUF_POOL_OPS_NAME_NUM:
		{
			char *ops_name = strdup(optarg);
			if (ops_name == NULL)
				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
			else {
				/* free old ops name */
				if (internal_conf->user_mbuf_pool_ops_name !=
						NULL)
					free(internal_conf->user_mbuf_pool_ops_name);

				internal_conf->user_mbuf_pool_ops_name =
						ops_name;
			}
			break;
		}
		case 'h':
			eal_usage(prgname);
			exit(EXIT_SUCCESS);
		default:
			if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
				RTE_LOG(ERR, EAL, "Option %c is not supported "
					"on FreeBSD\n", opt);
			} else if (opt >= OPT_LONG_MIN_NUM &&
				   opt < OPT_LONG_MAX_NUM) {
				RTE_LOG(ERR, EAL, "Option %s is not supported "
					"on FreeBSD\n",
					eal_long_options[option_index].name);
			} else {
				RTE_LOG(ERR, EAL, "Option %d is not supported "
					"on FreeBSD\n", opt);
			}
			eal_usage(prgname);
			ret = -1;
			goto out;
		}
	}

	/* create runtime data directory */
	if (internal_conf->no_shconf == 0 &&
			eal_create_runtime_dir() < 0) {
		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
		ret = -1;
		goto out;
	}

	if (eal_adjust_config(internal_conf) != 0) {
		ret = -1;
		goto out;
	}

	/* sanity checks */
	if (eal_check_common_options(internal_conf) != 0) {
		eal_usage(prgname);
		ret = -1;
		goto out;
	}

	if (optind >= 0)
		argv[optind-1] = prgname;
	ret = optind-1;

out:
	/* restore getopt lib */
	optind = old_optind;
	optopt = old_optopt;
	optreset = old_optreset;
	optarg = old_optarg;

	return ret;
}
/* Parse the argument given in the command line of the application */
Parse the argument given in the command line of the application
Parse the argument given in the command line of the application
static int
eal_parse_args(int argc, char **argv)
{
	int opt, ret;
	char **argvopt;
	int option_index;
	char *prgname = argv[0];
	const int old_optind = optind;
	const int old_optopt = optopt;
	const int old_optreset = optreset;
	char * const old_optarg = optarg;
	struct internal_config *internal_conf =
		eal_get_internal_configuration();
	argvopt = argv;
	optind = 1;
	optreset = 1;
	while ((opt = getopt_long(argc, argvopt, eal_short_options,
				  eal_long_options, &option_index)) != EOF) {
		if (opt == '?') {
			eal_usage(prgname);
			ret = -1;
			goto out;
		}
		ret = eal_parse_common_option(opt, optarg, internal_conf);
		if (ret < 0) {
			eal_usage(prgname);
			ret = -1;
			goto out;
		}
		if (ret == 0)
			continue;
		switch (opt) {
		case OPT_MBUF_POOL_OPS_NAME_NUM:
		{
			char *ops_name = strdup(optarg);
			if (ops_name == NULL)
				RTE_LOG(ERR, EAL, "Could not store mbuf pool ops name\n");
			else {
				if (internal_conf->user_mbuf_pool_ops_name !=
						NULL)
					free(internal_conf->user_mbuf_pool_ops_name);
				internal_conf->user_mbuf_pool_ops_name =
						ops_name;
			}
			break;
		}
		case 'h':
			eal_usage(prgname);
			exit(EXIT_SUCCESS);
		default:
			if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
				RTE_LOG(ERR, EAL, "Option %c is not supported "
					"on FreeBSD\n", opt);
			} else if (opt >= OPT_LONG_MIN_NUM &&
				   opt < OPT_LONG_MAX_NUM) {
				RTE_LOG(ERR, EAL, "Option %s is not supported "
					"on FreeBSD\n",
					eal_long_options[option_index].name);
			} else {
				RTE_LOG(ERR, EAL, "Option %d is not supported "
					"on FreeBSD\n", opt);
			}
			eal_usage(prgname);
			ret = -1;
			goto out;
		}
	}
	if (internal_conf->no_shconf == 0 &&
			eal_create_runtime_dir() < 0) {
		RTE_LOG(ERR, EAL, "Cannot create runtime directory\n");
		ret = -1;
		goto out;
	}
	if (eal_adjust_config(internal_conf) != 0) {
		ret = -1;
		goto out;
	}
	if (eal_check_common_options(internal_conf) != 0) {
		eal_usage(prgname);
		ret = -1;
		goto out;
	}
	if (optind >= 0)
		argv[optind-1] = prgname;
	ret = optind-1;
out:
	optind = old_optind;
	optopt = old_optopt;
	optreset = old_optreset;
	optarg = old_optarg;
	return ret;
}
static int eal_parse_args ( int argc , char * * argv ) { int opt , ret ; char * * argvopt ; int option_index ; char * prgname = argv [ 0 ] ; const int old_optind = optind ; const int old_optopt = optopt ; const int old_optreset = optreset ; char * const old_optarg = optarg ; struct internal_config * internal_conf = eal_get_internal_configuration ( ) ; argvopt = argv ; optind = 1 ; optreset = 1 ; while ( ( opt = getopt_long ( argc , argvopt , eal_short_options , eal_long_options , & option_index ) ) != EOF ) { if ( opt == ' ' ) { eal_usage ( prgname ) ; ret = -1 ; goto out ; } ret = eal_parse_common_option ( opt , optarg , internal_conf ) ; if ( ret < 0 ) { eal_usage ( prgname ) ; ret = -1 ; goto out ; } if ( ret == 0 ) continue ; switch ( opt ) { case OPT_MBUF_POOL_OPS_NAME_NUM : { char * ops_name = strdup ( optarg ) ; if ( ops_name == NULL ) RTE_LOG ( ERR , EAL , " \n " ) ; else { if ( internal_conf -> user_mbuf_pool_ops_name != NULL ) free ( internal_conf -> user_mbuf_pool_ops_name ) ; internal_conf -> user_mbuf_pool_ops_name = ops_name ; } break ; } case ' ' : eal_usage ( prgname ) ; exit ( EXIT_SUCCESS ) ; default : if ( opt < OPT_LONG_MIN_NUM && isprint ( opt ) ) { RTE_LOG ( ERR , EAL , " " " \n " , opt ) ; } else if ( opt >= OPT_LONG_MIN_NUM && opt < OPT_LONG_MAX_NUM ) { RTE_LOG ( ERR , EAL , " " " \n " , eal_long_options [ option_index ] . name ) ; } else { RTE_LOG ( ERR , EAL , " " " \n " , opt ) ; } eal_usage ( prgname ) ; ret = -1 ; goto out ; } } if ( internal_conf -> no_shconf == 0 && eal_create_runtime_dir ( ) < 0 ) { RTE_LOG ( ERR , EAL , " \n " ) ; ret = -1 ; goto out ; } if ( eal_adjust_config ( internal_conf ) != 0 ) { ret = -1 ; goto out ; } if ( eal_check_common_options ( internal_conf ) != 0 ) { eal_usage ( prgname ) ; ret = -1 ; goto out ; } if ( optind >= 0 ) argv [ optind - 1 ] = prgname ; ret = optind - 1 ; out : optind = old_optind ; optopt = old_optopt ; optreset = old_optreset ; optarg = old_optarg ; return ret ; }
Parse the argument given in the command line of the application
Parse the argument given in the command line of the application
/* getopt didn't recognise the option */ /* common parser is not happy */ /* common parser handled this option */ /* free old ops name */ /* create runtime data directory */ /* sanity checks */ /* restore getopt lib */