s3:nmbd: add _NMBD_NMBD_H_ guard to nmbd.h
[Samba/gebeck_regimport.git] / source4 / param / param.h
blob622250b8b7afc6e2e288c6621bc57a76af6bc652
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 parmlist_entry;
25 struct param_context {
26 struct param_section *sections;
29 struct param_section {
30 const char *name;
31 struct param_section *prev, *next;
32 struct parmlist *parameters;
35 struct param_context;
36 struct smbsrv_connection;
38 #define Auto (2)
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"
48 #include "libds/common/roles.h"
50 enum sid_generator {
51 SID_GENERATOR_INTERNAL=0,
52 SID_GENERATOR_BACKEND=1,
55 enum announce_as {/* Types of machine we can announce as. */
56 ANNOUNCE_AS_NT_SERVER=1,
57 ANNOUNCE_AS_WIN95=2,
58 ANNOUNCE_AS_WFW=3,
59 ANNOUNCE_AS_NT_WORKSTATION=4
62 struct loadparm_context;
63 struct loadparm_service;
64 struct smbcli_options;
65 struct smbcli_session_options;
66 struct gensec_settings;
68 #ifdef CONFIG_H_IS_FROM_SAMBA
69 #include "param/param_proto.h"
70 #endif
72 const char **lpcfg_interfaces(struct loadparm_context *);
73 const char *lpcfg_realm(struct loadparm_context *);
74 const char *lpcfg_netbios_name(struct loadparm_context *);
75 const char *lpcfg_private_dir(struct loadparm_context *);
76 int lpcfg_server_role(struct loadparm_context *);
78 void reload_charcnv(struct loadparm_context *lp_ctx);
80 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
81 struct parm_struct *lpcfg_parm_table(void);
84 char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
85 char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
86 char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
87 char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
88 char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
90 const char *lpcfg_servicename(const struct loadparm_service *service);
93 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
94 struct loadparm_service *service,
95 const char *type, const char *option);
97 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
98 struct loadparm_service *service, const char *type,
99 const char *option);
100 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
101 struct loadparm_context *lp_ctx,
102 struct loadparm_service *service,
103 const char *type,
104 const char *option, const char *separator);
105 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
106 struct loadparm_service *service, const char *type,
107 const char *option, int default_v);
108 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
109 struct loadparm_service *service, const char *type,
110 const char *option, int default_v);
111 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
112 struct loadparm_service *service, const char *type,
113 const char *option, unsigned long default_v);
114 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
115 struct loadparm_service *service, const char *type,
116 const char *option, double default_v);
117 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
118 struct loadparm_service *service, const char *type,
119 const char *option, bool default_v);
120 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
121 const struct loadparm_service *pservice,
122 const char *name);
123 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
124 const char *pszHomename,
125 struct loadparm_service *default_service,
126 const char *user, const char *pszHomedir);
127 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
128 const char *pszPrintername,
129 struct loadparm_service *default_service);
130 struct parm_struct *lpcfg_parm_struct(const char *name);
131 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
132 struct loadparm_service *service, struct parm_struct *parm);
133 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
135 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
136 const char *pszParmName, const char *pszParmValue);
137 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
138 struct loadparm_service *service,
139 const char *pszParmName, const char *pszParmValue);
142 * Process a parameter.
144 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
145 const char *pszParmName, const char *fmt, ...);
146 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
147 const char *pszParmValue);
148 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
151 * Display the contents of a single services record.
153 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
154 struct loadparm_service *service,
155 const char *parm_name, FILE * f);
158 * Return info about the next service in a service. snum==-1 gives the globals.
159 * Return NULL when out of parameters.
161 struct parm_struct *lpcfg_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
162 int allparameters);
165 * Unload unused services.
167 void lpcfg_killunused(struct loadparm_context *lp_ctx,
168 struct smbsrv_connection *smb,
169 bool (*snumused) (struct smbsrv_connection *, int));
172 * Initialise the global parameter structure.
174 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
175 struct loadparm_context *loadparm_init_global(bool load_default);
176 const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
177 bool lpcfg_load_default(struct loadparm_context *lp_ctx);
178 const char *lp_default_path(void);
181 * Load the services array from the services file.
183 * Return True on success, False on failure.
185 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
188 * Return the max number of services.
190 int lpcfg_numservices(struct loadparm_context *lp_ctx);
193 * Display the contents of the services array in human-readable form.
195 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
196 int maxtoprint);
199 * Display the contents of one service in human-readable form.
201 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
202 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
203 int snum);
204 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
205 const char *service_name);
208 * A useful volume label function.
210 const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
213 * If we are PDC then prefer us as DMB
215 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
218 * Return the max print jobs per queue.
220 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
221 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
222 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
223 struct smbcli_options *options);
224 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
225 struct smbcli_session_options *options);
226 struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
227 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
230 /* The following definitions come from param/generic.c */
232 struct param_section *param_get_section(struct param_context *ctx, const char *name);
233 struct parmlist_entry *param_section_get(struct param_section *section,
234 const char *name);
235 struct parmlist_entry *param_get (struct param_context *ctx, const char *name, const char *section_name);
236 struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
237 struct parmlist_entry *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
238 const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
239 int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
240 const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
241 int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
242 int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
243 void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
244 unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
245 void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
246 struct param_context *param_init(TALLOC_CTX *mem_ctx);
247 int param_read(struct param_context *ctx, const char *fn);
248 int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
249 int param_write(struct param_context *ctx, const char *fn);
251 /* The following definitions come from param/util.c */
255 * @file
256 * @brief Misc utility functions
258 bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
259 const char *domain);
261 bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
262 const char *domain);
265 see if a string matches either our primary or one of our secondary
266 netbios aliases. do a case insensitive match
268 bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
271 A useful function for returning a path in the Samba lock directory.
273 char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
274 const char *name);
277 * @brief Returns an absolute path to a file in the directory containing the current config file
279 * @param name File to find, relative to the config file directory.
281 * @retval Pointer to a talloc'ed string containing the full path.
283 char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
284 const char *name);
287 * @brief Returns an absolute path to a file in the Samba private directory.
289 * @param name File to find, relative to PRIVATEDIR.
290 * if name is not relative, then use it as-is
292 * @retval Pointer to a talloc'ed string containing the full path.
294 char *lpcfg_private_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);
308 * Obtain the init function from a shared library file
310 init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path);
313 * Obtain list of init functions from the modules in the specified
314 * directory
316 init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path);
319 * Run the specified init functions.
321 * @return true if all functions ran successfully, false otherwise
323 bool run_init_functions(init_module_fn *fns);
326 * Load the initialization functions from DSO files for a specific subsystem.
328 * Will return an array of function pointers to initialization functions
330 init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem);
331 const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
332 struct loadparm_context *lp_ctx);
333 struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
334 struct loadparm_context *lp_ctx,
335 struct smb_iconv_handle *old_ic);
337 const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
339 /* The following definitions come from lib/version.c */
341 const char *samba_version_string(void);
344 #endif /* _PARAM_H */