Source-Changes-HG archive

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

[src/trunk]: src Update for proplib(3) API changes.



details:   https://anonhg.NetBSD.org/src/rev/ec90069b7938
branches:  trunk
changeset: 934098:ec90069b7938
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jun 07 00:12:00 2020 +0000

description:
Update for proplib(3) API changes.

diffstat:

 usr.bin/btkey/file.c         |  12 ++++----
 usr.sbin/btdevctl/btdevctl.c |  25 ++++-------------
 usr.sbin/btdevctl/db.c       |  36 +++++++++---------------
 usr.sbin/btdevctl/print.c    |  24 ++++++++--------
 usr.sbin/btdevctl/sdp.c      |  63 ++++++++++---------------------------------
 5 files changed, 53 insertions(+), 107 deletions(-)

diffs (truncated from 466 to 300 lines):

diff -r aadd8cb1186a -r ec90069b7938 usr.bin/btkey/file.c
--- a/usr.bin/btkey/file.c      Sat Jun 06 23:02:25 2020 +0000
+++ b/usr.bin/btkey/file.c      Sun Jun 07 00:12:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: file.c,v 1.2 2014/02/23 07:50:01 mlelstv Exp $ */
+/*     $NetBSD: file.c,v 1.3 2020/06/07 00:15:37 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2007 Iain Hibbert
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: file.c,v 1.2 2014/02/23 07:50:01 mlelstv Exp $");
+__RCSID("$NetBSD: file.c,v 1.3 2020/06/07 00:15:37 thorpej Exp $");
 
 #include <sys/stat.h>
 #include <prop/proplib.h>
@@ -67,7 +67,7 @@
                goto done;
 
        while ((sym = prop_object_iterator_next(iter)) != NULL) {
-               if (bt_aton(prop_dictionary_keysym_cstring_nocopy(sym), &bdaddr) == 0)
+               if (bt_aton(prop_dictionary_keysym_value(sym), &bdaddr) == 0)
                        continue;
                if (bdaddr_any(&bdaddr))
                        continue;
@@ -78,7 +78,7 @@
 
                printf("\n");
                print_addr("bdaddr", &bdaddr);
-               print_key("file key", prop_data_data_nocopy(dat));
+               print_key("file key", prop_data_value(dat));
        }
 
        prop_object_iterator_release(iter);
@@ -111,7 +111,7 @@
        if (prop_data_size(dat) != HCI_KEY_SIZE)
                goto done;
 
-       memcpy(key, prop_data_data_nocopy(dat), HCI_KEY_SIZE);
+       memcpy(key, prop_data_value(dat), HCI_KEY_SIZE);
        rv = true;
 
 done:
@@ -149,7 +149,7 @@
                        goto done;
        }
 
-       dat = prop_data_create_data_nocopy(key, HCI_KEY_SIZE);
+       dat = prop_data_create_nocopy(key, HCI_KEY_SIZE);
        if (dat == NULL)
                goto done;
 
diff -r aadd8cb1186a -r ec90069b7938 usr.sbin/btdevctl/btdevctl.c
--- a/usr.sbin/btdevctl/btdevctl.c      Sat Jun 06 23:02:25 2020 +0000
+++ b/usr.sbin/btdevctl/btdevctl.c      Sun Jun 07 00:12:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $      */
+/*     $NetBSD: btdevctl.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 __COPYRIGHT("@(#) Copyright (c) 2006 The NetBSD Foundation, Inc.\
   @(#) Copyright (c) 2006 Itronix, Inc.\
   All rights reserved.");
-__RCSID("$NetBSD: btdevctl.c,v 1.10 2011/08/27 22:24:14 joerg Exp $");
+__RCSID("$NetBSD: btdevctl.c,v 1.11 2020/06/07 00:12:00 thorpej Exp $");
 
 #include <prop/proplib.h>
 #include <sys/ioctl.h>
@@ -62,7 +62,6 @@
 main(int argc, char *argv[])
 {
        prop_dictionary_t dev;
-       prop_object_t obj;
        bdaddr_t laddr, raddr;
        const char *service, *mode;
        int ch, query, verbose, attach, detach, set, none;
@@ -161,11 +160,8 @@
        }
 
        if (mode != NULL) {
-               obj = prop_string_create_cstring_nocopy(mode);
-               if (obj == NULL || !prop_dictionary_set(dev, BTDEVmode, obj))
+               if (!prop_dictionary_set_string_nocopy(dev, BTDEVmode, mode))
                        errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVmode);
-
-               prop_object_release(obj);
                set = true;
        }
 
@@ -178,26 +174,17 @@
                errx(EXIT_FAILURE, "service store failed");
 
        /* add binary local-bdaddr */
