aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core/utils.h
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-06-06 18:05:23 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-06-13 17:46:20 +0000
commit8d6dcd9bca7ce9b0a29954126c72050f8e2e110c (patch)
tree35cf450fc871395f4259e46e953edea392e7df0f /include/osmocom/core/utils.h
parent8a3c83ed00104bdb326c160a36c8f2b0625eeabd (diff)
add get_value_string_or_null() to handle unknown items
Add get_value_string_or_null() to return NULL in case the given value is not found in the list of strings, to be able to cleanly fall back to another list of strings. Absorb the lookup loop from get_value_string(). Context: in osmo-bts, I want to look up an RSL message name in rsl_msgt_names and fall back to rsl_ipac_msgt_names if not found, because the IPAC PDCH ACT and DEACT messages are sent in a standard ABIS_RSL_MDISC_DED_CHAN. In a subsequent commit, get_value_string_or_null() will be used by new rsl_or_ipac_msg_name(). Change-Id: I1fa3907e28d528d2758bc3eae9d19e6c1168f5e5 Reviewed-on: https://gerrit.osmocom.org/230 Reviewed-by: Harald Welte <laforge@gnumonks.org> Tested-by: Jenkins Builder
Diffstat (limited to 'include/osmocom/core/utils.h')
-rw-r--r--include/osmocom/core/utils.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index bc395193..476e492b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -25,6 +25,8 @@ struct value_string {
};
const char *get_value_string(const struct value_string *vs, uint32_t val);
+const char *get_value_string_or_null(const struct value_string *vs,
+ uint32_t val);
int get_string_value(const struct value_string *vs, const char *str);