From: Sheldon Demario <sheldon.demario@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Sheldon Demario <sheldon.demario@openbossa.org>
Subject: [PATCH 1/6] Create a helper function to deal with handles on interactive gatttool
Date: Thu, 24 Feb 2011 17:38:25 -0300 [thread overview]
Message-ID: <1298579910-15198-2-git-send-email-sheldon.demario@openbossa.org> (raw)
In-Reply-To: <1298579910-15198-1-git-send-email-sheldon.demario@openbossa.org>
---
attrib/interactive.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 7cc03bc..7b18e90 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -238,6 +238,19 @@ static void cmd_primary(int argcp, char **argvp)
gatt_discover_primary(attrib, &uuid, primary_by_uuid_cb, NULL);
}
+static int strtohandle(const char *src)
+{
+ char *e;
+ int dst;
+
+ errno = 0;
+ dst = strtoll(src, &e, 16);
+ if (errno != 0 || *e != '\0')
+ return -EINVAL;
+
+ return dst;
+}
+
static void cmd_char(int argcp, char **argvp)
{
int start = 0x0001;
@@ -249,28 +262,22 @@ static void cmd_char(int argcp, char **argvp)
}
if (argcp > 1) {
- char *e;
-
- start = strtoll(argvp[1], &e, 16);
- if (errno != 0 || *e != '\0') {
+ start = strtohandle(argvp[1]);
+ if (start < 0) {
printf("Invalid start handle: %s\n", argvp[1]);
return;
}
}
if (argcp > 2) {
- char *e;
-
- end = strtoll(argvp[2], &e, 16);
- if (errno != 0 || *e != '\0') {
+ end = strtohandle(argvp[2]);
+ if (end < 0) {
printf("Invalid end handle: %s\n", argvp[2]);
return;
}
}
gatt_discover_char(attrib, start, end, char_cb, NULL);
-
- return;
}
static struct {
--
1.7.1
next prev parent reply other threads:[~2011-02-24 20:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 20:38 [PATCH 0/6] *** SUBJECT HERE *** Sheldon Demario
2011-02-24 20:38 ` Sheldon Demario [this message]
2011-02-24 20:38 ` [PATCH 2/6] Add Characteristics Descriptor Discovery option in interactive gatttool Sheldon Demario
2011-02-24 20:38 ` [PATCH 3/6] Add characteristics read options " Sheldon Demario
2011-02-24 20:38 ` [PATCH 4/6] Move attr_data_from_string() to utils.c Sheldon Demario
2011-02-24 20:38 ` [PATCH 5/6] Add Write Request in interactive gatttool Sheldon Demario
2011-02-24 20:38 ` [PATCH 6/6] Add sec-level option to interactive gattool Sheldon Demario
2011-02-24 21:35 ` Johan Hedberg
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=1298579910-15198-2-git-send-email-sheldon.demario@openbossa.org \
--to=sheldon.demario@openbossa.org \
--cc=linux-bluetooth@vger.kernel.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