- newopt = get_opt(name1, name2, name3);
- if (!newopt)
- return -EINVAL;
- newopt->value.v_int = opt_intval;
- return 0;
- case option_type_uint:
- ret = sscanf(opt_valstr, "%u", &opt_uintval);
- if (ret != 1) {
- fprintf(stderr, "Option format error: %s\n", optarg);
- return -EINVAL;
- }
- newopt = get_opt(name1, name2, name3);
- if (!newopt)
- return -EINVAL;
- newopt->value.v_uint = opt_uintval;
- return 0;
- case option_type_positive:
- ret = sscanf(opt_valstr, "%u", &opt_uintval);
- if (ret != 1 || opt_uintval == 0) {
- fprintf(stderr, "Option format error: %s\n", optarg);
- return -EINVAL;
- }
- newopt = get_opt(name1, name2, name3);
- if (!newopt)
- return -EINVAL;
- newopt->value.v_uint = opt_uintval;
- return 0;
- case option_type_bool:
- if (opt_valstr[1] != 0) {
- fprintf(stderr, "Option format error: %s\n", optarg);
- return -EINVAL;
- }
- if (opt_valstr[0] == 'Y' || opt_valstr[0] == 'y'
- || opt_valstr[0] == '1')
- opt_intval = 1;
- else if (opt_valstr[0] == 'N' || opt_valstr[0] == 'n'
- || opt_valstr[0] == '0')
- opt_intval = 0;
- else {
- fprintf(stderr, "Option format error: %s\n", optarg);
- return -EINVAL;
- }
-
- newopt = get_opt(name1, name2, name3);
- if (!newopt)
- return -EINVAL;
- newopt->value.v_bool = opt_intval;
- return 0;
- default:
- fprintf(stderr, "Internal error on opt %s\n", optarg);