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 struct loadparm_context
*loadparm_init_global(bool load_default
);
179 const char *lpcfg_configfile(struct loadparm_context
*lp_ctx
);
180 bool lpcfg_load_default(struct loadparm_context
*lp_ctx
);
181 const char *lp_default_path(void);
184 * Load the services array from the services file.
186 * Return True on success, False on failure.
188 bool lpcfg_load(struct loadparm_context
*lp_ctx
, const char *filename
);
191 * Return the max number of services.
193 int lpcfg_numservices(struct loadparm_context
*lp_ctx
);
196 * Display the contents of the services array in human-readable form.
198 void lpcfg_dump(struct loadparm_context
*lp_ctx
, FILE *f
, bool show_defaults
,
202 * Display the contents of one service in human-readable form.
204 void lpcfg_dump_one(FILE *f
, bool show_defaults
, struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
205 struct loadparm_service
*lpcfg_servicebynum(struct loadparm_context
*lp_ctx
,
207 struct loadparm_service
*lpcfg_service(struct loadparm_context
*lp_ctx
,
208 const char *service_name
);
211 * A useful volume label function.
213 const char *volume_label(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
216 * If we are PDC then prefer us as DMB
218 const char *lpcfg_printername(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
221 * Return the max print jobs per queue.
223 int lpcfg_maxprintjobs(struct loadparm_service
*service
, struct loadparm_service
*sDefault
);
224 struct smb_iconv_convenience
*lpcfg_iconv_convenience(struct loadparm_context
*lp_ctx
);
225 void lpcfg_smbcli_options(struct loadparm_context
*lp_ctx
,
226 struct smbcli_options
*options
);
227 void lpcfg_smbcli_session_options(struct loadparm_context
*lp_ctx
,
228 struct smbcli_session_options
*options
);
229 struct dcerpc_server_info
*lpcfg_dcerpc_server_info(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
);
230 struct gensec_settings
*lpcfg_gensec_settings(TALLOC_CTX
*, struct loadparm_context
*);
233 /* The following definitions come from param/generic.c */
235 struct param_section
*param_get_section(struct param_context
*ctx
, const char *name
);
236 struct parmlist_entry
*param_section_get(struct param_section
*section
,
238 struct parmlist_entry
*param_get (struct param_context
*ctx
, const char *name
, const char *section_name
);
239 struct param_section
*param_add_section(struct param_context
*ctx
, const char *section_name
);
240 struct parmlist_entry
*param_get_add(struct param_context
*ctx
, const char *name
, const char *section_name
);
241 const char *param_get_string(struct param_context
*ctx
, const char *param
, const char *section
);
242 int param_set_string(struct param_context
*ctx
, const char *param
, const char *value
, const char *section
);
243 const char **param_get_string_list(struct param_context
*ctx
, const char *param
, const char *separator
, const char *section
);
244 int param_set_string_list(struct param_context
*ctx
, const char *param
, const char **list
, const char *section
);
245 int param_get_int(struct param_context
*ctx
, const char *param
, int default_v
, const char *section
);
246 void param_set_int(struct param_context
*ctx
, const char *param
, int value
, const char *section
);
247 unsigned long param_get_ulong(struct param_context
*ctx
, const char *param
, unsigned long default_v
, const char *section
);
248 void param_set_ulong(struct param_context
*ctx
, const char *name
, unsigned long value
, const char *section
);
249 struct param_context
*param_init(TALLOC_CTX
*mem_ctx
);
250 int param_read(struct param_context
*ctx
, const char *fn
);
251 int param_use(struct loadparm_context
*lp_ctx
, struct param_context
*ctx
);
252 int param_write(struct param_context
*ctx
, const char *fn
);
254 /* The following definitions come from param/util.c */
259 * @brief Misc utility functions
261 bool lpcfg_is_mydomain(struct loadparm_context
*lp_ctx
,
264 bool lpcfg_is_my_domain_or_realm(struct loadparm_context
*lp_ctx
,
268 see if a string matches either our primary or one of our secondary
269 netbios aliases. do a case insensitive match
271 bool lpcfg_is_myname(struct loadparm_context
*lp_ctx
, const char *name
);
274 A useful function for returning a path in the Samba lock directory.
276 char *lock_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
280 * @brief Returns an absolute path to a file in the directory containing the current config file
282 * @param name File to find, relative to the config file directory.
284 * @retval Pointer to a talloc'ed string containing the full path.
286 char *config_path(TALLOC_CTX
* mem_ctx
, struct loadparm_context
*lp_ctx
,
290 * @brief Returns an absolute path to a file in the Samba private directory.
292 * @param name File to find, relative to PRIVATEDIR.
293 * if name is not relative, then use it as-is
295 * @retval Pointer to a talloc'ed string containing the full path.
297 char *private_path(TALLOC_CTX
* mem_ctx
,
298 struct loadparm_context
*lp_ctx
,
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
306 char *smbd_tmp_path(TALLOC_CTX
*mem_ctx
,
307 struct loadparm_context
*lp_ctx
,
311 * Obtain the init function from a shared library file
313 init_module_fn
load_module(TALLOC_CTX
*mem_ctx
, const char *path
);
316 * Obtain list of init functions from the modules in the specified
319 init_module_fn
*load_modules(TALLOC_CTX
*mem_ctx
, const char *path
);
322 * Run the specified init functions.
324 * @return true if all functions ran successfully, false otherwise
326 bool run_init_functions(init_module_fn
*fns
);
329 * Load the initialization functions from DSO files for a specific subsystem.
331 * Will return an array of function pointers to initialization functions
333 init_module_fn
*load_samba_modules(TALLOC_CTX
*mem_ctx
, struct loadparm_context
*lp_ctx
, const char *subsystem
);
334 const char *lpcfg_messaging_path(TALLOC_CTX
*mem_ctx
,
335 struct loadparm_context
*lp_ctx
);
336 struct smb_iconv_convenience
*smb_iconv_convenience_reinit_lp(TALLOC_CTX
*mem_ctx
,
337 struct loadparm_context
*lp_ctx
,
338 struct smb_iconv_convenience
*old_ic
);
340 const char *lpcfg_sam_name(struct loadparm_context
*lp_ctx
);
342 /* The following definitions come from lib/version.c */
344 const char *samba_version_string(void);
347 #endif /* _PARAM_H */