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 */
23 struct loadparm_s3_context
;
25 struct parmlist_entry
;
27 struct param_context
{
28 struct param_section
*sections
;
31 struct param_section
{
33 struct param_section
*prev
, *next
;
34 struct parmlist
*parameters
;
38 struct smbsrv_connection
;
42 typedef NTSTATUS (*init_module_fn
) (void);
44 /* this needs to be a string which is not in the C library. We
45 previously used "init_module", but that meant that modules which
46 did not define this function ended up calling the C library
47 function init_module() which makes a system call */
48 #define SAMBA_INIT_MODULE "samba_init_module"
50 #include "libds/common/roles.h"
52 enum announce_as
{/* Types of machine we can announce as. */
53 ANNOUNCE_AS_NT_SERVER
=1,
56 ANNOUNCE_AS_NT_WORKSTATION
=4
59 struct loadparm_context
;
60 struct loadparm_service
;
61 struct smbcli_options
;
62 struct smbcli_session_options
;
63 struct gensec_settings
;
65 #ifdef CONFIG_H_IS_FROM_SAMBA
66 #include "param/param_proto.h"
69 const char **lpcfg_interfaces(struct loadparm_context
*);
70 const char *lpcfg_realm(struct loadparm_context
*);
71 const char *lpcfg_netbios_name(struct loadparm_context
*);
72 const char *lpcfg_private_dir(struct loadparm_context
*);
73 int lpcfg_server_role(struct loadparm_context
*);
75 void reload_charcnv(struct loadparm_context
*lp_ctx
);
77 struct loadparm_service
*lpcfg_default_service(struct loadparm_context
*lp_ctx
);
78 struct parm_struct
*lpcfg_parm_table(void);
81 char *lpcfg_tls_keyfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
82 char *lpcfg_tls_certfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
83 char *lpcfg_tls_cafile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
84 char *lpcfg_tls_dhpfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
85 char *lpcfg_tls_crlfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
87 const char *lpcfg_servicename(const struct loadparm_service
*service
);
90 const char *lpcfg_get_parametric(struct loadparm_context
*lp_ctx
,
91 struct loadparm_service
*service
,
92 const char *type
, const char *option
);
94 const char *lpcfg_parm_string(struct loadparm_context
*lp_ctx
,
95 struct loadparm_service
*service
, const char *type
,
97 const char **lpcfg_parm_string_list(TALLOC_CTX
*mem_ctx
,
98 struct loadparm_context
*lp_ctx
,
99 struct loadparm_service
*service
,
101 const char *option
, const char *separator
);
102 int lpcfg_parm_int(struct loadparm_context
*lp_ctx
,
103 struct loadparm_service
*service
, const char *type
,
104 const char *option
, int default_v
);
105 int lpcfg_parm_bytes(struct loadparm_context
*lp_ctx
,
106 struct loadparm_service
*service
, const char *type
,
107 const char *option
, int default_v
);
108 unsigned long lpcfg_parm_ulong(struct loadparm_context
*lp_ctx
,
109 struct loadparm_service
*service
, const char *type
,
110 const char *option
, unsigned long default_v
);
111 double lpcfg_parm_double(struct loadparm_context
*lp_ctx
,
112 struct loadparm_service
*service
, const char *type
,
113 const char *option
, double default_v
);
114 bool lpcfg_parm_bool(struct loadparm_context
*lp_ctx
,
115 struct loadparm_service
*service
, const char *type
,
116 const char *option
, bool default_v
);
117 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
118 const struct loadparm_service
*pservice
,
120 bool lpcfg_add_home(struct loadparm_context
*lp_ctx
,
121 const char *pszHomename
,
122 struct loadparm_service
*default_service
,
123 const char *user
, const char *pszHomedir
);
124 bool lpcfg_add_printer(struct loadparm_context
*lp_ctx
,
125 const char *pszPrintername
,
126 struct loadparm_service
*default_service
);
127 struct parm_struct
*lpcfg_parm_struct(const char *name
);
128 void *lpcfg_parm_ptr(struct loadparm_context
*lp_ctx
,
129 struct loadparm_service
*service
, struct parm_struct
*parm
);
130 bool lpcfg_file_list_changed(struct loadparm_context
*lp_ctx
);
132 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
133 const char *pszParmName
, const char *pszParmValue
);
134 bool lpcfg_do_service_parameter(struct loadparm_context
*lp_ctx
,
135 struct loadparm_service
*service
,
136 const char *pszParmName
, const char *pszParmValue
);
139 * Process a parameter.
141 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
,
142 const char *pszParmName
, const char *fmt
, ...);
143 bool lpcfg_set_cmdline(struct loadparm_context
*lp_ctx
, const char *pszParmName
,
144 const char *pszParmValue
);
145 bool lpcfg_set_option(struct loadparm_context
*lp_ctx
, const char *option
);
148 * Display the contents of a single services record.
150 bool lpcfg_dump_a_parameter(struct loadparm_context
*lp_ctx
,
151 struct loadparm_service
*service
,
152 const char *parm_name
, FILE * f
);
155 * Return info about the next service in a service. snum==-1 gives the globals.
156 * Return NULL when out of parameters.
158 struct parm_struct
*lpcfg_next_parameter(struct loadparm_context
*lp_ctx
, int snum
, int *i
,
162 * Unload unused services.
164 void lpcfg_killunused(struct loadparm_context
*lp_ctx
,
165 struct smbsrv_connection
*smb
,
166 bool (*snumused
) (struct smbsrv_connection
*, int));
169 * Initialise the global parameter structure.
171 struct loadparm_context
*loadparm_init(TALLOC_CTX
*mem_ctx
);
172 struct loadparm_context
*loadparm_init_global(bool load_default
);
173 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
);
174 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
);
175 const char *lp_default_path(void);
178 * Load the services array from the services file.
180 * Return True on success, False on failure.
182 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
);
185 * Return the max number of services.
187 int lpcfg_numservices(struct loadparm_context
*lp_ctx
);
190 * Display the contents of the services array in human-readable form.
192 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
196 * Display the contents of one service in human-readable form.
198 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
199 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
201 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
202 const char *service_name
);
205 * A useful volume label function.
207 const char *lp_cfg_volume_label(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
210 * If we are PDC then prefer us as DMB
212 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
215 * Return the max print jobs per queue.
217 int lpcfg_maxprintjobs(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
218 struct smb_iconv_handle
*lpcfg_iconv_handle(struct loadparm_context
*lp_ctx
);
219 void lpcfg_smbcli_options(struct loadparm_context
*lp_ctx
,
220 struct smbcli_options
*options
);
221 void lpcfg_smbcli_session_options(struct loadparm_context
*lp_ctx
,
222 struct smbcli_session_options
*options
);
223 struct dcerpc_server_info
*lpcfg_dcerpc_server_info(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
224 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*, struct loadparm_context
*);
227 /* The following definitions come from param/generic.c */
229 struct param_section
*param_get_section(struct param_context
*ctx
, const char *name
);
230 struct parmlist_entry
*param_section_get(struct param_section
*section
,
232 struct parmlist_entry
*param_get (struct param_context
*ctx
, const char *name
, const char *section_name
);
233 struct param_section
*param_add_section(struct param_context
*ctx
, const char *section_name
);
234 struct parmlist_entry
*param_get_add(struct param_context
*ctx
, const char *name
, const char *section_name
);
235 const char *param_get_string(struct param_context
*ctx
, const char *param
, const char *section
);
236 int param_set_string(struct param_context
*ctx
, const char *param
, const char *value
, const char *section
);
237 const char **param_get_string_list(struct param_context
*ctx
, const char *param
, const char *separator
, const char *section
);
238 int param_set_string_list(struct param_context
*ctx
, const char *param
, const char **list
, const char *section
);
239 int param_get_int(struct param_context
*ctx
, const char *param
, int default_v
, const char *section
);
240 void param_set_int(struct param_context
*ctx
, const char *param
, int value
, const char *section
);
241 unsigned long param_get_ulong(struct param_context
*ctx
, const char *param
, unsigned long default_v
, const char *section
);
242 void param_set_ulong(struct param_context
*ctx
, const char *name
, unsigned long value
, const char *section
);
243 struct param_context
*param_init(TALLOC_CTX
*mem_ctx
);
244 int param_read(struct param_context
*ctx
, const char *fn
);
245 int param_use(struct loadparm_context
*lp_ctx
, struct param_context
*ctx
);
246 int param_write(struct param_context
*ctx
, const char *fn
);
248 /* The following definitions come from param/util.c */
253 * @brief Misc utility functions
255 bool lpcfg_is_mydomain(struct loadparm_context
*lp_ctx
,
258 bool lpcfg_is_my_domain_or_realm(struct loadparm_context
*lp_ctx
,
262 see if a string matches either our primary or one of our secondary
263 netbios aliases. do a case insensitive match
265 bool lpcfg_is_myname(struct loadparm_context
*lp_ctx
, const char *name
);
268 A useful function for returning a path in the Samba lock directory.
270 char *lpcfg_lock_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
274 * @brief Returns an absolute path to a file in the directory containing the current config file
276 * @param name File to find, relative to the config file directory.
278 * @retval Pointer to a talloc'ed string containing the full path.
280 char *lpcfg_config_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
284 * @brief Returns an absolute path to a file in the Samba private directory.
286 * @param name File to find, relative to PRIVATEDIR.
287 * if name is not relative, then use it as-is
289 * @retval Pointer to a talloc'ed string containing the full path.
291 char *lpcfg_private_path(TALLOC_CTX
* mem_ctx
,
292 struct loadparm_context
*lp_ctx
,
296 return a path in the smbd.tmp directory, where all temporary file
297 for smbd go. If NULL is passed for name then return the directory
300 char *smbd_tmp_path(TALLOC_CTX
*mem_ctx
,
301 struct loadparm_context
*lp_ctx
,
305 * Obtain the init function from a shared library file
307 init_module_fn
load_module(TALLOC_CTX
*mem_ctx
, const char *path
);
310 * Obtain list of init functions from the modules in the specified
313 init_module_fn
*load_modules(TALLOC_CTX
*mem_ctx
, const char *path
);
316 * Run the specified init functions.
318 * @return true if all functions ran successfully, false otherwise
320 bool run_init_functions(init_module_fn
*fns
);
323 * Load the initialization functions from DSO files for a specific subsystem.
325 * Will return an array of function pointers to initialization functions
327 init_module_fn
*load_samba_modules(TALLOC_CTX
*mem_ctx
, const char *subsystem
);
328 const char *lpcfg_imessaging_path(TALLOC_CTX
*mem_ctx
,
329 struct loadparm_context
*lp_ctx
);
330 struct smb_iconv_handle
*smb_iconv_handle_reinit_lp(TALLOC_CTX
*mem_ctx
,
331 struct loadparm_context
*lp_ctx
,
332 struct smb_iconv_handle
*old_ic
);
334 const char *lpcfg_sam_name(struct loadparm_context
*lp_ctx
);
336 /* The following definitions come from lib/version.c */
338 const char *samba_version_string(void);
341 #endif /* _PARAM_H */