shadow_copy2: add snapshot_basepath to the config.
[Samba.git] / lib / param / param.h
blob7e73dd0f23403d67fd240acd085b3116b442a075
1 /*
2 Unix SMB/CIFS implementation.
3 Generic parameter parsing interface
4 Copyright (C) Jelmer Vernooij 2005
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _PARAM_H /* _PARAM_H */
21 #define _PARAM_H
23 struct loadparm_s3_helpers;
25 struct parmlist_entry;
27 struct param_context {
28 struct param_section *sections;
31 struct param_section {
32 const char *name;
33 struct param_section *prev, *next;
34 struct parmlist *parameters;
37 struct param_context;
38 struct smbsrv_connection;
40 #define Auto (2)
42 #include "libds/common/roles.h"
44 struct loadparm_context;
45 struct loadparm_service;
46 struct smbcli_options;
47 struct smbcli_session_options;
48 struct gensec_settings;
50 #ifdef CONFIG_H_IS_FROM_SAMBA
51 #include "lib/param/param_proto.h"
52 #endif
54 const char **lpcfg_interfaces(struct loadparm_context *);
55 const char *lpcfg_realm(struct loadparm_context *);
56 const char *lpcfg_netbios_name(struct loadparm_context *);
57 const char *lpcfg_private_dir(struct loadparm_context *);
58 int lpcfg_server_role(struct loadparm_context *);
59 int lpcfg_allow_dns_updates(struct loadparm_context *);
61 void reload_charcnv(struct loadparm_context *lp_ctx);
63 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
66 char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
67 char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
68 char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
69 char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
70 char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
72 const char *lpcfg_servicename(const struct loadparm_service *service);
75 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
76 struct loadparm_service *service,
77 const char *type, const char *option);
79 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
80 struct loadparm_service *service, const char *type,
81 const char *option);
82 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
83 struct loadparm_context *lp_ctx,
84 struct loadparm_service *service,
85 const char *type,
86 const char *option, const char *separator);
87 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
88 struct loadparm_service *service, const char *type,
89 const char *option, int default_v);
90 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
91 struct loadparm_service *service, const char *type,
92 const char *option, int default_v);
93 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
94 struct loadparm_service *service, const char *type,
95 const char *option, unsigned long default_v);
96 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
97 struct loadparm_service *service, const char *type,
98 const char *option, long default_v);
99 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
100 struct loadparm_service *service, const char *type,
101 const char *option, double default_v);
102 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
103 struct loadparm_service *service, const char *type,
104 const char *option, bool default_v);
105 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
106 const struct loadparm_service *pservice,
107 const char *name);
108 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
109 const char *pszHomename,
110 struct loadparm_service *default_service,
111 const char *user, const char *pszHomedir);
112 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
113 const char *pszPrintername,
114 struct loadparm_service *default_service);
115 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name);
116 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
117 struct loadparm_service *service, struct parm_struct *parm);
118 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name);
119 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
121 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
122 const char *pszParmName, const char *pszParmValue);
123 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
124 struct loadparm_service *service,
125 const char *pszParmName, const char *pszParmValue);
128 * Process a parameter.
130 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
131 const char *pszParmName, const char *fmt, ...);
132 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
133 const char *pszParmValue);
134 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
137 * Display the contents of a single services record.
139 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
140 struct loadparm_service *service,
141 const char *parm_name, FILE * f);
144 * Return info about the next service in a service. snum==-1 gives the globals.
145 * Return NULL when out of parameters.
147 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
148 int allparameters);
151 * Unload unused services.
153 void lpcfg_killunused(struct loadparm_context *lp_ctx,
154 struct smbsrv_connection *smb,
155 bool (*snumused) (struct smbsrv_connection *, int));
158 * Initialise the global parameter structure.
160 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
161 struct loadparm_context *loadparm_init_global(bool load_default);
162 const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
163 bool lpcfg_load_default(struct loadparm_context *lp_ctx);
164 const char *lp_default_path(void);
167 * Load the services array from the services file.
169 * Return True on success, False on failure.
171 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
174 * Return the max number of services.
176 int lpcfg_numservices(struct loadparm_context *lp_ctx);
179 * Display the contents of the services array in human-readable form.
181 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
182 int maxtoprint);
185 * Display the contents of one service in human-readable form.
187 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
188 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
189 int snum);
190 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
191 const char *service_name);
194 * A useful volume label function.
196 const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
199 * If we are PDC then prefer us as DMB
201 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
204 * Return the max print jobs per queue.
206 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
207 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
208 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
209 struct smbcli_options *options);
210 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
211 struct smbcli_session_options *options);
212 const char **lpcfg_smb_ports(struct loadparm_context *);
213 const char *lpcfg_socket_options(struct loadparm_context *);
214 struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
215 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
218 /* The following definitions come from param/generic.c */
220 struct param_section *param_get_section(struct param_context *ctx, const char *name);
221 struct parmlist_entry *param_section_get(struct param_section *section,
222 const char *name);
223 struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
224 struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
225 struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
226 const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
227 int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
228 const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
229 int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
230 int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
231 void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
232 unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
233 void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
234 struct param_context *param_init(TALLOC_CTX *mem_ctx);
235 int param_read(struct param_context *ctx, const char *fn);
236 int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
237 int param_write(struct param_context *ctx, const char *fn);
239 /* The following definitions come from param/util.c */
243 * @file
244 * @brief Misc utility functions
246 bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
247 const char *domain);
249 bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
250 const char *domain);
253 see if a string matches either our primary or one of our secondary
254 netbios aliases. do a case insensitive match
256 bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
259 A useful function for returning a path in the Samba lock directory.
261 char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
262 const char *name);
265 * @brief Returns an absolute path to a file in the directory containing the current config file
267 * @param name File to find, relative to the config file directory.
269 * @retval Pointer to a talloc'ed string containing the full path.
271 char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
272 const char *name);
275 * @brief Returns an absolute path to a file in the Samba private directory.
277 * @param name File to find, relative to PRIVATEDIR.
278 * if name is not relative, then use it as-is
280 * @retval Pointer to a talloc'ed string containing the full path.
282 char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
283 struct loadparm_context *lp_ctx,
284 const char *name);
287 * @brief Returns an absolute path to a NTDB or TDB file in the Samba
288 * private directory.
290 * @param name File to find, relative to PRIVATEDIR, without .(n)tdb extension.
291 * Only provide fixed-string names which are supposed to change with "use ntdb"
292 * option.
294 * @retval Pointer to a talloc'ed string containing the full path, for
295 * use with dbwrap_local_open().
297 char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
298 struct loadparm_context *lp_ctx,
299 const char *name);
302 return a path in the smbd.tmp directory, where all temporary file
303 for smbd go. If NULL is passed for name then return the directory
304 path itself
306 char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
307 struct loadparm_context *lp_ctx,
308 const char *name);
310 const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
311 struct loadparm_context *lp_ctx);
312 struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
313 struct loadparm_context *lp_ctx,
314 struct smb_iconv_handle *old_ic);
316 const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
318 void lpcfg_default_kdc_policy(struct loadparm_context *lp_ctx,
319 time_t *svc_tkt_lifetime,
320 time_t *usr_tkt_lifetime,
321 time_t *renewal_lifetime);
323 /* The following definitions come from lib/version.c */
325 const char *samba_version_string(void);
328 #endif /* _PARAM_H */