Changeset 740 for vendor/current/lib/smbconf
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/lib/smbconf
- Files:
-
- 1 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/smbconf/smbconf.c
r414 r740 28 28 **********************************************************************/ 29 29 30 static WERRORsmbconf_global_check(struct smbconf_ctx *ctx)30 static sbcErr smbconf_global_check(struct smbconf_ctx *ctx) 31 31 { 32 32 if (!smbconf_share_exists(ctx, GLOBAL_NAME)) { 33 33 return smbconf_create_share(ctx, GLOBAL_NAME); 34 34 } 35 return WERR_OK; 35 36 return SBC_ERR_OK; 36 37 } 37 38 … … 42 43 * 43 44 **********************************************************************/ 45 46 const char *sbcErrorString(sbcErr error) 47 { 48 switch (error) { 49 case SBC_ERR_OK: 50 return "SBC_ERR_OK"; 51 case SBC_ERR_NOT_IMPLEMENTED: 52 return "SBC_ERR_NOT_IMPLEMENTED"; 53 case SBC_ERR_NOT_SUPPORTED: 54 return "SBC_ERR_NOT_SUPPORTED"; 55 case SBC_ERR_UNKNOWN_FAILURE: 56 return "SBC_ERR_UNKNOWN_FAILURE"; 57 case SBC_ERR_NOMEM: 58 return "SBC_ERR_NOMEM"; 59 case SBC_ERR_INVALID_PARAM: 60 return "SBC_ERR_INVALID_PARAM"; 61 case SBC_ERR_BADFILE: 62 return "SBC_ERR_BADFILE"; 63 case SBC_ERR_NO_SUCH_SERVICE: 64 return "SBC_ERR_NO_SUCH_SERVICE"; 65 case SBC_ERR_IO_FAILURE: 66 return "SBC_ERR_IO_FAILURE"; 67 case SBC_ERR_CAN_NOT_COMPLETE: 68 return "SBC_ERR_CAN_NOT_COMPLETE"; 69 case SBC_ERR_NO_MORE_ITEMS: 70 return "SBC_ERR_NO_MORE_ITEMS"; 71 case SBC_ERR_FILE_EXISTS: 72 return "SBC_ERR_FILE_EXISTS"; 73 case SBC_ERR_ACCESS_DENIED: 74 return "SBC_ERR_ACCESS_DENIED"; 75 } 76 77 return "unknown sbcErr value"; 78 } 79 44 80 45 81 /** … … 92 128 * Drop the whole configuration (restarting empty). 93 129 */ 94 WERRORsmbconf_drop(struct smbconf_ctx *ctx)130 sbcErr smbconf_drop(struct smbconf_ctx *ctx) 95 131 { 96 132 return ctx->ops->drop(ctx); … … 106 142 * param_values : list of lists of parameter values for each share 107 143 */ 108 WERRORsmbconf_get_config(struct smbconf_ctx *ctx,144 sbcErr smbconf_get_config(struct smbconf_ctx *ctx, 109 145 TALLOC_CTX *mem_ctx, 110 146 uint32_t *num_shares, 111 147 struct smbconf_service ***services) 112 148 { 113 WERROR werr = WERR_OK;149 sbcErr err; 114 150 TALLOC_CTX *tmp_ctx = NULL; 115 151 uint32_t tmp_num_shares; … … 119 155 120 156 if ((num_shares == NULL) || (services == NULL)) { 121 werr = WERR_INVALID_PARAM;157 err = SBC_ERR_INVALID_PARAM; 122 158 goto done; 123 159 } … … 125 161 tmp_ctx = talloc_stackframe(); 126 162 127 werr = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares,128 129 if (! W_ERROR_IS_OK(werr)) {163 err = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares, 164 &tmp_share_names); 165 if (!SBC_ERROR_IS_OK(err)) { 130 166 goto done; 131 167 } … … 133 169 tmp_services = talloc_array(tmp_ctx, struct smbconf_service *, 134 170 tmp_num_shares); 135 136 171 if (tmp_services == NULL) { 137 werr = WERR_NOMEM;172 err = SBC_ERR_NOMEM; 138 173 goto done; 139 174 } 140 175 141 176 for (count = 0; count < tmp_num_shares; count++) { 142 werr = smbconf_get_share(ctx, tmp_services,143 144 145 if (! W_ERROR_IS_OK(werr)) {177 err = smbconf_get_share(ctx, tmp_services, 178 tmp_share_names[count], 179 &tmp_services[count]); 180 if (!SBC_ERROR_IS_OK(err)) { 146 181 goto done; 147 182 } 148 183 } 149 184 150 werr = WERR_OK;185 err = SBC_ERR_OK; 151 186 152 187 *num_shares = tmp_num_shares; … … 159 194 done: 160 195 talloc_free(tmp_ctx); 161 return werr;196 return err; 162 197 } 163 198 … … 165 200 * get the list of share names defined in the configuration. 166 201 */ 167 WERRORsmbconf_get_share_names(struct smbconf_ctx *ctx,202 sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx, 168 203 TALLOC_CTX *mem_ctx, 169 204 uint32_t *num_shares, … … 186 221 * Add a service if it does not already exist. 187 222 */ 188 WERRORsmbconf_create_share(struct smbconf_ctx *ctx,223 sbcErr smbconf_create_share(struct smbconf_ctx *ctx, 189 224 const char *servicename) 190 225 { 191 226 if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) { 192 return WERR_FILE_EXISTS;227 return SBC_ERR_FILE_EXISTS; 193 228 } 194 229 … … 199 234 * get a definition of a share (service) from configuration. 200 235 */ 201 WERRORsmbconf_get_share(struct smbconf_ctx *ctx,236 sbcErr smbconf_get_share(struct smbconf_ctx *ctx, 202 237 TALLOC_CTX *mem_ctx, 203 238 const char *servicename, … … 210 245 * delete a service from configuration 211 246 */ 212 WERRORsmbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)247 sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename) 213 248 { 214 249 if (!smbconf_share_exists(ctx, servicename)) { 215 return WERR_NO_SUCH_SERVICE;250 return SBC_ERR_NO_SUCH_SERVICE; 216 251 } 217 252 … … 222 257 * set a configuration parameter to the value provided. 223 258 */ 224 WERRORsmbconf_set_parameter(struct smbconf_ctx *ctx,259 sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx, 225 260 const char *service, 226 261 const char *param, … … 236 271 * This also creates [global] when it does not exist. 237 272 */ 238 WERRORsmbconf_set_global_parameter(struct smbconf_ctx *ctx,273 sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, 239 274 const char *param, const char *val) 240 275 { 241 WERROR werr; 242 243 werr = smbconf_global_check(ctx); 244 if (W_ERROR_IS_OK(werr)) { 245 werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val); 246 } 247 248 return werr; 276 sbcErr err; 277 278 err = smbconf_global_check(ctx); 279 if (!SBC_ERROR_IS_OK(err)) { 280 return err; 281 } 282 err = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val); 283 284 return err; 249 285 } 250 286 … … 252 288 * get the value of a configuration parameter as a string 253 289 */ 254 WERRORsmbconf_get_parameter(struct smbconf_ctx *ctx,290 sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx, 255 291 TALLOC_CTX *mem_ctx, 256 292 const char *service, … … 259 295 { 260 296 if (valstr == NULL) { 261 return WERR_INVALID_PARAM;297 return SBC_ERR_INVALID_PARAM; 262 298 } 263 299 … … 270 306 * Create [global] if it does not exist. 271 307 */ 272 WERRORsmbconf_get_global_parameter(struct smbconf_ctx *ctx,308 sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, 273 309 TALLOC_CTX *mem_ctx, 274 310 const char *param, 275 311 char **valstr) 276 312 { 277 WERROR werr; 278 279 werr = smbconf_global_check(ctx); 280 if (W_ERROR_IS_OK(werr)) { 281 werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, 282 valstr); 283 } 284 285 return werr; 313 sbcErr err; 314 315 err = smbconf_global_check(ctx); 316 if (!SBC_ERROR_IS_OK(err)) { 317 return err; 318 } 319 320 err = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param, 321 valstr); 322 323 return err; 286 324 } 287 325 … … 289 327 * delete a parameter from configuration 290 328 */ 291 WERRORsmbconf_delete_parameter(struct smbconf_ctx *ctx,329 sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, 292 330 const char *service, const char *param) 293 331 { … … 300 338 * Create [global] if it does not exist. 301 339 */ 302 WERRORsmbconf_delete_global_parameter(struct smbconf_ctx *ctx,340 sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, 303 341 const char *param) 304 342 { 305 WERROR werr; 306 307 werr = smbconf_global_check(ctx); 308 if (W_ERROR_IS_OK(werr)) { 309 werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); 310 } 311 312 return werr; 313 } 314 315 WERROR smbconf_get_includes(struct smbconf_ctx *ctx, 343 sbcErr err; 344 345 err = smbconf_global_check(ctx); 346 if (!SBC_ERROR_IS_OK(err)) { 347 return err; 348 } 349 err = smbconf_delete_parameter(ctx, GLOBAL_NAME, param); 350 351 return err; 352 } 353 354 sbcErr smbconf_get_includes(struct smbconf_ctx *ctx, 316 355 TALLOC_CTX *mem_ctx, 317 356 const char *service, … … 322 361 } 323 362 324 WERRORsmbconf_get_global_includes(struct smbconf_ctx *ctx,363 sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx, 325 364 TALLOC_CTX *mem_ctx, 326 365 uint32_t *num_includes, char ***includes) 327 366 { 328 WERROR werr; 329 330 werr = smbconf_global_check(ctx); 331 if (W_ERROR_IS_OK(werr)) { 332 werr = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME, 333 num_includes, includes); 334 } 335 336 return werr; 337 } 338 339 WERROR smbconf_set_includes(struct smbconf_ctx *ctx, 367 sbcErr err; 368 369 err = smbconf_global_check(ctx); 370 if (!SBC_ERROR_IS_OK(err)) { 371 return err; 372 } 373 err = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME, 374 num_includes, includes); 375 376 return err; 377 } 378 379 sbcErr smbconf_set_includes(struct smbconf_ctx *ctx, 340 380 const char *service, 341 381 uint32_t num_includes, const char **includes) … … 344 384 } 345 385 346 WERRORsmbconf_set_global_includes(struct smbconf_ctx *ctx,386 sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx, 347 387 uint32_t num_includes, 348 388 const char **includes) 349 389 { 350 WERROR werr; 351 352 werr = smbconf_global_check(ctx); 353 if (W_ERROR_IS_OK(werr)) { 354 werr = smbconf_set_includes(ctx, GLOBAL_NAME, 355 num_includes, includes); 356 } 357 358 return werr; 359 } 360 361 362 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service) 390 sbcErr err; 391 392 err = smbconf_global_check(ctx); 393 if (!SBC_ERROR_IS_OK(err)) { 394 return err; 395 } 396 err = smbconf_set_includes(ctx, GLOBAL_NAME, 397 num_includes, includes); 398 399 return err; 400 } 401 402 403 sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service) 363 404 { 364 405 return ctx->ops->delete_includes(ctx, service); 365 406 } 366 407 367 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx) 368 { 369 WERROR werr; 370 371 werr = smbconf_global_check(ctx); 372 if (W_ERROR_IS_OK(werr)) { 373 werr = smbconf_delete_includes(ctx, GLOBAL_NAME); 374 } 375 376 return werr; 377 } 378 379 WERROR smbconf_transaction_start(struct smbconf_ctx *ctx) 408 sbcErr smbconf_delete_global_includes(struct smbconf_ctx *ctx) 409 { 410 sbcErr err; 411 412 err = smbconf_global_check(ctx); 413 if (!SBC_ERROR_IS_OK(err)) { 414 return err; 415 } 416 err = smbconf_delete_includes(ctx, GLOBAL_NAME); 417 418 return err; 419 } 420 421 sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx) 380 422 { 381 423 return ctx->ops->transaction_start(ctx); 382 424 } 383 425 384 WERRORsmbconf_transaction_commit(struct smbconf_ctx *ctx)426 sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx) 385 427 { 386 428 return ctx->ops->transaction_commit(ctx); 387 429 } 388 430 389 WERRORsmbconf_transaction_cancel(struct smbconf_ctx *ctx)431 sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx) 390 432 { 391 433 return ctx->ops->transaction_cancel(ctx); -
vendor/current/lib/smbconf/smbconf.h
r414 r740 21 21 #define __LIBSMBCONF_H__ 22 22 23 /** 24 * @defgroup libsmbconf The smbconf API 25 * 26 * libsmbconf is a library to read or, based on the backend, modify the Samba 27 * configuration. 28 * 29 * @{ 30 */ 31 32 /** 33 * @brief Status codes returned from smbconf functions 34 */ 35 enum _sbcErrType { 36 SBC_ERR_OK = 0, /**< Successful completion **/ 37 SBC_ERR_NOT_IMPLEMENTED, /**< Function not implemented **/ 38 SBC_ERR_NOT_SUPPORTED, /**< Function not supported **/ 39 SBC_ERR_UNKNOWN_FAILURE, /**< General failure **/ 40 SBC_ERR_NOMEM, /**< Memory allocation error **/ 41 SBC_ERR_INVALID_PARAM, /**< An Invalid parameter was supplied **/ 42 SBC_ERR_BADFILE, /**< A bad file was supplied **/ 43 SBC_ERR_NO_SUCH_SERVICE, /**< There is no such service provided **/ 44 SBC_ERR_IO_FAILURE, /**< There was an IO error **/ 45 SBC_ERR_CAN_NOT_COMPLETE,/**< Can not complete action **/ 46 SBC_ERR_NO_MORE_ITEMS, /**< No more items left **/ 47 SBC_ERR_FILE_EXISTS, /**< File already exists **/ 48 SBC_ERR_ACCESS_DENIED, /**< Access has been denied **/ 49 }; 50 51 typedef enum _sbcErrType sbcErr; 52 53 #define SBC_ERROR_IS_OK(x) ((x) == SBC_ERR_OK) 54 #define SBC_ERROR_EQUAL(x,y) ((x) == (y)) 55 23 56 struct smbconf_ctx; 24 57 … … 28 61 }; 29 62 63 /** Information about a service */ 30 64 struct smbconf_service { 31 char *name; 32 uint32_t num_params; 33 char **param_names; 34 char **param_values; 65 char *name; /**< The name of the share */ 66 uint32_t num_params; /**< List of length num_shares of parameter counts for each share */ 67 char **param_names; /**< List of lists of parameter names for each share */ 68 char **param_values; /**< List of lists of parameter values for each share */ 35 69 }; 36 70 37 71 /* 38 * the smbconf API functions 72 * The smbconf API functions 73 */ 74 75 /** 76 * @brief Translate an error value into a string 77 * 78 * @param error 79 * 80 * @return a pointer to a static string 81 **/ 82 const char *sbcErrorString(sbcErr error); 83 84 /** 85 * @brief Check if the backend requires messaging to be set up. 86 * 87 * Tell whether the backend requires messaging to be set up 88 * for the backend to work correctly. 89 * 90 * @param[in] ctx The smbconf context to check. 91 * 92 * @return True if needed, false if not. 39 93 */ 40 94 bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx); 95 96 /** 97 * @brief Tell whether the source is writeable. 98 * 99 * @param[in] ctx The smbconf context to check. 100 * 101 * @return True if it is writeable, false if not. 102 */ 41 103 bool smbconf_is_writeable(struct smbconf_ctx *ctx); 104 105 /** 106 * @brief Close the configuration. 107 * 108 * @param[in] ctx The smbconf context to close. 109 */ 42 110 void smbconf_shutdown(struct smbconf_ctx *ctx); 111 112 /** 113 * @brief Detect changes in the configuration. 114 * 115 * Get the change sequence number of the given service/parameter. Service and 116 * parameter strings may be NULL. 117 * 118 * The given change sequence number (csn) struct is filled with the current 119 * csn. smbconf_changed() can also be used for initial retrieval of the csn. 120 * 121 * @param[in] ctx The smbconf context to check for changes. 122 * 123 * @param[inout] csn The smbconf csn to be filled. 124 * 125 * @param[in] service The service name to check or NULL. 126 * 127 * @param[in] param The param to check or NULL. 128 * 129 * @return True if it has been changed, false if not. 130 */ 43 131 bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn, 44 132 const char *service, const char *param); 45 WERROR smbconf_drop(struct smbconf_ctx *ctx); 46 WERROR smbconf_get_config(struct smbconf_ctx *ctx, 133 134 /** 135 * @brief Drop the whole configuration (restarting empty). 136 * 137 * @param[in] ctx The smbconf context to drop the config. 138 * 139 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 140 * error occured. 141 */ 142 sbcErr smbconf_drop(struct smbconf_ctx *ctx); 143 144 /** 145 * @brief Get the whole configuration as lists of strings with counts. 146 * 147 * @param[in] ctx The smbconf context to get the lists from. 148 * 149 * @param[in] mem_ctx The memory context to use. 150 * 151 * @param[in] num_shares A pointer to store the number of shares. 152 * 153 * @param[out] services A pointer to store the services. 154 * 155 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 156 * error occured. 157 * 158 * @see smbconf_service 159 */ 160 sbcErr smbconf_get_config(struct smbconf_ctx *ctx, 47 161 TALLOC_CTX *mem_ctx, 48 162 uint32_t *num_shares, 49 163 struct smbconf_service ***services); 50 WERROR smbconf_get_share_names(struct smbconf_ctx *ctx, 164 165 /** 166 * @brief Get the list of share names defined in the configuration. 167 * 168 * @param[in] ctx The smbconf context to use. 169 * 170 * @param[in] mem_ctx The memory context to use. 171 * 172 * @param[in] num_shares A pointer to store the number of shares. 173 * 174 * @param[in] share_names A pointer to store the share names. 175 * 176 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 177 * error occured. 178 */ 179 sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx, 51 180 TALLOC_CTX *mem_ctx, 52 181 uint32_t *num_shares, 53 182 char ***share_names); 183 184 /** 185 * @brief Check if a share/service of a given name exists. 186 * 187 * @param[in] ctx The smbconf context to use. 188 * 189 * @param[in] servicename The service name to check if it exists. 190 * 191 * @return True if it exists, false if not. 192 */ 54 193 bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename); 55 WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename); 56 WERROR smbconf_get_share(struct smbconf_ctx *ctx, 194 195 /** 196 * @brief Add a service if it does not already exist. 197 * 198 * @param[in] ctx The smbconf context to use. 199 * 200 * @param[in] servicename The name of the service to add. 201 * 202 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 203 * error occured. 204 */ 205 sbcErr smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename); 206 207 /** 208 * @brief Get a definition of a share (service) from configuration. 209 * 210 * @param[in] ctx The smbconf context to use. 211 * 212 * @param[in] mem_ctx A memory context to allocate the result. 213 * 214 * @param[in] servicename The service name to get the information from. 215 * 216 * @param[out] service A pointer to store the service information about the 217 * share. 218 * 219 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 220 * error occured. 221 * 222 * @see smbconf_service 223 */ 224 sbcErr smbconf_get_share(struct smbconf_ctx *ctx, 57 225 TALLOC_CTX *mem_ctx, 58 226 const char *servicename, 59 227 struct smbconf_service **service); 60 WERROR smbconf_delete_share(struct smbconf_ctx *ctx, 228 229 /** 230 * @brief Delete a service from configuration. 231 * 232 * @param[in] ctx The smbconf context to use. 233 * 234 * @param[in] servicename The service name to delete. 235 * 236 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 237 * error occured. 238 */ 239 sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, 61 240 const char *servicename); 62 WERROR smbconf_set_parameter(struct smbconf_ctx *ctx, 241 242 /** 243 * @brief Set a configuration parameter to the value provided. 244 * 245 * @param[in] ctx The smbconf context to use. 246 * 247 * @param[in] service The service name to set the parameter. 248 * 249 * @param[in] param The name of the parameter to set. 250 * 251 * @param[in] valstr The value to set. 252 * 253 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 254 * error occured. 255 */ 256 sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx, 63 257 const char *service, 64 258 const char *param, 65 259 const char *valstr); 66 WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx, 260 261 /** 262 * @brief Set a global configuration parameter to the value provided. 263 * 264 * This adds a paramet in the [global] service. It also creates [global] if it 265 * does't exist. 266 * 267 * @param[in] ctx The smbconf context to use. 268 * 269 * @param[in] param The name of the parameter to set. 270 * 271 * @param[in] val The value to set. 272 * 273 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 274 * error occured. 275 */ 276 sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx, 67 277 const char *param, const char *val); 68 WERROR smbconf_get_parameter(struct smbconf_ctx *ctx, 278 279 /** 280 * @brief Get the value of a configuration parameter as a string. 281 * 282 * @param[in] ctx The smbconf context to use. 283 * 284 * @param[in] mem_ctx The memory context to allocate the string on. 285 * 286 * @param[in] service The name of the service where to find the parameter. 287 * 288 * @param[in] param The parameter to get. 289 * 290 * @param[out] valstr A pointer to store the value as a string. 291 * 292 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 293 * error occured. 294 */ 295 sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx, 69 296 TALLOC_CTX *mem_ctx, 70 297 const char *service, 71 298 const char *param, 72 299 char **valstr); 73 WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx, 300 301 /** 302 * @brief Get the value of a global configuration parameter as a string. 303 * 304 * It also creates [global] if it does't exist. 305 * 306 * @param[in] ctx The smbconf context to use. 307 * 308 * @param[in] mem_ctx The memory context to allocate the string on. 309 * 310 * @param[in] param The parameter to get. 311 * 312 * @param[out] valstr A pointer to store the value as a string. 313 * 314 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 315 * error occured. 316 */ 317 sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx, 74 318 TALLOC_CTX *mem_ctx, 75 319 const char *param, 76 320 char **valstr); 77 WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx, 321 322 /** 323 * @brief Delete a parameter from the configuration. 324 * 325 * @param[in] ctx The smbconf context to use. 326 * 327 * @param[in] service The service where the parameter can be found. 328 * 329 * @param[in] param The name of the parameter to delete. 330 * 331 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 332 * error occured. 333 */ 334 sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx, 78 335 const char *service, const char *param); 79 WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx, 336 337 /** 338 * @brief Delete a global parameter from the configuration. 339 * 340 * It also creates [global] if it does't exist. 341 * 342 * @param[in] ctx The smbconf context to use. 343 * 344 * @param[in] param The name of the parameter to delete. 345 * 346 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 347 * error occured. 348 */ 349 sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx, 80 350 const char *param); 81 WERROR smbconf_get_includes(struct smbconf_ctx *ctx, 351 352 /** 353 * @brief Get the list of names of included files. 354 * 355 * @param[in] ctx The smbconf context to use. 356 * 357 * @param[in] mem_ctx The memory context to allocate the names. 358 * 359 * @param[in] service The service name to get the include files. 360 * 361 * @param[out] num_includes A pointer to store the number of included files. 362 * 363 * @param[out] includes A pointer to store the paths of the included files. 364 * 365 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 366 * error occured. 367 */ 368 sbcErr smbconf_get_includes(struct smbconf_ctx *ctx, 82 369 TALLOC_CTX *mem_ctx, 83 370 const char *service, 84 371 uint32_t *num_includes, char ***includes); 85 WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx, 372 373 /** 374 * @brief Get the list of globally included files. 375 * 376 * @param[in] ctx The smbconf context to use. 377 * 378 * @param[in] mem_ctx The memory context to allocate the names. 379 * 380 * @param[out] num_includes A pointer to store the number of included files. 381 * 382 * @param[out] includes A pointer to store the paths of the included files. 383 * 384 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 385 * error occured. 386 */ 387 sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx, 86 388 TALLOC_CTX *mem_ctx, 87 389 uint32_t *num_includes, char ***includes); 88 WERROR smbconf_set_includes(struct smbconf_ctx *ctx, 390 391 /** 392 * @brief Set a list of config files to include on the given service. 393 * 394 * @param[in] ctx The smbconf context to use. 395 * 396 * @param[in] service The service to add includes. 397 * 398 * @param[in] num_includes The number of includes to set. 399 * 400 * @param[in] includes A list of paths to include. 401 * 402 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 403 * error occured. 404 */ 405 sbcErr smbconf_set_includes(struct smbconf_ctx *ctx, 89 406 const char *service, 90 407 uint32_t num_includes, const char **includes); 91 WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx, 408 409 /** 410 * @brief Set a list of config files to include globally. 411 * 412 * @param[in] ctx The smbconf context to use. 413 * 414 * @param[in] num_includes The number of includes to set. 415 * 416 * @param[in] includes A list of paths to include. 417 * 418 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 419 * error occured. 420 */ 421 sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx, 92 422 uint32_t num_includes, 93 423 const char **includes); 94 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service); 95 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx); 96 97 WERROR smbconf_transaction_start(struct smbconf_ctx *ctx); 98 WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx); 99 WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx); 424 425 /** 426 * @brief Delete include parameter on the given service. 427 * 428 * @param[in] ctx The smbconf context to use. 429 * 430 * @param[in] service The name of the service to delete the includes from. 431 * 432 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 433 * error occured. 434 */ 435 sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service); 436 437 /** 438 * @brief Delete include parameter from the global service. 439 * 440 * @param[in] ctx The smbconf context to use. 441 * 442 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 443 * error occured. 444 */ 445 sbcErr smbconf_delete_global_includes(struct smbconf_ctx *ctx); 446 447 /** 448 * @brief Start a transaction on the configuration backend. 449 * 450 * This is to speed up writes to the registry based backend. 451 * 452 * @param[in] ctx The smbconf context to start the transaction. 453 * 454 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 455 * error occured. 456 */ 457 sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx); 458 459 /** 460 * @brief Commit a transaction on the configuration backend. 461 * 462 * This is to speed up writes to the registry based backend. 463 * 464 * @param[in] ctx The smbconf context to commit the transaction. 465 * 466 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 467 * error occured. 468 * 469 * @see smbconf_transaction_start() 470 */ 471 sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx); 472 473 /** 474 * @brief Cancel a transaction on the configuration backend. 475 * 476 * @param[in] ctx The smbconf context to cancel the transaction. 477 * 478 * @return SBC_ERR_OK on success, a corresponding sbcErr if an 479 * error occured. 480 * 481 * @see smbconf_transaction_start() 482 */ 483 sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx); 484 485 /* @} ******************************************************************/ 100 486 101 487 #endif /* _LIBSMBCONF_H_ */ -
vendor/current/lib/smbconf/smbconf_private.h
r414 r740 28 28 29 29 struct smbconf_ops { 30 WERROR(*init)(struct smbconf_ctx *ctx, const char *path);30 sbcErr (*init)(struct smbconf_ctx *ctx, const char *path); 31 31 int (*shutdown)(struct smbconf_ctx *ctx); 32 32 bool (*requires_messaging)(struct smbconf_ctx *ctx); 33 33 bool (*is_writeable)(struct smbconf_ctx *ctx); 34 WERROR(*open_conf)(struct smbconf_ctx *ctx);34 sbcErr (*open_conf)(struct smbconf_ctx *ctx); 35 35 int (*close_conf)(struct smbconf_ctx *ctx); 36 36 void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn, 37 37 const char *service, const char *param); 38 WERROR(*drop)(struct smbconf_ctx *ctx);39 WERROR(*get_share_names)(struct smbconf_ctx *ctx,38 sbcErr (*drop)(struct smbconf_ctx *ctx); 39 sbcErr (*get_share_names)(struct smbconf_ctx *ctx, 40 40 TALLOC_CTX *mem_ctx, 41 41 uint32_t *num_shares, 42 42 char ***share_names); 43 43 bool (*share_exists)(struct smbconf_ctx *ctx, const char *service); 44 WERROR(*create_share)(struct smbconf_ctx *ctx, const char *service);45 WERROR(*get_share)(struct smbconf_ctx *ctx,44 sbcErr (*create_share)(struct smbconf_ctx *ctx, const char *service); 45 sbcErr (*get_share)(struct smbconf_ctx *ctx, 46 46 TALLOC_CTX *mem_ctx, 47 47 const char *servicename, 48 48 struct smbconf_service **service); 49 WERROR(*delete_share)(struct smbconf_ctx *ctx,49 sbcErr (*delete_share)(struct smbconf_ctx *ctx, 50 50 const char *servicename); 51 WERROR(*set_parameter)(struct smbconf_ctx *ctx,51 sbcErr (*set_parameter)(struct smbconf_ctx *ctx, 52 52 const char *service, 53 53 const char *param, 54 54 const char *valstr); 55 WERROR(*get_parameter)(struct smbconf_ctx *ctx,55 sbcErr (*get_parameter)(struct smbconf_ctx *ctx, 56 56 TALLOC_CTX *mem_ctx, 57 57 const char *service, 58 58 const char *param, 59 59 char **valstr); 60 WERROR(*delete_parameter)(struct smbconf_ctx *ctx,60 sbcErr (*delete_parameter)(struct smbconf_ctx *ctx, 61 61 const char *service, const char *param); 62 WERROR(*get_includes)(struct smbconf_ctx *ctx,62 sbcErr (*get_includes)(struct smbconf_ctx *ctx, 63 63 TALLOC_CTX *mem_ctx, 64 64 const char *service, 65 65 uint32_t *num_includes, char ***includes); 66 WERROR(*set_includes)(struct smbconf_ctx *ctx,66 sbcErr (*set_includes)(struct smbconf_ctx *ctx, 67 67 const char *service, 68 68 uint32_t num_includes, const char **includes); 69 WERROR(*delete_includes)(struct smbconf_ctx *ctx,69 sbcErr (*delete_includes)(struct smbconf_ctx *ctx, 70 70 const char *service); 71 WERROR(*transaction_start)(struct smbconf_ctx *ctx);72 WERROR(*transaction_commit)(struct smbconf_ctx *ctx);73 WERROR(*transaction_cancel)(struct smbconf_ctx *ctx);71 sbcErr (*transaction_start)(struct smbconf_ctx *ctx); 72 sbcErr (*transaction_commit)(struct smbconf_ctx *ctx); 73 sbcErr (*transaction_cancel)(struct smbconf_ctx *ctx); 74 74 }; 75 75 … … 80 80 }; 81 81 82 WERRORsmbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,82 sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, 83 83 const char *path, struct smbconf_ops *ops); 84 84 85 WERRORsmbconf_add_string_to_array(TALLOC_CTX *mem_ctx,85 sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, 86 86 char ***array, 87 87 uint32_t count, -
vendor/current/lib/smbconf/smbconf_txt.c
r414 r740 28 28 #include "includes.h" 29 29 #include "smbconf_private.h" 30 #include "lib/smbconf/smbconf_txt.h" 30 31 31 32 struct txt_cache { … … 60 61 static bool smbconf_txt_do_section(const char *section, void *private_data) 61 62 { 62 WERROR werr;63 sbcErr err; 63 64 uint32_t idx; 64 65 struct txt_private_data *tpd = (struct txt_private_data *)private_data; … … 72 73 } 73 74 74 werr = smbconf_add_string_to_array(cache, &(cache->share_names),75 76 if (! W_ERROR_IS_OK(werr)) {75 err = smbconf_add_string_to_array(cache, &(cache->share_names), 76 cache->num_shares, section); 77 if (!SBC_ERROR_IS_OK(err)) { 77 78 return false; 78 79 } … … 114 115 void *private_data) 115 116 { 116 WERROR werr;117 sbcErr err; 117 118 char **param_names, **param_values; 118 119 uint32_t num_params; … … 146 147 return true; 147 148 } 148 werr = smbconf_add_string_to_array(cache,149 err = smbconf_add_string_to_array(cache, 149 150 &(cache->param_names[cache->current_share]), 150 151 num_params, param_name); 151 if (! W_ERROR_IS_OK(werr)) {152 if (!SBC_ERROR_IS_OK(err)) { 152 153 return false; 153 154 } 154 werr = smbconf_add_string_to_array(cache,155 err = smbconf_add_string_to_array(cache, 155 156 &(cache->param_values[cache->current_share]), 156 157 num_params, param_value); 157 158 cache->num_params[cache->current_share]++; 158 return W_ERROR_IS_OK(werr);159 return SBC_ERROR_IS_OK(err); 159 160 } 160 161 … … 165 166 } 166 167 167 static WERRORsmbconf_txt_init_cache(struct smbconf_ctx *ctx)168 static sbcErr smbconf_txt_init_cache(struct smbconf_ctx *ctx) 168 169 { 169 170 if (pd(ctx)->cache != NULL) { … … 174 175 175 176 if (pd(ctx)->cache == NULL) { 176 return WERR_NOMEM;177 } 178 179 return WERR_OK;180 } 181 182 static WERRORsmbconf_txt_load_file(struct smbconf_ctx *ctx)183 { 184 WERROR werr;177 return SBC_ERR_NOMEM; 178 } 179 180 return SBC_ERR_OK; 181 } 182 183 static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx) 184 { 185 sbcErr err; 185 186 uint64_t new_csn; 186 187 187 188 if (!file_exist(ctx->path)) { 188 return WERR_BADFILE;189 return SBC_ERR_BADFILE; 189 190 } 190 191 191 192 new_csn = (uint64_t)file_modtime(ctx->path); 192 193 if (new_csn == pd(ctx)->csn) { 193 return WERR_OK;194 } 195 196 werr = smbconf_txt_init_cache(ctx);197 if (! W_ERROR_IS_OK(werr)) {198 return werr;194 return SBC_ERR_OK; 195 } 196 197 err = smbconf_txt_init_cache(ctx); 198 if (!SBC_ERROR_IS_OK(err)) { 199 return err; 199 200 } 200 201 … … 202 203 smbconf_txt_do_parameter, pd(ctx))) 203 204 { 204 return WERR_CAN_NOT_COMPLETE;205 return SBC_ERR_CAN_NOT_COMPLETE; 205 206 } 206 207 207 208 pd(ctx)->csn = new_csn; 208 209 209 return WERR_OK;210 return SBC_ERR_OK; 210 211 } 211 212 … … 220 221 * initialize the text based smbconf backend 221 222 */ 222 static WERRORsmbconf_txt_init(struct smbconf_ctx *ctx, const char *path)223 static sbcErr smbconf_txt_init(struct smbconf_ctx *ctx, const char *path) 223 224 { 224 225 if (path == NULL) { 225 return WERR_BADFILE;226 return SBC_ERR_BADFILE; 226 227 } 227 228 ctx->path = talloc_strdup(ctx, path); 228 229 if (ctx->path == NULL) { 229 return WERR_NOMEM;230 return SBC_ERR_NOMEM; 230 231 } 231 232 232 233 ctx->data = talloc_zero(ctx, struct txt_private_data); 233 234 if (ctx->data == NULL) { 234 return WERR_NOMEM;235 return SBC_ERR_NOMEM; 235 236 } 236 237 237 238 pd(ctx)->verbatim = true; 238 239 239 return WERR_OK;240 return SBC_ERR_OK; 240 241 } 241 242 … … 256 257 } 257 258 258 static WERRORsmbconf_txt_open(struct smbconf_ctx *ctx)259 static sbcErr smbconf_txt_open(struct smbconf_ctx *ctx) 259 260 { 260 261 return smbconf_txt_load_file(ctx); … … 285 286 * Drop the whole configuration (restarting empty) 286 287 */ 287 static WERRORsmbconf_txt_drop(struct smbconf_ctx *ctx)288 { 289 return WERR_NOT_SUPPORTED;288 static sbcErr smbconf_txt_drop(struct smbconf_ctx *ctx) 289 { 290 return SBC_ERR_NOT_SUPPORTED; 290 291 } 291 292 … … 293 294 * get the list of share names defined in the configuration. 294 295 */ 295 static WERRORsmbconf_txt_get_share_names(struct smbconf_ctx *ctx,296 static sbcErr smbconf_txt_get_share_names(struct smbconf_ctx *ctx, 296 297 TALLOC_CTX *mem_ctx, 297 298 uint32_t *num_shares, … … 301 302 uint32_t added_count = 0; 302 303 TALLOC_CTX *tmp_ctx = NULL; 303 WERROR werr = WERR_OK;304 sbcErr err = SBC_ERR_OK; 304 305 char **tmp_share_names = NULL; 305 306 306 307 if ((num_shares == NULL) || (share_names == NULL)) { 307 werr = WERR_INVALID_PARAM; 308 goto done; 309 } 310 311 werr = smbconf_txt_load_file(ctx); 312 if (!W_ERROR_IS_OK(werr)) { 313 return werr; 308 return SBC_ERR_INVALID_PARAM; 309 } 310 311 err = smbconf_txt_load_file(ctx); 312 if (!SBC_ERROR_IS_OK(err)) { 313 return err; 314 314 } 315 315 … … 320 320 321 321 if (smbconf_share_exists(ctx, NULL)) { 322 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,323 324 if (! W_ERROR_IS_OK(werr)) {322 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, 323 0, NULL); 324 if (!SBC_ERROR_IS_OK(err)) { 325 325 goto done; 326 326 } … … 329 329 330 330 if (smbconf_share_exists(ctx, GLOBAL_NAME)) { 331 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,331 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, 332 332 added_count, GLOBAL_NAME); 333 if (! W_ERROR_IS_OK(werr)) {333 if (!SBC_ERROR_IS_OK(err)) { 334 334 goto done; 335 335 } … … 344 344 } 345 345 346 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,346 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names, 347 347 added_count, 348 348 pd(ctx)->cache->share_names[count]); 349 if (! W_ERROR_IS_OK(werr)) {349 if (!SBC_ERROR_IS_OK(err)) { 350 350 goto done; 351 351 } … … 362 362 done: 363 363 talloc_free(tmp_ctx); 364 return werr;364 return err; 365 365 } 366 366 … … 371 371 const char *servicename) 372 372 { 373 WERROR werr;374 375 werr = smbconf_txt_load_file(ctx);376 if (! W_ERROR_IS_OK(werr)) {373 sbcErr err; 374 375 err = smbconf_txt_load_file(ctx); 376 if (!SBC_ERROR_IS_OK(err)) { 377 377 return false; 378 378 } … … 386 386 * Add a service if it does not already exist 387 387 */ 388 static WERRORsmbconf_txt_create_share(struct smbconf_ctx *ctx,388 static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx, 389 389 const char *servicename) 390 390 { 391 return WERR_NOT_SUPPORTED;391 return SBC_ERR_NOT_SUPPORTED; 392 392 } 393 393 … … 395 395 * get a definition of a share (service) from configuration. 396 396 */ 397 static WERRORsmbconf_txt_get_share(struct smbconf_ctx *ctx,397 static sbcErr smbconf_txt_get_share(struct smbconf_ctx *ctx, 398 398 TALLOC_CTX *mem_ctx, 399 399 const char *servicename, 400 400 struct smbconf_service **service) 401 401 { 402 WERROR werr;402 sbcErr err; 403 403 uint32_t sidx, count; 404 404 bool found; … … 406 406 struct smbconf_service *tmp_service = NULL; 407 407 408 werr = smbconf_txt_load_file(ctx);409 if (! W_ERROR_IS_OK(werr)) {410 return werr;408 err = smbconf_txt_load_file(ctx); 409 if (!SBC_ERROR_IS_OK(err)) { 410 return err; 411 411 } 412 412 … … 416 416 &sidx); 417 417 if (!found) { 418 return WERR_NO_SUCH_SERVICE;418 return SBC_ERR_NO_SUCH_SERVICE; 419 419 } 420 420 … … 423 423 tmp_service = talloc_zero(tmp_ctx, struct smbconf_service); 424 424 if (tmp_service == NULL) { 425 werr = WERR_NOMEM;425 err = SBC_ERR_NOMEM; 426 426 goto done; 427 427 } … … 430 430 tmp_service->name = talloc_strdup(tmp_service, servicename); 431 431 if (tmp_service->name == NULL) { 432 werr = WERR_NOMEM;432 err = SBC_ERR_NOMEM; 433 433 goto done; 434 434 } … … 436 436 437 437 for (count = 0; count < pd(ctx)->cache->num_params[sidx]; count++) { 438 werr = smbconf_add_string_to_array(tmp_service,438 err = smbconf_add_string_to_array(tmp_service, 439 439 &(tmp_service->param_names), 440 440 count, 441 441 pd(ctx)->cache->param_names[sidx][count]); 442 if (! W_ERROR_IS_OK(werr)) {442 if (!SBC_ERROR_IS_OK(err)) { 443 443 goto done; 444 444 } 445 werr = smbconf_add_string_to_array(tmp_service,445 err = smbconf_add_string_to_array(tmp_service, 446 446 &(tmp_service->param_values), 447 447 count, 448 448 pd(ctx)->cache->param_values[sidx][count]); 449 if (! W_ERROR_IS_OK(werr)) {449 if (!SBC_ERROR_IS_OK(err)) { 450 450 goto done; 451 451 } … … 453 453 454 454 tmp_service->num_params = count; 455 if (count > 0) { 456 *service = talloc_move(mem_ctx, &tmp_service); 457 } else { 458 *service = NULL; 459 } 455 *service = talloc_move(mem_ctx, &tmp_service); 460 456 461 457 done: 462 458 talloc_free(tmp_ctx); 463 return werr;459 return err; 464 460 } 465 461 … … 467 463 * delete a service from configuration 468 464 */ 469 static WERRORsmbconf_txt_delete_share(struct smbconf_ctx *ctx,465 static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx, 470 466 const char *servicename) 471 467 { 472 return WERR_NOT_SUPPORTED;468 return SBC_ERR_NOT_SUPPORTED; 473 469 } 474 470 … … 476 472 * set a configuration parameter to the value provided. 477 473 */ 478 static WERRORsmbconf_txt_set_parameter(struct smbconf_ctx *ctx,474 static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx, 479 475 const char *service, 480 476 const char *param, 481 477 const char *valstr) 482 478 { 483 return WERR_NOT_SUPPORTED;479 return SBC_ERR_NOT_SUPPORTED; 484 480 } 485 481 … … 487 483 * get the value of a configuration parameter as a string 488 484 */ 489 static WERRORsmbconf_txt_get_parameter(struct smbconf_ctx *ctx,485 static sbcErr smbconf_txt_get_parameter(struct smbconf_ctx *ctx, 490 486 TALLOC_CTX *mem_ctx, 491 487 const char *service, … … 493 489 char **valstr) 494 490 { 495 WERROR werr;491 sbcErr err; 496 492 bool found; 497 493 uint32_t share_index, param_index; 498 494 499 werr = smbconf_txt_load_file(ctx);500 if (! W_ERROR_IS_OK(werr)) {501 return werr;495 err = smbconf_txt_load_file(ctx); 496 if (!SBC_ERROR_IS_OK(err)) { 497 return err; 502 498 } 503 499 … … 507 503 &share_index); 508 504 if (!found) { 509 return WERR_NO_SUCH_SERVICE;505 return SBC_ERR_NO_SUCH_SERVICE; 510 506 } 511 507 … … 515 511 ¶m_index); 516 512 if (!found) { 517 return WERR_INVALID_PARAM;513 return SBC_ERR_INVALID_PARAM; 518 514 } 519 515 … … 522 518 523 519 if (*valstr == NULL) { 524 return WERR_NOMEM;525 } 526 527 return WERR_OK;520 return SBC_ERR_NOMEM; 521 } 522 523 return SBC_ERR_OK; 528 524 } 529 525 … … 531 527 * delete a parameter from configuration 532 528 */ 533 static WERRORsmbconf_txt_delete_parameter(struct smbconf_ctx *ctx,529 static sbcErr smbconf_txt_delete_parameter(struct smbconf_ctx *ctx, 534 530 const char *service, 535 531 const char *param) 536 532 { 537 return WERR_NOT_SUPPORTED;538 } 539 540 static WERRORsmbconf_txt_get_includes(struct smbconf_ctx *ctx,533 return SBC_ERR_NOT_SUPPORTED; 534 } 535 536 static sbcErr smbconf_txt_get_includes(struct smbconf_ctx *ctx, 541 537 TALLOC_CTX *mem_ctx, 542 538 const char *service, … … 544 540 char ***includes) 545 541 { 546 WERROR werr;542 sbcErr err; 547 543 bool found; 548 544 uint32_t sidx, count; … … 551 547 char **tmp_includes = NULL; 552 548 553 werr = smbconf_txt_load_file(ctx);554 if (! W_ERROR_IS_OK(werr)) {555 return werr;549 err = smbconf_txt_load_file(ctx); 550 if (!SBC_ERROR_IS_OK(err)) { 551 return err; 556 552 } 557 553 … … 561 557 &sidx); 562 558 if (!found) { 563 return WERR_NO_SUCH_SERVICE;559 return SBC_ERR_NO_SUCH_SERVICE; 564 560 } 565 561 … … 570 566 "include")) 571 567 { 572 werr = smbconf_add_string_to_array(tmp_ctx,568 err = smbconf_add_string_to_array(tmp_ctx, 573 569 &tmp_includes, 574 570 tmp_num_includes, 575 571 pd(ctx)->cache->param_values[sidx][count]); 576 if (! W_ERROR_IS_OK(werr)) {572 if (!SBC_ERROR_IS_OK(err)) { 577 573 goto done; 578 574 } … … 585 581 *includes = talloc_move(mem_ctx, &tmp_includes); 586 582 if (*includes == NULL) { 587 werr = WERR_NOMEM;583 err = SBC_ERR_NOMEM; 588 584 goto done; 589 585 } … … 592 588 } 593 589 594 werr = WERR_OK;590 err = SBC_ERR_OK; 595 591 596 592 done: 597 593 talloc_free(tmp_ctx); 598 return werr;599 } 600 601 static WERRORsmbconf_txt_set_includes(struct smbconf_ctx *ctx,594 return err; 595 } 596 597 static sbcErr smbconf_txt_set_includes(struct smbconf_ctx *ctx, 602 598 const char *service, 603 599 uint32_t num_includes, 604 600 const char **includes) 605 601 { 606 return WERR_NOT_SUPPORTED;607 } 608 609 static WERRORsmbconf_txt_delete_includes(struct smbconf_ctx *ctx,602 return SBC_ERR_NOT_SUPPORTED; 603 } 604 605 static sbcErr smbconf_txt_delete_includes(struct smbconf_ctx *ctx, 610 606 const char *service) 611 607 { 612 return WERR_NOT_SUPPORTED;613 } 614 615 static WERRORsmbconf_txt_transaction_start(struct smbconf_ctx *ctx)616 { 617 return WERR_OK;618 } 619 620 static WERRORsmbconf_txt_transaction_commit(struct smbconf_ctx *ctx)621 { 622 return WERR_OK;623 } 624 625 static WERRORsmbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)626 { 627 return WERR_OK;608 return SBC_ERR_NOT_SUPPORTED; 609 } 610 611 static sbcErr smbconf_txt_transaction_start(struct smbconf_ctx *ctx) 612 { 613 return SBC_ERR_OK; 614 } 615 616 static sbcErr smbconf_txt_transaction_commit(struct smbconf_ctx *ctx) 617 { 618 return SBC_ERR_OK; 619 } 620 621 static sbcErr smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx) 622 { 623 return SBC_ERR_OK; 628 624 } 629 625 … … 658 654 * the only function that is exported from this module 659 655 */ 660 WERRORsmbconf_init_txt(TALLOC_CTX *mem_ctx,656 sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx, 661 657 struct smbconf_ctx **conf_ctx, 662 658 const char *path) 663 659 { 664 WERROR werr;665 666 werr = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt);667 if (! W_ERROR_IS_OK(werr)) {668 return werr;660 sbcErr err; 661 662 err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt); 663 if (!SBC_ERROR_IS_OK(err)) { 664 return err; 669 665 } 670 666 -
vendor/current/lib/smbconf/smbconf_txt.h
r414 r740 27 27 */ 28 28 29 WERRORsmbconf_init_txt(TALLOC_CTX *mem_ctx,29 sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx, 30 30 struct smbconf_ctx **conf_ctx, 31 31 const char *path); -
vendor/current/lib/smbconf/smbconf_util.c
r414 r740 40 40 * should be called. 41 41 */ 42 WERRORsmbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,42 sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx, 43 43 const char *path, struct smbconf_ops *ops) 44 44 { 45 WERROR werr = WERR_OK;45 sbcErr err = SBC_ERR_OK; 46 46 struct smbconf_ctx *ctx; 47 47 48 48 if (conf_ctx == NULL) { 49 return WERR_INVALID_PARAM;49 return SBC_ERR_INVALID_PARAM; 50 50 } 51 51 52 52 ctx = talloc_zero(mem_ctx, struct smbconf_ctx); 53 53 if (ctx == NULL) { 54 return WERR_NOMEM;54 return SBC_ERR_NOMEM; 55 55 } 56 56 57 57 ctx->ops = ops; 58 58 59 werr = ctx->ops->init(ctx, path);60 if (! W_ERROR_IS_OK(werr)) {59 err = ctx->ops->init(ctx, path); 60 if (!SBC_ERROR_IS_OK(err)) { 61 61 goto fail; 62 62 } … … 65 65 66 66 *conf_ctx = ctx; 67 return werr;67 return err; 68 68 69 69 fail: 70 70 talloc_free(ctx); 71 return werr;71 return err; 72 72 } 73 73 … … 76 76 * add a string to a talloced array of strings. 77 77 */ 78 WERRORsmbconf_add_string_to_array(TALLOC_CTX *mem_ctx,78 sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx, 79 79 char ***array, 80 80 uint32_t count, … … 84 84 85 85 if (array == NULL) { 86 return WERR_INVALID_PARAM;86 return SBC_ERR_INVALID_PARAM; 87 87 } 88 88 89 89 new_array = talloc_realloc(mem_ctx, *array, char *, count + 1); 90 90 if (new_array == NULL) { 91 return WERR_NOMEM;91 return SBC_ERR_NOMEM; 92 92 } 93 93 … … 98 98 if (new_array[count] == NULL) { 99 99 talloc_free(new_array); 100 return WERR_NOMEM;100 return SBC_ERR_NOMEM; 101 101 } 102 102 } … … 104 104 *array = new_array; 105 105 106 return WERR_OK;106 return SBC_ERR_OK; 107 107 } 108 108
Note:
See TracChangeset
for help on using the changeset viewer.