param: use a single copy_service function in lib/param
[Samba.git] / lib / param / param.h
blob0b65a3c827366ac6ba20df516baaabc3bafabe97
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;
49 struct bitmap;
51 #ifdef CONFIG_H_IS_FROM_SAMBA
52 #include "lib/param/param_proto.h"
53 #include "lib/param/param_functions.h"
54 #endif
56 const char **lpcfg_interfaces(struct loadparm_context *);
57 const char *lpcfg_realm(struct loadparm_context *);
58 const char *lpcfg_netbios_name(struct loadparm_context *);
59 const char *lpcfg_private_dir(struct loadparm_context *);
60 int lpcfg_server_role(struct loadparm_context *);
61 int lpcfg_allow_dns_updates(struct loadparm_context *);
63 void reload_charcnv(struct loadparm_context *lp_ctx);
65 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
66 bool lpcfg_autoloaded(struct loadparm_service *, struct loadparm_service *);
68 char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
69 char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
70 char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
71 char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
72 char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
74 const char *lpcfg_dnsdomain(struct loadparm_context *);
76 const char *lpcfg_servicename(const struct loadparm_service *service);
79 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
80 struct loadparm_service *service,
81 const char *type, const char *option);
83 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
84 struct loadparm_service *service, const char *type,
85 const char *option);
86 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
87 struct loadparm_context *lp_ctx,
88 struct loadparm_service *service,
89 const char *type,
90 const char *option, const char *separator);
91 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
92 struct loadparm_service *service, const char *type,
93 const char *option, int default_v);
94 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
95 struct loadparm_service *service, const char *type,
96 const char *option, int default_v);
97 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
98 struct loadparm_service *service, const char *type,
99 const char *option, unsigned long default_v);
100 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
101 struct loadparm_service *service, const char *type,
102 const char *option, long default_v);
103 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
104 struct loadparm_service *service, const char *type,
105 const char *option, double default_v);
106 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
107 struct loadparm_service *service, const char *type,
108 const char *option, bool default_v);
109 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
110 const struct loadparm_service *pservice,
111 const char *name);
112 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
113 const char *pszHomename,
114 struct loadparm_service *default_service,
115 const char *user, const char *pszHomedir);
116 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
117 const char *pszPrintername,
118 struct loadparm_service *default_service);
119 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name);
120 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
121 struct loadparm_service *service, struct parm_struct *parm);
122 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name);
123 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
125 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
126 const char *pszParmName, const char *pszParmValue);
127 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
128 struct loadparm_service *service,
129 const char *pszParmName, const char *pszParmValue);
132 * Process a parameter.
134 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
135 const char *pszParmName, const char *fmt, ...);
136 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
137 const char *pszParmValue);
138 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
141 * Display the contents of a single services record.
143 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
144 struct loadparm_service *service,
145 const char *parm_name, FILE * f);
148 * Unload unused services.
150 void lpcfg_killunused(struct loadparm_context *lp_ctx,
151 struct smbsrv_connection *smb,
152 bool (*snumused) (struct smbsrv_connection *, int));
155 * Initialise the global parameter structure.
157 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
158 struct loadparm_context *loadparm_init_global(bool load_default);
159 const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
160 bool lpcfg_load_default(struct loadparm_context *lp_ctx);
161 const char *lp_default_path(void);
164 * Load the services array from the services file.
166 * Return True on success, False on failure.
168 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
171 * Return the max number of services.
173 int lpcfg_numservices(struct loadparm_context *lp_ctx);
176 * Display the contents of the services array in human-readable form.
178 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
179 int maxtoprint);
182 * Display the contents of one service in human-readable form.
184 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
185 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
186 int snum);
187 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
188 const char *service_name);
191 * A useful volume label function.
193 const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
196 * If we are PDC then prefer us as DMB
198 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
201 * Return the max print jobs per queue.
203 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
204 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
205 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
206 struct smbcli_options *options);
207 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
208 struct smbcli_session_options *options);
209 const char **lpcfg_smb_ports(struct loadparm_context *);
210 const char *lpcfg_socket_options(struct loadparm_context *);
211 struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
212 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
215 /* The following definitions come from param/generic.c */
217 struct param_section *param_get_section(struct param_context *ctx, const char *name);
218 struct parmlist_entry *param_section_get(struct param_section *section,
219 const char *name);
220 struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
221 struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
222 struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
223 const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
224 int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
225 const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
226 int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
227 int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
228 void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
229 unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
230 void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
231 struct param_context *param_init(TALLOC_CTX *mem_ctx);
232 int param_read(struct param_context *ctx, const char *fn);
233 int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
234 int param_write(struct param_context *ctx, const char *fn);
236 /* The following definitions come from param/util.c */
240 * @file
241 * @brief Misc utility functions
243 bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
244 const char *domain);
246 bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
247 const char *domain);
250 see if a string matches either our primary or one of our secondary
251 netbios aliases. do a case insensitive match
253 bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
256 A useful function for returning a path in the Samba lock directory.
258 char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
259 const char *name);
262 * @brief Returns an absolute path to a file in the directory containing the current config file
264 * @param name File to find, relative to the config file directory.
266 * @retval Pointer to a talloc'ed string containing the full path.
268 char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
269 const char *name);
272 * @brief Returns an absolute path to a file in the Samba private directory.
274 * @param name File to find, relative to PRIVATEDIR.
275 * if name is not relative, then use it as-is
277 * @retval Pointer to a talloc'ed string containing the full path.
279 char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
280 struct loadparm_context *lp_ctx,
281 const char *name);
284 * @brief Returns an absolute path to a NTDB or TDB file in the Samba
285 * private directory.
287 * @param name File to find, relative to PRIVATEDIR, without .(n)tdb extension.
288 * Only provide fixed-string names which are supposed to change with "use ntdb"
289 * option.
291 * @retval Pointer to a talloc'ed string containing the full path, for
292 * use with dbwrap_local_open().
294 char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
295 struct loadparm_context *lp_ctx,
296 const char *name);
299 return a path in the smbd.tmp directory, where all temporary file
300 for smbd go. If NULL is passed for name then return the directory
301 path itself
303 char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
304 struct loadparm_context *lp_ctx,
305 const char *name);
307 const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
308 struct loadparm_context *lp_ctx);
309 struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
310 struct loadparm_context *lp_ctx,
311 struct smb_iconv_handle *old_ic);
313 const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
315 void lpcfg_default_kdc_policy(struct loadparm_context *lp_ctx,
316 time_t *svc_tkt_lifetime,
317 time_t *usr_tkt_lifetime,
318 time_t *renewal_lifetime);
320 /* The following definitions come from lib/version.c */
322 const char *samba_version_string(void);
325 #endif /* _PARAM_H */