示例#1
0
文件: nested.c 项目: gokzy/netbsd-src
/*=export_func  optionNestedVal
 * private:
 *
 * what:  parse a hierarchical option argument
 * arg:   + tOptions * + opts + program options descriptor +
 * arg:   + tOptDesc * + od   + the descriptor for this arg +
 *
 * doc:
 *  Nested value was found on the command line
=*/
void
optionNestedVal(tOptions * opts, tOptDesc * od)
{
    if (opts < OPTPROC_EMIT_LIMIT)
        return;

    if (od->fOptState & OPTST_RESET) {
        tArgList *    arg_list = od->optCookie;
        int           ct;
        char const ** av;

        if (arg_list == NULL)
            return;
        ct = arg_list->useCt;
        av = arg_list->apzArgs;

        while (--ct >= 0) {
            void * p = VOIDP(*(av++));
            optionUnloadNested((tOptionValue const *)p);
        }

        AGFREE(od->optCookie);

    } else {
        tOptionValue * opt_val = optionLoadNested(
            od->optArg.argString, od->pz_Name, strlen(od->pz_Name));

        if (opt_val != NULL)
            addArgListEntry(&(od->optCookie), VOIDP(opt_val));
    }
}
示例#2
0
/*=export_func  optionNestedVal
 * private:
 *
 * what:  parse a hierarchical option argument
 * arg:   + tOptions* + pOpts    + program options descriptor +
 * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
 *
 * doc:
 *  Nested value was found on the command line
=*/
void
optionNestedVal(tOptions* pOpts, tOptDesc* pOD)
{
    if (pOpts < OPTPROC_EMIT_LIMIT)
        return;

    if (pOD->fOptState & OPTST_RESET) {
        tArgList* pAL = pOD->optCookie;
        int       ct;
        tCC **    av;

        if (pAL == NULL)
            return;
        ct = pAL->useCt;
        av = pAL->apzArgs;

        while (--ct >= 0) {
            void * p = (void *)(intptr_t)*(av++);
            optionUnloadNested((tOptionValue const *)p);
        }

        AGFREE(pOD->optCookie);

    } else {
        tOptionValue* pOV = optionLoadNested(
            pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));

        if (pOV != NULL)
            addArgListEntry( &(pOD->optCookie), (void*)pOV );
    }
}