3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <unistd.h>
26 #include <strings.h>
27 #include <libintl.h>
28 #include <sys/types.h>
29 #include <sys/inttypes.h>
30 #include <stdarg.h>
31 #include <note.h>
32 #include "libnvpair.h"
33
34 /*
35 * libnvpair - A tools library for manipulating <name, value> pairs.
36 *
37 * This library provides routines packing an unpacking nv pairs
38 * for transporting data across process boundaries, transporting
39 * between kernel and userland, and possibly saving onto disk files.
40 */
41
42 /*
786 }
787
788 /*
789 * Similar to nvlist_print() but handles arrays slightly differently.
790 */
791 void
792 dump_nvlist(nvlist_t *list, int indent)
793 {
794 nvpair_t *elem = NULL;
795 boolean_t bool_value;
796 nvlist_t *nvlist_value;
797 nvlist_t **nvlist_array_value;
798 uint_t i, count;
799
800 if (list == NULL) {
801 return;
802 }
803
804 while ((elem = nvlist_next_nvpair(list, elem)) != NULL) {
805 switch (nvpair_type(elem)) {
806 case DATA_TYPE_BOOLEAN_VALUE:
807 (void) nvpair_value_boolean_value(elem, &bool_value);
808 (void) printf("%*s%s: %s\n", indent, "",
809 nvpair_name(elem), bool_value ? "true" : "false");
810 break;
811
812 case DATA_TYPE_BYTE:
813 NVP(elem, byte, uchar_t, int, "%u");
814 break;
815
816 case DATA_TYPE_INT8:
817 NVP(elem, int8, int8_t, int, "%d");
818 break;
819
820 case DATA_TYPE_UINT8:
821 NVP(elem, uint8, uint8_t, int, "%u");
822 break;
823
824 case DATA_TYPE_INT16:
825 NVP(elem, int16, int16_t, int, "%d");
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 */
25
26 #include <unistd.h>
27 #include <strings.h>
28 #include <libintl.h>
29 #include <sys/types.h>
30 #include <sys/inttypes.h>
31 #include <stdarg.h>
32 #include <note.h>
33 #include "libnvpair.h"
34
35 /*
36 * libnvpair - A tools library for manipulating <name, value> pairs.
37 *
38 * This library provides routines packing an unpacking nv pairs
39 * for transporting data across process boundaries, transporting
40 * between kernel and userland, and possibly saving onto disk files.
41 */
42
43 /*
787 }
788
789 /*
790 * Similar to nvlist_print() but handles arrays slightly differently.
791 */
792 void
793 dump_nvlist(nvlist_t *list, int indent)
794 {
795 nvpair_t *elem = NULL;
796 boolean_t bool_value;
797 nvlist_t *nvlist_value;
798 nvlist_t **nvlist_array_value;
799 uint_t i, count;
800
801 if (list == NULL) {
802 return;
803 }
804
805 while ((elem = nvlist_next_nvpair(list, elem)) != NULL) {
806 switch (nvpair_type(elem)) {
807 case DATA_TYPE_BOOLEAN:
808 (void) printf("%*s%s\n", indent, "", nvpair_name(elem));
809 break;
810
811 case DATA_TYPE_BOOLEAN_VALUE:
812 (void) nvpair_value_boolean_value(elem, &bool_value);
813 (void) printf("%*s%s: %s\n", indent, "",
814 nvpair_name(elem), bool_value ? "true" : "false");
815 break;
816
817 case DATA_TYPE_BYTE:
818 NVP(elem, byte, uchar_t, int, "%u");
819 break;
820
821 case DATA_TYPE_INT8:
822 NVP(elem, int8, int8_t, int, "%d");
823 break;
824
825 case DATA_TYPE_UINT8:
826 NVP(elem, uint8, uint8_t, int, "%u");
827 break;
828
829 case DATA_TYPE_INT16:
830 NVP(elem, int16, int16_t, int, "%d");
|