aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-03-23 12:44:33 +0100
committerMax <msuraev@sysmocom.de>2017-03-23 13:08:39 +0100
commite16b59357411ffa4903ac110ac4ce46d343e878d (patch)
tree4f390d3d231ad45723e21e65d87fab8695f141aa /src/common
parent957843959d4d9046b4eb5beb42cc41dd7bb56bed (diff)
vty: reduce code duplication
Use libosmocore's osmo_str2lower() instead of local equivalent. Change-Id: I7faced2eaf0f6f87f06081235eea9d4c3ba71a7e
Diffstat (limited to 'src/common')
-rw-r--r--src/common/vty.c38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/common/vty.c b/src/common/vty.c
index 646ac87f..3f736c97 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -35,7 +35,7 @@
#include <osmocom/vty/misc.h>
#include <osmocom/vty/ports.h>
#include <osmocom/core/gsmtap.h>
-
+#include <osmocom/core/utils.h>
#include <osmocom/trau/osmo_ortp.h>
@@ -234,37 +234,11 @@ DEFUN(cfg_bts_trx, cfg_bts_trx_cmd,
return CMD_SUCCESS;
}
-/* FIXME: move to libosmocore ? */
-static char buf_casecnvt[256];
-char *osmo_str_tolower(const char *in)
-{
- int len, i;
-
- if (!in)
- return NULL;
-
- len = strlen(in);
- if (len > sizeof(buf_casecnvt))
- len = sizeof(buf_casecnvt);
-
- for (i = 0; i < len; i++) {
- buf_casecnvt[i] = tolower(in[i]);
- if (in[i] == '\0')
- break;
- }
- if (i < sizeof(buf_casecnvt))
- buf_casecnvt[i] = '\0';
-
- /* just to make sure we're always zero-terminated */
- buf_casecnvt[sizeof(buf_casecnvt)-1] = '\0';
-
- return buf_casecnvt;
-}
-
static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
{
struct gsm_bts_role_bts *btsb = bts_role_bts(bts);
struct gsm_bts_trx *trx;
+ char buf_casecnvt[256];
int i;
vty_out(vty, "bts %u%s", bts->nr, VTY_NEWLINE);
@@ -294,13 +268,13 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
for (i = 0; i < 32; i++) {
if (gsmtap_sapi_mask & (1 << i)) {
- const char *name = get_value_string(gsmtap_sapi_names, i);
- vty_out(vty, " gsmtap-sapi %s%s", osmo_str_tolower(name), VTY_NEWLINE);
+ osmo_str2lower(buf_casecnvt, get_value_string(gsmtap_sapi_names, i));
+ vty_out(vty, " gsmtap-sapi %s%s", buf_casecnvt, VTY_NEWLINE);
}
}
if (gsmtap_sapi_acch) {
- const char *name = get_value_string(gsmtap_sapi_names, GSMTAP_CHANNEL_ACCH);
- vty_out(vty, " gsmtap-sapi %s%s", osmo_str_tolower(name), VTY_NEWLINE);
+ osmo_str2lower(buf_casecnvt, get_value_string(gsmtap_sapi_names, GSMTAP_CHANNEL_ACCH));
+ vty_out(vty, " gsmtap-sapi %s%s", buf_casecnvt, VTY_NEWLINE);
}
vty_out(vty, " min-qual-rach %.0f%s", btsb->min_qual_rach * 10.0f,
VTY_NEWLINE);