Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/lib/smbconf
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/smbconf/smbconf.c

    r414 r740  
    2828 **********************************************************************/
    2929
    30 static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
     30static sbcErr smbconf_global_check(struct smbconf_ctx *ctx)
    3131{
    3232        if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
    3333                return smbconf_create_share(ctx, GLOBAL_NAME);
    3434        }
    35         return WERR_OK;
     35
     36        return SBC_ERR_OK;
    3637}
    3738
     
    4243 *
    4344 **********************************************************************/
     45
     46const 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
    4480
    4581/**
     
    92128 * Drop the whole configuration (restarting empty).
    93129 */
    94 WERROR smbconf_drop(struct smbconf_ctx *ctx)
     130sbcErr smbconf_drop(struct smbconf_ctx *ctx)
    95131{
    96132        return ctx->ops->drop(ctx);
     
    106142 *  param_values : list of lists of parameter values for each share
    107143 */
    108 WERROR smbconf_get_config(struct smbconf_ctx *ctx,
     144sbcErr smbconf_get_config(struct smbconf_ctx *ctx,
    109145                          TALLOC_CTX *mem_ctx,
    110146                          uint32_t *num_shares,
    111147                          struct smbconf_service ***services)
    112148{
    113         WERROR werr = WERR_OK;
     149        sbcErr err;
    114150        TALLOC_CTX *tmp_ctx = NULL;
    115151        uint32_t tmp_num_shares;
     
    119155
    120156        if ((num_shares == NULL) || (services == NULL)) {
    121                 werr = WERR_INVALID_PARAM;
     157                err = SBC_ERR_INVALID_PARAM;
    122158                goto done;
    123159        }
     
    125161        tmp_ctx = talloc_stackframe();
    126162
    127         werr = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares,
    128                                        &tmp_share_names);
    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)) {
    130166                goto done;
    131167        }
     
    133169        tmp_services = talloc_array(tmp_ctx, struct smbconf_service *,
    134170                                    tmp_num_shares);
    135 
    136171        if (tmp_services == NULL) {
    137                 werr = WERR_NOMEM;
     172                err = SBC_ERR_NOMEM;
    138173                goto done;
    139174        }
    140175
    141176        for (count = 0; count < tmp_num_shares; count++) {
    142                 werr = smbconf_get_share(ctx, tmp_services,
    143                                          tmp_share_names[count],
    144                                          &tmp_services[count]);
    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)) {
    146181                        goto done;
    147182                }
    148183        }
    149184
    150         werr = WERR_OK;
     185        err = SBC_ERR_OK;
    151186
    152187        *num_shares = tmp_num_shares;
     
    159194done:
    160195        talloc_free(tmp_ctx);
    161         return werr;
     196        return err;
    162197}
    163198
     
    165200 * get the list of share names defined in the configuration.
    166201 */
    167 WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
     202sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
    168203                               TALLOC_CTX *mem_ctx,
    169204                               uint32_t *num_shares,
     
    186221 * Add a service if it does not already exist.
    187222 */
    188 WERROR smbconf_create_share(struct smbconf_ctx *ctx,
     223sbcErr smbconf_create_share(struct smbconf_ctx *ctx,
    189224                            const char *servicename)
    190225{
    191226        if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) {
    192                 return WERR_FILE_EXISTS;
     227                return SBC_ERR_FILE_EXISTS;
    193228        }
    194229
     
    199234 * get a definition of a share (service) from configuration.
    200235 */
    201 WERROR smbconf_get_share(struct smbconf_ctx *ctx,
     236sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
    202237                         TALLOC_CTX *mem_ctx,
    203238                         const char *servicename,
     
    210245 * delete a service from configuration
    211246 */
    212 WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
     247sbcErr smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
    213248{
    214249        if (!smbconf_share_exists(ctx, servicename)) {
    215                 return WERR_NO_SUCH_SERVICE;
     250                return SBC_ERR_NO_SUCH_SERVICE;
    216251        }
    217252
     
    222257 * set a configuration parameter to the value provided.
    223258 */
    224 WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
     259sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
    225260                             const char *service,
    226261                             const char *param,
     
    236271 * This also creates [global] when it does not exist.
    237272 */
    238 WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
     273sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
    239274                                    const char *param, const char *val)
    240275{
    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;
    249285}
    250286
     
    252288 * get the value of a configuration parameter as a string
    253289 */
    254 WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
     290sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx,
    255291                             TALLOC_CTX *mem_ctx,
    256292                             const char *service,
     
    259295{
    260296        if (valstr == NULL) {
    261                 return WERR_INVALID_PARAM;
     297                return SBC_ERR_INVALID_PARAM;
    262298        }
    263299
     
    270306 * Create [global] if it does not exist.
    271307 */
    272 WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
     308sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx,
    273309                                    TALLOC_CTX *mem_ctx,
    274310                                    const char *param,
    275311                                    char **valstr)
    276312{
    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;
    286324}
    287325
     
    289327 * delete a parameter from configuration
    290328 */
    291 WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
     329sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx,
    292330                                const char *service, const char *param)
    293331{
     
    300338 * Create [global] if it does not exist.
    301339 */
    302 WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
     340sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
    303341                                       const char *param)
    304342{
    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
     354sbcErr smbconf_get_includes(struct smbconf_ctx *ctx,
    316355                            TALLOC_CTX *mem_ctx,
    317356                            const char *service,
     
    322361}
    323362
    324 WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx,
     363sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
    325364                                   TALLOC_CTX *mem_ctx,
    326365                                   uint32_t *num_includes, char ***includes)
    327366{
    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
     379sbcErr smbconf_set_includes(struct smbconf_ctx *ctx,
    340380                            const char *service,
    341381                            uint32_t num_includes, const char **includes)
     
    344384}
    345385
    346 WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
     386sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx,
    347387                                   uint32_t num_includes,
    348388                                   const char **includes)
    349389{
    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
     403sbcErr smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
    363404{
    364405        return ctx->ops->delete_includes(ctx, service);
    365406}
    366407
    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)
     408sbcErr 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
     421sbcErr smbconf_transaction_start(struct smbconf_ctx *ctx)
    380422{
    381423        return ctx->ops->transaction_start(ctx);
    382424}
    383425
    384 WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx)
     426sbcErr smbconf_transaction_commit(struct smbconf_ctx *ctx)
    385427{
    386428        return ctx->ops->transaction_commit(ctx);
    387429}
    388430
    389 WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx)
     431sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx)
    390432{
    391433        return ctx->ops->transaction_cancel(ctx);
  • vendor/current/lib/smbconf/smbconf.h

    r414 r740  
    2121#define __LIBSMBCONF_H__
    2222
     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 */
     35enum _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
     51typedef 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
    2356struct smbconf_ctx;
    2457
     
    2861};
    2962
     63/** Information about a service */
    3064struct 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 */
    3569};
    3670
    3771/*
    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 **/
     82const 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.
    3993 */
    4094bool 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 */
    41103bool 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 */
    42110void 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 */
    43131bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
    44132                     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 */
     142sbcErr 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 */
     160sbcErr smbconf_get_config(struct smbconf_ctx *ctx,
    47161                          TALLOC_CTX *mem_ctx,
    48162                          uint32_t *num_shares,
    49163                          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 */
     179sbcErr smbconf_get_share_names(struct smbconf_ctx *ctx,
    51180                               TALLOC_CTX *mem_ctx,
    52181                               uint32_t *num_shares,
    53182                               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 */
    54193bool 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 */
     205sbcErr 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 */
     224sbcErr smbconf_get_share(struct smbconf_ctx *ctx,
    57225                         TALLOC_CTX *mem_ctx,
    58226                         const char *servicename,
    59227                         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 */
     239sbcErr smbconf_delete_share(struct smbconf_ctx *ctx,
    61240                            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 */
     256sbcErr smbconf_set_parameter(struct smbconf_ctx *ctx,
    63257                             const char *service,
    64258                             const char *param,
    65259                             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 */
     276sbcErr smbconf_set_global_parameter(struct smbconf_ctx *ctx,
    67277                                    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 */
     295sbcErr smbconf_get_parameter(struct smbconf_ctx *ctx,
    69296                             TALLOC_CTX *mem_ctx,
    70297                             const char *service,
    71298                             const char *param,
    72299                             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 */
     317sbcErr smbconf_get_global_parameter(struct smbconf_ctx *ctx,
    74318                                    TALLOC_CTX *mem_ctx,
    75319                                    const char *param,
    76320                                    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 */
     334sbcErr smbconf_delete_parameter(struct smbconf_ctx *ctx,
    78335                                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 */
     349sbcErr smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
    80350                                       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 */
     368sbcErr smbconf_get_includes(struct smbconf_ctx *ctx,
    82369                            TALLOC_CTX *mem_ctx,
    83370                            const char *service,
    84371                            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 */
     387sbcErr smbconf_get_global_includes(struct smbconf_ctx *ctx,
    86388                                   TALLOC_CTX *mem_ctx,
    87389                                   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 */
     405sbcErr smbconf_set_includes(struct smbconf_ctx *ctx,
    89406                            const char *service,
    90407                            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 */
     421sbcErr smbconf_set_global_includes(struct smbconf_ctx *ctx,
    92422                                   uint32_t num_includes,
    93423                                   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 */
     435sbcErr 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 */
     445sbcErr 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 */
     457sbcErr 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 */
     471sbcErr 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 */
     483sbcErr smbconf_transaction_cancel(struct smbconf_ctx *ctx);
     484
     485/* @} ******************************************************************/
    100486
    101487#endif /*  _LIBSMBCONF_H_  */
  • vendor/current/lib/smbconf/smbconf_private.h

    r414 r740  
    2828
    2929struct smbconf_ops {
    30         WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
     30        sbcErr (*init)(struct smbconf_ctx *ctx, const char *path);
    3131        int (*shutdown)(struct smbconf_ctx *ctx);
    3232        bool (*requires_messaging)(struct smbconf_ctx *ctx);
    3333        bool (*is_writeable)(struct smbconf_ctx *ctx);
    34         WERROR (*open_conf)(struct smbconf_ctx *ctx);
     34        sbcErr (*open_conf)(struct smbconf_ctx *ctx);
    3535        int (*close_conf)(struct smbconf_ctx *ctx);
    3636        void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
    3737                        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,
    4040                                  TALLOC_CTX *mem_ctx,
    4141                                  uint32_t *num_shares,
    4242                                  char ***share_names);
    4343        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,
    4646                            TALLOC_CTX *mem_ctx,
    4747                            const char *servicename,
    4848                            struct smbconf_service **service);
    49         WERROR (*delete_share)(struct smbconf_ctx *ctx,
     49        sbcErr (*delete_share)(struct smbconf_ctx *ctx,
    5050                                    const char *servicename);
    51         WERROR (*set_parameter)(struct smbconf_ctx *ctx,
     51        sbcErr (*set_parameter)(struct smbconf_ctx *ctx,
    5252                                const char *service,
    5353                                const char *param,
    5454                                const char *valstr);
    55         WERROR (*get_parameter)(struct smbconf_ctx *ctx,
     55        sbcErr (*get_parameter)(struct smbconf_ctx *ctx,
    5656                                TALLOC_CTX *mem_ctx,
    5757                                const char *service,
    5858                                const char *param,
    5959                                char **valstr);
    60         WERROR (*delete_parameter)(struct smbconf_ctx *ctx,
     60        sbcErr (*delete_parameter)(struct smbconf_ctx *ctx,
    6161                                   const char *service, const char *param);
    62         WERROR (*get_includes)(struct smbconf_ctx *ctx,
     62        sbcErr (*get_includes)(struct smbconf_ctx *ctx,
    6363                               TALLOC_CTX *mem_ctx,
    6464                               const char *service,
    6565                               uint32_t *num_includes, char ***includes);
    66         WERROR (*set_includes)(struct smbconf_ctx *ctx,
     66        sbcErr (*set_includes)(struct smbconf_ctx *ctx,
    6767                               const char *service,
    6868                               uint32_t num_includes, const char **includes);
    69         WERROR (*delete_includes)(struct smbconf_ctx *ctx,
     69        sbcErr (*delete_includes)(struct smbconf_ctx *ctx,
    7070                                  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);
    7474};
    7575
     
    8080};
    8181
    82 WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
     82sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
    8383                             const char *path, struct smbconf_ops *ops);
    8484
    85 WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
     85sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
    8686                                   char ***array,
    8787                                   uint32_t count,
  • vendor/current/lib/smbconf/smbconf_txt.c

    r414 r740  
    2828#include "includes.h"
    2929#include "smbconf_private.h"
     30#include "lib/smbconf/smbconf_txt.h"
    3031
    3132struct txt_cache {
     
    6061static bool smbconf_txt_do_section(const char *section, void *private_data)
    6162{
    62         WERROR werr;
     63        sbcErr err;
    6364        uint32_t idx;
    6465        struct txt_private_data *tpd = (struct txt_private_data *)private_data;
     
    7273        }
    7374
    74         werr = smbconf_add_string_to_array(cache, &(cache->share_names),
    75                                            cache->num_shares, section);
    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)) {
    7778                return false;
    7879        }
     
    114115                                     void *private_data)
    115116{
    116         WERROR werr;
     117        sbcErr err;
    117118        char **param_names, **param_values;
    118119        uint32_t num_params;
     
    146147                return true;
    147148        }
    148         werr = smbconf_add_string_to_array(cache,
     149        err = smbconf_add_string_to_array(cache,
    149150                                &(cache->param_names[cache->current_share]),
    150151                                num_params, param_name);
    151         if (!W_ERROR_IS_OK(werr)) {
     152        if (!SBC_ERROR_IS_OK(err)) {
    152153                return false;
    153154        }
    154         werr = smbconf_add_string_to_array(cache,
     155        err = smbconf_add_string_to_array(cache,
    155156                                &(cache->param_values[cache->current_share]),
    156157                                num_params, param_value);
    157158        cache->num_params[cache->current_share]++;
    158         return W_ERROR_IS_OK(werr);
     159        return SBC_ERROR_IS_OK(err);
    159160}
    160161
     
    165166}
    166167
    167 static WERROR smbconf_txt_init_cache(struct smbconf_ctx *ctx)
     168static sbcErr smbconf_txt_init_cache(struct smbconf_ctx *ctx)
    168169{
    169170        if (pd(ctx)->cache != NULL) {
     
    174175
    175176        if (pd(ctx)->cache == NULL) {
    176                 return WERR_NOMEM;
    177         }
    178 
    179         return WERR_OK;
    180 }
    181 
    182 static WERROR smbconf_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
     183static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx)
     184{
     185        sbcErr err;
    185186        uint64_t new_csn;
    186187
    187188        if (!file_exist(ctx->path)) {
    188                 return WERR_BADFILE;
     189                return SBC_ERR_BADFILE;
    189190        }
    190191
    191192        new_csn = (uint64_t)file_modtime(ctx->path);
    192193        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;
    199200        }
    200201
     
    202203                        smbconf_txt_do_parameter, pd(ctx)))
    203204        {
    204                 return WERR_CAN_NOT_COMPLETE;
     205                return SBC_ERR_CAN_NOT_COMPLETE;
    205206        }
    206207
    207208        pd(ctx)->csn = new_csn;
    208209
    209         return WERR_OK;
     210        return SBC_ERR_OK;
    210211}
    211212
     
    220221 * initialize the text based smbconf backend
    221222 */
    222 static WERROR smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
     223static sbcErr smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
    223224{
    224225        if (path == NULL) {
    225                 return WERR_BADFILE;
     226                return SBC_ERR_BADFILE;
    226227        }
    227228        ctx->path = talloc_strdup(ctx, path);
    228229        if (ctx->path == NULL) {
    229                 return WERR_NOMEM;
     230                return SBC_ERR_NOMEM;
    230231        }
    231232
    232233        ctx->data = talloc_zero(ctx, struct txt_private_data);
    233234        if (ctx->data == NULL) {
    234                 return WERR_NOMEM;
     235                return SBC_ERR_NOMEM;
    235236        }
    236237
    237238        pd(ctx)->verbatim = true;
    238239
    239         return WERR_OK;
     240        return SBC_ERR_OK;
    240241}
    241242
     
    256257}
    257258
    258 static WERROR smbconf_txt_open(struct smbconf_ctx *ctx)
     259static sbcErr smbconf_txt_open(struct smbconf_ctx *ctx)
    259260{
    260261        return smbconf_txt_load_file(ctx);
     
    285286 * Drop the whole configuration (restarting empty)
    286287 */
    287 static WERROR smbconf_txt_drop(struct smbconf_ctx *ctx)
    288 {
    289         return WERR_NOT_SUPPORTED;
     288static sbcErr smbconf_txt_drop(struct smbconf_ctx *ctx)
     289{
     290        return SBC_ERR_NOT_SUPPORTED;
    290291}
    291292
     
    293294 * get the list of share names defined in the configuration.
    294295 */
    295 static WERROR smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
     296static sbcErr smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
    296297                                          TALLOC_CTX *mem_ctx,
    297298                                          uint32_t *num_shares,
     
    301302        uint32_t added_count = 0;
    302303        TALLOC_CTX *tmp_ctx = NULL;
    303         WERROR werr = WERR_OK;
     304        sbcErr err = SBC_ERR_OK;
    304305        char **tmp_share_names = NULL;
    305306
    306307        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;
    314314        }
    315315
     
    320320
    321321        if (smbconf_share_exists(ctx, NULL)) {
    322                 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
    323                                                    0, NULL);
    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)) {
    325325                        goto done;
    326326                }
     
    329329
    330330        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,
    332332                                                   added_count, GLOBAL_NAME);
    333                 if (!W_ERROR_IS_OK(werr)) {
     333                if (!SBC_ERROR_IS_OK(err)) {
    334334                        goto done;
    335335                }
     
    344344                }
    345345
    346                 werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
     346                err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
    347347                                        added_count,
    348348                                        pd(ctx)->cache->share_names[count]);
    349                 if (!W_ERROR_IS_OK(werr)) {
     349                if (!SBC_ERROR_IS_OK(err)) {
    350350                        goto done;
    351351                }
     
    362362done:
    363363        talloc_free(tmp_ctx);
    364         return werr;
     364        return err;
    365365}
    366366
     
    371371                                     const char *servicename)
    372372{
    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)) {
    377377                return false;
    378378        }
     
    386386 * Add a service if it does not already exist
    387387 */
    388 static WERROR smbconf_txt_create_share(struct smbconf_ctx *ctx,
     388static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx,
    389389                                       const char *servicename)
    390390{
    391         return WERR_NOT_SUPPORTED;
     391        return SBC_ERR_NOT_SUPPORTED;
    392392}
    393393
     
    395395 * get a definition of a share (service) from configuration.
    396396 */
    397 static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
     397static sbcErr smbconf_txt_get_share(struct smbconf_ctx *ctx,
    398398                                    TALLOC_CTX *mem_ctx,
    399399                                    const char *servicename,
    400400                                    struct smbconf_service **service)
    401401{
    402         WERROR werr;
     402        sbcErr err;
    403403        uint32_t sidx, count;
    404404        bool found;
     
    406406        struct smbconf_service *tmp_service = NULL;
    407407
    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;
    411411        }
    412412
     
    416416                                      &sidx);
    417417        if (!found) {
    418                 return WERR_NO_SUCH_SERVICE;
     418                return SBC_ERR_NO_SUCH_SERVICE;
    419419        }
    420420
     
    423423        tmp_service = talloc_zero(tmp_ctx, struct smbconf_service);
    424424        if (tmp_service == NULL) {
    425                 werr = WERR_NOMEM;
     425                err = SBC_ERR_NOMEM;
    426426                goto done;
    427427        }
     
    430430                tmp_service->name = talloc_strdup(tmp_service, servicename);
    431431                if (tmp_service->name == NULL) {
    432                         werr = WERR_NOMEM;
     432                        err = SBC_ERR_NOMEM;
    433433                        goto done;
    434434                }
     
    436436
    437437        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,
    439439                                &(tmp_service->param_names),
    440440                                count,
    441441                                pd(ctx)->cache->param_names[sidx][count]);
    442                 if (!W_ERROR_IS_OK(werr)) {
     442                if (!SBC_ERROR_IS_OK(err)) {
    443443                        goto done;
    444444                }
    445                 werr = smbconf_add_string_to_array(tmp_service,
     445                err = smbconf_add_string_to_array(tmp_service,
    446446                                &(tmp_service->param_values),
    447447                                count,
    448448                                pd(ctx)->cache->param_values[sidx][count]);
    449                 if (!W_ERROR_IS_OK(werr)) {
     449                if (!SBC_ERROR_IS_OK(err)) {
    450450                        goto done;
    451451                }
     
    453453
    454454        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);
    460456
    461457done:
    462458        talloc_free(tmp_ctx);
    463         return werr;
     459        return err;
    464460}
    465461
     
    467463 * delete a service from configuration
    468464 */
    469 static WERROR smbconf_txt_delete_share(struct smbconf_ctx *ctx,
     465static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx,
    470466                                       const char *servicename)
    471467{
    472         return WERR_NOT_SUPPORTED;
     468        return SBC_ERR_NOT_SUPPORTED;
    473469}
    474470
     
    476472 * set a configuration parameter to the value provided.
    477473 */
    478 static WERROR smbconf_txt_set_parameter(struct smbconf_ctx *ctx,
     474static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx,
    479475                                        const char *service,
    480476                                        const char *param,
    481477                                        const char *valstr)
    482478{
    483         return WERR_NOT_SUPPORTED;
     479        return SBC_ERR_NOT_SUPPORTED;
    484480}
    485481
     
    487483 * get the value of a configuration parameter as a string
    488484 */
    489 static WERROR smbconf_txt_get_parameter(struct smbconf_ctx *ctx,
     485static sbcErr smbconf_txt_get_parameter(struct smbconf_ctx *ctx,
    490486                                        TALLOC_CTX *mem_ctx,
    491487                                        const char *service,
     
    493489                                        char **valstr)
    494490{
    495         WERROR werr;
     491        sbcErr err;
    496492        bool found;
    497493        uint32_t share_index, param_index;
    498494
    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;
    502498        }
    503499
     
    507503                                      &share_index);
    508504        if (!found) {
    509                 return WERR_NO_SUCH_SERVICE;
     505                return SBC_ERR_NO_SUCH_SERVICE;
    510506        }
    511507
     
    515511                                &param_index);
    516512        if (!found) {
    517                 return WERR_INVALID_PARAM;
     513                return SBC_ERR_INVALID_PARAM;
    518514        }
    519515
     
    522518
    523519        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;
    528524}
    529525
     
    531527 * delete a parameter from configuration
    532528 */
    533 static WERROR smbconf_txt_delete_parameter(struct smbconf_ctx *ctx,
     529static sbcErr smbconf_txt_delete_parameter(struct smbconf_ctx *ctx,
    534530                                           const char *service,
    535531                                           const char *param)
    536532{
    537         return WERR_NOT_SUPPORTED;
    538 }
    539 
    540 static WERROR smbconf_txt_get_includes(struct smbconf_ctx *ctx,
     533        return SBC_ERR_NOT_SUPPORTED;
     534}
     535
     536static sbcErr smbconf_txt_get_includes(struct smbconf_ctx *ctx,
    541537                                       TALLOC_CTX *mem_ctx,
    542538                                       const char *service,
     
    544540                                       char ***includes)
    545541{
    546         WERROR werr;
     542        sbcErr err;
    547543        bool found;
    548544        uint32_t sidx, count;
     
    551547        char **tmp_includes = NULL;
    552548
    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;
    556552        }
    557553
     
    561557                                      &sidx);
    562558        if (!found) {
    563                 return WERR_NO_SUCH_SERVICE;
     559                return SBC_ERR_NO_SUCH_SERVICE;
    564560        }
    565561
     
    570566                             "include"))
    571567                {
    572                         werr = smbconf_add_string_to_array(tmp_ctx,
     568                        err = smbconf_add_string_to_array(tmp_ctx,
    573569                                &tmp_includes,
    574570                                tmp_num_includes,
    575571                                pd(ctx)->cache->param_values[sidx][count]);
    576                         if (!W_ERROR_IS_OK(werr)) {
     572                        if (!SBC_ERROR_IS_OK(err)) {
    577573                                goto done;
    578574                        }
     
    585581                *includes = talloc_move(mem_ctx, &tmp_includes);
    586582                if (*includes == NULL) {
    587                         werr = WERR_NOMEM;
     583                        err = SBC_ERR_NOMEM;
    588584                        goto done;
    589585                }
     
    592588        }
    593589
    594         werr = WERR_OK;
     590        err = SBC_ERR_OK;
    595591
    596592done:
    597593        talloc_free(tmp_ctx);
    598         return werr;
    599 }
    600 
    601 static WERROR smbconf_txt_set_includes(struct smbconf_ctx *ctx,
     594        return err;
     595}
     596
     597static sbcErr smbconf_txt_set_includes(struct smbconf_ctx *ctx,
    602598                                       const char *service,
    603599                                       uint32_t num_includes,
    604600                                       const char **includes)
    605601{
    606         return WERR_NOT_SUPPORTED;
    607 }
    608 
    609 static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
     602        return SBC_ERR_NOT_SUPPORTED;
     603}
     604
     605static sbcErr smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
    610606                                          const char *service)
    611607{
    612         return WERR_NOT_SUPPORTED;
    613 }
    614 
    615 static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
    616 {
    617         return WERR_OK;
    618 }
    619 
    620 static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
    621 {
    622         return WERR_OK;
    623 }
    624 
    625 static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
    626 {
    627         return WERR_OK;
     608        return SBC_ERR_NOT_SUPPORTED;
     609}
     610
     611static sbcErr smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
     612{
     613        return SBC_ERR_OK;
     614}
     615
     616static sbcErr smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
     617{
     618        return SBC_ERR_OK;
     619}
     620
     621static sbcErr smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
     622{
     623        return SBC_ERR_OK;
    628624}
    629625
     
    658654 * the only function that is exported from this module
    659655 */
    660 WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
     656sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
    661657                        struct smbconf_ctx **conf_ctx,
    662658                        const char *path)
    663659{
    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;
    669665        }
    670666
  • vendor/current/lib/smbconf/smbconf_txt.h

    r414 r740  
    2727 */
    2828
    29 WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
     29sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
    3030                        struct smbconf_ctx **conf_ctx,
    3131                        const char *path);
  • vendor/current/lib/smbconf/smbconf_util.c

    r414 r740  
    4040 * should be called.
    4141 */
    42 WERROR smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
     42sbcErr smbconf_init_internal(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
    4343                             const char *path, struct smbconf_ops *ops)
    4444{
    45         WERROR werr = WERR_OK;
     45        sbcErr err = SBC_ERR_OK;
    4646        struct smbconf_ctx *ctx;
    4747
    4848        if (conf_ctx == NULL) {
    49                 return WERR_INVALID_PARAM;
     49                return SBC_ERR_INVALID_PARAM;
    5050        }
    5151
    5252        ctx = talloc_zero(mem_ctx, struct smbconf_ctx);
    5353        if (ctx == NULL) {
    54                 return WERR_NOMEM;
     54                return SBC_ERR_NOMEM;
    5555        }
    5656
    5757        ctx->ops = ops;
    5858
    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)) {
    6161                goto fail;
    6262        }
     
    6565
    6666        *conf_ctx = ctx;
    67         return werr;
     67        return err;
    6868
    6969fail:
    7070        talloc_free(ctx);
    71         return werr;
     71        return err;
    7272}
    7373
     
    7676 * add a string to a talloced array of strings.
    7777 */
    78 WERROR smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
     78sbcErr smbconf_add_string_to_array(TALLOC_CTX *mem_ctx,
    7979                                   char ***array,
    8080                                   uint32_t count,
     
    8484
    8585        if (array == NULL) {
    86                 return WERR_INVALID_PARAM;
     86                return SBC_ERR_INVALID_PARAM;
    8787        }
    8888
    8989        new_array = talloc_realloc(mem_ctx, *array, char *, count + 1);
    9090        if (new_array == NULL) {
    91                 return WERR_NOMEM;
     91                return SBC_ERR_NOMEM;
    9292        }
    9393
     
    9898                if (new_array[count] == NULL) {
    9999                        talloc_free(new_array);
    100                         return WERR_NOMEM;
     100                        return SBC_ERR_NOMEM;
    101101                }
    102102        }
     
    104104        *array = new_array;
    105105
    106         return WERR_OK;
     106        return SBC_ERR_OK;
    107107}
    108108
Note: See TracChangeset for help on using the changeset viewer.