Andrey Nakin
2013-10-21 811e11d96f5ae2fa6972ac1bf095eeebd9486f9a
libscpi/src/parser.c
@@ -370,7 +370,7 @@
 * @return 
 */
size_t SCPI_ResultBool(scpi_t * context, bool_t val) {
   return SCPI_ResultInt(context, val);
   return SCPI_ResultInt(context, val ? 1 : 0);
}
/**
@@ -617,3 +617,35 @@
    return TRUE;
}
/**
 * Parse choice parameter
 * @param context
 * @param options
 * @param value
 * @param mandatory
 * @return
 */
bool_t SCPI_ParamChoice(scpi_t * context, const char * options[], size_t * value, bool_t mandatory) {
    const char * param;
    size_t param_len;
    size_t res;
    if (!options || !value) {
        return FALSE;
    }
    if (!SCPI_ParamString(context, &param, &param_len, mandatory)) {
        return FALSE;
    }
   for (res = 0; options[res]; ++res) {
       if (matchPattern(options[res], strlen(options[res]), param, param_len)) {
         *value = res;
         return TRUE;
      }
    }
   SCPI_ErrorPush(context, SCPI_ERROR_ILLEGAL_PARAMETER_VALUE);
    return FALSE;
}