xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_conf.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FMD_CONF_H
29 #define	_FMD_CONF_H
30 
31 #include <sys/types.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 struct fmd_conf_param;
38 
39 typedef struct fmd_conf_ops {
40 	int (*co_set)(struct fmd_conf_param *, const char *);
41 	void (*co_get)(const struct fmd_conf_param *, void *);
42 	int (*co_del)(struct fmd_conf_param *, const char *);
43 	void (*co_free)(struct fmd_conf_param *);
44 } fmd_conf_ops_t;
45 
46 typedef struct fmd_conf_formal {
47 	const char *cf_name;
48 	const fmd_conf_ops_t *cf_ops;
49 	const char *cf_default;
50 } fmd_conf_formal_t;
51 
52 typedef struct fmd_conf_param {
53 	const fmd_conf_formal_t *cp_formal;
54 	struct fmd_conf_param *cp_next;
55 	union {
56 		uint64_t cpv_num;
57 		char *cpv_str;
58 		void *cpv_ptr;
59 	} cp_value;
60 } fmd_conf_param_t;
61 
62 typedef struct fmd_conf_defer {
63 	char *cd_name;
64 	char *cd_value;
65 	struct fmd_conf_defer *cd_next;
66 } fmd_conf_defer_t;
67 
68 typedef struct fmd_conf {
69 	pthread_rwlock_t cf_lock;
70 	const fmd_conf_formal_t *cf_argv;
71 	int cf_argc;
72 	uint_t cf_flag;
73 	fmd_conf_param_t *cf_params;
74 	fmd_conf_param_t **cf_parhash;
75 	uint_t cf_parhashlen;
76 	fmd_conf_defer_t *cf_defer;
77 } fmd_conf_t;
78 
79 typedef struct fmd_conf_verb {
80 	const char *cv_name;
81 	int (*cv_exec)(fmd_conf_t *, int, char *[]);
82 } fmd_conf_verb_t;
83 
84 typedef struct fmd_conf_path {
85 	const char **cpa_argv;
86 	int cpa_argc;
87 } fmd_conf_path_t;
88 
89 typedef struct fmd_conf_mode {
90 	const char *cm_name;
91 	const char *cm_desc;
92 	uint_t cm_bits;
93 } fmd_conf_mode_t;
94 
95 extern int fmd_conf_mode_set(const fmd_conf_mode_t *,
96     fmd_conf_param_t *, const char *);
97 extern void fmd_conf_mode_get(const fmd_conf_param_t *, void *);
98 
99 extern int fmd_conf_notsup(fmd_conf_param_t *, const char *);
100 extern void fmd_conf_nop(fmd_conf_param_t *);
101 
102 extern const fmd_conf_ops_t fmd_conf_bool;	/* int */
103 extern const fmd_conf_ops_t fmd_conf_int8;	/* int8_t */
104 extern const fmd_conf_ops_t fmd_conf_uint8;	/* uint8_t */
105 extern const fmd_conf_ops_t fmd_conf_int16;	/* int16_t */
106 extern const fmd_conf_ops_t fmd_conf_uint16;	/* uint16_t */
107 extern const fmd_conf_ops_t fmd_conf_int32;	/* int32_t */
108 extern const fmd_conf_ops_t fmd_conf_uint32;	/* uint32_t */
109 extern const fmd_conf_ops_t fmd_conf_int64;	/* int64_t */
110 extern const fmd_conf_ops_t fmd_conf_uint64;	/* uint64_t */
111 extern const fmd_conf_ops_t fmd_conf_string;	/* const char* */
112 extern const fmd_conf_ops_t fmd_conf_path;	/* fmd_conf_path_t* */
113 extern const fmd_conf_ops_t fmd_conf_list;	/* fmd_conf_path_t* */
114 extern const fmd_conf_ops_t fmd_conf_time;	/* hrtime_t */
115 extern const fmd_conf_ops_t fmd_conf_size;	/* uint64_t */
116 extern const fmd_conf_ops_t fmd_conf_signal;	/* int */
117 extern const fmd_conf_ops_t fmd_conf_parent;	/* any */
118 
119 extern const char FMD_PROP_SUBSCRIPTIONS[];	/* fmd_conf_list */
120 extern const char FMD_PROP_DICTIONARIES[];	/* fmd_conf_list */
121 
122 #define	FMD_CONF_DEFER	0x1			/* permit deferred settings */
123 
124 extern fmd_conf_t *fmd_conf_open(const char *,
125     int, const fmd_conf_formal_t *, uint_t);
126 extern void fmd_conf_merge(fmd_conf_t *, const char *);
127 extern void fmd_conf_propagate(fmd_conf_t *, fmd_conf_t *, const char *);
128 extern void fmd_conf_close(fmd_conf_t *);
129 
130 extern const char *fmd_conf_getnzstr(fmd_conf_t *, const char *);
131 extern const fmd_conf_ops_t *fmd_conf_gettype(fmd_conf_t *, const char *);
132 extern int fmd_conf_getprop(fmd_conf_t *, const char *, void *);
133 extern int fmd_conf_setprop(fmd_conf_t *, const char *, const char *);
134 extern int fmd_conf_delprop(fmd_conf_t *, const char *, const char *);
135 
136 #ifdef	__cplusplus
137 }
138 #endif
139 
140 #endif	/* _FMD_CONF_H */
141