From 8045fdfb09c2e3b466f371b2ab64ff01f9f7aec1 Mon Sep 17 00:00:00 2001 From: laforge Date: Fri, 20 Oct 2006 20:41:12 +0000 Subject: - some more gsmd / libgsmd code - use autotools for build process git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@94 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/util/Makefile.am | 9 +++++++ src/util/libgsmd-tool.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/util/Makefile.am create mode 100644 src/util/libgsmd-tool.c (limited to 'src/util') diff --git a/src/util/Makefile.am b/src/util/Makefile.am new file mode 100644 index 0000000..bb257f5 --- /dev/null +++ b/src/util/Makefile.am @@ -0,0 +1,9 @@ +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -std=gnu99 + +bin_PROGRAMS = libgsmd-tool + +libgsmd_tool_SOURCES = libgsmd-tool.c +libgsmd_tool_LDADD = ../libgsmd/libgsmd.la +libgsmd_tool_LDFLAGS = -dynamic + diff --git a/src/util/libgsmd-tool.c b/src/util/libgsmd-tool.c new file mode 100644 index 0000000..a3da490 --- /dev/null +++ b/src/util/libgsmd-tool.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#define _GNU_SOURCE +#include + +#include + +static struct lgsm_handle *lgsmh; +static int verbose = 0; + +static struct option opts[] = { + { "help", 0, 0, 'h' }, + { "version", 0, 0, 'V' }, + { "verbose", 0, 0, 'v' }, + { 0, 0, 0, 0 } +}; + +static void help(void) +{ + printf("Usage:\n" + "\t-h\t--help\tPrint this Help message\n" + "\t-V\t--version\tPrint version number\n" + "\t-v\t--verbose\tBe more verbose\n"); +} + +int main(int argc, char **argv) +{ + int rc, i; + + 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); + if (c == -1) + break; + + switch (c) { + case 'v': + verbose = 1; + break; + case 'V': + /* FIXME */ + break; + case 'h': + help(); + exit(0); + break; + } + } + + lgsmh = lgsm_init(LGSMD_DEVICE_GSMD); + if (!lgsmh) { + fprintf(stderr, "Can't connect to gsmd\n"); + exit(1); + } + + + exit(0); +} -- cgit v1.2.3