ntvfs: Avoid passing lp_ctx to tdb_wrap_open in py_wrap_setxattr
[Samba/wip.git] / lib / param / param.h
blob428a2a31c29fd7721647401e306eb53ccf77586a
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 #include "lib/param/param_functions.h"
53 #endif
55 const char **lpcfg_interfaces(struct loadparm_context *);
56 const char *lpcfg_realm(struct loadparm_context *);
57 const char *lpcfg_netbios_name(struct loadparm_context *);
58 const char *lpcfg_private_dir(struct loadparm_context *);
59 int lpcfg_server_role(struct loadparm_context *);
60 int lpcfg_allow_dns_updates(struct loadparm_context *);
62 void reload_charcnv(struct loadparm_context *lp_ctx);
64 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
65 bool lpcfg_autoloaded(struct loadparm_service *, struct loadparm_service *);
67 char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
68 char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
69 char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
70 char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
71 char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
73 const char *lpcfg_dnsdomain(struct loadparm_context *);
75 const char *lpcfg_servicename(const struct loadparm_service *service);
78 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
79 struct loadparm_service *service,
80 const char *type, const char *option);
82 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
83 struct loadparm_service *service, const char *type,
84 const char *option);
85 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
86 struct loadparm_context *lp_ctx,
87 struct loadparm_service *service,
88 const char *type,
89 const char *option, const char *separator);
90 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
91 struct loadparm_service *service, const char *type,
92 const char *option, int default_v);
93 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
94 struct loadparm_service *service, const char *type,
95 const char *option, int default_v);
96 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
97 struct loadparm_service *service, const char *type,
98 const char *option, unsigned long default_v);
99 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
100 struct loadparm_service *service, const char *type,
101 const char *option, long default_v);
102 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
103 struct loadparm_service *service, const char *type,
104 const char *option, double default_v);
105 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
106 struct loadparm_service *service, const char *type,
107 const char *option, bool default_v);
108 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
109 const struct loadparm_service *pservice,
110 const char *name);
111 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
112 const char *pszHomename,
113 struct loadparm_service *default_service,
114 const char *user, const char *pszHomedir);
115 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
116 const char *pszPrintername,
117 struct loadparm_service *default_service);
118 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name);
119 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
120 struct loadparm_service *service, struct parm_struct *parm);
121 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name);
122 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
124 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
125 const char *pszParmName, const char *pszParmValue);
126 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
127 struct loadparm_service *service,
128 const char *pszParmName, const char *pszParmValue);
131 * Process a parameter.
133 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
134 const char *pszParmName, const char *fmt, ...);
135 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
136 const char *pszParmValue);
137 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
140 * Display the contents of a single services record.
142 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
143 struct loadparm_service *service,
144 const char *parm_name, FILE * f);
147 * Unload unused services.
149 void lpcfg_killunused(struct loadparm_context *lp_ctx,
150 struct smbsrv_connection *smb,
151 bool (*snumused) (struct smbsrv_connection *, int));
154 * Initialise the global parameter structure.
156 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
157 struct loadparm_context *loadparm_init_global(bool load_default);
158 const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
159 bool lpcfg_load_default(struct loadparm_context *lp_ctx);
160 const char *lp_default_path(void);
163 * Load the services array from the services file.
165 * Return True on success, False on failure.
167 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
170 * Return the max number of services.
172 int lpcfg_numservices(struct loadparm_context *lp_ctx);
175 * Display the contents of the services array in human-readable form.
177 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
178 int maxtoprint);
181 * Display the contents of one service in human-readable form.
183 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
184 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
185 int snum);
186 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
187 const char *service_name);
190 * A useful volume label function.
192 const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
195 * If we are PDC then prefer us as DMB
197 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
200 * Return the max print jobs per queue.
202 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
203 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
204 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
205 struct smbcli_options *options);
206 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
207 struct smbcli_session_options *options);
208 const char **lpcfg_smb_ports(struct loadparm_context *);
209 const char *lpcfg_socket_options(struct loadparm_context *);
210 struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
211 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
214 /* The following definitions come from param/generic.c */
216 struct param_section *param_get_section(struct param_context *ctx, const char *name);
217 struct parmlist_entry *param_section_get(struct param_section *section,
218 const char *name);
219 struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
220 struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
221 struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
222 const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
223 int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
224 const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
225 int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
226 int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
227 void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
228 unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
229 void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
230 struct param_context *param_init(TALLOC_CTX *mem_ctx);
231 int param_read(struct param_context *ctx, const char *fn);
232 int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
233 int param_write(struct param_context *ctx, const char *fn);
235 /* The following definitions come from param/util.c */
239 * @file
240 * @brief Misc utility functions
242 bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
243 const char *domain);
245 bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
246 const char *domain);
249 see if a string matches either our primary or one of our secondary
250 netbios aliases. do a case insensitive match
252 bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
255 A useful function for returning a path in the Samba lock directory.
257 char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
258 const char *name);
261 * @brief Returns an absolute path to a file in the directory containing the current config file
263 * @param name File to find, relative to the config file directory.
265 * @retval Pointer to a talloc'ed string containing the full path.
267 char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
268 const char *name);
271 * @brief Returns an absolute path to a file in the Samba private directory.
273 * @param name File to find, relative to PRIVATEDIR.
274 * if name is not relative, then use it as-is
276 * @retval Pointer to a talloc'ed string containing the full path.
278 char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
279 struct loadparm_context *lp_ctx,
280 const char *name);
283 * @brief Returns an absolute path to a NTDB or TDB file in the Samba
284 * private directory.
286 * @param name File to find, relative to PRIVATEDIR, without .(n)tdb extension.
287 * Only provide fixed-string names which are supposed to change with "use ntdb"
288 * option.
290 * @retval Pointer to a talloc'ed string containing the full path, for
291 * use with dbwrap_local_open().
293 char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
294 struct loadparm_context *lp_ctx,
295 const char *name);
298 return a path in the smbd.tmp directory, where all temporary file
299 for smbd go. If NULL is passed for name then return the directory
300 path itself
302 char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
303 struct loadparm_context *lp_ctx,
304 const char *name);
306 const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
307 struct loadparm_context *lp_ctx);
308 struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
309 struct loadparm_context *lp_ctx,
310 struct smb_iconv_handle *old_ic);
312 const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
314 void lpcfg_default_kdc_policy(struct loadparm_context *lp_ctx,
315 time_t *svc_tkt_lifetime,
316 time_t *usr_tkt_lifetime,
317 time_t *renewal_lifetime);
319 /* The following definitions come from lib/version.c */
321 const char *samba_version_string(void);
324 #endif /* _PARAM_H */