nvpair.h revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa
/*
* 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
*/
/*
*/
#ifndef _SYS_NVPAIR_H
#define _SYS_NVPAIR_H
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
DATA_TYPE_UNKNOWN = 0,
#if !defined(_KERNEL)
#else
#endif
} data_type_t;
typedef struct nvpair {
/* name string */
/* aligned ptr array for string arrays */
/* aligned array of data for value */
} nvpair_t;
/* nvlist header */
typedef struct nvlist {
} nvlist_t;
/* nvp implementation version */
#define NV_VERSION 0
/* nvlist pack encoding */
#define NV_ENCODE_NATIVE 0
#define NV_ENCODE_XDR 1
/* nvlist persistent unique name flags, stored in nvl_nvflags */
#define NV_UNIQUE_NAME 0x1
#define NV_UNIQUE_NAME_TYPE 0x2
/* nvlist lookup pairs related flags */
#define NV_FLAG_NOENTOK 0x1
/* convenience macros */
+ (nvp)->nvp_name_sz))
/* NV allocator framework */
typedef struct nv_alloc_ops nv_alloc_ops_t;
typedef struct nv_alloc {
const nv_alloc_ops_t *nva_ops;
void *nva_arg;
} nv_alloc_t;
struct nv_alloc_ops {
void (*nv_ao_fini)(nv_alloc_t *);
void (*nv_ao_reset)(nv_alloc_t *);
};
extern const nv_alloc_ops_t *nv_fixed_ops;
extern nv_alloc_t *nv_alloc_nosleep;
extern nv_alloc_t *nv_alloc_sleep;
#endif
void nv_alloc_reset(nv_alloc_t *);
void nv_alloc_fini(nv_alloc_t *);
/* list management */
void nvlist_free(nvlist_t *);
int nvlist_add_boolean(nvlist_t *, const char *);
int nvlist_add_string(nvlist_t *, const char *, const char *);
#if !defined(_KERNEL)
int nvlist_add_double(nvlist_t *, const char *, double);
#endif
int nvlist_remove_all(nvlist_t *, const char *);
int nvlist_lookup_boolean(nvlist_t *, const char *);
int nvlist_lookup_string(nvlist_t *, const char *, char **);
int nvlist_lookup_boolean_array(nvlist_t *, const char *,
int nvlist_lookup_nvlist_array(nvlist_t *, const char *,
int nvlist_lookup_pairs(nvlist_t *, int, ...);
#if !defined(_KERNEL)
int nvlist_lookup_double(nvlist_t *, const char *, double *);
#endif
int *, char **);
/* processing nvpair */
char *nvpair_name(nvpair_t *);
int nvpair_type_is_array(nvpair_t *);
int nvpair_value_string(nvpair_t *, char **);
#if !defined(_KERNEL)
int nvpair_value_double(nvpair_t *, double *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NVPAIR_H */