Module Name: src Committed By: snj Date: Sat Mar 7 06:06:24 UTC 2015
Modified Files: src/sbin/drvctl [netbsd-7]: drvctl.8 drvctl.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.13.18.1 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.16 -r1.16.18.1 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.13 src/sbin/drvctl/drvctl.8:1.13.18.1 --- src/sbin/drvctl/drvctl.8:1.13 Mon Jan 16 19:43:50 2012 +++ src/sbin/drvctl/drvctl.8 Sat Mar 7 06:06:24 2015 @@ -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 @@ argument. 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 , Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.16 src/sbin/drvctl/drvctl.c:1.16.18.1 --- src/sbin/drvctl/drvctl.c:1.16 Tue Jan 17 08:22:09 2012 +++ src/sbin/drvctl/drvctl.c Sat Mar 7 06:06:24 2015 @@ -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 @@ extract_property(prop_dictionary_t dict, { 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); }