libnvpair.c revision 602ca9ea8f9ce0933f0944601cc5d230e91a950d
/*
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <strings.h>
#include <sys/inttypes.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.
*/
static void
{
while (depth-- > 0)
}
/*
* nvlist_print - Prints elements in an event buffer
*/
static
void
{
int i;
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_STRING: {
char *val;
break;
}
case DATA_TYPE_BOOLEAN_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_BYTE_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_INT8_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT8_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_INT16_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT16_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_INT32_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT32_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_INT64_ARRAY: {
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT64_ARRAY: {
for (i = 0; i < nelem; i++)
(u_longlong_t)val[i]);
break;
}
case DATA_TYPE_STRING_ARRAY: {
char **val;
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_HRTIME: {
break;
}
case DATA_TYPE_NVLIST: {
break;
}
case DATA_TYPE_NVLIST_ARRAY: {
for (i = 0; i < nelem; i++) {
"(start %s[%d])\n", name, i);
}
break;
}
default:
break;
}
}
}
void
{
}
/*
* 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_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
{
}