s3:libsmbconf: add transactions to the libsmbconf api
authorMichael Adam <obnox@samba.org>
Tue, 24 Feb 2009 09:52:30 +0000 (10:52 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 26 Feb 2009 10:05:23 +0000 (11:05 +0100)
This is useful for wrapping higher level aggregate operations
in transactions. The text backend implementations just return
WERR_OK, the registry backend implementatoins use the
regdb_transaction_start|commit|cancel routines just added.

Michael

lib/smbconf/smbconf.c
lib/smbconf/smbconf.h
lib/smbconf/smbconf_private.h
lib/smbconf/smbconf_txt.c
source3/lib/smbconf/smbconf_reg.c

index 595fd23421482c2704663850c95717f0d4472354..f25ccae0d41c9f819bb8256ec3824e904ff41dcd 100644 (file)
@@ -399,3 +399,18 @@ WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx)
 
        return werr;
 }
+
+WERROR smbconf_transaction_start(struct smbconf_ctx *ctx)
+{
+       return ctx->ops->transaction_start(ctx);
+}
+
+WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx)
+{
+       return ctx->ops->transaction_commit(ctx);
+}
+
+WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx)
+{
+       return ctx->ops->transaction_cancel(ctx);
+}
index 106fae6431d7f7ab65f4a0edd741888dc2a1e13f..517302ac883acf5cb54a6ca4664159adefdfc8ed 100644 (file)
@@ -94,4 +94,8 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
 WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
 WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx);
 
+WERROR smbconf_transaction_start(struct smbconf_ctx *ctx);
+WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx);
+WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx);
+
 #endif /*  _LIBSMBCONF_H_  */
index c9e44181c6e57e1ff7c12daa6b6af55b57a16bed..e6998ad6392241a794167074a4adaefa7d7eacc3 100644 (file)
@@ -68,6 +68,9 @@ struct smbconf_ops {
                               uint32_t num_includes, const char **includes);
        WERROR (*delete_includes)(struct smbconf_ctx *ctx,
                                  const char *service);
+       WERROR (*transaction_start)(struct smbconf_ctx *ctx);
+       WERROR (*transaction_commit)(struct smbconf_ctx *ctx);
+       WERROR (*transaction_cancel)(struct smbconf_ctx *ctx);
 };
 
 struct smbconf_ctx {
index 1df4a9fdb73c0a5dd3ddf65f9d11969d65b335d1..501382cc5fd0416ab50fe61f69ffe7bc9ba69092 100644 (file)
@@ -612,6 +612,20 @@ static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
        return WERR_NOT_SUPPORTED;
 }
 
+static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
+{
+       return WERR_OK;
+}
+
+static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
+{
+       return WERR_OK;
+}
+
+static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
+{
+       return WERR_OK;
+}
 
 static struct smbconf_ops smbconf_ops_txt = {
        .init                   = smbconf_txt_init,
@@ -633,6 +647,9 @@ static struct smbconf_ops smbconf_ops_txt = {
        .get_includes           = smbconf_txt_get_includes,
        .set_includes           = smbconf_txt_set_includes,
        .delete_includes        = smbconf_txt_delete_includes,
+       .transaction_start      = smbconf_txt_transaction_start,
+       .transaction_commit     = smbconf_txt_transaction_commit,
+       .transaction_cancel     = smbconf_txt_transaction_cancel,
 };
 
 
index b1e34e51645bfd7246d0ccd72cf9c3e5d1c7151e..5a5c0ead654516414db37f6ad1bd3de31f78784a 100644 (file)
@@ -1066,6 +1066,21 @@ done:
        return werr;
 }
 
+static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
+{
+       return regdb_transaction_start();
+}
+
+static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
+{
+       return regdb_transaction_commit();
+}
+
+static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
+{
+       return regdb_transaction_cancel();
+}
+
 struct smbconf_ops smbconf_ops_reg = {
        .init                   = smbconf_reg_init,
        .shutdown               = smbconf_reg_shutdown,
@@ -1086,6 +1101,9 @@ struct smbconf_ops smbconf_ops_reg = {
        .get_includes           = smbconf_reg_get_includes,
        .set_includes           = smbconf_reg_set_includes,
        .delete_includes        = smbconf_reg_delete_includes,
+       .transaction_start      = smbconf_reg_transaction_start,
+       .transaction_commit     = smbconf_reg_transaction_commit,
+       .transaction_cancel     = smbconf_reg_transaction_cancel,
 };