add 'get_string_value()' as inverse function of 'get_value_string()'
This commit is contained in:
parent
441e483bd4
commit
240ce88185
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue