8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libdscfg / common / cfg.h
blob84e64b8ebee32844e8dd6378ea82bfe824674002
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _CFG_H
27 #define _CFG_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #include <sys/nsctl/nsctl.h>
35 #define CFG_MAX_BUF 1024 /* maximum buffer size for cfg_get_?string() */
36 #define CFG_MAX_KEY 256 /* maximum key size for cfg_get_?string() */
38 #ifndef _CFG_IMPL_H
40 * These are really declared in cfg_impl.h, declare as dummy's here to
41 * allow clients to compile without including cfg_impl.h.
43 typedef struct cfgfile CFGFILE;
44 typedef struct cfp cfp_t;
46 #endif /* _CFG_IMPL_H */
48 int cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
49 int cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
50 int cfg_find_cstring(CFGFILE *cfg, const char *target, const char *section,
51 int numflds, ...);
52 int cfg_get_options(CFGFILE *cfg, int section, const char *basekey,
53 char *tag, int tag_len, char *val, int val_len);
54 int cfg_put_options(CFGFILE *cfg, int section, const char *basekey,
55 char *tag, char *val);
56 int cfg_get_single_option(CFGFILE *, int, const char *, char *, char *, int);
57 int cfg_del_option(CFGFILE *, int, const char *, char *);
59 int cfg_get_num_entries(CFGFILE *cfg, char *section);
61 int cfg_get_tags(CFGFILE *cfg, char ***taglist);
63 int cfg_cfg_isempty(CFGFILE *cfg);
64 int cfg_get_section(CFGFILE *cfg, char ***buf, const char *section);
65 CFGFILE *cfg_open(char *filename);
66 void cfg_rewind(CFGFILE *cfg, int section);
67 int cfg_is_cfg(CFGFILE *cfg);
68 int cfg_shldskip_vtoc(int fd, const char *loc);
69 int cfg_get_srtdsec(CFGFILE *cfg, char ***list,
70 const char *sec, const char *field);
71 void cfg_free_section(char ***, int);
75 * Handle cluster configuration
77 #define FP_SUN_CLUSTER(x) \
78 (((x->cf_node) && (x->cf[1].cf_fd)) ? &x->cf[1] : &x->cf[0])
81 * rewind sections
83 #define CFG_SEC_CONF 0 /* configuration section */
84 #define CFG_SEC_PERS 1 /* persistent section */
85 #define CFG_SEC_ALL 2 /* rewind both sections */
87 int cfg_update_parser_config(CFGFILE *, const char *key, int section);
89 * parser sections
91 #define CFG_PARSE_CONF 0 /* config section key */
92 #define CFG_PARSE_PERS 1 /* persistent section key */
94 char *cfg_error(int *severity);
96 * error codes
98 #define CFG_ENONFATAL 0 /* non fatal error */
99 #define CFG_EFATAL 1 /* fatal error exit */
102 * some error strings
104 #define CFG_NOTLOCKED "Configuration not locked"
105 #define CFG_RDFAILED "Unable to read configuration"
106 #define CFG_EINVAL "Invalid Argument"
107 #define CFG_EGENERIC "Generic cfg failure"
110 char *cfg_location(char *location, int mode, char *altroot);
113 * location modes
115 #define CFG_LOC_SET_LOCAL 0
116 #define CFG_LOC_GET_LOCAL 1
117 #define CFG_LOC_SET_CLUSTER 2
118 #define CFG_LOC_GET_CLUSTER 3
121 * location strings
123 #define CFG_LOCAL_LOCATION "/etc/dscfg_local"
124 #define CFG_CLUSTER_LOCATION "/etc/dscfg_cluster"
126 void cfg_close(CFGFILE *);
129 * lock mode
131 typedef enum {
132 CFG_RDLOCK,
133 CFG_WRLOCK,
134 CFG_UPGRADE
135 } CFGLOCK;
137 int cfg_lock(CFGFILE *, CFGLOCK); /* lock the configuration */
138 void cfp_unlock(cfp_t *); /* unlock the configuration */
139 void cfg_unlock(CFGFILE *);
140 int cfg_get_lock(CFGFILE *, CFGLOCK *, pid_t *); /* get config lock */
142 int cfg_commit(CFGFILE *);
143 void cfg_resource(CFGFILE *, const char *); /* Set/clear cluster node */
144 char *cfg_get_resource(CFGFILE *); /* get current cluster node */
145 char *cfg_dgname(const char *, char *, size_t); /* parse dg from pathname */
146 char *cfg_l_dgname(const char *, char *, size_t); /* parse dg from pathname */
147 int cfg_dgname_islocal(char *, char **); /* find locality of dg */
148 int cfg_iscluster(void); /* running in a cluster? */
149 int cfg_issuncluster(void); /* running in a Sun Cluster? */
150 void cfg_invalidate_sizes(int);
153 * add/rem result codes
155 #define CFG_USER_ERR 1
156 #define CFG_USER_OK 2
157 #define CFG_USER_FIRST 3
158 #define CFG_USER_LAST 4
159 #define CFG_USER_GONE 5
160 #define CFG_USER_REPEAT 6
162 int cfg_add_user(CFGFILE *, char *, char *, char *); /* add volume user */
163 int cfg_rem_user(CFGFILE *, char *, char *, char *); /* remove vol user */
164 int cfg_vol_enable(CFGFILE *, char *, char *, char *); /* enable volume */
165 int cfg_vol_disable(CFGFILE *, char *, char *, char *); /* disable volume */
167 int cfg_load_dsvols(CFGFILE *); /* load dsvol: section */
168 void cfg_unload_dsvols(); /* unload dsvol: section */
169 int cfg_load_svols(CFGFILE *); /* load sv: section */
170 void cfg_unload_svols(); /* unload sv: section */
171 int cfg_load_shadows(CFGFILE *); /* load shadows & bitmaps from ii: */
172 void cfg_unload_shadows(); /* unload ii: */
174 int cfg_get_canonical_name(CFGFILE *, const char *, char **);
176 #ifdef __cplusplus
178 #endif
180 #endif /* _CFG_H */