Hi Philippe, On 11/15/2011 07:04 AM, Philippe Nunes wrote: > --- > Makefile.am | 7 ++- > tools/lookup-provider-name.c | 104 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 110 insertions(+), 1 deletions(-) > create mode 100644 tools/lookup-provider-name.c > > diff --git a/Makefile.am b/Makefile.am > index a28f790..337aeb7 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -627,7 +627,8 @@ TESTS = $(unit_tests) > > if TOOLS > noinst_PROGRAMS += tools/huawei-audio tools/auto-enable \ > - tools/get-location tools/lookup-apn > + tools/get-location tools/lookup-apn \ > + tools/lookup-provider-name > > tools_huawei_audio_SOURCES = $(gdbus_sources) tools/huawei-audio.c > tools_huawei_audio_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ > @@ -640,6 +641,10 @@ tools_get_location_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ > > tools_lookup_apn_SOURCES = plugins/mbpi.c plugins/mbpi.h tools/lookup-apn.c > tools_lookup_apn_LDADD = @GLIB_LIBS@ > + > +tools_lookup_provider_name_SOURCES = plugins/mbpi.c plugins/mbpi.h \ > + tools/lookup-provider-name.c > +tools_lookup_provider_name_LDADD = @GLIB_LIBS@ > endif > > noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm > diff --git a/tools/lookup-provider-name.c b/tools/lookup-provider-name.c > new file mode 100644 > index 0000000..dc91ae5 > --- /dev/null > +++ b/tools/lookup-provider-name.c > @@ -0,0 +1,104 @@ > +/* > + * > + * oFono - Open Source Telephony > + * > + * Copyright (C) 2008-2011 Intel Corporation. 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 version 2 as > + * published by the Free Software Foundation. > + * > + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA > + * > + */ > + > +#ifdef HAVE_CONFIG_H > +#include > +#endif > + > +#include > + > +#include > + > +#define OFONO_API_SUBJECT_TO_CHANGE > +#include > +#include > + > +#include "plugins/mbpi.h" > + > +static void lookup_cdma_provider_name(const char *match_sid) > +{ > + GError *error = NULL; > + char *name; > + > + g_print("Searching for serving network name with SID: %s\n", match_sid); > + > + name = mbpi_lookup_cdma_provider_name(match_sid, &error); > + > + if (name == NULL) { > + if (error != NULL) { > + g_printerr("Lookup failed: %s\n", error->message); > + g_error_free(error); > + } > + else > + g_printerr("Not found\n"); Please re-read the kernel style guidelines with regard to placing of curly braces in compound statements. It should be on the same line as the else statement. > + > + return; > + } > + > + g_print("CDMA provider name: %s\n", name); > + > + g_free(name); > +} > + > +static gboolean option_version = FALSE; > +static gboolean option_duplicates = FALSE; > + > +static GOptionEntry options[] = { > + { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, > + "Show version information and exit" }, > + { "allow-duplicates", 0, 0, G_OPTION_ARG_NONE, &option_duplicates, > + "Allow duplicate access point types" }, Why exactly do we need this option? > + { NULL }, > +}; > + > +int main(int argc, char **argv) > +{ > + GOptionContext *context; > + GError *error = NULL; > + > + context = g_option_context_new(NULL); > + g_option_context_add_main_entries(context, options, NULL); > + > + if (g_option_context_parse(context, &argc, &argv, &error) == FALSE) { > + if (error != NULL) { > + g_printerr("%s\n", error->message); > + g_error_free(error); > + } else > + g_printerr("An unknown error occurred\n"); > + exit(1); > + } > + > + g_option_context_free(context); > + > + if (option_version == TRUE) { > + g_print("%s\n", VERSION); > + exit(0); > + } > + > + if (argc < 1) { > + g_printerr("Missing parameters\n"); > + exit(1); > + } > + > + lookup_cdma_provider_name(argv[1]); > + > + return 0; > +} Regards, -Denis