/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <unistd.h>
#include <strings.h>
#include <libintl.h>
#include <sys/inttypes.h>
#include <stdarg.h>
#include <note.h>
#include "libnvpair.h"
/*
* libnvpair - A tools library for manipulating <name, value> pairs.
*
* This library provides routines packing an unpacking nv pairs
* for transporting data across process boundaries, transporting
* between kernel and userland, and possibly saving onto disk files.
*/
/*
* Print control structure.
*/
struct { \
const char *, vtype); \
void *arg; \
} opname
struct { \
void *arg; \
} opname
struct nvlist_printops {
DEFINEOP(print_boolean, int);
DEFINEOP(print_double, double);
DEFINEOP(print_string, char *);
DEFINEARROP(print_string_array, char **);
};
struct nvlist_prtctl {
};
{ \
int done = 0; \
} \
if (!done) { \
} \
}
{ \
int done = 0; \
} \
if (!done) { \
} \
}
/*
* ======================================================================
* | |
* | Indentation |
* | |
* ======================================================================
*/
static void
{
int depth;
switch (pctl->nvprt_indent_mode) {
case NVLIST_INDENT_ABS:
break;
case NVLIST_INDENT_TABBED:
while (depth-- > 0)
}
}
/*
* ======================================================================
* | |
* | Default nvlist member rendering functions. |
* | |
* ======================================================================
*/
/*
* Generate functions to print single-valued nvlist members.
*
* type_and_variant - suffix to form function name
* vtype - C type for the member value
* ptype - C type to cast value to for printing
* vfmt - format string for pair value, e.g "%d" or "0x%llx"
*/
static int \
{ \
return (1); \
}
NVLIST_PRTFUNC(double, double, double, "0x%llf")
/*
* Generate functions to print array-valued nvlist members.
*/
static int \
{ \
uint_t i; \
for (i = 0; i < count; i++) { \
if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
if (pctl->nvprt_btwnarrfmt_nl) \
} \
if (i != 0) \
} \
return (1); \
}
/*ARGSUSED*/
static int
{
return (1);
}
/*ARGSUSED*/
static int
{
uint_t i;
for (i = 0; i < count; i++) {
}
return (1);
}
/*
* ======================================================================
* | |
* | Interfaces that allow control over formatting. |
* | |
* ======================================================================
*/
void
{
}
FILE *
{
}
void
{
if (start < 0)
start = 0;
if (inc < 0)
inc = 1;
}
void
{
}
void
const char *fmt)
{
switch (which) {
case NVLIST_FMT_MEMBER_NAME:
fmt = "%s = ";
break;
fmt = "\n";
break;
case NVLIST_FMT_BTWN_ARRAY:
pctl->nvprt_btwnarrfmt_nl = 0;
} else {
}
break;
default:
break;
}
}
void
{
char *name;
switch (which) {
case NVLIST_FMT_MEMBER_NAME:
break;
break;
case NVLIST_FMT_BTWN_ARRAY:
break;
default:
break;
}
}
/*
* ======================================================================
* | |
* | Interfaces to allow appointment of replacement rendering functions.|
* | |
* ======================================================================
*/
void \
void *private) \
{ \
}
NVLIST_PRINTCTL_REPLACE(double, double)
NVLIST_PRINTCTL_REPLACE(string, char *)
void \
{ \
}
NVLIST_PRINTCTL_AREPLACE(string_array, char **)
/*
* ======================================================================
* | |
* | Interfaces to manage nvlist_prtctl_t cookies. |
* | |
* ======================================================================
*/
{ nvprint_boolean, NULL },
{ nvprint_boolean_value, NULL },
{ nvprint_byte, NULL },
{ nvprint_int8, NULL },
{ nvprint_uint8, NULL },
{ nvprint_int16, NULL },
{ nvprint_uint16, NULL },
{ nvprint_int32, NULL },
{ nvprint_uint32, NULL },
{ nvprint_int64, NULL },
{ nvprint_uint64, NULL },
{ nvprint_double, NULL },
{ nvprint_string, NULL },
{ nvprint_hrtime, NULL },
{ nvprint_nvlist, NULL },
{ nvaprint_boolean_array, NULL },
{ nvaprint_byte_array, NULL },
{ nvaprint_int8_array, NULL },
{ nvaprint_uint8_array, NULL },
{ nvaprint_int16_array, NULL },
{ nvaprint_uint16_array, NULL },
{ nvaprint_int32_array, NULL },
{ nvaprint_uint32_array, NULL },
{ nvaprint_int64_array, NULL },
{ nvaprint_uint64_array, NULL },
{ nvaprint_string_array, NULL },
{ nvaprint_nvlist_array, NULL },
};
static void
struct nvlist_printops *ops)
{
pctl->nvprt_indent = 0;
pctl->nvprt_btwnarrfmt_nl = 0;
}
nvlist_prtctl_alloc(void)
{
return (NULL);
return (NULL);
}
return (pctl);
}
void
{
}
}
/*
* ======================================================================
* | |
* | Top-level print request interfaces. |
* | |
* ======================================================================
*/
/*
* nvlist_print - Prints elements in an event buffer
*/
static void
{
char *name;
return;
while (nvp) {
nelem = 0;
switch (type) {
case DATA_TYPE_BOOLEAN: {
break;
}
case DATA_TYPE_BOOLEAN_VALUE: {
break;
}
case DATA_TYPE_BYTE: {
break;
}
case DATA_TYPE_INT8: {
break;
}
case DATA_TYPE_UINT8: {
break;
}
case DATA_TYPE_INT16: {
break;
}
case DATA_TYPE_UINT16: {
break;
}
case DATA_TYPE_INT32: {
break;
}
case DATA_TYPE_UINT32: {
break;
}
case DATA_TYPE_INT64: {
break;
}
case DATA_TYPE_UINT64: {
break;
}
case DATA_TYPE_DOUBLE: {
double val;
break;
}
case DATA_TYPE_STRING: {
char *val;
break;
}
case DATA_TYPE_BOOLEAN_ARRAY: {
break;
}
case DATA_TYPE_BYTE_ARRAY: {
break;
}
case DATA_TYPE_INT8_ARRAY: {
break;
}
case DATA_TYPE_UINT8_ARRAY: {
break;
}
case DATA_TYPE_INT16_ARRAY: {
break;
}
case DATA_TYPE_UINT16_ARRAY: {
break;
}
case DATA_TYPE_INT32_ARRAY: {
break;
}
case DATA_TYPE_UINT32_ARRAY: {
break;
}
case DATA_TYPE_INT64_ARRAY: {
break;
}
case DATA_TYPE_UINT64_ARRAY: {
break;
}
case DATA_TYPE_STRING_ARRAY: {
char **val;
break;
}
case DATA_TYPE_HRTIME: {
break;
}
case DATA_TYPE_NVLIST: {
break;
}
case DATA_TYPE_NVLIST_ARRAY: {
break;
}
default:
break;
}
}
}
void
{
}
void
{
}
\
}
\
for (i = 0; i < count; i++) { \
} \
}
/*
* Similar to nvlist_print() but handles arrays slightly differently.
*/
void
{
return;
}
switch (nvpair_type(elem)) {
case DATA_TYPE_BOOLEAN_VALUE:
break;
case DATA_TYPE_BYTE:
break;
case DATA_TYPE_INT8:
break;
case DATA_TYPE_UINT8:
break;
case DATA_TYPE_INT16:
break;
case DATA_TYPE_UINT16:
break;
case DATA_TYPE_INT32:
break;
case DATA_TYPE_UINT32:
break;
case DATA_TYPE_INT64:
break;
case DATA_TYPE_UINT64:
break;
case DATA_TYPE_STRING:
break;
case DATA_TYPE_BYTE_ARRAY:
break;
case DATA_TYPE_INT8_ARRAY:
break;
case DATA_TYPE_UINT8_ARRAY:
break;
case DATA_TYPE_INT16_ARRAY:
break;
case DATA_TYPE_UINT16_ARRAY:
break;
case DATA_TYPE_INT32_ARRAY:
break;
case DATA_TYPE_UINT32_ARRAY:
break;
case DATA_TYPE_INT64_ARRAY:
break;
case DATA_TYPE_UINT64_ARRAY:
"%llu");
break;
case DATA_TYPE_STRING_ARRAY:
break;
case DATA_TYPE_NVLIST:
nvpair_name(elem));
break;
case DATA_TYPE_NVLIST_ARRAY:
(void) nvpair_value_nvlist_array(elem,
&nvlist_array_value, &count);
for (i = 0; i < count; i++) {
nvpair_name(elem), i);
}
break;
default:
nvpair_name(elem));
}
}
}
/*
* ======================================================================
* | |
* | Misc private interface. |
* | |
* ======================================================================
*/
/*
* Determine if string 'value' matches 'nvp' value. The 'value' string is
* converted, depending on the type of 'nvp', prior to match. For numeric
* types, a radix independent sscanf conversion of 'value' is used. If 'nvp'
* is an array type, 'ai' is the index into the array against which we are
* checking for match. If nvp is of DATA_TYPE_STRING*, the caller can pass
* in a regex_t compilation of value in 'value_regex' to trigger regular
* expression string match instead of simple strcmp().
*
* Return 1 on match, 0 on no-match, and -1 on error. If the error is
* related to value syntax error and 'ep' is non-NULL, *ep will point into
* the 'value' string at the location where the error exists.
*
* NOTE: It may be possible to move the non-regex_t version of this into
*/
int
{
char *evalue;
int sr;
if (ep)
return (-1); /* error fail match - invalid args */
/* make sure array and index combination make sense */
return (-1); /* error fail match - bad index */
/* non-string values should be single 'chunk' */
if (*evalue) {
if (ep)
return (-1); /* error fail match - syntax */
}
}
switch (nvpair_type(nvp)) {
case DATA_TYPE_STRING: {
char *val;
/* check string value for match */
if (value_regex) {
return (1); /* match */
} else {
return (1); /* match */
}
}
break;
}
case DATA_TYPE_STRING_ARRAY: {
char **val_array;
/* check indexed string value of array for match */
if (value_regex) {
return (1);
} else {
return (1);
}
}
break;
}
case DATA_TYPE_BYTE: {
/* scanf uchar_t from value and check for match */
return (1);
break;
}
case DATA_TYPE_BYTE_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT8: {
/* scanf int8_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT8_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT8: {
/* scanf uint8_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT8_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT16: {
/* scanf int16_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT16_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT16: {
/* scanf uint16_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT16_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT32: {
/* scanf int32_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT32_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT32: {
/* scanf uint32_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT32_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT64: {
/* scanf int64_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_INT64_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT64: {
/* scanf uint64_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_UINT64_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_BOOLEAN_VALUE: {
/* scanf boolean_t from value and check for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_BOOLEAN_ARRAY: {
/* check indexed value of array for match */
if ((sr == 1) &&
return (1);
break;
}
case DATA_TYPE_HRTIME:
case DATA_TYPE_NVLIST:
case DATA_TYPE_NVLIST_ARRAY:
case DATA_TYPE_BOOLEAN:
case DATA_TYPE_DOUBLE:
case DATA_TYPE_UNKNOWN:
default:
/*
* unknown/unsupported data type
*/
return (-1); /* error fail match */
}
/*
* check to see if sscanf failed conversion, return approximate
* pointer to problem
*/
if (sr != 1) {
if (ep)
return (-1); /* error fail match - syntax */
}
return (0); /* fail match */
}
int
{
}