s3:libsmbconf: add transactions to the libsmbconf api
authorMichael Adam <obnox@samba.org>
Tue, 24 Feb 2009 10:25:44 +0000 (11:25 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 19 Mar 2009 17:03:56 +0000 (18:03 +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

Signed-off-by: Michael Adam <obnox@samba.org>
source/lib/smbconf/smbconf.c
source/lib/smbconf/smbconf.h
source/lib/smbconf/smbconf_private.h
source/lib/smbconf/smbconf_reg.c
source/lib/smbconf/smbconf_txt.c

index b69c9a2cf11c66e62aa9337c2908e20e4bd1a2f3..01557a764fbc4ea04f7eadafd5fc33be226362fe 100644 (file)
@@ -375,3 +375,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 b0333e981aabe61da133484f512bc24e4f0fe0a4..3465694d2ca68af5f55440b1d127724d45e3ce4a 100644 (file)
@@ -62,6 +62,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 b0cd09f8407a76bbc81f3df24dc55e2b4f24adc8..9a78692e42cbec2f4d1a2b20199bca8728866861 100644 (file)
@@ -1071,6 +1071,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,
@@ -1091,6 +1106,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,
 };
 
 
index d9e4e088c66a189657a32a743ce5ad35133054e0..3a6d0b8b9680892bc71943e2992182ad0d54bce1 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,
 };