Logo Search packages:      
Sourcecode: zebra version File versions  Download package

int zebra_parse_config ( const char *  config_string,
zebra_symbol_type_t symbology,
zebra_config_t config,
int *  value 
)

parse a configuration string of the form "[symbology.]config[=value]". the config must match one of the recognized names. the symbology, if present, must match one of the recognized names. if symbology is unspecified, it will be set to 0. if value is unspecified it will be set to 1.

Returns:
0 if the config is parsed successfully, 1 otherwise
Since:
0.4

Definition at line 32 of file config.c.

References ZEBRA_ADDON2, ZEBRA_ADDON5, ZEBRA_CFG_ADD_CHECK, ZEBRA_CFG_ASCII, ZEBRA_CFG_EMIT_CHECK, ZEBRA_CFG_ENABLE, ZEBRA_CODE128, ZEBRA_CODE39, ZEBRA_EAN13, ZEBRA_EAN8, ZEBRA_I25, ZEBRA_ISBN10, ZEBRA_ISBN13, zebra_parse_config(), ZEBRA_UPCA, and ZEBRA_UPCE.

Referenced by zebra_decoder_parse_config(), zebra_image_scanner_parse_config(), zebra_parse_config(), and zebra_processor_parse_config().

{
    if(!cfgstr)
        return(1);

    const char *dot = strchr(cfgstr, '.');
    if(dot) {
        int symlen = dot - cfgstr;
        if(!symlen || !strncmp(cfgstr, "*", symlen))
            *sym = 0;
        else if(!strncmp(cfgstr, "ean8", symlen))
            *sym = ZEBRA_EAN8;
        else if(!strncmp(cfgstr, "isbn10", symlen))
            *sym = ZEBRA_ISBN10;
        else if(!strncmp(cfgstr, "upce", symlen))
            *sym = ZEBRA_UPCE;
        else if(!strncmp(cfgstr, "upca", symlen))
            *sym = ZEBRA_UPCA;
        else if(!strncmp(cfgstr, "ean13", symlen))
            *sym = ZEBRA_EAN13;
        else if(!strncmp(cfgstr, "isbn13", symlen))
            *sym = ZEBRA_ISBN13;
        else if(!strncmp(cfgstr, "i25", symlen))
            *sym = ZEBRA_I25;
        else if(!strncmp(cfgstr, "code39", symlen))
            *sym = ZEBRA_CODE39;
        else if(!strncmp(cfgstr, "code128", symlen))
            *sym = ZEBRA_CODE128;

#if 0
        /* FIXME addons are configured per-main symbol type */
        else if(!strncmp(cfgstr, "addon2", symlen))
            *sym = ZEBRA_ADDON2;
        else if(!strncmp(cfgstr, "addon5", symlen))
            *sym = ZEBRA_ADDON5;
#endif
        else
            return(1);
        cfgstr = dot + 1;
    }
    else
        *sym = 0;

    int cfglen = strlen(cfgstr);
    const char *eq = strchr(cfgstr, '=');
    if(eq)
        cfglen = eq - cfgstr;
    else
        *val = 1;  /* handle this here so we can override later */
    char negate = 0;

    if(cfglen > 3 && !strncmp(cfgstr, "no-", 3)) {
        negate = 1;
        cfgstr += 3;
        cfglen -= 3;
    }

    if(!strncmp(cfgstr, "enable", cfglen))
        *cfg = ZEBRA_CFG_ENABLE;
    else if(!strncmp(cfgstr, "disable", cfglen)) {
        *cfg = ZEBRA_CFG_ENABLE;
        negate = !negate; /* no-disable ?!? */
    }
    else if(!strncmp(cfgstr, "ascii", cfglen))
        *cfg = ZEBRA_CFG_ASCII;
    else if(!strncmp(cfgstr, "add-check", cfglen))
        *cfg = ZEBRA_CFG_ADD_CHECK;
    else if(!strncmp(cfgstr, "emit-check", cfglen))
        *cfg = ZEBRA_CFG_EMIT_CHECK;
    else
        return(1);

    if(eq) {
        errno = 0;
        *val = strtol(eq + 1, NULL, 0);
        if(errno)
            return(1);
    }
    if(negate)
        *val = !*val;

    return(0);
}


Generated by  Doxygen 1.6.0   Back to index