xref: /illumos-gate/usr/src/cmd/fm/fmd/common/fmd_conf.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_FMD_CONF_H
28 #define	_FMD_CONF_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 struct fmd_conf_param;
39 
40 typedef struct fmd_conf_ops {
41 	int (*co_set)(struct fmd_conf_param *, const char *);
42 	void (*co_get)(const struct fmd_conf_param *, void *);
43 	int (*co_del)(struct fmd_conf_param *, const char *);
44 	void (*co_free)(struct fmd_conf_param *);
45 } fmd_conf_ops_t;
46 
47 typedef struct fmd_conf_formal {
48 	const char *cf_name;
49 	const fmd_conf_ops_t *cf_ops;
50 	const char *cf_default;
51 } fmd_conf_formal_t;
52 
53 typedef struct fmd_conf_param {
54 	const fmd_conf_formal_t *cp_formal;
55 	struct fmd_conf_param *cp_next;
56 	union {
57 		uint64_t cpv_num;
58 		char *cpv_str;
59 		void *cpv_ptr;
60 	} cp_value;
61 } fmd_conf_param_t;
62 
63 typedef struct fmd_conf {
64 	pthread_rwlock_t cf_lock;
65 	const fmd_conf_formal_t *cf_argv;
66 	int cf_argc;
67 	fmd_conf_param_t *cf_params;
68 	fmd_conf_param_t **cf_parhash;
69 	uint_t cf_parhashlen;
70 } fmd_conf_t;
71 
72 typedef struct fmd_conf_verb {
73 	const char *cv_name;
74 	int (*cv_exec)(fmd_conf_t *, int, char *[]);
75 } fmd_conf_verb_t;
76 
77 typedef struct fmd_conf_path {
78 	const char **cpa_argv;
79 	int cpa_argc;
80 } fmd_conf_path_t;
81 
82 typedef struct fmd_conf_mode {
83 	const char *cm_name;
84 	const char *cm_desc;
85 	uint_t cm_bits;
86 } fmd_conf_mode_t;
87 
88 extern int fmd_conf_mode_set(const fmd_conf_mode_t *,
89     fmd_conf_param_t *, const char *);
90 extern void fmd_conf_mode_get(const fmd_conf_param_t *, void *);
91 
92 extern int fmd_conf_notsup(fmd_conf_param_t *, const char *);
93 extern void fmd_conf_nop(fmd_conf_param_t *);
94 
95 extern const fmd_conf_ops_t fmd_conf_bool;	/* int */
96 extern const fmd_conf_ops_t fmd_conf_int32;	/* int32_t */
97 extern const fmd_conf_ops_t fmd_conf_uint32;	/* uint32_t */
98 extern const fmd_conf_ops_t fmd_conf_int64;	/* int64_t */
99 extern const fmd_conf_ops_t fmd_conf_uint64;	/* uint64_t */
100 extern const fmd_conf_ops_t fmd_conf_string;	/* const char* */
101 extern const fmd_conf_ops_t fmd_conf_path;	/* fmd_conf_path_t* */
102 extern const fmd_conf_ops_t fmd_conf_list;	/* fmd_conf_path_t* */
103 extern const fmd_conf_ops_t fmd_conf_time;	/* hrtime_t */
104 extern const fmd_conf_ops_t fmd_conf_size;	/* uint64_t */
105 extern const fmd_conf_ops_t fmd_conf_signal;	/* int */
106 extern const fmd_conf_ops_t fmd_conf_parent;	/* any */
107 
108 extern const char FMD_PROP_SUBSCRIPTIONS[];	/* fmd_conf_list */
109 extern const char FMD_PROP_DICTIONARIES[];	/* fmd_conf_list */
110 
111 extern fmd_conf_t *fmd_conf_open(const char *, int, const fmd_conf_formal_t *);
112 extern void fmd_conf_merge(fmd_conf_t *, const char *);
113 extern void fmd_conf_close(fmd_conf_t *);
114 
115 extern const fmd_conf_ops_t *fmd_conf_gettype(fmd_conf_t *, const char *);
116 extern int fmd_conf_getprop(fmd_conf_t *, const char *, void *);
117 extern int fmd_conf_setprop(fmd_conf_t *, const char *, const char *);
118 extern int fmd_conf_delprop(fmd_conf_t *, const char *, const char *);
119 
120 #ifdef	__cplusplus
121 }
122 #endif
123 
124 #endif	/* _FMD_CONF_H */
125