nvpair.h revision 1af98250c8b03bdc43d8ac3aac6390221d75b92e
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_NVPAIR_H
#define _SYS_NVPAIR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
DATA_TYPE_UNKNOWN = 0,
} 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 *);
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 *,
/* processing nvpair */
char *nvpair_name(nvpair_t *);
int nvpair_value_string(nvpair_t *, char **);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NVPAIR_H */