• Home
  • Raw
  • Download

Lines Matching full:options

21  * options cannot be processed with getopt(). Most implementations
24 * subcommands and continuing parsing of options with another option
40 * Optparse also supports GNU-style long options with optparse_long().
80 void optparse_init(struct optparse *options, char **argv);
92 int optparse(struct optparse *options, const char *optstring);
95 * Handles GNU-style long options in addition to getopt() options.
101 int optparse_long(struct optparse *options,
110 * function. That would be used to parse the options for the
115 char *optparse_arg(struct optparse *options);
125 optparse_error(struct optparse *options, const char *msg, const char *data) in optparse_error() argument
130 options->errmsg[p++] = *msg++; in optparse_error()
132 options->errmsg[p++] = *sep++; in optparse_error()
133 while (p < sizeof(options->errmsg) - 2 && *data) in optparse_error()
134 options->errmsg[p++] = *data++; in optparse_error()
135 options->errmsg[p++] = '\''; in optparse_error()
136 options->errmsg[p++] = '\0'; in optparse_error()
142 optparse_init(struct optparse *options, char **argv) in optparse_init() argument
144 options->argv = argv; in optparse_init()
145 options->permute = 1; in optparse_init()
146 options->optind = 1; in optparse_init()
147 options->subopt = 0; in optparse_init()
148 options->optarg = 0; in optparse_init()
149 options->errmsg[0] = '\0'; in optparse_init()
171 optparse_permute(struct optparse *options, int index) in optparse_permute() argument
173 char *nonoption = options->argv[index]; in optparse_permute()
175 for (i = index; i < options->optind - 1; i++) in optparse_permute()
176 options->argv[i] = options->argv[i + 1]; in optparse_permute()
177 options->argv[options->optind - 1] = nonoption; in optparse_permute()
196 optparse(struct optparse *options, const char *optstring) in optparse() argument
200 char *option = options->argv[options->optind]; in optparse()
201 options->errmsg[0] = '\0'; in optparse()
202 options->optopt = 0; in optparse()
203 options->optarg = 0; in optparse()
207 options->optind++; /* consume "--" */ in optparse()
210 if (options->permute) { in optparse()
211 int index = options->optind++; in optparse()
212 int r = optparse(options, optstring); in optparse()
213 optparse_permute(options, index); in optparse()
214 options->optind--; in optparse()
220 option += options->subopt + 1; in optparse()
221 options->optopt = option[0]; in optparse()
223 next = options->argv[options->optind + 1]; in optparse()
228 options->optind++; in optparse()
229 return optparse_error(options, OPTPARSE_MSG_INVALID, str); in optparse()
233 options->subopt++; in optparse()
235 options->subopt = 0; in optparse()
236 options->optind++; in optparse()
240 options->subopt = 0; in optparse()
241 options->optind++; in optparse()
243 options->optarg = option + 1; in optparse()
245 options->optarg = next; in optparse()
246 options->optind++; in optparse()
250 options->optarg = 0; in optparse()
251 return optparse_error(options, OPTPARSE_MSG_MISSING, str); in optparse()
255 options->subopt = 0; in optparse()
256 options->optind++; in optparse()
258 options->optarg = option + 1; in optparse()
260 options->optarg = 0; in optparse()
268 optparse_arg(struct optparse *options) in optparse_arg() argument
270 char *option = options->argv[options->optind]; in optparse_arg()
271 options->subopt = 0; in optparse_arg()
273 options->optind++; in optparse_arg()
299 /* Unlike strcmp(), handles options containing "=". */
324 optparse_long_fallback(struct optparse *options, in optparse_long_fallback() argument
331 result = optparse(options, optstring); in optparse_long_fallback()
337 if (longopts[i].shortname == options->optopt) in optparse_long_fallback()
346 optparse_long(struct optparse *options, in optparse_long() argument
351 char *option = options->argv[options->optind]; in optparse_long()
355 options->optind++; /* consume "--" */ in optparse_long()
358 return optparse_long_fallback(options, longopts, longindex); in optparse_long()
360 if (options->permute) { in optparse_long()
361 int index = options->optind++; in optparse_long()
362 int r = optparse_long(options, longopts, longindex); in optparse_long()
363 optparse_permute(options, index); in optparse_long()
364 options->optind--; in optparse_long()
372 options->errmsg[0] = '\0'; in optparse_long()
373 options->optopt = 0; in optparse_long()
374 options->optarg = 0; in optparse_long()
376 options->optind++; in optparse_long()
383 options->optopt = longopts[i].shortname; in optparse_long()
386 return optparse_error(options, OPTPARSE_MSG_TOOMANY, name); in optparse_long()
388 options->optarg = arg; in optparse_long()
390 options->optarg = options->argv[options->optind]; in optparse_long()
391 if (options->optarg == 0) in optparse_long()
392 return optparse_error(options, OPTPARSE_MSG_MISSING, name); in optparse_long()
394 options->optind++; in optparse_long()
396 return options->optopt; in optparse_long()
399 return optparse_error(options, OPTPARSE_MSG_INVALID, option); in optparse_long()