summaryrefslogtreecommitdiff
path: root/src/util/libgsmd-tool.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/libgsmd-tool.c')
-rw-r--r--src/util/libgsmd-tool.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/util/libgsmd-tool.c b/src/util/libgsmd-tool.c
index a3da490..e8590c1 100644
--- a/src/util/libgsmd-tool.c
+++ b/src/util/libgsmd-tool.c
@@ -8,13 +8,42 @@
#include <libgsmd/libgsmd.h>
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
static struct lgsm_handle *lgsmh;
static int verbose = 0;
+enum mode_enum {
+ MODE_NONE,
+ MODE_SHELL,
+ MODE_EVENTLOG,
+};
+
+static char *modes[] = {
+ [MODE_NONE] = "",
+ [MODE_SHELL] = "shell",
+ [MODE_EVENTLOG] = "eventlog",
+};
+
+static int parse_mode(char *modestr)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(modes); i++) {
+ if (!strcmp(modes[i], modestr))
+ return i;
+ }
+
+ return -1;
+}
+
static struct option opts[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "verbose", 0, 0, 'v' },
+ { "mode", 1, 0, 'm' },
{ 0, 0, 0, 0 }
};
@@ -28,14 +57,14 @@ static void help(void)
int main(int argc, char **argv)
{
- int rc, i;
+ int rc, i, mode;
printf("libgsm-tool - (C) 2006 by Harald Welte\n"
"This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n");
while (1) {
int c, option_index = 0;
- c = getopt_long(argc, argv, "hVv", opts, &option_index);
+ c = getopt_long(argc, argv, "vVhm:", opts, &option_index);
if (c == -1)
break;
@@ -50,6 +79,13 @@ int main(int argc, char **argv)
help();
exit(0);
break;
+ case 'm':
+ mode = parse_mode(optarg);
+ if (mode < 0) {
+ fprintf(stderr, "unknown/unsupported mode `%s'\n", optarg);
+ exit(2);
+ }
+ break;
}
}
@@ -59,6 +95,11 @@ int main(int argc, char **argv)
exit(1);
}
+ switch (mode) {
+ case MODE_SHELL:
+ shell_main(lgsmh);
+ break;
+ }
exit(0);
}
personal git repositories of Harald Welte. Your mileage may vary