libsmbconf: Convert smbconf_get_includes() to sbcErr.
[Samba.git] / lib / smbconf / smbconf.h
blob672c2564808388b6c084c7b6f6cd2ca8349731c5
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 struct smbconf_service {
55 char *name;
56 uint32_t num_params;
57 char **param_names;
58 char **param_values;
61 /**
62 * @brief Translate an error value into a string
64 * @param error
66 * @return a pointer to a static string
67 **/
68 const char *sbcErrorString(sbcErr error);
71 * the smbconf API functions
73 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
74 bool smbconf_is_writeable(struct smbconf_ctx *ctx);
75 void smbconf_shutdown(struct smbconf_ctx *ctx);
76 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
77 const char *service, const char *param);
78 sbcErr smbconf_drop(struct smbconf_ctx *ctx);
79 WERROR smbconf_get_config(struct smbconf_ctx *ctx,
80 TALLOC_CTX *mem_ctx,
81 uint32_t *num_shares,
82 struct smbconf_service ***services);
83 sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
84 TALLOC_CTX *mem_ctx,
85 uint32_t *num_shares,
86 char ***share_names);
87 bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename);
88 sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
89 sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
90 TALLOC_CTX *mem_ctx,
91 const char *servicename,
92 struct smbconf_service **service);
93 sbcErr smbconf_delete_share(struct smbconf_ctx *ctx,
94 const char *servicename);
95 sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
96 const char *service,
97 const char *param,
98 const char *valstr);
99 sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
100 const char *param, const char *val);
101 sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx,
102 TALLOC_CTX *mem_ctx,
103 const char *service,
104 const char *param,
105 char **valstr);
106 sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx,
107 TALLOC_CTX *mem_ctx,
108 const char *param,
109 char **valstr);
110 sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx,
111 const char *service, const char *param);
112 sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
113 const char *param);
114 sbcErr smbconf_get_includes(struct smbconf_ctx *ctx,
115 TALLOC_CTX *mem_ctx,
116 const char *service,
117 uint32_t *num_includes, char ***includes);
118 sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
119 TALLOC_CTX *mem_ctx,
120 uint32_t *num_includes, char ***includes);
121 WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
122 const char *service,
123 uint32_t num_includes, const char **includes);
124 WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
125 uint32_t num_includes,
126 const char **includes);
127 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
128 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx);
130 WERROR smbconf_transaction_start(struct smbconf_ctx *ctx);
131 WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx);
132 WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx);
134 #endif /* _LIBSMBCONF_H_ */