-       obj = prop_data_create_data(&laddr, sizeof(laddr));
-       if (obj == NULL || !prop_dictionary_set(dev, BTDEVladdr, obj))
+       if (!prop_dictionary_set_data(dev, BTDEVladdr, &laddr, sizeof(laddr)))
                errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVladdr);
 
-       prop_object_release(obj);
-
        /* add binary remote-bdaddr */
-       obj = prop_data_create_data(&raddr, sizeof(raddr));
-       if (obj == NULL || !prop_dictionary_set(dev, BTDEVraddr, obj))
+       if (!prop_dictionary_set_data(dev, BTDEVraddr, &raddr, sizeof(raddr)))
                errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVraddr);
 
-       prop_object_release(obj);
-
        /* add service name */
-       obj = prop_string_create_cstring(service);
-       if (obj == NULL || !prop_dictionary_set(dev, BTDEVservice, obj))
+       if (!prop_dictionary_set_string(dev, BTDEVservice, service))
                errx(EXIT_FAILURE, "proplib failure (%s)", BTDEVservice);
 
-       prop_object_release(obj);
-
        if (verbose == true)
                cfg_print(dev);
 
diff -r aadd8cb1186a -r ec90069b7938 usr.sbin/btdevctl/db.c
--- a/usr.sbin/btdevctl/db.c    Sat Jun 06 23:02:25 2020 +0000
+++ b/usr.sbin/btdevctl/db.c    Sun Jun 07 00:12:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db.c,v 1.5 2019/02/03 03:19:30 mrg Exp $       */
+/*     $NetBSD: db.c,v 1.6 2020/06/07 00:12:00 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: db.c,v 1.5 2019/02/03 03:19:30 mrg Exp $");
+__RCSID("$NetBSD: db.c,v 1.6 2020/06/07 00:12:00 thorpej Exp $");
 
 #include <bluetooth.h>
 #include <err.h>
@@ -75,7 +75,7 @@
                        return NULL;
                } else {
                        obj = prop_dictionary_get(db, "btdevctl-version");
-                       switch(prop_number_integer_value(obj)) {
+                       switch(prop_number_signed_value(obj)) {
                        case 0: db_update0();
                                /* FALLTHROUGH */
                        case 1: db_update1();
