9ff9a83fad281539b821f25c78d034c4852afd86
[ira/wip.git] / source3 / lib / smbconf / smbconf.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  libsmbconf - Samba configuration library
4  *  Copyright (C) Michael Adam 2008
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 __LIBSMBCONF_H__
21 #define __LIBSMBCONF_H__
22
23 struct smbconf_ctx;
24
25 /* the change sequence number */
26 struct smbconf_csn {
27         uint64_t csn;
28 };
29
30 struct smbconf_service {
31         char *name;
32         uint32_t num_params;
33         char **param_names;
34         char **param_values;
35 };
36
37
38 /**
39  * intialization dispatcher function.
40  * takes source string in the form of "backend:path"
41  */
42 WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
43                     const char *source);
44
45 /**
46  * initialization functions for the available modules
47  */
48
49 WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
50                         const char *path);
51
52 WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
53                         struct smbconf_ctx **conf_ctx,
54                         const char *path);
55
56 /*
57  * the smbconf API functions
58  */
59 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
60 bool smbconf_is_writeable(struct smbconf_ctx *ctx);
61 void smbconf_shutdown(struct smbconf_ctx *ctx);
62 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
63                      const char *service, const char *param);
64 WERROR smbconf_drop(struct smbconf_ctx *ctx);
65 WERROR smbconf_get_config(struct smbconf_ctx *ctx,
66                           TALLOC_CTX *mem_ctx,
67                           uint32_t *num_shares,
68                           struct smbconf_service ***services);
69 WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
70                                TALLOC_CTX *mem_ctx,
71                                uint32_t *num_shares,
72                                char ***share_names);
73 bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename);
74 WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
75 WERROR smbconf_get_share(struct smbconf_ctx *ctx,
76                          TALLOC_CTX *mem_ctx,
77                          const char *servicename,
78                          struct smbconf_service **service);
79 WERROR smbconf_delete_share(struct smbconf_ctx *ctx,
80                             const char *servicename);
81 WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
82                              const char *service,
83                              const char *param,
84                              const char *valstr);
85 WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
86                                     const char *param, const char *val);
87 WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
88                              TALLOC_CTX *mem_ctx,
89                              const char *service,
90                              const char *param,
91                              char **valstr);
92 WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
93                                     TALLOC_CTX *mem_ctx,
94                                     const char *param,
95                                     char **valstr);
96 WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
97                                 const char *service, const char *param);
98 WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
99                                        const char *param);
100 WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
101                             TALLOC_CTX *mem_ctx,
102                             const char *service,
103                             uint32_t *num_includes, char ***includes);
104 WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx,
105                                    TALLOC_CTX *mem_ctx,
106                                    uint32_t *num_includes, char ***includes);
107 WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
108                             const char *service,
109                             uint32_t num_includes, const char **includes);
110 WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
111                                    uint32_t num_includes,
112                                    const char **includes);
113 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
114 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx);
115
116 #endif /*  _LIBSMBCONF_H_  */