[MERGED] libosmocore[master]: gsm23003: add osmo_mcc_from_str()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 5 10:51:41 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: gsm23003: add osmo_mcc_from_str()
......................................................................


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
---
M include/osmocom/gsm/gsm23003.h
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/gsm/gsm23003.h b/include/osmocom/gsm/gsm23003.h
index 660186e..5d1fbd7 100644
--- a/include/osmocom/gsm/gsm23003.h
+++ b/include/osmocom/gsm/gsm23003.h
@@ -98,5 +98,16 @@
 
 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);

-- 
To view, visit https://gerrit.osmocom.org/7083
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I020a4f11791c61742a3d795f782805f7b7e8733e
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list