xref: /titanic_41/usr/src/cmd/fm/fmd/common/fmd_conf.h (revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/types.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 struct fmd_conf_param;
40 
41 typedef struct fmd_conf_ops {
42 	int (*co_set)(struct fmd_conf_param *, const char *);
43 	void (*co_get)(const struct fmd_conf_param *, void *);
44 	int (*co_del)(struct fmd_conf_param *, const char *);
45 	void (*co_free)(struct fmd_conf_param *);
46 } fmd_conf_ops_t;
47 
48 typedef struct fmd_conf_formal {
49 	const char *cf_name;
50 	const fmd_conf_ops_t *cf_ops;
51 	const char *cf_default;
52 } fmd_conf_formal_t;
53 
54 typedef struct fmd_conf_param {
55 	const fmd_conf_formal_t *cp_formal;
56 	struct fmd_conf_param *cp_next;
57 	union {
58 		uint64_t cpv_num;
59 		char *cpv_str;
60 		void *cpv_ptr;
61 	} cp_value;
62 } fmd_conf_param_t;
63 
64 typedef struct fmd_conf_defer {
65 	char *cd_name;
66 	char *cd_value;
67 	struct fmd_conf_defer *cd_next;
68 } fmd_conf_defer_t;
69 
70 typedef struct fmd_conf {
71 	pthread_rwlock_t cf_lock;
72 	const fmd_conf_formal_t *cf_argv;
73 	int cf_argc;
74 	uint_t cf_flag;
75 	fmd_conf_param_t *cf_params;
76 	fmd_conf_param_t **cf_parhash;
77 	uint_t cf_parhashlen;
78 	fmd_conf_defer_t *cf_defer;
79 } fmd_conf_t;
80 
81 typedef struct fmd_conf_verb {
82 	const char *cv_name;
83 	int (*cv_exec)(fmd_conf_t *, int, char *[]);
84 } fmd_conf_verb_t;
85 
86 typedef struct fmd_conf_path {
87 	const char **cpa_argv;
88 	int cpa_argc;
89 } fmd_conf_path_t;
90 
91 typedef struct fmd_conf_mode {
92 	const char *cm_name;
93 	const char *cm_desc;
94 	uint_t cm_bits;
95 } fmd_conf_mode_t;
96 
97 extern int fmd_conf_mode_set(const fmd_conf_mode_t *,
98     fmd_conf_param_t *, const char *);
99 extern void fmd_conf_mode_get(const fmd_conf_param_t *, void *);
100 
101 extern int fmd_conf_notsup(fmd_conf_param_t *, const char *);
102 extern void fmd_conf_nop(fmd_conf_param_t *);
103 
104 extern const fmd_conf_ops_t fmd_conf_bool;	/* int */
105 extern const fmd_conf_ops_t fmd_conf_int8;	/* int8_t */
106 extern const fmd_conf_ops_t fmd_conf_uint8;	/* uint8_t */
107 extern const fmd_conf_ops_t fmd_conf_int16;	/* int16_t */
108 extern const fmd_conf_ops_t fmd_conf_uint16;	/* uint16_t */
109 extern const fmd_conf_ops_t fmd_conf_int32;	/* int32_t */
110 extern const fmd_conf_ops_t fmd_conf_uint32;	/* uint32_t */
111 extern const fmd_conf_ops_t fmd_conf_int64;	/* int64_t */
112 extern const fmd_conf_ops_t fmd_conf_uint64;	/* uint64_t */
113 extern const fmd_conf_ops_t fmd_conf_string;	/* const char* */
114 extern const fmd_conf_ops_t fmd_conf_path;	/* fmd_conf_path_t* */
115 extern const fmd_conf_ops_t fmd_conf_list;	/* fmd_conf_path_t* */
116 extern const fmd_conf_ops_t fmd_conf_time;	/* hrtime_t */
117 extern const fmd_conf_ops_t fmd_conf_size;	/* uint64_t */
118 extern const fmd_conf_ops_t fmd_conf_signal;	/* int */
119 extern const fmd_conf_ops_t fmd_conf_parent;	/* any */
120 
121 extern const char FMD_PROP_SUBSCRIPTIONS[];	/* fmd_conf_list */
122 extern const char FMD_PROP_DICTIONARIES[];	/* fmd_conf_list */
123 
124 #define	FMD_CONF_DEFER	0x1			/* permit deferred settings */
125 
126 extern fmd_conf_t *fmd_conf_open(const char *,
127     int, const fmd_conf_formal_t *, uint_t);
128 extern void fmd_conf_merge(fmd_conf_t *, const char *);
129 extern void fmd_conf_propagate(fmd_conf_t *, fmd_conf_t *, const char *);
130 extern void fmd_conf_close(fmd_conf_t *);
131 
132 extern const char *fmd_conf_getnzstr(fmd_conf_t *, const char *);
133 extern const fmd_conf_ops_t *fmd_conf_gettype(fmd_conf_t *, const char *);
134 extern int fmd_conf_getprop(fmd_conf_t *, const char *, void *);
135 extern int fmd_conf_setprop(fmd_conf_t *, const char *, const char *);
136 extern int fmd_conf_delprop(fmd_conf_t *, const char *, const char *);
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif	/* _FMD_CONF_H */
143