Lines Matching refs:arg
28 struct arg arg_init(char **argv) in arg_init()
30 struct arg a; in arg_init()
40 int arg_match(struct arg *arg_, const struct arg_def *def, char **argv) in arg_match()
42 struct arg arg; in arg_match() local
47 arg = arg_init(argv); in arg_match()
50 && strlen(arg.argv[0]) == strlen(def->short_name) + 1 in arg_match()
51 && !strcmp(arg.argv[0] + 1, def->short_name)) in arg_match()
54 arg.name = arg.argv[0] + 1; in arg_match()
55 arg.val = def->has_val ? arg.argv[1] : NULL; in arg_match()
56 arg.argv_step = def->has_val ? 2 : 1; in arg_match()
62 if (strlen(arg.argv[0]) >= name_len + 2 in arg_match()
63 && arg.argv[0][1] == '-' in arg_match()
64 && !strncmp(arg.argv[0] + 2, def->long_name, name_len) in arg_match()
65 && (arg.argv[0][name_len+2] == '=' in arg_match()
66 || arg.argv[0][name_len+2] == '\0')) in arg_match()
69 arg.name = arg.argv[0] + 2; in arg_match()
70 arg.val = arg.name[name_len] == '=' ? arg.name + name_len + 1 : NULL; in arg_match()
71 arg.argv_step = 1; in arg_match()
75 if (arg.name && !arg.val && def->has_val) in arg_match()
76 die("Error: option %s requires argument.\n", arg.name); in arg_match()
78 if (arg.name && arg.val && !def->has_val) in arg_match()
79 die("Error: option %s requires no argument.\n", arg.name); in arg_match()
81 if (arg.name in arg_match()
82 && (arg.val || !def->has_val)) in arg_match()
84 arg.def = def; in arg_match()
85 *arg_ = arg; in arg_match()
93 const char *arg_next(struct arg *arg) in arg_next() argument
95 if (arg->argv[0]) in arg_next()
96 arg->argv += arg->argv_step; in arg_next()
98 return *arg->argv; in arg_next()
153 unsigned int arg_parse_uint(const struct arg *arg) in arg_parse_uint() argument
158 rawval = strtol(arg->val, &endptr, 10); in arg_parse_uint()
160 if (arg->val[0] != '\0' && endptr[0] == '\0') in arg_parse_uint()
166 arg->name, rawval); in arg_parse_uint()
169 die("Option %s: Invalid character '%c'\n", arg->name, *endptr); in arg_parse_uint()
174 int arg_parse_int(const struct arg *arg) in arg_parse_int() argument
179 rawval = strtol(arg->val, &endptr, 10); in arg_parse_int()
181 if (arg->val[0] != '\0' && endptr[0] == '\0') in arg_parse_int()
187 arg->name, rawval); in arg_parse_int()
190 die("Option %s: Invalid character '%c'\n", arg->name, *endptr); in arg_parse_int()
200 struct vpx_rational arg_parse_rational(const struct arg *arg) in arg_parse_rational() argument
207 rawval = strtol(arg->val, &endptr, 10); in arg_parse_rational()
209 if (arg->val[0] != '\0' && endptr[0] == '/') in arg_parse_rational()
214 arg->name, rawval); in arg_parse_rational()
216 else die("Option %s: Expected / at '%c'\n", arg->name, *endptr); in arg_parse_rational()
221 if (arg->val[0] != '\0' && endptr[0] == '\0') in arg_parse_rational()
226 arg->name, rawval); in arg_parse_rational()
228 else die("Option %s: Invalid character '%c'\n", arg->name, *endptr); in arg_parse_rational()
234 int arg_parse_enum(const struct arg *arg) in arg_parse_enum() argument
241 rawval = strtol(arg->val, &endptr, 10); in arg_parse_enum()
242 if (arg->val[0] != '\0' && endptr[0] == '\0') in arg_parse_enum()
245 for(listptr = arg->def->enums; listptr->name; listptr++) in arg_parse_enum()
251 for(listptr = arg->def->enums; listptr->name; listptr++) in arg_parse_enum()
252 if(!strcmp(arg->val, listptr->name)) in arg_parse_enum()
255 die("Option %s: Invalid value '%s'\n", arg->name, arg->val); in arg_parse_enum()
260 int arg_parse_enum_or_int(const struct arg *arg) in arg_parse_enum_or_int() argument
262 if(arg->def->enums) in arg_parse_enum_or_int()
263 return arg_parse_enum(arg); in arg_parse_enum_or_int()
264 return arg_parse_int(arg); in arg_parse_enum_or_int()