Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/sdpquery allow to specify 32-bit bluetooth short ali...



details:   https://anonhg.NetBSD.org/src/rev/4e0221693835
branches:  trunk
changeset: 747950:4e0221693835
user:      plunky <plunky%NetBSD.org@localhost>
date:      Tue Oct 06 19:21:17 2009 +0000

description:
allow to specify 32-bit bluetooth short alias or full UUID strings
on the commandline.

diffstat:

 usr.bin/sdpquery/command.c  |  46 +++++++++++++++++++++++++-------------------
 usr.bin/sdpquery/sdpquery.1 |  12 ++--------
 2 files changed, 29 insertions(+), 29 deletions(-)

diffs (131 lines):

diff -r 834c3063288b -r 4e0221693835 usr.bin/sdpquery/command.c
--- a/usr.bin/sdpquery/command.c        Tue Oct 06 16:57:54 2009 +0000
+++ b/usr.bin/sdpquery/command.c        Tue Oct 06 19:21:17 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: command.c,v 1.1 2009/05/12 18:37:50 plunky Exp $       */
+/*     $NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $       */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: command.c,v 1.1 2009/05/12 18:37:50 plunky Exp $");
+__RCSID("$NetBSD: command.c,v 1.2 2009/10/06 19:21:17 plunky Exp $");
 
 #include <bluetooth.h>
 #include <err.h>
@@ -129,7 +129,7 @@
                if (*argv[0] == '\0' || *ep != '\0' || handle > UINT32_MAX)
                        errx(EXIT_FAILURE, "Invalid handle: %s\n", *argv);
 
-               rv = sdp_service_attribute(ss, handle, NULL, &rsp);
+               rv = sdp_service_attribute(ss, (uint32_t)handle, NULL, &rsp);
                if (!rv)
                        warn("%s", *argv);
                else
@@ -205,36 +205,42 @@
 static void
 build_ssp(sdp_data_t *ssp, int argc, const char **argv)
 {
-       static uint8_t  data[36];       /* 12 * sizeof(uuid16) */
+       static uint8_t  data[12 * sizeof(uuid_t)];
        char *          ep;
-       unsigned long   uuid;
+       uintmax_t       umax;
+       uuid_t          uuid;
+       uint32_t        status;
        int             i;
 
        ssp->next = data;
        ssp->end = data + sizeof(data);
 
        for (; argc-- > 0; argv++) {
-               uuid = strtoul(*argv, &ep, 0);
-               if (*argv[0] == '\0' || *ep != '\0') {
-                       for (i = 0;; i++) {
-                               if (i == __arraycount(aliases))
-                                       errx(EXIT_FAILURE,
-                                           "Unknown alias \"%s\"", *argv);
+               uuid_from_string(*argv, &uuid, &status);
+               if (status != uuid_s_ok) {
+                       umax = strtoumax(*argv, &ep, 0);
+                       if (*argv[0] == '\0' || *ep != '\0') {
+                               for (i = 0;; i++) {
+                                       if (i == __arraycount(aliases))
+                                               errx(EXIT_FAILURE,
+                                                   "%s: Bad UUID", *argv);
 
-                               if (strcasecmp(aliases[i].name, *argv) == 0)
-                                       break;
-                       }
+                                       if (strcasecmp(aliases[i].name,
+                                           *argv) == 0)
+                                               break;
+                               }
 
-                       uuid = aliases[i].uuid;
+                               umax = aliases[i].uuid;
+                       } else if (umax > UINT32_MAX)
+                               errx(EXIT_FAILURE, "%s: Bad UUID", *argv);
+
+                       uuid = BLUETOOTH_BASE_UUID;
+                       uuid.time_low = (uint32_t)umax;
                }
 
-               if (uuid > UINT16_MAX)
-                       errx(EXIT_FAILURE, "%s: Not 16-bit UUID", *argv);
-
-               sdp_put_uuid16(ssp, uuid);
+               sdp_put_uuid(ssp, &uuid);
        }
 
        ssp->end = ssp->next;
        ssp->next = data;
-       return;
 }
diff -r 834c3063288b -r 4e0221693835 usr.bin/sdpquery/sdpquery.1
--- a/usr.bin/sdpquery/sdpquery.1       Tue Oct 06 16:57:54 2009 +0000
+++ b/usr.bin/sdpquery/sdpquery.1       Tue Oct 06 19:21:17 2009 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sdpquery.1,v 1.11 2009/05/12 18:54:31 wiz Exp $
+.\"    $NetBSD: sdpquery.1,v 1.12 2009/10/06 19:21:17 plunky Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -54,7 +54,7 @@
 .\"
 .\" $FreeBSD: src/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.8,v 1.6 2005/07/09 19:04:43 markus Exp $
 .\"
-.Dd May 7, 2009
+.Dd Oct 6, 2009
 .Dt SDPQUERY 1
 .Os
 .Sh NAME
@@ -130,7 +130,7 @@
 Browse for services.
 The
 .Ar group
-parameter is a 16-bit UUID of the group to browse.
+parameter is the UUID of the group to browse.
 If omitted, the "Public Browse Group" is used.
 .Pp
 .It Cm Record Ar handle Op Ar handle...
@@ -140,7 +140,6 @@
 .Pp
 .It Cm Search Ar uuid Op Ar uuid...
 Search for records matching the list of
-.Pq 16-bit
 UUIDs which can be given in numerical form, or the
 following aliases are known:
 .Pp
@@ -215,8 +214,3 @@
 .An Maksim Yevmenkin Aq m_evmenkin%yahoo.com@localhost
 .An Iain Hibbert
 for Itronix, Inc.
-.Sh BUGS
-.Nm
-will only search for Bluetooth
-.Qq short alias
-16-bit UUIDs.



Home | Main Index | Thread Index | Old Index