Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 3/3] tools: Add utility for looking CDMA network name from database
Date: Mon, 14 Nov 2011 14:45:55 -0600	[thread overview]
Message-ID: <4EC17E03.6050303@gmail.com> (raw)
In-Reply-To: <1321362255-11262-4-git-send-email-philippe.nunes@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 4564 bytes --]

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 <config.h>
> +#endif
> +
> +#include <stdlib.h>
> +
> +#include <glib.h>
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include <ofono/modem.h>
> +#include <ofono/gprs-provision.h>
> +
> +#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

      reply	other threads:[~2011-11-14 20:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15 13:04 [PATCH 0/3] Add a parser to retrieve the CDMA network name Philippe Nunes
2011-11-15 13:04 ` [PATCH 1/3] mbpi: mbpi_lookup becomes mbpi_lookup_apn Philippe Nunes
2011-11-14 20:12   ` Denis Kenzior
2011-11-15 13:04 ` [PATCH 2/3] mbpi: Add mbpi_lookup_cdma_provider_name API Philippe Nunes
2011-11-14 20:42   ` Denis Kenzior
2011-11-15 13:04 ` [PATCH 3/3] tools: Add utility for looking CDMA network name from database Philippe Nunes
2011-11-14 20:45   ` Denis Kenzior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC17E03.6050303@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox