/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <pool.h>
#include "pool_internal.h"
/*
* libpool Value Manipulation Routines
*
* pool_value.c implements the value (pool_value_t) functionality for
* libpool. The datatypes supported are: uint64_t, int64_t, double,
* uchar_t (boolean), const char * (string). Values are used to
* represent data stored to and retrieved from the datastore in a
* simple discriminated union.
*
* Values are dynamically allocated using pool_value_alloc() and
* destroyed using pool_value_free().
*
* Values may be allocated statically for internal use in
* libpool. Statically allocated pool_value_t variables must be
* initialised with the POOL_VALUE_INITIALIZER macro, otherwise the
* results are unpredictable.
*
* A pool_value_t variable can be used to store values in any of the
* supported datatypes.
*
* A pool_value_t's name and string value are limited in size to
* PV_NAME_MAX_LEN and PV_VALUE_MAX_LEN respectively. Attempting to
* store values which are greater than this in length will fail with a
* POE_BADPARAM error.
*/
/*
* Get the uint64_t data held by the value. If the data type isn't
* uint64_t return PO_FAIL and set pool_error to be POE_BAD_PROP_TYPE.
*/
int
{
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Get the int64_t data held by the value. If the data type isn't
* int64_t return PO_FAIL and set pool_error to be POE_BAD_PROP_TYPE.
*/
int
{
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Get the double data held by the value. If the data type isn't
* double return PO_FAIL and set pool_error to be POE_BAD_PROP_TYPE.
*/
int
{
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Get the boolean data held by the value. If the data type isn't
* boolean return PO_FAIL and set pool_error to be POE_BAD_PROP_TYPE.
*/
int
{
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Get the string data held by the value. If the data type isn't
* string return PO_FAIL and set pool_error to be POE_BAD_PROP_TYPE.
*/
int
{
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Get the type of the data held by the value. If the value has never
* been used to store data, then the type is POC_INVAL.
*/
{
}
/*
* Set the value's data to the supplied uint64_t data. Update the type
* of the value data to POC_UINT.
*/
void
{
}
/*
* Set the value's data to the supplied int64_t data. Update the type
* of the value data to POC_INT.
*/
void
{
}
/*
* Set the value's data to the supplied double data. Update the type
* of the value data to POC_DOUBLE.
*/
void
{
}
/*
* Set the value's data to the supplied uchar_t data. Update the type
* of the value data to POC_BOOL.
*/
void
{
}
/*
* Try to make an internal copy of the val, returning PO_SUCCESS or
* PO_FAIL if the copy works or fails.
*/
int
{
return (PO_FAIL);
} else {
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Allocate a pool_value_t structure and initialise it to 0. Set the
* type to POC_INVAL and return a pointer to the new pool_value_t. If
* memory allocation fails, set POE_SYSTEM and return NULL.
*/
pool_value_alloc(void)
{
return (NULL);
}
return (val);
}
/*
* Free any atoms associated with the value and then free the value
* itself.
*/
void
{
}
/*
* Return a pointer to the name of the value. This may be NULL if the
* name has never been set.
*/
const char *
{
}
/*
* Set the name of the value to the supplied name.
*/
int
{
return (PO_FAIL);
} else {
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Use the supplied nvpair_t to set the name, type and value of the
* supplied pool_value_t.
*
* Return: PO_SUCCESS/PO_FAIL
*/
int
{
double dval;
char *sval;
return (PO_FAIL);
switch (nvpair_type(pn)) {
case DATA_TYPE_BYTE:
return (PO_FAIL);
}
break;
case DATA_TYPE_BYTE_ARRAY:
return (PO_FAIL);
}
break;
case DATA_TYPE_INT64:
return (PO_FAIL);
}
break;
case DATA_TYPE_UINT64:
return (PO_FAIL);
}
break;
case DATA_TYPE_STRING:
return (PO_FAIL);
}
return (PO_FAIL);
break;
default:
return (PO_FAIL);
}
return (PO_SUCCESS);
}
/*
* Check to see if the values held by two supplied values are
* equal. First compare the pointers to see if we are comparing to
* ourselves, if we are return PO_TRUE. If not, get the types and
* ensure they match, if they don't return PO_FALSE. Then do a type
* specific comparison returning PO_TRUE or PO_FALSE accordingly.
*/
int
{
return (PO_TRUE);
return (PO_FALSE);
switch (type) {
case POC_UINT:
return (PO_TRUE);
break;
case POC_INT:
return (PO_TRUE);
break;
case POC_DOUBLE:
return (PO_TRUE);
break;
case POC_BOOL:
return (PO_TRUE);
break;
case POC_STRING:
return (PO_TRUE);
break;
}
return (PO_FALSE);
}
#ifdef DEBUG
/*
* Trace pool_value_t details using dprintf
*/
void
{
const char *class_name[] = {
"POC_UINT",
"POC_INT",
"POC_DOUBLE",
"POC_BOOL",
"POC_STRING"
};
else
dprintf("type: POC_INVAL\n");
case POC_UINT:
break;
case POC_INT:
break;
case POC_DOUBLE:
break;
case POC_BOOL:
break;
case POC_STRING:
break;
default:
dprintf("value: invalid\n");
break;
}
}
#endif /* DEBUG */