e1_recorder: add config option for configuration file
diff --git a/src/e1_recorder.c b/src/e1_recorder.c
index 11ec93e..9110ccb 100644
--- a/src/e1_recorder.c
+++ b/src/e1_recorder.c
@@ -1,4 +1,5 @@
 #include <signal.h>
+#include <getopt.h>
 
 #include <osmocom/core/signal.h>
 #include <osmocom/core/logging.h>
@@ -88,6 +89,7 @@
 
 static void *rec_tall_ctx;
 struct e1_recorder g_recorder;
+static char *g_config_file = "osmo-e1-recorder.cfg";
 
 static void signal_handler(int signo)
 {
@@ -101,6 +103,28 @@
 	}
 }
 
+static void handle_options(int argc, char **argv)
+{
+	while (1) {
+		int option_index = 0, c;
+		static const struct option long_options[] = {
+			{ "config-file", 1, 0, 'c' },
+			{ 0, 0, 0, 0 }
+		};
+
+		c = getopt_long(argc, argv, "c:",
+				long_options, &option_index);
+		if (c == -1)
+			break;
+
+		switch (c) {
+		case 'c':
+			g_config_file = optarg;
+			break;
+		}
+	}
+}
+
 int main(int argc, char **argv)
 {
 	int rc;
@@ -118,7 +142,9 @@
 	signal(SIGHUP, &signal_handler);
 	signal(SIGUSR1, &signal_handler);
 
-	rc = vty_read_config_file("osmo-e1-recorder.cfg", NULL);
+	handle_options(argc, argv);
+
+	rc = vty_read_config_file(g_config_file, NULL);
 	if (rc < 0)
 		exit(1);