Source-Changes-HG archive

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

[src/netbsd-7]: src/sbin/drvctl Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/a7e5e02515da
branches:  netbsd-7
changeset: 799056:a7e5e02515da
user:      snj <snj%NetBSD.org@localhost>
date:      Sat Mar 07 06:06:24 2015 +0000

description:
Pull up following revision(s) (requested by mlelstv in ticket #562):
        sbin/drvctl/drvctl.8: revision 1.14
        sbin/drvctl/drvctl.c: revision 1.17
Let drvctl -p select elements from an array property by numeric index.

diffstat:

 sbin/drvctl/drvctl.8 |   6 ++++--
 sbin/drvctl/drvctl.c |  28 ++++++++++++++++++++++------
 2 files changed, 26 insertions(+), 8 deletions(-)

diffs (72 lines):

diff -r f9e116f190e4 -r a7e5e02515da sbin/drvctl/drvctl.8
--- a/sbin/drvctl/drvctl.8      Sat Mar 07 06:00:01 2015 +0000
+++ b/sbin/drvctl/drvctl.8      Sat Mar 07 06:06:24 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: drvctl.8,v 1.13 2012/01/16 19:43:50 pgoyette Exp $
+.\" $NetBSD: drvctl.8,v 1.13.18.1 2015/03/07 06:06:24 snj Exp $
 .\"
 .\" Copyright (c) 2004
 .\"    Matthias Drochner.  All rights reserved.
@@ -114,7 +114,9 @@
 If
 .Ar property
 is specified, the value of that property is printed, otherwise
-the properties are displayed as an XML property list.
+the properties are displayed as an XML property list. The
+property can be given as a path of dictionary keys and numeric
+array indexes separated by slashes.
 .It Fl Q
 Resume the ancestors of
 .Ar device ,
diff -r f9e116f190e4 -r a7e5e02515da sbin/drvctl/drvctl.c
--- a/sbin/drvctl/drvctl.c      Sat Mar 07 06:00:01 2015 +0000
+++ b/sbin/drvctl/drvctl.c      Sat Mar 07 06:06:24 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drvctl.c,v 1.16 2012/01/17 08:22:09 wiz Exp $ */
+/* $NetBSD: drvctl.c,v 1.16.18.1 2015/03/07 06:06:24 snj Exp $ */
 
 /*
  * Copyright (c) 2004
@@ -226,21 +226,37 @@
 {
        char *s, *p, *cur, *ep = NULL;
        prop_object_t obj;
+       unsigned long ind;
 
+       obj = dict;
+       cur = NULL;
        s = strdup(prop);
        p = strtok_r(s, "/", &ep);
        while (p) {
                cur = p;
                p = strtok_r(NULL, "/", &ep);
-               if (p) {
-                       if (prop_dictionary_get_dict(dict, cur, &dict) == false)
+
+               switch (prop_object_type(obj)) {
+               case PROP_TYPE_DICTIONARY:
+                       obj = prop_dictionary_get(obj, cur);
+                       if (obj == NULL)
                                exit(EXIT_FAILURE);
-               } else {
-                       obj = prop_dictionary_get(dict, cur);
-                       display_object(obj, nflag);
+                       break;
+               case PROP_TYPE_ARRAY:
+                       ind = strtoul(cur, NULL, 0);
+                       obj = prop_array_get(obj, ind);
+                       if (obj == NULL)
+                               exit(EXIT_FAILURE);
+                       break;
+               default:
+                       fprintf(stderr, "select neither dict nor array with '%s'\n", cur);
+                       exit(EXIT_FAILURE);
                }
        }
 
+       if (obj != NULL && cur != NULL)
+               display_object(obj, nflag);
+
        free(s);
 }
 



Home | Main Index | Thread Index | Old Index