summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-03-05 04:16:48 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-05 04:28:04 +0100
commit4d68fd0955010625cbaa7d19cb9f69b9f44900ab (patch)
tree16f74b764ec67af32b245e94140962290039648a /include
parent20f7d0ecb4d04bd20b132fadad50b3f914ed9fe0 (diff)
gsm23003: add osmo_mcc_from_str()
I found myself often using osmo_mnc_from_str() to also decode an MCC and be strict about it, but each time I felt the need to comment like "using osmo_mnc_from_str() also for MCC". Rather formalize this properly. Use a static inline function, no need to add more symbols to libosmo-gsm. Change-Id: I020a4f11791c61742a3d795f782805f7b7e8733e
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/gsm/gsm23003.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 660186e3..5d1fbd7f 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -98,5 +98,16 @@ void osmo_plmn_from_bcd(const uint8_t *bcd_src, struct osmo_plmn_id *plmn);
int osmo_mnc_from_str(const char *mnc_str, uint16_t *mnc, bool *mnc_3_digits);
+/* Convert string to MCC.
+ * \param mcc_str[in] String representation of an MCC, with or without leading zeros.
+ * \param mcc[out] MCC result buffer, or NULL.
+ * \returns zero on success, -EINVAL in case of surplus characters, negative errno in case of conversion
+ * errors. In case of error, do not modify the out-arguments.
+ */
+static inline int osmo_mcc_from_str(const char *mcc_str, uint16_t *mcc)
+{
+ return osmo_mnc_from_str(mcc_str, mcc, NULL);
+}
+
int osmo_mnc_cmp(uint16_t a_mnc, bool a_mnc_3_digits, uint16_t b_mnc, bool b_mnc_3_digits);
int osmo_plmn_cmp(const struct osmo_plmn_id *a, const struct osmo_plmn_id *b);