ldb: Only set public headers field when installing as a public library.
[obnox/samba/samba-obnox.git] / lib / param / param.h
1 /* 
2    Unix SMB/CIFS implementation.
3    Generic parameter parsing interface
4    Copyright (C) Jelmer Vernooij                                          2005
5    
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.
10    
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.
15    
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/>.
18 */
19
20 #ifndef _PARAM_H /* _PARAM_H */
21 #define _PARAM_H 
22
23 struct loadparm_s3_helpers;
24
25 struct parmlist_entry;
26
27 struct param_context {
28         struct param_section *sections;
29 };
30
31 struct param_section {
32         const char *name;
33         struct param_section *prev, *next;
34         struct parmlist *parameters;
35 };
36
37 struct param_context;
38 struct smbsrv_connection;
39
40 #define Auto (2)
41
42 #include "libds/common/roles.h"
43
44 struct loadparm_context;
45 struct loadparm_service;
46 struct smbcli_options;
47 struct smbcli_session_options;
48 struct gensec_settings;
49 struct bitmap;
50 struct file_lists;
51
52 typedef bool (*lpcfg_defaults_hook) (struct loadparm_context *);
53
54 #ifdef CONFIG_H_IS_FROM_SAMBA
55 #include "lib/param/param_proto.h"
56 #include "lib/param/param_functions.h"
57 #endif
58
59 const char **lpcfg_interfaces(struct loadparm_context *);
60 const char *lpcfg_realm(struct loadparm_context *);
61 const char *lpcfg_netbios_name(struct loadparm_context *);
62 const char *lpcfg_private_dir(struct loadparm_context *);
63 int lpcfg_server_role(struct loadparm_context *);
64 int lpcfg_allow_dns_updates(struct loadparm_context *);
65
66 void reload_charcnv(struct loadparm_context *lp_ctx);
67
68 struct loadparm_service *lpcfg_default_service(struct loadparm_context *lp_ctx);
69 bool lpcfg_autoloaded(struct loadparm_service *, struct loadparm_service *);
70
71 char *lpcfg_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
72 char *lpcfg_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
73 char *lpcfg_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
74 char *lpcfg_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
75 char *lpcfg_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
76
77 const char *lpcfg_dnsdomain(struct loadparm_context *);
78
79 const char *lpcfg_servicename(const struct loadparm_service *service);
80
81
82 const char *lpcfg_get_parametric(struct loadparm_context *lp_ctx,
83                               struct loadparm_service *service,
84                               const char *type, const char *option);
85
86 const char *lpcfg_parm_string(struct loadparm_context *lp_ctx,
87                            struct loadparm_service *service, const char *type,
88                            const char *option);
89 const char **lpcfg_parm_string_list(TALLOC_CTX *mem_ctx,
90                                  struct loadparm_context *lp_ctx,
91                                  struct loadparm_service *service,
92                                  const char *type,
93                                  const char *option, const char *separator);
94 int lpcfg_parm_int(struct loadparm_context *lp_ctx,
95                 struct loadparm_service *service, const char *type,
96                 const char *option, int default_v);
97 int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
98                   struct loadparm_service *service, const char *type,
99                   const char *option, int default_v);
100 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
101                             struct loadparm_service *service, const char *type,
102                             const char *option, unsigned long default_v);
103 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
104                      struct loadparm_service *service, const char *type,
105                      const char *option, long default_v);
106 double lpcfg_parm_double(struct loadparm_context *lp_ctx,
107                       struct loadparm_service *service, const char *type,
108                       const char *option, double default_v);
109 bool lpcfg_parm_bool(struct loadparm_context *lp_ctx,
110                      struct loadparm_service *service, const char *type,
111                      const char *option, bool default_v);
112 struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
113                                      const struct loadparm_service *pservice,
114                                      const char *name);
115 bool lpcfg_add_home(struct loadparm_context *lp_ctx,
116                  const char *pszHomename,
117                  struct loadparm_service *default_service,
118                  const char *user, const char *pszHomedir);
119 bool lpcfg_add_printer(struct loadparm_context *lp_ctx,
120                     const char *pszPrintername,
121                     struct loadparm_service *default_service);
122 struct parm_struct *lpcfg_parm_struct(struct loadparm_context *lp_ctx, const char *name);
123 void *lpcfg_parm_ptr(struct loadparm_context *lp_ctx,
124                   struct loadparm_service *service, struct parm_struct *parm);
125 bool lpcfg_parm_is_cmdline(struct loadparm_context *lp_ctx, const char *name);
126 bool lpcfg_file_list_changed(struct loadparm_context *lp_ctx);
127
128 bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
129                             const char *pszParmName, const char *pszParmValue);
130 bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
131                              struct loadparm_service *service,
132                              const char *pszParmName, const char *pszParmValue);
133
134 /**
135  * Process a parameter.
136  */
137 bool lpcfg_do_global_parameter_var(struct loadparm_context *lp_ctx,
138                                 const char *pszParmName, const char *fmt, ...);
139 bool lpcfg_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
140                     const char *pszParmValue);
141 bool lpcfg_set_option(struct loadparm_context *lp_ctx, const char *option);
142
143 /**
144  * Display the contents of a single services record.
145  */
146 bool lpcfg_dump_a_parameter(struct loadparm_context *lp_ctx,
147                          struct loadparm_service *service,
148                          const char *parm_name, FILE * f);
149
150 /**
151  * Unload unused services.
152  */
153 void lpcfg_killunused(struct loadparm_context *lp_ctx,
154                    struct smbsrv_connection *smb,
155                    bool (*snumused) (struct smbsrv_connection *, int));
156
157 /**
158  * Initialise the global parameter structure.
159  */
160 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
161 struct loadparm_context *loadparm_init_global(bool load_default);
162 const char *lpcfg_configfile(struct loadparm_context *lp_ctx);
163 bool lpcfg_load_default(struct loadparm_context *lp_ctx);
164 const char *lp_default_path(void);
165
166 /**
167  * Load the services array from the services file.
168  *
169  * Return True on success, False on failure.
170  */
171 bool lpcfg_load(struct loadparm_context *lp_ctx, const char *filename);
172
173 /**
174  * Return the max number of services.
175  */
176 int lpcfg_numservices(struct loadparm_context *lp_ctx);
177
178 /**
179  * Display the contents of the services array in human-readable form.
180  */
181 void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
182              int maxtoprint);
183
184 /**
185  * Display the contents of one service in human-readable form.
186  */
187 void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
188 struct loadparm_service *lpcfg_servicebynum(struct loadparm_context *lp_ctx,
189                                          int snum);
190 struct loadparm_service *lpcfg_service(struct loadparm_context *lp_ctx,
191                                     const char *service_name);
192
193 /**
194  * A useful volume label function.
195  */
196 const char *lp_cfg_volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
197
198 /**
199  * If we are PDC then prefer us as DMB
200  */
201 const char *lpcfg_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
202
203 /**
204  * Return the max print jobs per queue.
205  */
206 int lpcfg_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
207 struct smb_iconv_handle *lpcfg_iconv_handle(struct loadparm_context *lp_ctx);
208 void lpcfg_smbcli_options(struct loadparm_context *lp_ctx,
209                          struct smbcli_options *options);
210 void lpcfg_smbcli_session_options(struct loadparm_context *lp_ctx,
211                                  struct smbcli_session_options *options);
212 const char **lpcfg_smb_ports(struct loadparm_context *);
213 const char *lpcfg_socket_options(struct loadparm_context *);
214 struct dcerpc_server_info *lpcfg_dcerpc_server_info(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
215 struct gensec_settings *lpcfg_gensec_settings(TALLOC_CTX *, struct loadparm_context *);
216
217 /* Hooks to override defaults.
218  *
219  * Every time a loadparm context is initialized, the hooks are
220  * called on it, once Samba itself has set defaults.
221  *
222  * This allows modules to tweak defaults (before any smb.conf file or registry
223  * is loaded). Usually they would do this by calling lpcfg_do_global_parameter
224  * or lpcfg_do_service_parameter.
225  *
226  * A good use case for this is OpenChange, which by default enables its
227  * DCE/RPC services when it is installed.
228  * */
229 bool lpcfg_register_defaults_hook(const char *name, lpcfg_defaults_hook hook);
230
231 /* The following definitions come from param/util.c  */
232
233
234 /**
235  * @file
236  * @brief Misc utility functions
237  */
238 bool lpcfg_is_mydomain(struct loadparm_context *lp_ctx,
239                              const char *domain);
240
241 bool lpcfg_is_my_domain_or_realm(struct loadparm_context *lp_ctx,
242                               const char *domain);
243
244 /**
245   see if a string matches either our primary or one of our secondary 
246   netbios aliases. do a case insensitive match
247 */
248 bool lpcfg_is_myname(struct loadparm_context *lp_ctx, const char *name);
249
250 /**
251  A useful function for returning a path in the Samba lock directory.
252 **/
253 char *lpcfg_lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
254                          const char *name);
255
256 /**
257  * @brief Returns an absolute path to a file in the directory containing the current config file
258  *
259  * @param name File to find, relative to the config file directory.
260  *
261  * @retval Pointer to a talloc'ed string containing the full path.
262  **/
263 char *lpcfg_config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
264                            const char *name);
265
266 /**
267  * @brief Returns an absolute path to a file in the Samba private directory.
268  *
269  * @param name File to find, relative to PRIVATEDIR.
270  * if name is not relative, then use it as-is
271  *
272  * @retval Pointer to a talloc'ed string containing the full path.
273  **/
274 char *lpcfg_private_path(TALLOC_CTX* mem_ctx,
275                             struct loadparm_context *lp_ctx,
276                             const char *name);
277
278 /**
279  * @brief Returns an absolute path to a NTDB or TDB file in the Samba
280  * private directory.
281  *
282  * @param name File to find, relative to PRIVATEDIR, without .tdb extension.
283  *
284  * @retval Pointer to a talloc'ed string containing the full path, for
285  * use with dbwrap_local_open().
286  **/
287 char *lpcfg_private_db_path(TALLOC_CTX *mem_ctx,
288                             struct loadparm_context *lp_ctx,
289                             const char *name);
290
291 /**
292   return a path in the smbd.tmp directory, where all temporary file
293   for smbd go. If NULL is passed for name then return the directory 
294   path itself
295 */
296 char *smbd_tmp_path(TALLOC_CTX *mem_ctx, 
297                              struct loadparm_context *lp_ctx,
298                              const char *name);
299
300 const char *lpcfg_imessaging_path(TALLOC_CTX *mem_ctx,
301                                        struct loadparm_context *lp_ctx);
302 struct smb_iconv_handle *smb_iconv_handle_reinit_lp(TALLOC_CTX *mem_ctx,
303                                                               struct loadparm_context *lp_ctx,
304                                                               struct smb_iconv_handle *old_ic);
305
306 const char *lpcfg_sam_name(struct loadparm_context *lp_ctx);
307
308 void lpcfg_default_kdc_policy(struct loadparm_context *lp_ctx,
309                                 time_t *svc_tkt_lifetime,
310                                 time_t *usr_tkt_lifetime,
311                                 time_t *renewal_lifetime);
312
313 /* The following definitions come from lib/version.c  */
314
315 const char *samba_version_string(void);
316
317
318 #endif /* _PARAM_H */