From c87f26652258ea7133efe57d1e8c8fc2f21c0efd Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 7 Oct 2010 00:00:15 +0800 Subject: 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... --- tests/msgfile/Makefile.am | 5 +++++ tests/msgfile/msgconfig.cfg | 1 + tests/msgfile/msgfile_test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/msgfile/Makefile.am create mode 100644 tests/msgfile/msgconfig.cfg create mode 100644 tests/msgfile/msgfile_test.c (limited to 'tests/msgfile') 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 + +#include + +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; +} -- cgit v1.2.3