summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-20 12:28:41 +0100
committerMichael Adam <obnox@samba.org>2008-03-21 02:25:56 +0100
commit2135f7dd61ea46b539fefc9af3d0212a9281edcd (patch)
tree37dff3507895acdfa4138991fc2822f5d1a164be /source3/lib
parentf12b10566df44df3c86b59c0cff80b52534558b3 (diff)
downloadsamba-2135f7dd61ea46b539fefc9af3d0212a9281edcd.tar.gz
samba-2135f7dd61ea46b539fefc9af3d0212a9281edcd.tar.bz2
samba-2135f7dd61ea46b539fefc9af3d0212a9281edcd.zip
libsmbconf: introduce a smbconf_ops layer to allow interchangeable backends.
Michael (This used to be commit a857f643d1558c0fdab4b647695d75223b730b96)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/smbconf/smbconf.c47
-rw-r--r--source3/lib/smbconf/smbconf_private.h31
2 files changed, 64 insertions, 14 deletions
diff --git a/source3/lib/smbconf/smbconf.c b/source3/lib/smbconf/smbconf.c
index ba20316b57..a9e895a168 100644
--- a/source3/lib/smbconf/smbconf.c
+++ b/source3/lib/smbconf/smbconf.c
@@ -413,7 +413,10 @@ static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
*
**********************************************************************/
-static WERROR smbconf_reg_initialize(struct smbconf_ctx *ctx)
+/**
+ * initialize the registry smbconf backend
+ */
+static WERROR smbconf_reg_init(struct smbconf_ctx *ctx)
{
WERROR werr = WERR_OK;
@@ -746,6 +749,20 @@ done:
return werr;
}
+struct smbconf_ops smbconf_ops_reg = {
+ .init = smbconf_reg_init,
+ .get_csn = smbconf_reg_get_csn,
+ .drop = smbconf_reg_drop,
+ .get_share_names = smbconf_reg_get_share_names,
+ .share_exists = smbconf_reg_share_exists,
+ .create_share = smbconf_reg_create_share,
+ .get_share = smbconf_reg_get_share,
+ .delete_share = smbconf_reg_delete_share,
+ .set_parameter = smbconf_reg_set_parameter,
+ .get_parameter = smbconf_reg_get_parameter,
+ .delete_parameter = smbconf_reg_delete_parameter
+};
+
/**********************************************************************
*
@@ -780,7 +797,9 @@ WERROR smbconf_open(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx)
return WERR_NOMEM;
}
- werr = smbconf_reg_initialize(ctx);
+ ctx->ops = &smbconf_ops_reg;
+
+ werr = ctx->ops->init(ctx);
if (!W_ERROR_IS_OK(werr)) {
goto fail;
}
@@ -821,7 +840,7 @@ bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
old_csn = *csn;
- smbconf_reg_get_csn(ctx, csn, service, param);
+ ctx->ops->get_csn(ctx, csn, service, param);
return (csn->csn != old_csn.csn);
}
@@ -830,7 +849,7 @@ bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
*/
WERROR smbconf_drop(struct smbconf_ctx *ctx)
{
- return smbconf_reg_drop(ctx);
+ return ctx->ops->drop(ctx);
}
/**
@@ -927,8 +946,8 @@ WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
uint32_t *num_shares,
char ***share_names)
{
- return smbconf_reg_get_share_names(ctx, mem_ctx, num_shares,
- share_names);
+ return ctx->ops->get_share_names(ctx, mem_ctx, num_shares,
+ share_names);
}
/**
@@ -940,7 +959,7 @@ bool smbconf_share_exists(struct smbconf_ctx *ctx,
if (servicename == NULL) {
return false;
}
- return smbconf_reg_share_exists(ctx, servicename);
+ return ctx->ops->share_exists(ctx, servicename);
}
/**
@@ -953,7 +972,7 @@ WERROR smbconf_create_share(struct smbconf_ctx *ctx,
return WERR_ALREADY_EXISTS;
}
- return smbconf_reg_create_share(ctx, servicename);
+ return ctx->ops->create_share(ctx, servicename);
}
/**
@@ -968,8 +987,8 @@ WERROR smbconf_get_share(struct smbconf_ctx *ctx,
return WERR_NO_SUCH_SERVICE;
}
- return smbconf_reg_get_share(ctx, mem_ctx, servicename, num_params,
- param_names, param_values);
+ return ctx->ops->get_share(ctx, mem_ctx, servicename, num_params,
+ param_names, param_values);
}
/**
@@ -981,7 +1000,7 @@ WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
return WERR_NO_SUCH_SERVICE;
}
- return smbconf_reg_delete_share(ctx, servicename);
+ return ctx->ops->delete_share(ctx, servicename);
}
/**
@@ -996,7 +1015,7 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
return WERR_NO_SUCH_SERVICE;
}
- return smbconf_reg_set_parameter(ctx, service, param, valstr);
+ return ctx->ops->set_parameter(ctx, service, param, valstr);
}
/**
@@ -1035,7 +1054,7 @@ WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
return WERR_NO_SUCH_SERVICE;
}
- return smbconf_reg_get_parameter(ctx, mem_ctx, service, param, valstr);
+ return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
}
/**
@@ -1069,7 +1088,7 @@ WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
return WERR_NO_SUCH_SERVICE;
}
- return smbconf_reg_delete_parameter(ctx, service, param);
+ return ctx->ops->delete_parameter(ctx, service, param);
}
/**
diff --git a/source3/lib/smbconf/smbconf_private.h b/source3/lib/smbconf/smbconf_private.h
index 1827645583..d9e0f1396a 100644
--- a/source3/lib/smbconf/smbconf_private.h
+++ b/source3/lib/smbconf/smbconf_private.h
@@ -20,8 +20,39 @@
#ifndef __LIBSMBCONF_PRIVATE_H__
#define __LIBSMBCONF_PRIVATE_H__
+struct smbconf_ops {
+ WERROR (*init)(struct smbconf_ctx *ctx);
+ void (*get_csn)(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
+ const char *service, const char *param);
+ WERROR (*drop)(struct smbconf_ctx *ctx);
+ WERROR (*get_share_names)(struct smbconf_ctx *ctx,
+ TALLOC_CTX *mem_ctx,
+ uint32_t *num_shares,
+ char ***share_names);
+ bool (*share_exists)(struct smbconf_ctx *ctx, const char *service);
+ WERROR (*create_share)(struct smbconf_ctx *ctx, const char *service);
+ WERROR (*get_share)(struct smbconf_ctx *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *servicename, uint32_t *num_params,
+ char ***param_names, char ***param_values);
+ WERROR (*delete_share)(struct smbconf_ctx *ctx,
+ const char *servicename);
+ WERROR (*set_parameter)(struct smbconf_ctx *ctx,
+ const char *service,
+ const char *param,
+ const char *valstr);
+ WERROR (*get_parameter)(struct smbconf_ctx *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *service,
+ const char *param,
+ char **valstr);
+ WERROR (*delete_parameter)(struct smbconf_ctx *ctx,
+ const char *service, const char *param);
+};
+
struct smbconf_ctx {
NT_USER_TOKEN *token;
+ struct smbconf_ops *ops;
};
#endif