diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-12 03:55:23 +0000 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2005-07-12 03:55:23 +0000 |
commit | e598a2372179812389a702b78d5f8537eb6827d9 (patch) | |
tree | fad90d39ca5781d5ffdf4e9131050fe79d3e5383 /src/opt.c | |
parent | 6b44784148735f594ac862abcd38c50c5d556df0 (diff) | |
download | librcc-e598a2372179812389a702b78d5f8537eb6827d9.tar.gz librcc-e598a2372179812389a702b78d5f8537eb6827d9.tar.bz2 librcc-e598a2372179812389a702b78d5f8537eb6827d9.tar.xz librcc-e598a2372179812389a702b78d5f8537eb6827d9.zip |
Language and Option Names
Diffstat (limited to 'src/opt.c')
-rw-r--r-- | src/opt.c | 102 |
1 files changed, 100 insertions, 2 deletions
@@ -1,5 +1,6 @@ #include <stdio.h> +#include "rccconfig.h" #include "internal.h" #include "opt.h" @@ -24,12 +25,27 @@ int rccOptionIsDefault(rcc_context ctx, rcc_option option) { } int rccSetOption(rcc_context ctx, rcc_option option, rcc_option_value value) { + rcc_option_description *desc; + rcc_option_value min, max; + + if (!ctx) { if (rcc_default_ctx) ctx = rcc_default_ctx; else return -1; } if ((option<0)||(option>=RCC_MAX_OPTIONS)) return -1; - + + + desc = rccGetOptionDescription(option); + if (desc) { + // DS: More checks for different range types + min = desc->range.min; + max = desc->range.max; + if ((min)&&(min!=max)) { + if ((option<min)||(option>max)) return -1; + } + } + ctx->default_options[option] = 0; if (ctx->options[option] != value) { @@ -41,6 +57,7 @@ int rccSetOption(rcc_context ctx, rcc_option option, rcc_option_value value) { } int rccOptionSetDefault(rcc_context ctx, rcc_option option) { + rcc_option_description *desc; rcc_option_value value; if (!ctx) { @@ -50,7 +67,10 @@ int rccOptionSetDefault(rcc_context ctx, rcc_option option) { if ((option<0)||(option>=RCC_MAX_OPTIONS)) return -1; ctx->default_options[option] = 1; - value = rccGetOptionDefaultValue(option); + + desc = rccGetOptionDescription(option); + if (desc) value = desc->value; + else value = 0; if (ctx->options[option] != value) { ctx->configure = 1; @@ -59,3 +79,81 @@ int rccOptionSetDefault(rcc_context ctx, rcc_option option) { return 0; } + +rcc_option_type rccOptionGetType(rcc_context ctx, rcc_option option) { + rcc_option_description *desc; + + desc = rccGetOptionDescription(option); + if (desc) return desc->type; + return 0; +} + +rcc_option_range *rccOptionGetRange(rcc_context ctx, rcc_option option) { + rcc_option_description *desc; + + desc = rccGetOptionDescription(option); + if (desc) return &desc->range; + return 0; +} + +const char *rccOptionDescriptionGetName(rcc_option_description *desc) { + if (desc) return desc->sn; + return NULL; +} + +rcc_option rccOptionDescriptionGetOption(rcc_option_description *desc) { + if (desc) return desc->option; + return (rcc_option)-1; +} + +const char *rccOptionDescriptionGetValueName(rcc_option_description *desc, rcc_option_value value) { + unsigned int i; + + if (desc) { + for (i=0;desc->vsn[i];i++) { + if (i == value) return desc->vsn[i]; + } + } + return NULL; +} + +rcc_option_value rccOptionDescriptionGetValueByName(rcc_option_description *desc, const char *name) { + unsigned int i; + + if ((desc)&&(name)) { + for (i=0;desc->vsn[i];i++) { + if (!strcasecmp(desc->vsn[i], name)) return (rcc_option_value)i; + } + } + + return (rcc_option_value)-1; +} + + +const char *rccGetOptionName(rcc_option option) { + rcc_option_description *desc; + + desc = rccGetOptionDescription(option); + return rccOptionDescriptionGetName(desc); +} + +const char *rccGetOptionValueName(rcc_option option, rcc_option_value value) { + rcc_option_description *desc; + + desc = rccGetOptionDescription(option); + return rccOptionDescriptionGetValueName(desc, value); +} + +rcc_option rccGetOptionByName(const char *name) { + rcc_option_description *desc; + + desc = rccGetOptionDescriptionByName(name); + return rccOptionDescriptionGetOption(desc); +} + +rcc_option_value rccGetOptionValueByName(rcc_option option, const char *name) { + rcc_option_description *desc; + + desc = rccGetOptionDescription(option); + return rccOptionDescriptionGetValueByName(desc, name); +} |