@@ -111,7 +111,6 @@
 db_set(prop_dictionary_t dev, bdaddr_t *laddr, bdaddr_t *raddr, const char *service)
 {
        prop_dictionary_t ldev, rdev;
-       prop_number_t version;
 
        ldev = prop_dictionary_get(db, bt_ntoa(laddr, NULL));
        if (ldev == NULL) {
@@ -141,14 +140,9 @@
                return 0;
 
        if (db_flush == true) {
-               version = prop_number_create_integer(BTDEVCTL_VERSION);
-               if (version == NULL)
-                       err(EXIT_FAILURE, "prop_number_create_integer");
-
-               if (!prop_dictionary_set(db, "btdevctl-version", version))
-                       err(EXIT_FAILURE, "prop_dictionary_set");
-
-               prop_object_release(version);
+               if (!prop_dictionary_set_int(db, "btdevctl-version",
+                                            BTDEVCTL_VERSION))
+                       err(EXIT_FAILURE, "prop_dictionary_set_int");
 
                if (!prop_dictionary_externalize_to_file(db, BTDEVCTL_PLIST))
                        warn("%s", BTDEVCTL_PLIST);
@@ -194,20 +188,20 @@
                if (prop_data_size(obj) != sizeof(laddr))
                        errx(EXIT_FAILURE, "invalid %s", BTDEVladdr);
 
-               bdaddr_copy(&laddr, prop_data_data_nocopy(obj));
+               bdaddr_copy(&laddr, prop_data_value(obj));
                prop_dictionary_remove(dev, BTDEVladdr);
 
                obj = prop_dictionary_get(dev, BTDEVraddr);
                if (prop_data_size(obj) != sizeof(raddr))
                        errx(EXIT_FAILURE, "invalid %s", BTDEVraddr);
 
-               bdaddr_copy(&raddr, prop_data_data_nocopy(obj));
+               bdaddr_copy(&raddr, prop_data_value(obj));
                prop_dictionary_remove(dev, BTDEVraddr);
 
                obj = prop_dictionary_get(dev, BTDEVtype);
-               if (prop_string_equals_cstring(obj, "bthidev"))
+               if (prop_string_equals_string(obj, "bthidev"))
                        service = "HID";
-               else if (prop_string_equals_cstring(obj, "btsco")) {
+               else if (prop_string_equals_string(obj, "btsco")) {
                        obj = prop_dictionary_get(dev, BTSCOlisten);
                        if (prop_bool_true(obj))
                                service = "HF";
@@ -247,7 +241,7 @@
        while ((key = prop_object_iterator_next(iter0)) != NULL) {
                ldev = prop_dictionary_get_keysym(db, key);
                if (prop_object_type(ldev) != PROP_TYPE_DICTIONARY
-                   || !bt_aton(prop_dictionary_keysym_cstring_nocopy(key), &bdaddr))
+                   || !bt_aton(prop_dictionary_keysym_value(key), &bdaddr))
                        continue;
 
                iter1 = prop_dictionary_iterator(ldev);
@@ -257,7 +251,7 @@
                while ((key = prop_object_iterator_next(iter1)) != NULL) {
                        rdev = prop_dictionary_get_keysym(ldev, key);
                        if (prop_object_type(rdev) != PROP_TYPE_DICTIONARY
-                           || !bt_aton(prop_dictionary_keysym_cstring_nocopy(key), &bdaddr))
+                           || !bt_aton(prop_dictionary_keysym_value(key), &bdaddr))
                                continue;
 
                        srv = prop_dictionary_get(rdev, "HID");
@@ -268,11 +262,9 @@
                        if (prop_object_type(obj) != PROP_TYPE_DATA)
                                continue;
 
-                       obj = prop_string_create_cstring_nocopy(hid_mode(obj));
-                       if (obj == NULL || !prop_dictionary_set(srv, BTDEVmode, obj))
+                       if (!prop_dictionary_set_string_nocopy(srv, BTDEVmode,
+                                                              hid_mode(obj)))
                                err(EXIT_FAILURE, "Cannot set %s", BTDEVmode);
-
-                       prop_object_release(obj);
                }
 
                prop_object_iterator_release(iter1);
diff -r aadd8cb1186a -r ec90069b7938 usr.sbin/btdevctl/print.c
--- a/usr.sbin/btdevctl/print.c Sat Jun 06 23:02:25 2020 +0000
+++ b/usr.sbin/btdevctl/print.c Sun Jun 07 00:12:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.11 2017/12/10 20:38:14 bouyer Exp $        */
+/*     $NetBSD: print.c,v 1.12 2020/06/07 00:12:00 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: print.c,v 1.11 2017/12/10 20:38:14 bouyer Exp $");
+__RCSID("$NetBSD: print.c,v 1.12 2020/06/07 00:12:00 thorpej Exp $");
 
 #include <sys/types.h>
 
@@ -92,17 +92,17 @@
        if (prop_object_type(obj) != PROP_TYPE_DATA) {
                return;
        }
-       printf("local bdaddr: %s\n", bt_ntoa(prop_data_data_nocopy(obj), NULL));
+       printf("local bdaddr: %s\n", bt_ntoa(prop_data_value(obj), NULL));
 
        obj = prop_dictionary_get(dict, BTDEVraddr);
        if (prop_object_type(obj) != PROP_TYPE_DATA) {
                return;
        }
-       printf("remote bdaddr: %s\n", bt_ntoa(prop_data_data_nocopy(obj), NULL));
+       printf("remote bdaddr: %s\n", bt_ntoa(prop_data_value(obj), NULL));
 
        obj = prop_dictionary_get(dict, BTDEVmode);
        if (prop_object_type(obj) == PROP_TYPE_STRING)
-               printf("link mode: %s\n", prop_string_cstring_nocopy(obj));
+               printf("link mode: %s\n", prop_string_value(obj));
 
        if (prop_dictionary_get_uint16(dict, BTDEVvendor, &v))
                printf("vendor id: 0x%04x\n", v);
@@ -115,14 +115,14 @@
                printf("No device type!\n");
                return;
        }
-       printf("device type: %s\n", prop_string_cstring_nocopy(obj));
+       printf("device type: %s\n", prop_string_value(obj));
 
-       if (prop_string_equals_cstring(obj, "bthidev")) {
+       if (prop_string_equals_string(obj, "bthidev")) {
                cfg_bthidev(dict);
                return;
        }
 
-       if (prop_string_equals_cstring(obj, "btsco")) {
+       if (prop_string_equals_string(obj, "btsco")) {
                cfg_btsco(dict);
                return;
        }
@@ -138,12 +138,12 @@
        obj = prop_dictionary_get(dict, BTHIDEVcontrolpsm);
        if (prop_object_type(obj) == PROP_TYPE_NUMBER)
                printf("control psm: 0x%4.4" PRIx64 "\n",
-                       prop_number_integer_value(obj));
+                       prop_number_signed_value(obj));
 
        obj = prop_dictionary_get(dict, BTHIDEVinterruptpsm);
        if (prop_object_type(obj) == PROP_TYPE_NUMBER)
                printf("interrupt psm: 0x%4.4" PRIx64 "\n",



Home | Main Index | Thread Index | Old Index