2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _LIBNVPAIR_H
2N/A#define _LIBNVPAIR_H
2N/A
2N/A#include <sys/nvpair.h>
2N/A#include <stdlib.h>
2N/A#include <stdio.h>
2N/A#include <regex.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * All interfaces described in this file are private to Solaris, and
2N/A * are subject to change at any time and without notice. The public
2N/A * nvlist/nvpair interfaces, as documented in manpage sections 3NVPAIR,
2N/A * are all imported from <sys/nvpair.h> included above.
2N/A */
2N/A
2N/Aextern int nvpair_value_match(nvpair_t *, int, char *, char **);
2N/Aextern int nvpair_value_match_regex(nvpair_t *, int, char *, regex_t *,
2N/A char **);
2N/A
2N/Aextern void nvlist_print(FILE *, nvlist_t *);
2N/Aextern void dump_nvlist(nvlist_t *, int);
2N/A
2N/A/*
2N/A * Private nvlist printing interface that allows the caller some control
2N/A * over output rendering (as opposed to nvlist_print and dump_nvlist).
2N/A *
2N/A * Obtain an opaque nvlist_prtctl_t cookie using nvlist_prtctl_alloc
2N/A * (NULL on failure); on return the cookie is set up for default formatting
2N/A * and rendering. Quote the cookie in subsequent customisation functions and
2N/A * then pass the cookie to nvlist_prt to render the nvlist. Finally,
2N/A * use nvlist_prtctl_free to release the cookie.
2N/A *
2N/A * For all nvlist_lookup_xxx and nvlist_lookup_xxx_array functions
2N/A * we have a corresponding brace of functions that appoint replacement
2N/A * rendering functions:
2N/A *
2N/A * extern void nvlist_prtctl_xxx(nvlist_prtctl_t,
2N/A * void (*)(nvlist_prtctl_t ctl, void *private, const char *name,
2N/A * xxxtype value))
2N/A *
2N/A * and
2N/A *
2N/A * extern void nvlist_prtctl_xxx_array(nvlist_prtctl_t,
2N/A * void (*)(nvlist_prtctl_t ctl, void *private, const char *name,
2N/A * xxxtype value, uint_t count))
2N/A *
2N/A * where xxxtype is the C datatype corresponding to xxx, eg int8_t for "int8"
2N/A * and char * for "string". The function that is appointed to render the
2N/A * specified datatype receives as arguments the cookie, the nvlist
2N/A * member name, the value of that member (or a pointer for array function),
2N/A * and (for array rendering functions) a count of the number of elements.
2N/A */
2N/A
2N/Atypedef struct nvlist_prtctl *nvlist_prtctl_t; /* opaque */
2N/A
2N/Aenum nvlist_indent_mode {
2N/A NVLIST_INDENT_ABS, /* Absolute indentation */
2N/A NVLIST_INDENT_TABBED /* Indent with tabstops */
2N/A};
2N/A
2N/Aextern nvlist_prtctl_t nvlist_prtctl_alloc(void);
2N/Aextern void nvlist_prtctl_free(nvlist_prtctl_t);
2N/Aextern void nvlist_prt(nvlist_t *, nvlist_prtctl_t);
2N/A
2N/A/* Output stream */
2N/Aextern void nvlist_prtctl_setdest(nvlist_prtctl_t, FILE *);
2N/Aextern FILE *nvlist_prtctl_getdest(nvlist_prtctl_t);
2N/A
2N/A/* Indentation mode, start indent, indent increment; default tabbed/0/1 */
2N/Aextern void nvlist_prtctl_setindent(nvlist_prtctl_t, enum nvlist_indent_mode,
2N/A int, int);
2N/Aextern void nvlist_prtctl_doindent(nvlist_prtctl_t, int);
2N/A
2N/Aenum nvlist_prtctl_fmt {
2N/A NVLIST_FMT_MEMBER_NAME, /* name fmt; default "%s = " */
2N/A NVLIST_FMT_MEMBER_POSTAMBLE, /* after nvlist member; default "\n" */
2N/A NVLIST_FMT_BTWN_ARRAY /* between array members; default " " */
2N/A};
2N/A
2N/Aextern void nvlist_prtctl_setfmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt,
2N/A const char *);
2N/Aextern void nvlist_prtctl_dofmt(nvlist_prtctl_t, enum nvlist_prtctl_fmt, ...);
2N/A
2N/A/*
2N/A * Function prototypes for interfaces that appoint a new rendering function
2N/A * for single-valued nvlist members.
2N/A *
2N/A * A replacement function receives arguments as follows:
2N/A *
2N/A * nvlist_prtctl_t Print control structure; do not change preferences
2N/A * for this object from a print callback function.
2N/A *
2N/A * void * The function-private cookie argument registered
2N/A * when the replacement function was appointed.
2N/A *
2N/A * nvlist_t * The full nvlist that is being processed. The
2N/A * rendering function is called to render a single
2N/A * member (name and value passed as below) but it may
2N/A * want to reference or incorporate other aspects of
2N/A * the full nvlist.
2N/A *
2N/A * const char * Member name to render
2N/A *
2N/A * valtype Value of the member to render
2N/A *
2N/A * The function must return non-zero if it has rendered output for this
2N/A * member, or 0 if it wants to default to standard rendering for this
2N/A * one member.
2N/A */
2N/A
2N/A#define NVLIST_PRINTCTL_SVDECL(funcname, valtype) \
2N/A extern void funcname(nvlist_prtctl_t, \
2N/A int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, valtype), \
2N/A void *)
2N/A
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean, int);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_boolean_value, boolean_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_byte, uchar_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int8, int8_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint8, uint8_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int16, int16_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint16, uint16_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int32, int32_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint32, uint32_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_int64, int64_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_uint64, uint64_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_double, double);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_string, char *);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_hrtime, hrtime_t);
2N/ANVLIST_PRINTCTL_SVDECL(nvlist_prtctlop_nvlist, nvlist_t *);
2N/A
2N/A#undef NVLIST_PRINTCTL_SVDECL /* was just for "clarity" above */
2N/A
2N/A/*
2N/A * Function prototypes for interfaces that appoint a new rendering function
2N/A * for array-valued nvlist members.
2N/A *
2N/A * One additional argument is taken: uint_t for the number of array elements
2N/A *
2N/A * Return values as above.
2N/A */
2N/A#define NVLIST_PRINTCTL_AVDECL(funcname, vtype) \
2N/A extern void funcname(nvlist_prtctl_t, \
2N/A int (*)(nvlist_prtctl_t, void *, nvlist_t *, const char *, vtype, uint_t), \
2N/A void *)
2N/A
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_boolean_array, boolean_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_byte_array, uchar_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int8_array, int8_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint8_array, uint8_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int16_array, int16_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint16_array, uint16_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int32_array, int32_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint32_array, uint32_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_int64_array, int64_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_uint64_array, uint64_t *);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_string_array, char **);
2N/ANVLIST_PRINTCTL_AVDECL(nvlist_prtctlop_nvlist_array, nvlist_t **);
2N/A
2N/A#undef NVLIST_PRINTCTL_AVDECL /* was just for "clarity" above */
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBNVPAIR_H */