[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-63-ga868d2f

Michael Adam obnox at samba.org
Wed Jan 21 17:39:39 GMT 2009


The branch, master has been updated
       via  a868d2f3d5281dea923718486e4e42b20cf8fe74 (commit)
       via  85447ac7479daebe1f9dfefccef5529eba99dadc (commit)
       via  7ac06f16095c45e0a4388e9420dca28077b0e2b7 (commit)
       via  1ed0cc7c9bc0043fe34562438136c0fed30a1746 (commit)
       via  d0a8c356fb7bc5536a8ea7db53ba8a5dd6bee78e (commit)
       via  f0f5029fd73e2c6edcaac4e381bc12316fe381cc (commit)
       via  53ea5742554f1a7064e5836df5d05ea2632b3088 (commit)
       via  c94fd054ca441f7ef6ea04dd268f495ec4884569 (commit)
       via  9f3c67e80c8b791cbfef9d58b5aa7a9ecdf909f3 (commit)
       via  52b77c928c14c9742293bcd0b0f82f56696fb5b3 (commit)
      from  3089cfcc4b75088db4dd5683902be81bc4ee48b4 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a868d2f3d5281dea923718486e4e42b20cf8fe74
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 18:10:23 2009 +0100

    libsmbconf: move the non-registry parts of libsmbconf to top level
    
    Michael

commit 85447ac7479daebe1f9dfefccef5529eba99dadc
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 18:25:47 2009 +0100

    s3:libsmbconf: include smbconf headers with lib/smbconf prefix
    
    Michael

commit 7ac06f16095c45e0a4388e9420dca28077b0e2b7
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:16:37 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in reg backend
    
    Michael

commit 1ed0cc7c9bc0043fe34562438136c0fed30a1746
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:14:56 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in txt backend
    
    Michael

commit d0a8c356fb7bc5536a8ea7db53ba8a5dd6bee78e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:12:50 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in smbconf_init
    
    Michael

commit f0f5029fd73e2c6edcaac4e381bc12316fe381cc
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:11:46 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in testsuite
    
    Michael

commit 53ea5742554f1a7064e5836df5d05ea2632b3088
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:11:02 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in smbconf_util.c
    
    Michael

commit c94fd054ca441f7ef6ea04dd268f495ec4884569
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 17:10:20 2009 +0100

    s3:libsmbconf: use talloc_free instead of TALLOC_FREE in smbconf.c
    
    Michael

commit 9f3c67e80c8b791cbfef9d58b5aa7a9ecdf909f3
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 16:59:09 2009 +0100

    s3:libsmbconf: remove the init headers from smbconf.h
    
    give the smbconf_init() dispatcher and the backends
    (smbconf_reg and smbconf_txt) a header of their own each.
    
    This allows to use the basic infrastructure and
    single backends individually.
    
    Michael

commit 52b77c928c14c9742293bcd0b0f82f56696fb5b3
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jan 21 16:24:32 2009 +0100

    s3:libsmbconf: remove unused function smbconf_is_writeable_bystring()
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 lib/smbconf/smbconf.c                          |  405 +++++++++++++++
 lib/smbconf/smbconf.h                          |   97 ++++
 {source3/lib => lib}/smbconf/smbconf_private.h |    0 
 lib/smbconf/smbconf_txt.c                      |  655 ++++++++++++++++++++++++
 lib/smbconf/smbconf_txt.h                      |   33 ++
 lib/smbconf/smbconf_util.c                     |  151 ++++++
 source3/Makefile.in                            |    5 +-
 source3/include/includes.h                     |    3 +
 source3/lib/smbconf/smbconf.c                  |  431 ----------------
 source3/lib/smbconf/smbconf.h                  |  117 -----
 source3/lib/smbconf/smbconf_init.c             |    6 +-
 source3/lib/smbconf/smbconf_init.h             |   32 ++
 source3/lib/smbconf/smbconf_reg.c              |   42 +-
 source3/lib/smbconf/smbconf_reg.h              |   33 ++
 source3/lib/smbconf/smbconf_txt.c              |  654 -----------------------
 source3/lib/smbconf/smbconf_util.c             |  151 ------
 source3/lib/smbconf/testsuite.c                |   10 +-
 17 files changed, 1442 insertions(+), 1383 deletions(-)
 create mode 100644 lib/smbconf/smbconf.c
 create mode 100644 lib/smbconf/smbconf.h
 rename {source3/lib => lib}/smbconf/smbconf_private.h (100%)
 create mode 100644 lib/smbconf/smbconf_txt.c
 create mode 100644 lib/smbconf/smbconf_txt.h
 create mode 100644 lib/smbconf/smbconf_util.c
 delete mode 100644 source3/lib/smbconf/smbconf.c
 delete mode 100644 source3/lib/smbconf/smbconf.h
 create mode 100644 source3/lib/smbconf/smbconf_init.h
 create mode 100644 source3/lib/smbconf/smbconf_reg.h
 delete mode 100644 source3/lib/smbconf/smbconf_txt.c
 delete mode 100644 source3/lib/smbconf/smbconf_util.c


Changeset truncated at 500 lines:

diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
new file mode 100644
index 0000000..d723f0b
--- /dev/null
+++ b/lib/smbconf/smbconf.c
@@ -0,0 +1,405 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  libsmbconf - Samba configuration library
+ *  Copyright (C) Michael Adam 2007-2008
+ *  Copyright (C) Guenther Deschner 2007
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "smbconf_private.h"
+
+/**********************************************************************
+ *
+ * internal helper functions
+ *
+ **********************************************************************/
+
+static WERROR smbconf_global_check(struct smbconf_ctx *ctx)
+{
+	if (!smbconf_share_exists(ctx, GLOBAL_NAME)) {
+		return smbconf_create_share(ctx, GLOBAL_NAME);
+	}
+	return WERR_OK;
+}
+
+
+/**********************************************************************
+ *
+ * The actual libsmbconf API functions that are exported.
+ *
+ **********************************************************************/
+
+/**
+ * Tell whether the backend requires messaging to be set up
+ * for the backend to work correctly.
+ */
+bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx)
+{
+	return ctx->ops->requires_messaging(ctx);
+}
+
+/**
+ * Tell whether the source is writeable.
+ */
+bool smbconf_is_writeable(struct smbconf_ctx *ctx)
+{
+	return ctx->ops->is_writeable(ctx);
+}
+
+/**
+ * Close the configuration.
+ */
+void smbconf_shutdown(struct smbconf_ctx *ctx)
+{
+	talloc_free(ctx);
+}
+
+/**
+ * Detect changes in the configuration.
+ * The given csn struct is filled with the current csn.
+ * smbconf_changed() can also be used for initial retrieval
+ * of the csn.
+ */
+bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
+		     const char *service, const char *param)
+{
+	struct smbconf_csn old_csn;
+
+	if (csn == NULL) {
+		return false;
+	}
+
+	old_csn = *csn;
+
+	ctx->ops->get_csn(ctx, csn, service, param);
+	return (csn->csn != old_csn.csn);
+}
+
+/**
+ * Drop the whole configuration (restarting empty).
+ */
+WERROR smbconf_drop(struct smbconf_ctx *ctx)
+{
+	return ctx->ops->drop(ctx);
+}
+
+/**
+ * Get the whole configuration as lists of strings with counts:
+ *
+ *  num_shares   : number of shares
+ *  share_names  : list of length num_shares of share names
+ *  num_params   : list of length num_shares of parameter counts for each share
+ *  param_names  : list of lists of parameter names for each share
+ *  param_values : list of lists of parameter values for each share
+ */
+WERROR smbconf_get_config(struct smbconf_ctx *ctx,
+			  TALLOC_CTX *mem_ctx,
+			  uint32_t *num_shares,
+			  struct smbconf_service ***services)
+{
+	WERROR werr = WERR_OK;
+	TALLOC_CTX *tmp_ctx = NULL;
+	uint32_t tmp_num_shares;
+	char **tmp_share_names;
+	struct smbconf_service **tmp_services;
+	uint32_t count;
+
+	if ((num_shares == NULL) || (services == NULL)) {
+		werr = WERR_INVALID_PARAM;
+		goto done;
+	}
+
+	tmp_ctx = talloc_stackframe();
+
+	werr = smbconf_get_share_names(ctx, tmp_ctx, &tmp_num_shares,
+				       &tmp_share_names);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	tmp_services = TALLOC_ARRAY(tmp_ctx, struct smbconf_service *,
+				    tmp_num_shares);
+
+	if (tmp_services == NULL) {
+		werr = WERR_NOMEM;
+		goto done;
+	}
+
+	for (count = 0; count < tmp_num_shares; count++) {
+		werr = smbconf_get_share(ctx, tmp_services,
+					 tmp_share_names[count],
+					 &tmp_services[count]);
+		if (!W_ERROR_IS_OK(werr)) {
+			goto done;
+		}
+	}
+
+	werr = WERR_OK;
+
+	*num_shares = tmp_num_shares;
+	if (tmp_num_shares > 0) {
+		*services = talloc_move(mem_ctx, &tmp_services);
+	} else {
+		*services = NULL;
+	}
+
+done:
+	talloc_free(tmp_ctx);
+	return werr;
+}
+
+/**
+ * get the list of share names defined in the configuration.
+ */
+WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
+			       TALLOC_CTX *mem_ctx,
+			       uint32_t *num_shares,
+			       char ***share_names)
+{
+	return ctx->ops->get_share_names(ctx, mem_ctx, num_shares,
+					 share_names);
+}
+
+/**
+ * check if a share/service of a given name exists
+ */
+bool smbconf_share_exists(struct smbconf_ctx *ctx,
+			  const char *servicename)
+{
+	return ctx->ops->share_exists(ctx, servicename);
+}
+
+/**
+ * Add a service if it does not already exist.
+ */
+WERROR smbconf_create_share(struct smbconf_ctx *ctx,
+			    const char *servicename)
+{
+	if ((servicename != NULL) && smbconf_share_exists(ctx, servicename)) {
+		return WERR_FILE_EXISTS;
+	}
+
+	return ctx->ops->create_share(ctx, servicename);
+}
+
+/**
+ * get a definition of a share (service) from configuration.
+ */
+WERROR smbconf_get_share(struct smbconf_ctx *ctx,
+			 TALLOC_CTX *mem_ctx,
+			 const char *servicename,
+			 struct smbconf_service **service)
+{
+	if (!smbconf_share_exists(ctx, servicename)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->get_share(ctx, mem_ctx, servicename, service);
+}
+
+/**
+ * delete a service from configuration
+ */
+WERROR smbconf_delete_share(struct smbconf_ctx *ctx, const char *servicename)
+{
+	if (!smbconf_share_exists(ctx, servicename)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->delete_share(ctx, servicename);
+}
+
+/**
+ * set a configuration parameter to the value provided.
+ */
+WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
+			     const char *service,
+			     const char *param,
+			     const char *valstr)
+{
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->set_parameter(ctx, service, param, valstr);
+}
+
+/**
+ * Set a global parameter
+ * (i.e. a parameter in the [global] service).
+ *
+ * This also creates [global] when it does not exist.
+ */
+WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
+				    const char *param, const char *val)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_set_parameter(ctx, GLOBAL_NAME, param, val);
+	}
+
+	return werr;
+}
+
+/**
+ * get the value of a configuration parameter as a string
+ */
+WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
+			     TALLOC_CTX *mem_ctx,
+			     const char *service,
+			     const char *param,
+			     char **valstr)
+{
+	if (valstr == NULL) {
+		return WERR_INVALID_PARAM;
+	}
+
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
+}
+
+/**
+ * Get the value of a global parameter.
+ *
+ * Create [global] if it does not exist.
+ */
+WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
+				    TALLOC_CTX *mem_ctx,
+				    const char *param,
+				    char **valstr)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_get_parameter(ctx, mem_ctx, GLOBAL_NAME, param,
+					     valstr);
+	}
+
+	return werr;
+}
+
+/**
+ * delete a parameter from configuration
+ */
+WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
+				const char *service, const char *param)
+{
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->delete_parameter(ctx, service, param);
+}
+
+/**
+ * Delete a global parameter.
+ *
+ * Create [global] if it does not exist.
+ */
+WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
+				       const char *param)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_delete_parameter(ctx, GLOBAL_NAME, param);
+	}
+
+	return werr;
+}
+
+WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
+			    TALLOC_CTX *mem_ctx,
+			    const char *service,
+			    uint32_t *num_includes, char ***includes)
+{
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes,
+				      includes);
+}
+
+WERROR smbconf_get_global_includes(struct smbconf_ctx *ctx,
+				   TALLOC_CTX *mem_ctx,
+				   uint32_t *num_includes, char ***includes)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_get_includes(ctx, mem_ctx, GLOBAL_NAME,
+					    num_includes, includes);
+	}
+
+	return werr;
+}
+
+WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
+			    const char *service,
+			    uint32_t num_includes, const char **includes)
+{
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->set_includes(ctx, service, num_includes, includes);
+}
+
+WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
+				   uint32_t num_includes,
+				   const char **includes)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_set_includes(ctx, GLOBAL_NAME,
+					    num_includes, includes);
+	}
+
+	return werr;
+}
+
+
+WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
+{
+	if (!smbconf_share_exists(ctx, service)) {
+		return WERR_NO_SUCH_SERVICE;
+	}
+
+	return ctx->ops->delete_includes(ctx, service);
+}
+
+WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx)
+{
+	WERROR werr;
+
+	werr = smbconf_global_check(ctx);
+	if (W_ERROR_IS_OK(werr)) {
+		werr = smbconf_delete_includes(ctx, GLOBAL_NAME);
+	}
+
+	return werr;
+}
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
new file mode 100644
index 0000000..106fae6
--- /dev/null
+++ b/lib/smbconf/smbconf.h
@@ -0,0 +1,97 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  libsmbconf - Samba configuration library
+ *  Copyright (C) Michael Adam 2008
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __LIBSMBCONF_H__
+#define __LIBSMBCONF_H__
+
+struct smbconf_ctx;
+
+/* the change sequence number */
+struct smbconf_csn {
+	uint64_t csn;
+};
+
+struct smbconf_service {
+	char *name;
+	uint32_t num_params;
+	char **param_names;
+	char **param_values;
+};
+
+/*
+ * the smbconf API functions
+ */
+bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
+bool smbconf_is_writeable(struct smbconf_ctx *ctx);
+void smbconf_shutdown(struct smbconf_ctx *ctx);
+bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
+		     const char *service, const char *param);
+WERROR smbconf_drop(struct smbconf_ctx *ctx);
+WERROR smbconf_get_config(struct smbconf_ctx *ctx,
+			  TALLOC_CTX *mem_ctx,
+			  uint32_t *num_shares,
+			  struct smbconf_service ***services);
+WERROR smbconf_get_share_names(struct smbconf_ctx *ctx,
+			       TALLOC_CTX *mem_ctx,
+			       uint32_t *num_shares,
+			       char ***share_names);
+bool smbconf_share_exists(struct smbconf_ctx *ctx, const char *servicename);
+WERROR smbconf_create_share(struct smbconf_ctx *ctx, const char *servicename);
+WERROR smbconf_get_share(struct smbconf_ctx *ctx,
+			 TALLOC_CTX *mem_ctx,
+			 const char *servicename,
+			 struct smbconf_service **service);
+WERROR smbconf_delete_share(struct smbconf_ctx *ctx,
+			    const char *servicename);
+WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
+			     const char *service,
+			     const char *param,
+			     const char *valstr);
+WERROR smbconf_set_global_parameter(struct smbconf_ctx *ctx,
+				    const char *param, const char *val);
+WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
+			     TALLOC_CTX *mem_ctx,
+			     const char *service,
+			     const char *param,
+			     char **valstr);
+WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
+				    TALLOC_CTX *mem_ctx,
+				    const char *param,
+				    char **valstr);
+WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
+				const char *service, const char *param);
+WERROR smbconf_delete_global_parameter(struct smbconf_ctx *ctx,
+				       const char *param);
+WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
+			    TALLOC_CTX *mem_ctx,
+			    const char *service,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list