add 'get_string_value()' as inverse function of 'get_value_string()'

This commit is contained in:
Harald Welte (local) 2009-12-26 19:43:11 +01:00 committed by Harald Welte
parent 441e483bd4
commit 240ce88185
2 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,7 @@ struct value_string {
};
const char *get_value_string(const struct value_string *vs, u_int32_t val);
int get_string_value(const struct value_string *vs, const char *str);
enum gsm_band {
GSM_BAND_400,

View File

@ -45,6 +45,19 @@ const char *get_value_string(const struct value_string *vs, u_int32_t val)
return "unknown";
}
int get_string_value(const struct value_string *vs, const char *str)
{
int i;
for (i = 0;; i++) {
if (vs[i].value == 0 && vs[i].str == NULL)
break;
if (!strcasecmp(vs[i].str, str))
return vs[i].value;
}
return -EINVAL;
}
void set_ts_e1link(struct gsm_bts_trx_ts *ts, u_int8_t e1_nr,
u_int8_t e1_ts, u_int8_t e1_ts_ss)
{