[PATCH] osmocom-bb[master]: Add arbitrary config file location support

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Sep 7 10:23:47 UTC 2017


Review at  https://gerrit.osmocom.org/3884

Add arbitrary config file location support

All other Osmocom projects use '-c' command line option to specify the
location of config file. Let's do the same and remove existing implicit
logic.

Change-Id: Idaac3ff8d1f8541e00c45290db948a67bb899311
---
M src/host/layer23/src/mobile/main.c
1 file changed, 7 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/84/3884/1

diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c
index 630bc53..0fc74c1 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -51,6 +51,7 @@
 void *l23_ctx = NULL;
 struct llist_head ms_list;
 static char *gsmtap_ip = 0;
+static const char *config_file = "mobile.cfg";
 struct gsmtap_inst *gsmtap_inst = NULL;
 static char *vty_ip = "127.0.0.1";
 unsigned short vty_port = 4247;
@@ -96,6 +97,7 @@
 	printf("  -d --debug		Change debug flags. default: %s\n",
 		debug_default);
 	printf("  -D --daemonize	Run as daemon\n");
+	printf("  -c --config-file filename The config file to use.\n");
 	printf("  -m --mncc-sock	Disable built-in MNCC handler and "
 		"offer socket\n");
 }
@@ -111,11 +113,12 @@
 			{"vty-port", 1, 0, 'v'},
 			{"debug", 1, 0, 'd'},
 			{"daemonize", 0, 0, 'D'},
+			{"config-file", 1, 0, 'c'},
 			{"mncc-sock", 0, 0, 'm'},
 			{0, 0, 0, 0},
 		};
 
-		c = getopt_long(argc, argv, "hi:u:v:d:Dm",
+		c = getopt_long(argc, argv, "hi:u:c:v:d:Dm",
 				long_options, &option_index);
 		if (c == -1)
 			break;
@@ -131,6 +134,9 @@
 			break;
 		case 'u':
 			vty_ip = optarg;
+			break;
+		case 'c':
+			config_file = optarg;
 			break;
 		case 'v':
 			vty_port = atoi(optarg);
@@ -201,10 +207,6 @@
 {
 	int quit = 0;
 	int rc;
-	char const * home;
-	size_t len;
-	const char osmocomcfg[] = ".osmocom/bb/mobile.cfg";
-	char *config_file = NULL;
 
 	printf("%s\n", openbsc_copyright);
 
@@ -234,13 +236,6 @@
 		gsmtap_source_add_sink(gsmtap_inst);
 	}
 
-	home = getenv("HOME");
-	if (home != NULL) {
-		len = strlen(home) + 1 + sizeof(osmocomcfg);
-		config_file = talloc_size(l23_ctx, len);
-		if (config_file != NULL)
-			snprintf(config_file, len, "%s/%s", home, osmocomcfg);
-	}
 	/* save the config file directory name */
 	config_dir = talloc_strdup(l23_ctx, config_file);
 	config_dir = dirname(config_dir);
@@ -277,7 +272,6 @@
 
 	l23_app_exit();
 
-	talloc_free(config_file);
 	talloc_free(config_dir);
 	talloc_report_full(l23_ctx, stderr);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idaac3ff8d1f8541e00c45290db948a67bb899311
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list