libsmbconf: Document smbconf_get_share_names().
[Samba.git] / lib / smbconf / smbconf.h
blob0a46874fc5bb9987fd72d0edbfbd9561f05204b5
1 /*
2 * Unix SMB/CIFS implementation.
3 * libsmbconf - Samba configuration library
4 * Copyright (C) Michael Adam 2008
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 __LIBSMBCONF_H__
21 #define __LIBSMBCONF_H__
23 /**
24 * @brief Status codes returned from smbconf functions
26 enum _sbcErrType {
27 SBC_ERR_OK = 0, /**< Successful completion **/
28 SBC_ERR_NOT_IMPLEMENTED, /**< Function not implemented **/
29 SBC_ERR_NOT_SUPPORTED, /**< Function not supported **/
30 SBC_ERR_UNKNOWN_FAILURE, /**< General failure **/
31 SBC_ERR_NOMEM, /**< Memory allocation error **/
32 SBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/
33 SBC_ERR_BADFILE, /**< A bad file was supplied **/
34 SBC_ERR_NO_SUCH_SERVICE, /**< There is no such service provided **/
35 SBC_ERR_IO_FAILURE, /**< There was an IO error **/
36 SBC_ERR_CAN_NOT_COMPLETE,/**< Can not complete action **/
37 SBC_ERR_NO_MORE_ITEMS, /**< No more items left **/
38 SBC_ERR_FILE_EXISTS, /**< File already exists **/
39 SBC_ERR_ACCESS_DENIED, /**< Access has been denied **/
42 typedef enum _sbcErrType sbcErr;
44 #define SBC_ERROR_IS_OK(x) ((x) == SBC_ERR_OK)
45 #define SBC_ERROR_EQUAL(x,y) ((x) == (y))
47 struct smbconf_ctx;
49 /* the change sequence number */
50 struct smbconf_csn {
51 uint64_t csn;
54 /** Information about a service */
55 struct smbconf_service {
56 char *name; /**< The name of the share */
57 uint32_t num_params; /**< List of length num_shares of parameter counts for each share */
58 char **param_names; /**< List of lists of parameter names for each share */
59 char **param_values; /**< List of lists of parameter values for each share */
63 * The smbconf API functions
66 /**
67 * @brief Translate an error value into a string
69 * @param error
71 * @return a pointer to a static string
72 **/
73 const char *sbcErrorString(sbcErr error);
75 /**
76 * @brief Check if the backend requires messaging to be set up.
78 * Tell whether the backend requires messaging to be set up
79 * for the backend to work correctly.
81 * @param[in] ctx The smbconf context to check.
83 * @return True if needed, false if not.
85 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
87 /**
88 * @brief Tell whether the source is writeable.
90 * @param[in] ctx The smbconf context to check.
92 * @return True if it is writeable, false if not.
94 bool smbconf_is_writeable(struct smbconf_ctx *ctx);
96 /**
97 * @brief Close the configuration.
99 * @param[in] ctx The smbconf context to close.
101 void smbconf_shutdown(struct smbconf_ctx *ctx);
104 * @brief Detect changes in the configuration.
106 * Get the change sequence number of the given service/parameter. Service and
107 * parameter strings may be NULL.
109 * The given change sequence number (csn) struct is filled with the current
110 * csn. smbconf_changed() can also be used for initial retrieval of the csn.
112 * @param[in] ctx The smbconf context to check for changes.
114 * @param[inout] csn The smbconf csn to be filled.
116 * @param[in] service The service name to check or NULL.
118 * @param[in] param The param to check or NULL.
120 * @return True if it has been changed, false if not.
122 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
123 const char *service, const char *param);
126 * @brief Drop the whole configuration (restarting empty).
128 * @param[in] ctx The smbconf context to drop the config.
130 * @return SBC_ERR_OK on success, a corresponding sbcErr if an
131 * error occured.
133 sbcErr smbconf_drop(struct smbconf_ctx *ctx);
136 * @brief Get the whole configuration as lists of strings with counts.
138 * @param[in] ctx The smbconf context to get the lists from.
140 * @param[in] mem_ctx The memory context to use.
142 * @param[in] num_shares A pointer to store the number of shares.
144 * @param[out] services A pointer to store the services.
146 * @return SBC_ERR_OK on success, a corresponding sbcErr if an
147 * error occured.
149 * @see smbconf_service
151 sbcErr smbconf_get_config(struct smbconf_ctx *ctx,
152 TALLOC_CTX *mem_ctx,
153 uint32_t *num_shares,
154 struct smbconf_service ***services);
157 * @brief Get the list of share names defined in the configuration.
159 * @param[in] ctx The smbconf context to use.
161 * @param[in] mem_ctx The memory context to use.
163 * @param[in] num_shares A pointer to store the number of shares.
165 * @param[in] share_names A pointer to store the share names.
167 * @return SBC_ERR_OK on success, a corresponding sbcErr if an
168 * error occured.
170 sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
171 TALLOC_CTX *mem_ctx,
172 uint32_t *num_shares,
173 char ***share_names);
175 bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename);
176 sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
177 sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
178 TALLOC_CTX *mem_ctx,
179 const char *servicename,
180 struct smbconf_service **service);
181 sbcErr smbconf_delete_share(struct smbconf_ctx *ctx,
182 const char *servicename);
183 sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
184 const char *service,
185 const char *param,
186 const char *valstr);
187 sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
188 const char *param, const char *val);
189 sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx,
190 TALLOC_CTX *mem_ctx,
191 const char *service,
192 const char *param,
193 char **valstr);
194 sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx,
195 TALLOC_CTX *mem_ctx,
196 const char *param,
197 char **valstr);
198 sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx,
199 const char *service, const char *param);
200 sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
201 const char *param);
202 sbcErr smbconf_get_includes(struct smbconf_ctx *ctx,
203 TALLOC_CTX *mem_ctx,
204 const char *service,
205 uint32_t *num_includes, char ***includes);
206 sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
207 TALLOC_CTX *mem_ctx,
208 uint32_t *num_includes, char ***includes);
209 sbcErr smbconf_set_includes(struct smbconf_ctx *ctx,
210 const char *service,
211 uint32_t num_includes, const char **includes);
212 sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx,
213 uint32_t num_includes,
214 const char **includes);
215 sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
216 sbcErr smbconf_delete_global_includes(struct smbconf_ctx *ctx);
218 sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx);
219 sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx);
220 sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx);
222 #endif /* _LIBSMBCONF_H_ */