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 parmlist_entry
;
25 struct param_context
{
26 struct param_section
*sections
;
29 struct param_section
{
31 struct param_section
*prev
, *next
;
32 struct parmlist
*parameters
;
36 struct smbsrv_connection
;
40 typedef NTSTATUS (*init_module_fn
) (void);
42 /* this needs to be a string which is not in the C library. We
43 previously used "init_module", but that meant that modules which
44 did not define this function ended up calling the C library
45 function init_module() which makes a system call */
46 #define SAMBA_INIT_MODULE "samba_init_module"
51 ROLE_DOMAIN_CONTROLLER
=2,
55 SID_GENERATOR_INTERNAL
=0,
56 SID_GENERATOR_BACKEND
=1,
59 enum announce_as
{/* Types of machine we can announce as. */
60 ANNOUNCE_AS_NT_SERVER
=1,
63 ANNOUNCE_AS_NT_WORKSTATION
=4
66 struct loadparm_context
;
67 struct loadparm_service
;
68 struct smbcli_options
;
69 struct smbcli_session_options
;
70 struct gensec_settings
;
72 #ifdef CONFIG_H_IS_FROM_SAMBA
73 #include "param/param_proto.h"
76 const char **lpcfg_interfaces(struct loadparm_context
*);
77 const char *lpcfg_realm(struct loadparm_context
*);
78 const char *lpcfg_netbios_name(struct loadparm_context
*);
79 const char *lpcfg_private_dir(struct loadparm_context
*);
81 void reload_charcnv(struct loadparm_context
*lp_ctx
);
83 struct loadparm_service
*lpcfg_default_service(struct loadparm_context
*lp_ctx
);
84 struct parm_struct
*lpcfg_parm_table(void);
87 char *lpcfg_tls_keyfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
88 char *lpcfg_tls_certfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
89 char *lpcfg_tls_cafile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
90 char *lpcfg_tls_dhpfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
91 char *lpcfg_tls_crlfile(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*);
93 const char *lpcfg_servicename(const struct loadparm_service
*service
);
96 const char *lpcfg_get_parametric(struct loadparm_context
*lp_ctx
,
97 struct loadparm_service
*service
,
98 const char *type
, const char *option
);
100 const char *lpcfg_parm_string(struct loadparm_context
*lp_ctx
,
101 struct loadparm_service
*service
, const char *type
,
103 const char **lpcfg_parm_string_list(TALLOC_CTX
*mem_ctx
,
104 struct loadparm_context
*lp_ctx
,
105 struct loadparm_service
*service
,
107 const char *option
, const char *separator
);
108 int lpcfg_parm_int(struct loadparm_context
*lp_ctx
,
109 struct loadparm_service
*service
, const char *type
,
110 const char *option
, int default_v
);
111 int lpcfg_parm_bytes(struct loadparm_context
*lp_ctx
,
112 struct loadparm_service
*service
, const char *type
,
113 const char *option
, int default_v
);
114 unsigned long lpcfg_parm_ulong(struct loadparm_context
*lp_ctx
,
115 struct loadparm_service
*service
, const char *type
,
116 const char *option
, unsigned long default_v
);
117 double lpcfg_parm_double(struct loadparm_context
*lp_ctx
,
118 struct loadparm_service
*service
, const char *type
,
119 const char *option
, double default_v
);
120 bool lpcfg_parm_bool(struct loadparm_context
*lp_ctx
,
121 struct loadparm_service
*service
, const char *type
,
122 const char *option
, bool default_v
);
123 struct loadparm_service
*lpcfg_add_service(struct loadparm_context
*lp_ctx
,
124 const struct loadparm_service
*pservice
,
126 bool lpcfg_add_home(struct loadparm_context
*lp_ctx
,
127 const char *pszHomename
,
128 struct loadparm_service
*default_service
,
129 const char *user
, const char *pszHomedir
);
130 bool lpcfg_add_printer(struct loadparm_context
*lp_ctx
,
131 const char *pszPrintername
,
132 struct loadparm_service
*default_service
);
133 struct parm_struct
*lpcfg_parm_struct(const char *name
);
134 void *lpcfg_parm_ptr(struct loadparm_context
*lp_ctx
,
135 struct loadparm_service
*service
, struct parm_struct
*parm
);
136 bool lpcfg_file_list_changed(struct loadparm_context
*lp_ctx
);
138 bool lpcfg_do_global_parameter(struct loadparm_context
*lp_ctx
,
139 const char *pszParmName
, const char *pszParmValue
);
140 bool lpcfg_do_service_parameter(struct loadparm_context
*lp_ctx
,
141 struct loadparm_service
*service
,
142 const char *pszParmName
, const char *pszParmValue
);
145 * Process a parameter.
147 bool lpcfg_do_global_parameter_var(struct loadparm_context
*lp_ctx
,
148 const char *pszParmName
, const char *fmt
, ...);
149 bool lpcfg_set_cmdline(struct loadparm_context
*lp_ctx
, const char *pszParmName
,
150 const char *pszParmValue
);
151 bool lpcfg_set_option(struct loadparm_context
*lp_ctx
, const char *option
);
154 * Display the contents of a single services record.
156 bool lpcfg_dump_a_parameter(struct loadparm_context
*lp_ctx
,
157 struct loadparm_service
*service
,
158 const char *parm_name
, FILE * f
);
161 * Return info about the next service in a service. snum==-1 gives the globals.
162 * Return NULL when out of parameters.
164 struct parm_struct
*lpcfg_next_parameter(struct loadparm_context
*lp_ctx
, int snum
, int *i
,
168 * Unload unused services.
170 void lpcfg_killunused(struct loadparm_context
*lp_ctx
,
171 struct smbsrv_connection
*smb
,
172 bool (*snumused
) (struct smbsrv_connection
*, int));
175 * Initialise the global parameter structure.
177 struct loadparm_context
*loadparm_init(TALLOC_CTX
*mem_ctx
);
178 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
);
179 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
);
180 const char *lp_default_path(void);
183 * Load the services array from the services file.
185 * Return True on success, False on failure.
187 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
);
190 * Return the max number of services.
192 int lpcfg_numservices(struct loadparm_context
*lp_ctx
);
195 * Display the contents of the services array in human-readable form.
197 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
201 * Display the contents of one service in human-readable form.
203 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
204 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
206 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
207 const char *service_name
);
210 * A useful volume label function.
212 const char *volume_label(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
215 * If we are PDC then prefer us as DMB
217 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
220 * Return the max print jobs per queue.
222 int lpcfg_maxprintjobs(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
223 struct smb_iconv_convenience
*lpcfg_iconv_convenience(struct loadparm_context
*lp_ctx
);
224 void lpcfg_smbcli_options(struct loadparm_context
*lp_ctx
,
225 struct smbcli_options
*options
);
226 void lpcfg_smbcli_session_options(struct loadparm_context
*lp_ctx
,
227 struct smbcli_session_options
*options
);
228 struct dcerpc_server_info
*lpcfg_dcerpc_server_info(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
229 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*, struct loadparm_context
*);
232 /* The following definitions come from param/generic.c */
234 struct param_section
*param_get_section(struct param_context
*ctx
, const char *name
);
235 struct parmlist_entry
*param_section_get(struct param_section
*section
,
237 struct parmlist_entry
*param_get (struct param_context
*ctx
, const char *name
, const char *section_name
);
238 struct param_section
*param_add_section(struct param_context
*ctx
, const char *section_name
);
239 struct parmlist_entry
*param_get_add(struct param_context
*ctx
, const char *name
, const char *section_name
);
240 const char *param_get_string(struct param_context
*ctx
, const char *param
, const char *section
);
241 int param_set_string(struct param_context
*ctx
, const char *param
, const char *value
, const char *section
);
242 const char **param_get_string_list(struct param_context
*ctx
, const char *param
, const char *separator
, const char *section
);
243 int param_set_string_list(struct param_context
*ctx
, const char *param
, const char **list
, const char *section
);
244 int param_get_int(struct param_context
*ctx
, const char *param
, int default_v
, const char *section
);
245 void param_set_int(struct param_context
*ctx
, const char *param
, int value
, const char *section
);
246 unsigned long param_get_ulong(struct param_context
*ctx
, const char *param
, unsigned long default_v
, const char *section
);
247 void param_set_ulong(struct param_context
*ctx
, const char *name
, unsigned long value
, const char *section
);
248 struct param_context
*param_init(TALLOC_CTX
*mem_ctx
);
249 int param_read(struct param_context
*ctx
, const char *fn
);
250 int param_use(struct loadparm_context
*lp_ctx
, struct param_context
*ctx
);
251 int param_write(struct param_context
*ctx
, const char *fn
);
253 /* The following definitions come from param/util.c */
258 * @brief Misc utility functions
260 bool lpcfg_is_mydomain(struct loadparm_context
*lp_ctx
,
263 bool lpcfg_is_my_domain_or_realm(struct loadparm_context
*lp_ctx
,
267 see if a string matches either our primary or one of our secondary
268 netbios aliases. do a case insensitive match
270 bool lpcfg_is_myname(struct loadparm_context
*lp_ctx
, const char *name
);
273 A useful function for returning a path in the Samba lock directory.
275 char *lock_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
279 * @brief Returns an absolute path to a file in the directory containing the current config file
281 * @param name File to find, relative to the config file directory.
283 * @retval Pointer to a talloc'ed string containing the full path.
285 char *config_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
289 * @brief Returns an absolute path to a file in the Samba private directory.
291 * @param name File to find, relative to PRIVATEDIR.
292 * if name is not relative, then use it as-is
294 * @retval Pointer to a talloc'ed string containing the full path.
296 char *private_path(TALLOC_CTX
* mem_ctx
,
297 struct loadparm_context
*lp_ctx
,
301 return a path in the smbd.tmp directory, where all temporary file
302 for smbd go. If NULL is passed for name then return the directory
305 char *smbd_tmp_path(TALLOC_CTX
*mem_ctx
,
306 struct loadparm_context
*lp_ctx
,
310 * Obtain the init function from a shared library file
312 init_module_fn
load_module(TALLOC_CTX
*mem_ctx
, const char *path
);
315 * Obtain list of init functions from the modules in the specified
318 init_module_fn
*load_modules(TALLOC_CTX
*mem_ctx
, const char *path
);
321 * Run the specified init functions.
323 * @return true if all functions ran successfully, false otherwise
325 bool run_init_functions(init_module_fn
*fns
);
328 * Load the initialization functions from DSO files for a specific subsystem.
330 * Will return an array of function pointers to initialization functions
332 init_module_fn
*load_samba_modules(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
, const char *subsystem
);
333 const char *lpcfg_messaging_path(TALLOC_CTX
*mem_ctx
,
334 struct loadparm_context
*lp_ctx
);
335 struct smb_iconv_convenience
*smb_iconv_convenience_reinit_lp(TALLOC_CTX
*mem_ctx
,
336 struct loadparm_context
*lp_ctx
,
337 struct smb_iconv_convenience
*old_ic
);
339 const char *lpcfg_sam_name(struct loadparm_context
*lp_ctx
);
341 /* The following definitions come from lib/version.c */
343 const char *samba_version_string(void);
346 #endif /* _PARAM_H */