summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-10-07 00:00:15 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-10-08 19:23:18 +0800
commitc87f26652258ea7133efe57d1e8c8fc2f21c0efd (patch)
tree3fa26598e44cb2ac084ede967ec9c8c7ee8bfe2e /tests
parent55aea5099c1780700e5acebda712e47b575853e5 (diff)
msgfile: Add a file parser for a simple file format
This file format will be used to store per country code, per network code messages. This will be used for various things ranging from access control, to messages...
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/msgfile/Makefile.am5
-rw-r--r--tests/msgfile/msgconfig.cfg1
-rw-r--r--tests/msgfile/msgfile_test.c50
4 files changed, 59 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0119a02c..14c8ca87 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,6 @@
if ENABLE_TESTS
SUBDIRS = timer sms
+if ENABLE_MSGFILE
+SUBDIRS += msgfile
+endif
endif
diff --git a/tests/msgfile/Makefile.am b/tests/msgfile/Makefile.am
new file mode 100644
index 00000000..c9f4bec2
--- /dev/null
+++ b/tests/msgfile/Makefile.am
@@ -0,0 +1,5 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+noinst_PROGRAMS = msgfile_test
+
+msgfile_test_SOURCES = msgfile_test.c
+msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la
diff --git a/tests/msgfile/msgconfig.cfg b/tests/msgfile/msgconfig.cfg
new file mode 100644
index 00000000..dfaad299
--- /dev/null
+++ b/tests/msgfile/msgconfig.cfg
@@ -0,0 +1 @@
+*:*::Hello Welt
diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c
new file mode 100644
index 00000000..a82ac516
--- /dev/null
+++ b/tests/msgfile/msgfile_test.c
@@ -0,0 +1,50 @@
+/*
+ * (C) 2010 by Holger Hans Peter Freyther
+ * (C) 2010 by On-Waves
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <osmocore/msgfile.h>
+
+#include <stdio.h>
+
+static void dump_entries(struct msg_entries *entries)
+{
+ struct msg_entry *entry;
+
+ if (!entries) {
+ fprintf(stderr, "Failed to parse the file\n");
+ return;
+ }
+
+ llist_for_each_entry(entry, &entries->entry, list) {
+ printf("Entry '%s:%s:%s:%s'\n",
+ entry->mcc, entry->mnc, entry->option, entry->text);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ struct msg_entries *entries;
+
+ /* todo use msgfile_test.c.in and replace the path */
+ entries = msg_entry_parse(NULL, "msgconfig.cfg");
+ dump_entries(entries);
+
+ return 0;
+}