All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH v2 2/6] tools: Add utility for looking CDMA network name from database
Date: Thu, 17 Nov 2011 17:21:00 +0100	[thread overview]
Message-ID: <1321546864-368-3-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1321546864-368-1-git-send-email-philippe.nunes@linux.intel.com>

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

---
 Makefile.am                  |    7 +++-
 tools/lookup-provider-name.c |  100 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 106 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..596b6c1
--- /dev/null
+++ b/tools/lookup-provider-name.c
@@ -0,0 +1,100 @@
+/*
+ *
+ *  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");
+
+		return;
+	}
+
+	g_print("CDMA provider name: %s\n", name);
+
+	g_free(name);
+}
+
+static gboolean option_version = FALSE;
+
+static GOptionEntry options[] = {
+	{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
+				"Show version information and exit" },
+	{ 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;
+}
-- 
1.7.1


  parent reply	other threads:[~2011-11-17 16:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17 16:20 [PATCH v2 0/6] Add a parser to retrieve the CDMA network name Philippe Nunes
2011-11-17 16:20 ` [PATCH v2 1/6] mbpi: Add mbpi_lookup_cdma_provider_name API Philippe Nunes
2011-11-16 10:28   ` Denis Kenzior
2011-11-17 16:21 ` Philippe Nunes [this message]
2011-11-16 10:28   ` [PATCH v2 2/6] tools: Add utility for looking CDMA network name from database Denis Kenzior
2011-11-17 16:21 ` [PATCH v2 3/6] Huaweicdmamodem: remove this specific driver Philippe Nunes
2011-11-17 16:21 ` [PATCH v2 4/6] huaweicdmamodem: Merge this driver with cdmamodem driver Philippe Nunes
2011-11-17 16:21 ` [PATCH v2 5/6] cdmamodem: Add CDMA network-registration support Philippe Nunes
2011-11-17 16:21 ` [PATCH v2 6/6] cdmamodem: Add serving system identifier support Philippe Nunes
2011-11-16 10:26   ` Denis Kenzior
2011-11-18 13:18     ` Philippe Nunes
2011-11-18 15:18       ` Denis Kenzior
2011-11-24 17:35         ` Philippe Nunes
2011-11-24  7:03           ` Denis Kenzior
2011-11-25 16:31             ` Philippe Nunes
2011-11-24 23:35               ` Denis Kenzior

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=1321546864-368-3-git-send-email-philippe.nunes@linux.intel.com \
    --to=philippe.nunes@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.