Lines Matching +full:short +full:- +full:descriptor

4  * @brief Hunt for options in the option descriptor list
15 * AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
58 return -1; in parse_opt()
75 tOptDesc * pOD = opts->pOptDesc; in opt_ambiguities()
80 if (pOD->pz_Name == NULL) in opt_ambiguities()
83 if (strneqvcmp(name, pOD->pz_Name, nm_len) == 0) in opt_ambiguities()
84 fprintf(stderr, zambig_file, hyph, pOD->pz_Name); in opt_ambiguities()
86 else if ( (pOD->pz_DisableName != NULL) in opt_ambiguities()
87 && (strneqvcmp(name, pOD->pz_DisableName, nm_len) == 0) in opt_ambiguities()
89 fprintf(stderr, zambig_file, hyph, pOD->pz_DisableName); in opt_ambiguities()
90 } while (pOD++, (++idx < opts->optCt)); in opt_ambiguities()
109 int idxLim = opts->optCt; in opt_match_ct()
110 tOptDesc * pOD = opts->pOptDesc; in opt_match_ct()
116 if (pOD->pz_Name == NULL) in opt_match_ct()
120 && (pOD->fOptState != (OPTST_OMITTED | OPTST_NO_INIT))) in opt_match_ct()
123 if (strneqvcmp(name, pOD->pz_Name, nm_len) == 0) { in opt_match_ct()
128 if (pOD->pz_Name[ nm_len ] == NUL) { in opt_match_ct()
139 else if ( (pOD->pz_DisableName != NULL) in opt_match_ct()
140 && (strneqvcmp(name, pOD->pz_DisableName, nm_len) == 0) in opt_match_ct()
148 if (pOD->pz_DisableName[ nm_len ] == NUL) { in opt_match_ct()
181 tOptDesc * pOD = opts->pOptDesc + idx; in opt_set()
184 if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0) in opt_set()
187 fprintf(stderr, zDisabledErr, opts->pzProgName, pOD->pz_Name); in opt_set()
188 if (pOD->pzText != NULL) in opt_set()
189 fprintf(stderr, SET_OFF_FMT, pOD->pzText); in opt_set()
191 (*opts->pUsageProc)(opts, EXIT_FAILURE); in opt_set()
201 st->flags |= OPTST_DISABLED; in opt_set()
203 st->pOD = pOD; in opt_set()
204 st->pzOptArg = arg; in opt_set()
205 st->optType = TOPT_LONG; in opt_set()
232 && (opts->specOptIdx.default_opt != NO_EQUIVALENT)) { in opt_unknown()
234 st->pOD = opts->pOptDesc + opts->specOptIdx.default_opt; in opt_unknown()
235 st->pzOptArg = name; in opt_unknown()
236 st->optType = TOPT_DEFAULT; in opt_unknown()
240 if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) { in opt_unknown()
241 fprintf(stderr, zIllOptStr, opts->pzProgPath, name); in opt_unknown()
242 (*opts->pUsageProc)(opts, EXIT_FAILURE); in opt_unknown()
262 if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) { in opt_ambiguous()
263 fprintf(stderr, zambig_opt_fmt, opts->pzProgPath, name, match_ct); in opt_ambiguous()
266 (*opts->pUsageProc)(opts, EXIT_FAILURE); in opt_ambiguous()
277 * arg: + tOptions * + pOpts + program options descriptor +
278 * arg: + tOptDesc * + pOptDesc + the descriptor for this arg +
284 * definitions contain a "vendor-opt" attribute.
290 char const * vopt_str = pOD->optArg.argString; in optionVendorOption()
295 if ((pOD->fOptState & OPTST_RESET) != 0) in optionVendorOption()
298 if ((pOD->fOptState & OPTPROC_IMMEDIATE) == 0) in optionVendorOption()
301 if ( ((pOpts->fOptSet & OPTPROC_VENDOR_OPT) == 0) in optionVendorOption()
305 fprintf(stderr, zIllVendOptStr, pOpts->pzProgName, vopt_str); in optionVendorOption()
306 (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE); in optionVendorOption()
314 if (pOpts->fOptSet & OPTPROC_IMMEDIATE) { in optionVendorOption()
323 * non-immediate direction. in optionVendorOption()
332 * Find the option descriptor by full name.
352 if ((opts->fOptSet & OPTPROC_ERRSTOP) == 0) in opt_find_long()
355 fprintf(stderr, zInvalOptName, opts->pzProgName, opt_name); in opt_find_long()
356 (*opts->pUsageProc)(opts, EXIT_FAILURE); in opt_find_long()
375 * Find the short option descriptor for the current option
384 tOptDesc * pRes = pOpts->pOptDesc; in opt_find_short()
385 int ct = pOpts->optCt; in opt_find_short()
391 if (optValue != pRes->optValue) in opt_find_short()
395 if ( (pRes->fOptState == (OPTST_OMITTED | OPTST_NO_INIT)) in opt_find_short()
396 && (pRes->pz_Name != NULL)) { in opt_find_short()
397 if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0) in opt_find_short()
400 fprintf(stderr, zDisabledErr, pOpts->pzProgPath, pRes->pz_Name); in opt_find_short()
401 if (pRes->pzText != NULL) in opt_find_short()
402 fprintf(stderr, SET_OFF_FMT, pRes->pzText); in opt_find_short()
404 (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE); in opt_find_short()
411 pOptState->pOD = pRes; in opt_find_short()
412 pOptState->optType = TOPT_SHORT; in opt_find_short()
415 } while (pRes++, --ct > 0); in opt_find_short()
419 * AND there is a special number option ("-n") in opt_find_short()
424 && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) { in opt_find_short()
425 pOptState->pOD = \ in opt_find_short()
426 pRes = pOpts->pOptDesc + pOpts->specOptIdx.number_option; in opt_find_short()
427 (pOpts->pzCurOpt)--; in opt_find_short()
428 pOptState->optType = TOPT_SHORT; in opt_find_short()
438 if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { in opt_find_short()
439 fprintf(stderr, zIllOptChr, pOpts->pzProgPath, optValue); in opt_find_short()
440 (*pOpts->pUsageProc)(pOpts, EXIT_FAILURE); in opt_find_short()
453 * @param[in,out] opts the program option descriptor
460 switch (o_st->optType) { in get_opt_arg_must()
465 if (*++(opts->pzCurOpt) == NUL) in get_opt_arg_must()
466 opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx++ ]; in get_opt_arg_must()
467 o_st->pzOptArg = opts->pzCurOpt; in get_opt_arg_must()
475 if (o_st->pzOptArg == NULL) in get_opt_arg_must()
476 o_st->pzOptArg = opts->origArgVect[ opts->curOptIdx++ ]; in get_opt_arg_must()
496 if (opts->curOptIdx > opts->origArgCt) { in get_opt_arg_must()
497 fprintf(stderr, zMisArg, opts->pzProgPath, o_st->pOD->pz_Name); in get_opt_arg_must()
501 opts->pzCurOpt = NULL; /* next time advance to next arg */ in get_opt_arg_must()
506 * Process an option with an optional argument. For short options, it looks
512 * @param pOpts the option descriptor
522 switch (o_st->optType) { in get_opt_arg_may()
524 if (*++pOpts->pzCurOpt != NUL) in get_opt_arg_may()
525 o_st->pzOptArg = pOpts->pzCurOpt; in get_opt_arg_may()
527 char * pzLA = pOpts->origArgVect[ pOpts->curOptIdx ]; in get_opt_arg_may()
534 if ((pzLA == NULL) || (*pzLA == '-')) in get_opt_arg_may()
535 o_st->pzOptArg = NULL; in get_opt_arg_may()
537 pOpts->curOptIdx++; /* argument found */ in get_opt_arg_may()
538 o_st->pzOptArg = pzLA; in get_opt_arg_may()
548 if ( (o_st->pzOptArg == NULL) in get_opt_arg_may()
550 char * pzLA = pOpts->origArgVect[ pOpts->curOptIdx ]; in get_opt_arg_may()
557 if ((pzLA == NULL) || (*pzLA == '-')) in get_opt_arg_may()
558 o_st->pzOptArg = NULL; in get_opt_arg_may()
560 pOpts->curOptIdx++; /* argument found */ in get_opt_arg_may()
561 o_st->pzOptArg = pzLA; in get_opt_arg_may()
577 pOpts->pzCurOpt = NULL; in get_opt_arg_may()
584 * @param[in,out] opts the program option descriptor
593 * the correct option flag character for short options in get_opt_arg_none()
595 if (o_st->optType == TOPT_SHORT) in get_opt_arg_none()
596 (pOpts->pzCurOpt)++; in get_opt_arg_none()
601 else if (o_st->pzOptArg != NULL) { in get_opt_arg_none()
602 fprintf(stderr, zNoArg, pOpts->pzProgPath, o_st->pOD->pz_Name); in get_opt_arg_none()
610 pOpts->pzCurOpt = NULL; in get_opt_arg_none()
618 * @param[in,out] opts the program option descriptor
625 o_st->flags |= (o_st->pOD->fOptState & OPTST_PERSISTENT_MASK); in get_opt_arg()
632 if ((o_st->flags & OPTST_DISABLED) != 0) in get_opt_arg()
635 switch (OPTST_GET_ARGTYPE(o_st->flags)) { in get_opt_arg()
642 o_st->pzOptArg = o_st->pOD->optArg.argString; in get_opt_arg()
650 if (o_st->flags & OPTST_ARG_OPTIONAL) in get_opt_arg()
657 * Find the option descriptor for the current option.
659 * @param[in,out] opts the program option descriptor
667 * IF we are continuing a short option list (e.g. -xyz...) in find_opt()
671 if ((opts->pzCurOpt != NULL) && (*opts->pzCurOpt != NUL)) in find_opt()
672 return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st); in find_opt()
674 if (opts->curOptIdx >= opts->origArgCt) in find_opt()
677 opts->pzCurOpt = opts->origArgVect[ opts->curOptIdx ]; in find_opt()
683 char * pz = opts->pzCurOpt; in find_opt()
688 opts->curOptIdx++; in find_opt()
690 if (*pz != '-') in find_opt()
698 while (*(++pz) == '-') ; in find_opt()
699 def_opt = VOIDP(&(opts->specOptIdx.default_opt)); in find_opt()
710 if (*((opts->pzCurOpt)++) != '-') in find_opt()
711 return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */ in find_opt()
716 if (*(opts->pzCurOpt) == NUL) in find_opt()
717 return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */ in find_opt()
722 opts->curOptIdx++; in find_opt()
728 if (opts->pzCurOpt[0] == '-') { in find_opt()
729 if (*++(opts->pzCurOpt) == NUL) in find_opt()
731 * NORMAL COMPLETION - NOT this arg, but rest are operands in find_opt()
739 if ((opts->fOptSet & OPTPROC_LONGOPT) == 0) { in find_opt()
740 fprintf(stderr, zIllOptStr, opts->pzProgPath, opts->pzCurOpt-2); in find_opt()
744 return opt_find_long(opts, opts->pzCurOpt, o_st); in find_opt()
748 * If short options are not allowed, then do long in find_opt()
750 * short (i.e. single character) option. in find_opt()
752 if ((opts->fOptSet & OPTPROC_SHORTOPT) != 0) in find_opt()
753 return opt_find_short(opts, (uint8_t)*(opts->pzCurOpt), o_st); in find_opt()
755 return opt_find_long(opts, opts->pzCurOpt, o_st); in find_opt()
762 * c-file-style: "stroustrup"
763 * indent-tabs-mode: nil