Lines Matching full:option

63  * Returns the name of the long option that matches the character @a c.
66 * @return The name of the long option that matches @a c, or "NULL".
86 * Issues a fatal error for an option parsing failure.
88 * @param c The character for the failing option.
89 * @param str Either the string for the failing option, or the invalid
90 * option.
91 * @param use_short True if the short option should be used for error printing,
114 * Returns the type of the long option that matches @a c.
117 * @return The type of the long option as an integer, or -1 if none.
137 * Parses a short option.
138 * @param o The option parser.
140 * @return The character for the short option, or -1 if none left.
147 const char* option = o->argv[o->optind]; in bc_opt_parseShort() local
154 // Get the next option. in bc_opt_parseShort()
155 option += o->subopt + 1; in bc_opt_parseShort()
156 o->optopt = option[0]; in bc_opt_parseShort()
159 type = bc_opt_type(longopts, option[0]); in bc_opt_parseShort()
168 // Check for invalid option and barf if so. in bc_opt_parseShort()
174 str[0] = option[0]; in bc_opt_parseShort()
177 bc_opt_error(BC_ERR_FATAL_OPTION, option[0], str, true); in bc_opt_parseShort()
187 if (option[1]) o->subopt += 1; in bc_opt_parseShort()
195 ret = (int) option[0]; in bc_opt_parseShort()
205 bc_opt_error(BC_ERR_FATAL_OPTION, option[0], in bc_opt_parseShort()
206 bc_opt_longopt(longopts, option[0]), true); in bc_opt_parseShort()
221 if (option[1]) o->optarg = option + 1; in bc_opt_parseShort()
231 bc_opt_error(BC_ERR_FATAL_OPTION_NO_ARG, option[0], in bc_opt_parseShort()
232 bc_opt_longopt(longopts, option[0]), true); in bc_opt_parseShort()
235 ret = (int) option[0]; in bc_opt_parseShort()
245 * Ensures that a long option argument matches a long option name, regardless of
248 * @param option The command-line argument.
249 * @return True if @a option matches @a name, false otherwise.
252 bc_opt_longoptsMatch(const char* name, const char* option) in bc_opt_longoptsMatch() argument
254 const char* a = option; in bc_opt_longoptsMatch()
271 * Returns a pointer to the argument of a long option, or NULL if it not in the
273 * @param option The option to find the argument of.
274 * @return A pointer to the argument of the option, or NULL if none.
277 bc_opt_longoptsArg(const char* option) in bc_opt_longoptsArg() argument
280 for (; *option && *option != '='; ++option) in bc_opt_longoptsArg()
285 if (*option == '=') return option + 1; in bc_opt_longoptsArg()
293 const char* option; in bc_opt_parse() local
299 option = o->argv[o->optind]; in bc_opt_parse()
300 if (option == NULL) return -1; in bc_opt_parse()
302 empty = !strcmp(option, ""); in bc_opt_parse()
307 // If the option is just a "--". in bc_opt_parse()
308 if (BC_OPT_ISDASHDASH(option)) in bc_opt_parse()
314 // Parse a short option. in bc_opt_parse()
315 else if (BC_OPT_ISSHORTOPT(option)) return bc_opt_parseShort(o, longopts); in bc_opt_parse()
316 // If the option is not long at this point, we are done. in bc_opt_parse()
317 else if (!BC_OPT_ISLONGOPT(option)) return -1; in bc_opt_parse()
323 // Skip "--" at beginning of the option. in bc_opt_parse()
324 option += 2; in bc_opt_parse()
333 if (bc_opt_longoptsMatch(name, option)) in bc_opt_parse()
337 // Get the option char and the argument. in bc_opt_parse()
339 arg = bc_opt_longoptsArg(option); in bc_opt_parse()
341 // Error if the option is invalid.. in bc_opt_parse()
377 // If we reach this point, the option is invalid. in bc_opt_parse()
378 bc_opt_error(BC_ERR_FATAL_OPTION, 0, option, false); in bc_opt_parse()