コード例 #1
0
static void
print_membership(tOptions * pOpts, tOptDesc * pOD)
{
    char const * pz;
    uintptr_t val = 1;
    printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
           (int)(uintptr_t)(pOD->optCookie));
    pOD->optCookie = (void*)(uintptr_t)~0UL;
    (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);

    /*
     *  We are building the typeset list.  The list returned starts with
     *  'none + ' for use by option saving stuff.  We must ignore that.
     */
    pz = pOD->optArg.argString + 7;
    while (*pz != NUL) {
        printf("typeset -x -i %s_", pOD->pz_NAME);
        while (IS_PLUS_N_SPACE_CHAR(*pz))  pz++;

        for (;;) {
            int ch = *(pz++);
            if (IS_LOWER_CASE_CHAR(ch))   fputc(toupper(ch), stdout);
            else if (IS_UPPER_CASE_CHAR(ch))   fputc(ch, stdout);
            else if (IS_PLUS_N_SPACE_CHAR(ch)) goto name_done;
            else if (ch == NUL)        { pz--; goto name_done; }
            else fputc('_', stdout);
        } name_done:;
        printf("=%1$lu # 0x%1$lX\n", (unsigned long)val);
        val <<= 1;
    }

    AGFREE(pOD->optArg.argString);
    pOD->optArg.argString = NULL;
    pOD->fOptState &= ~OPTST_ALLOC_ARG;
}
コード例 #2
0
ファイル: putshell.c プロジェクト: Distrotech/autogen
static void
print_membership(tOptions * pOpts, tOptDesc * pOD)
{
    char const * svstr = pOD->optArg.argString;
    char const * pz;
    uintptr_t val = 1;
    printf(zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
           (int)(uintptr_t)(pOD->optCookie));
    pOD->optCookie = VOIDP(~0UL);
    (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD);

    pz = pOD->optArg.argString;
    while (*pz != NUL) {
        printf("readonly %s_", pOD->pz_NAME);
        pz = SPN_PLUS_N_SPACE_CHARS(pz);

        for (;;) {
            int ch = *(pz++);
            if (IS_LOWER_CASE_CHAR(ch))   fputc(toupper(ch), stdout);
            else if (IS_UPPER_CASE_CHAR(ch))   fputc(ch, stdout);
            else if (IS_PLUS_N_SPACE_CHAR(ch)) goto name_done;
            else if (ch == NUL)        { pz--; goto name_done; }
            else fputc('_', stdout);
        } name_done:;
        printf(SHOW_VAL_FMT, (unsigned long)val);
        val <<= 1;
    }

    AGFREE(pOD->optArg.argString);
    pOD->optArg.argString = svstr;
}
コード例 #3
0
ファイル: configfile.c プロジェクト: Distrotech/sharutils
/**
 *  Parse the various attributes of an XML-styled config file entry
 *
 * @returns NULL on failure, otherwise the scan point
 */
LOCAL char const *
parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
            tOptionValue * pType)
{
    size_t len = 0;

    for (;;) {
        len = (size_t)(SPN_LOWER_CASE_CHARS(txt) - txt);

        /*
         * The enumeration used in this switch is derived from this switch
         * statement itself.  The "find_option_xat_attribute_cmd" function
         * will return XAT_CMD_MEMBERS for the "txt" string value
         * "members", etc.
         */
        switch (find_option_xat_attribute_cmd(txt, len)) {
        case XAT_CMD_TYPE:
            txt = parse_value(txt+len, pType);
            break;

        case XAT_CMD_WORDS:
            txt = parse_keyword(opts, txt+len, pType);
            break;

        case XAT_CMD_MEMBERS:
            txt = parse_set_mem(opts, txt+len, pType);
            break;

        case XAT_CMD_COOKED:
            txt += len;
            if (! IS_END_XML_TOKEN_CHAR(*txt))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_COOKED;
            break;

        case XAT_CMD_UNCOOKED:
            txt += len;
            if (! IS_END_XML_TOKEN_CHAR(*txt))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_UNCOOKED;
            break;

        case XAT_CMD_KEEP:
            txt += len;
            if (! IS_END_XML_TOKEN_CHAR(*txt))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_KEEP;
            break;

        default:
        case XAT_INVALID_CMD:
        invalid_kwd:
            pType->valType = OPARG_TYPE_NONE;
            return skip_unkn(txt);
        }

        if (txt == NULL)
            return NULL;
        txt = SPN_WHITESPACE_CHARS(txt);
        switch (*txt) {
            case '/': pType->valType = OPARG_TYPE_NONE;
                      /* FALLTHROUGH */
            case '>': return txt;
        }
        if (! IS_LOWER_CASE_CHAR(*txt))
            return NULL;
    }
}
コード例 #4
0
ファイル: configfile.c プロジェクト: pexip/os-ntp
/**
 *  Parse the various attributes of an XML-styled config file entry
 */
LOCAL char*
parseAttributes(
    tOptions*           pOpts,
    char*               pzText,
    tOptionLoadMode*    pMode,
    tOptionValue*       pType )
{
    size_t len;

    do  {
        if (! IS_WHITESPACE_CHAR(*pzText))
            switch (*pzText) {
            case '/': pType->valType = OPARG_TYPE_NONE;
            case '>': return pzText;

            default:
            case NUL: return NULL;
            }

        while (IS_WHITESPACE_CHAR(*++pzText))     ;
        len = 0;
        while (IS_LOWER_CASE_CHAR(pzText[len]))   len++;

        switch (find_xat_attribute_id(pzText, len)) {
        case XAT_KWD_TYPE:
            pzText = parse_value(pzText+len, pType);
            break;

        case XAT_KWD_WORDS:
            pzText = parse_keyword(pOpts, pzText+len, pType);
            break;

        case XAT_KWD_MEMBERS:
            pzText = parse_set_mem(pOpts, pzText+len, pType);
            break;

        case XAT_KWD_COOKED:
            pzText += len;
            if (! IS_END_XML_TOKEN_CHAR(*pzText))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_COOKED;
            break;

        case XAT_KWD_UNCOOKED:
            pzText += len;
            if (! IS_END_XML_TOKEN_CHAR(*pzText))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_UNCOOKED;
            break;

        case XAT_KWD_KEEP:
            pzText += len;
            if (! IS_END_XML_TOKEN_CHAR(*pzText))
                goto invalid_kwd;

            *pMode = OPTION_LOAD_KEEP;
            break;

        default:
        case XAT_KWD_INVALID:
        invalid_kwd:
            pType->valType = OPARG_TYPE_NONE;
            return skip_unkn(pzText);
        }
    } while (pzText != NULL);

    return pzText;
}