summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/README4
-rw-r--r--source4/param/config.mk68
-rw-r--r--source4/param/generic.c296
-rw-r--r--source4/param/loadparm.c2636
-rw-r--r--source4/param/loadparm.h75
-rw-r--r--source4/param/param.h430
-rw-r--r--source4/param/param.i350
-rw-r--r--source4/param/param.py267
-rw-r--r--source4/param/param_wrap.c4849
-rw-r--r--source4/param/provision.c139
-rw-r--r--source4/param/provision.h51
-rw-r--r--source4/param/samba-hostconfig.pc.in10
-rw-r--r--source4/param/secrets.c196
-rw-r--r--source4/param/secrets.h53
-rw-r--r--source4/param/share.c156
-rw-r--r--source4/param/share.h137
-rw-r--r--source4/param/share_classic.c362
-rw-r--r--source4/param/share_ldb.c592
-rw-r--r--source4/param/tests/bindings.py72
-rw-r--r--source4/param/tests/loadparm.c167
-rw-r--r--source4/param/tests/share.c215
-rw-r--r--source4/param/util.c297
22 files changed, 11422 insertions, 0 deletions
diff --git a/source4/param/README b/source4/param/README
new file mode 100644
index 0000000000..403a217588
--- /dev/null
+++ b/source4/param/README
@@ -0,0 +1,4 @@
+This directory contains "libsamba-hostconfig".
+
+The libsamba-hostconfig library provides access to all host-wide configuration
+such as the configured shares, default parameter values and host secret keys.
diff --git a/source4/param/config.mk b/source4/param/config.mk
new file mode 100644
index 0000000000..6af9dab5d9
--- /dev/null
+++ b/source4/param/config.mk
@@ -0,0 +1,68 @@
+[LIBRARY::LIBSAMBA-HOSTCONFIG]
+PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL
+PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET
+
+LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1
+LIBSAMBA-HOSTCONFIG_SOVERSION = 0
+
+LIBSAMBA-HOSTCONFIG_OBJ_FILES = $(addprefix $(paramsrcdir)/, \
+ loadparm.o generic.o util.o)
+
+PUBLIC_HEADERS += param/param.h
+
+PC_FILES += $(paramsrcdir)/samba-hostconfig.pc
+
+[SUBSYSTEM::PROVISION]
+PRIVATE_DEPENDENCIES = LIBPYTHON swig_ldb
+
+PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o
+
+#################################
+# Start SUBSYSTEM share
+[SUBSYSTEM::share]
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
+# End SUBSYSTEM share
+#################################
+
+share_OBJ_FILES = $(paramsrcdir)/share.o
+
+$(eval $(call proto_header_template,$(paramsrcdir)/share_proto.h,$(share_OBJ_FILES:.o=.c)))
+
+PUBLIC_HEADERS += param/share.h
+
+################################################
+# Start MODULE share_classic
+[MODULE::share_classic]
+SUBSYSTEM = share
+INIT_FUNCTION = share_classic_init
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
+# End MODULE share_classic
+################################################
+
+share_classic_OBJ_FILES = $(paramsrcdir)/share_classic.o
+
+################################################
+# Start MODULE share_ldb
+[MODULE::share_ldb]
+SUBSYSTEM = share
+INIT_FUNCTION = share_ldb_init
+PRIVATE_DEPENDENCIES = LIBLDB LDB_WRAP
+# End MODULE share_ldb
+################################################
+
+share_ldb_OBJ_FILES = $(paramsrcdir)/share_ldb.o
+
+[SUBSYSTEM::SECRETS]
+PRIVATE_DEPENDENCIES = LIBLDB TDB_WRAP UTIL_TDB NDR_SECURITY
+
+SECRETS_OBJ_FILES = $(paramsrcdir)/secrets.o
+
+[PYTHON::param]
+LIBRARY_REALNAME = samba/_param.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG
+
+param_OBJ_FILES = $(paramsrcdir)/param_wrap.o
+
+$(eval $(call python_py_module_template,samba/param.py,$(paramsrcdir)/param.py))
+
+$(param_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/param/generic.c b/source4/param/generic.c
new file mode 100644
index 0000000000..b86e3ad234
--- /dev/null
+++ b/source4/param/generic.c
@@ -0,0 +1,296 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Copyright (C) Jelmer Vernooij 2005
+ *
+ * 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 "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "system/filesys.h"
+
+struct param_section *param_get_section(struct param_context *ctx, const char *name)
+{
+ struct param_section *sect;
+
+ if (name == NULL)
+ name = GLOBAL_NAME;
+
+ for (sect = ctx->sections; sect; sect = sect->next) {
+ if (!strcasecmp_m(sect->name, name))
+ return sect;
+ }
+
+ return NULL;
+}
+
+struct param_opt *param_section_get(struct param_section *section,
+ const char *name)
+{
+ struct param_opt *p;
+
+ for (p = section->parameters; p; p = p->next) {
+ if (strcasecmp_m(p->key, name) == 0)
+ return p;
+ }
+
+ return NULL;
+}
+
+struct param_opt *param_get (struct param_context *ctx, const char *name, const char *section_name)
+{
+ struct param_section *section = param_get_section(ctx, section_name);
+ if (section == NULL)
+ return NULL;
+
+ return param_section_get(section, name);
+}
+
+struct param_section *param_add_section(struct param_context *ctx, const char *section_name)
+{
+ struct param_section *section;
+ section = talloc_zero(ctx, struct param_section);
+ if (section == NULL)
+ return NULL;
+
+ section->name = talloc_strdup(section, section_name);
+ DLIST_ADD_END(ctx->sections, section, struct param_section *);
+ return section;
+}
+
+/* Look up parameter. If it is not found, add it */
+struct param_opt *param_get_add(struct param_context *ctx, const char *name, const char *section_name)
+{
+ struct param_section *section;
+ struct param_opt *p;
+
+ SMB_ASSERT(section_name != NULL);
+ SMB_ASSERT(name != NULL);
+
+ section = param_get_section(ctx, section_name);
+
+ if (section == NULL) {
+ section = param_add_section(ctx, section_name);
+ }
+
+ p = param_section_get(section, name);
+ if (p == NULL) {
+ p = talloc_zero(section, struct param_opt);
+ if (p == NULL)
+ return NULL;
+
+ p->key = talloc_strdup(p, name);
+ DLIST_ADD_END(section->parameters, p, struct param_opt *);
+ }
+
+ return p;
+}
+
+const char *param_get_string(struct param_context *ctx, const char *param, const char *section)
+{
+ struct param_opt *p = param_get(ctx, param, section);
+
+ if (p == NULL)
+ return NULL;
+
+ return p->value;
+}
+
+int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section)
+{
+ struct param_opt *p = param_get_add(ctx, param, section);
+
+ if (p == NULL)
+ return -1;
+
+ p->value = talloc_strdup(p, value);
+
+ return 0;
+}
+
+const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section)
+{
+ struct param_opt *p = param_get(ctx, param, section);
+
+ if (p == NULL)
+ return NULL;
+
+ if (separator == NULL)
+ separator = LIST_SEP;
+
+ return str_list_make(ctx, p->value, separator);
+}
+
+int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section)
+{
+ struct param_opt *p = param_get_add(ctx, param, section);
+
+ p->value = str_list_join(p, list, ' ');
+
+ return 0;
+}
+
+int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section)
+{
+ const char *value = param_get_string(ctx, param, section);
+
+ if (value)
+ return strtol(value, NULL, 0);
+
+ return default_v;
+}
+
+void param_set_int(struct param_context *ctx, const char *param, int value, const char *section)
+{
+ struct param_opt *p = param_get_add(ctx, section, param);
+
+ if (!p)
+ return;
+
+ p->value = talloc_asprintf(p, "%d", value);
+}
+
+unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section)
+{
+ const char *value = param_get_string(ctx, param, section);
+
+ if (value)
+ return strtoul(value, NULL, 0);
+
+ return default_v;
+}
+
+void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section)
+{
+ struct param_opt *p = param_get_add(ctx, name, section);
+
+ if (!p)
+ return;
+
+ p->value = talloc_asprintf(p, "%lu", value);
+}
+
+static bool param_sfunc (const char *name, void *_ctx)
+{
+ struct param_context *ctx = (struct param_context *)_ctx;
+ struct param_section *section = param_get_section(ctx, name);
+
+ if (section == NULL) {
+ section = talloc_zero(ctx, struct param_section);
+ if (section == NULL)
+ return false;
+
+ section->name = talloc_strdup(section, name);
+
+ DLIST_ADD_END(ctx->sections, section, struct param_section *);
+ }
+
+ /* Make sure this section is on top of the list for param_pfunc */
+ DLIST_PROMOTE(ctx->sections, section);
+
+ return true;
+}
+
+static bool param_pfunc (const char *name, const char *value, void *_ctx)
+{
+ struct param_context *ctx = (struct param_context *)_ctx;
+ struct param_opt *p = param_section_get(ctx->sections, name);
+
+ if (!p) {
+ p = talloc_zero(ctx->sections, struct param_opt);
+ if (p == NULL)
+ return false;
+
+ p->key = talloc_strdup(p, name);
+ p->value = talloc_strdup(p, value);
+ DLIST_ADD(ctx->sections->parameters, p);
+ } else { /* Replace current value */
+ talloc_free(p->value);
+ p->value = talloc_strdup(p, value);
+ }
+
+ return true;
+}
+
+struct param_context *param_init(TALLOC_CTX *mem_ctx)
+{
+ return talloc_zero(mem_ctx, struct param_context);
+}
+
+
+int param_read(struct param_context *ctx, const char *fn)
+{
+ ctx->sections = talloc_zero(ctx, struct param_section);
+ if (ctx->sections == NULL)
+ return -1;
+
+ ctx->sections->name = talloc_strdup(ctx->sections, "global");
+ if (!pm_process( fn, param_sfunc, param_pfunc, ctx)) {
+ return -1;
+ }
+
+ return 0;
+}
+
+int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx)
+{
+ struct param_section *section;
+
+ for (section = ctx->sections; section; section = section->next) {
+ struct param_opt *param;
+ bool isglobal = strcmp(section->name, "global") == 0;
+ for (param = section->parameters; param; param = param->next) {
+ if (isglobal)
+ lp_do_global_parameter(lp_ctx, param->key,
+ param->value);
+ else {
+ struct loadparm_service *service =
+ lp_service(lp_ctx, section->name);
+ if (service == NULL)
+ service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), section->name);
+ lp_do_service_parameter(lp_ctx, service, param->key, param->value);
+ }
+ }
+ }
+ return 0;
+}
+
+int param_write(struct param_context *ctx, const char *fn)
+{
+ int file;
+ struct param_section *section;
+
+ if (fn == NULL || ctx == NULL)
+ return -1;
+
+ file = open(fn, O_WRONLY|O_CREAT, 0755);
+
+ if (file == -1)
+ return -1;
+
+ for (section = ctx->sections; section; section = section->next) {
+ struct param_opt *param;
+
+ fdprintf(file, "[%s]\n", section->name);
+ for (param = section->parameters; param; param = param->next) {
+ fdprintf(file, "\t%s = %s\n", param->key, param->value);
+ }
+ fdprintf(file, "\n");
+ }
+
+ close(file);
+
+ return 0;
+}
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
new file mode 100644
index 0000000000..e63a7aa8a1
--- /dev/null
+++ b/source4/param/loadparm.c
@@ -0,0 +1,2636 @@
+/*
+ Unix SMB/CIFS implementation.
+ Parameter loading functions
+ Copyright (C) Karl Auer 1993-1998
+
+ Largely re-written by Andrew Tridgell, September 1994
+
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Alexander Bokovoy 2002
+ Copyright (C) Stefan (metze) Metzmacher 2002
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
+ Copyright (C) James Myers 2003 <myersjj@samba.org>
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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/>.
+*/
+
+/*
+ * Load parameters.
+ *
+ * This module provides suitable callback functions for the params
+ * module. It builds the internal table of service details which is
+ * then used by the rest of the server.
+ *
+ * To add a parameter:
+ *
+ * 1) add it to the global or service structure definition
+ * 2) add it to the parm_table
+ * 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
+ * 4) If it's a global then initialise it in init_globals. If a local
+ * (ie. service) parameter then initialise it in the sDefault structure
+ *
+ *
+ * Notes:
+ * The configuration file is processed sequentially for speed. It is NOT
+ * accessed randomly as happens in 'real' Windows. For this reason, there
+ * is a fair bit of sequence-dependent code here - ie., code which assumes
+ * that certain things happen before others. In particular, the code which
+ * happens at the boundary between sections is delicately poised, so be
+ * careful!
+ *
+ */
+
+#include "includes.h"
+#include "version.h"
+#include "dynconfig/dynconfig.h"
+#include "system/time.h"
+#include "system/locale.h"
+#include "system/network.h" /* needed for TCP_NODELAY */
+#include "smb_server/smb_server.h"
+#include "libcli/raw/signing.h"
+#include "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "param/loadparm.h"
+#include "libcli/raw/libcliraw.h"
+
+#define standard_sub_basic talloc_strdup
+
+static bool do_parameter(const char *, const char *, void *);
+static bool defaults_saved = false;
+
+/**
+ * This structure describes global (ie., server-wide) parameters.
+ */
+struct loadparm_global
+{
+ enum server_role server_role;
+
+ const char **smb_ports;
+ char *ncalrpc_dir;
+ char *dos_charset;
+ char *unix_charset;
+ char *display_charset;
+ char *szLockDir;
+ char *szModulesDir;
+ char *szPidDir;
+ char *szSetupDir;
+ char *szServerString;
+ char *szAutoServices;
+ char *szPasswdChat;
+ char *szShareBackend;
+ char *szSAM_URL;
+ char *szIDMAP_URL;
+ char *szSECRETS_URL;
+ char *szSPOOLSS_URL;
+ char *szWINS_CONFIG_URL;
+ char *szWINS_URL;
+ char *szPrivateDir;
+ const char **jsInclude;
+ char *jsonrpcServicesDir;
+ const char **szPasswordServers;
+ char *szSocketOptions;
+ char *szRealm;
+ const char **szWINSservers;
+ const char **szInterfaces;
+ char *szSocketAddress;
+ char *szAnnounceVersion; /* This is initialised in init_globals */
+ char *szWorkgroup;
+ char *szNetbiosName;
+ const char **szNetbiosAliases;
+ char *szNetbiosScope;
+ char *szDomainOtherSIDs;
+ const char **szNameResolveOrder;
+ const char **dcerpc_ep_servers;
+ const char **server_services;
+ char *ntptr_providor;
+ char *szWinbindSeparator;
+ char *szWinbinddPrivilegedSocketDirectory;
+ char *szWinbinddSocketDirectory;
+ char *szTemplateShell;
+ char *szTemplateHomedir;
+ int bWinbindSealedPipes;
+ int bIdmapTrustedOnly;
+ char *swat_directory;
+ int tls_enabled;
+ char *tls_keyfile;
+ char *tls_certfile;
+ char *tls_cafile;
+ char *tls_crlfile;
+ char *tls_dhpfile;
+ char *logfile;
+ char *panic_action;
+ int max_mux;
+ int debuglevel;
+ int max_xmit;
+ int pwordlevel;
+ int srv_maxprotocol;
+ int srv_minprotocol;
+ int cli_maxprotocol;
+ int cli_minprotocol;
+ int security;
+ int paranoid_server_security;
+ int max_wins_ttl;
+ int min_wins_ttl;
+ int announce_as; /* This is initialised in init_globals */
+ int nbt_port;
+ int dgram_port;
+ int cldap_port;
+ int krb5_port;
+ int kpasswd_port;
+ int web_port;
+ char *socket_options;
+ int bWINSsupport;
+ int bWINSdnsProxy;
+ char *szWINSHook;
+ int bLocalMaster;
+ int bPreferredMaster;
+ int bEncryptPasswords;
+ int bNullPasswords;
+ int bObeyPamRestrictions;
+ int bLargeReadwrite;
+ int bReadRaw;
+ int bWriteRaw;
+ int bTimeServer;
+ int bBindInterfacesOnly;
+ int bNTSmbSupport;
+ int bNTStatusSupport;
+ int bLanmanAuth;
+ int bNTLMAuth;
+ int bUseSpnego;
+ int server_signing;
+ int client_signing;
+ int bClientPlaintextAuth;
+ int bClientLanManAuth;
+ int bClientNTLMv2Auth;
+ int client_use_spnego_principal;
+ int bHostMSDfs;
+ int bUnicode;
+ int bUnixExtensions;
+ int bDisableNetbios;
+ int bRpcBigEndian;
+ char *szNTPSignDSocketDirectory;
+ struct param_opt *param_opt;
+};
+
+
+/**
+ * This structure describes a single service.
+ */
+struct loadparm_service
+{
+ char *szService;
+ char *szPath;
+ char *szCopy;
+ char *szInclude;
+ char *szPrintername;
+ char **szHostsallow;
+ char **szHostsdeny;
+ char *comment;
+ char *volume;
+ char *fstype;
+ char **ntvfs_handler;
+ int iMaxPrintJobs;
+ int iMaxConnections;
+ int iCSCPolicy;
+ int bAvailable;
+ int bBrowseable;
+ int bRead_only;
+ int bPrint_ok;
+ int bMap_system;
+ int bMap_hidden;
+ int bMap_archive;
+ int bStrictLocking;
+ int bOplocks;
+ int iCreate_mask;
+ int iCreate_force_mode;
+ int iDir_mask;
+ int iDir_force_mode;
+ int *copymap;
+ int bMSDfsRoot;
+ int bStrictSync;
+ int bCIFileSystem;
+ struct param_opt *param_opt;
+
+ char dummy[3]; /* for alignment */
+};
+
+
+struct loadparm_context *global_loadparm = NULL;
+
+#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
+
+
+/* prototypes for the special type handlers */
+static bool handle_include(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
+static bool handle_copy(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
+static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
+static bool handle_logfile(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr);
+
+static const struct enum_list enum_protocol[] = {
+ {PROTOCOL_SMB2, "SMB2"},
+ {PROTOCOL_NT1, "NT1"},
+ {PROTOCOL_LANMAN2, "LANMAN2"},
+ {PROTOCOL_LANMAN1, "LANMAN1"},
+ {PROTOCOL_CORE, "CORE"},
+ {PROTOCOL_COREPLUS, "COREPLUS"},
+ {PROTOCOL_COREPLUS, "CORE+"},
+ {-1, NULL}
+};
+
+static const struct enum_list enum_security[] = {
+ {SEC_SHARE, "SHARE"},
+ {SEC_USER, "USER"},
+ {-1, NULL}
+};
+
+static const struct enum_list enum_announce_as[] = {
+ {ANNOUNCE_AS_NT_SERVER, "NT"},
+ {ANNOUNCE_AS_NT_SERVER, "NT Server"},
+ {ANNOUNCE_AS_NT_WORKSTATION, "NT Workstation"},
+ {ANNOUNCE_AS_WIN95, "win95"},
+ {ANNOUNCE_AS_WFW, "WfW"},
+ {-1, NULL}
+};
+
+static const struct enum_list enum_bool_auto[] = {
+ {false, "No"},
+ {false, "False"},
+ {false, "0"},
+ {true, "Yes"},
+ {true, "True"},
+ {true, "1"},
+ {Auto, "Auto"},
+ {-1, NULL}
+};
+
+/* Client-side offline caching policy types */
+enum csc_policy {
+ CSC_POLICY_MANUAL=0,
+ CSC_POLICY_DOCUMENTS=1,
+ CSC_POLICY_PROGRAMS=2,
+ CSC_POLICY_DISABLE=3
+};
+
+static const struct enum_list enum_csc_policy[] = {
+ {CSC_POLICY_MANUAL, "manual"},
+ {CSC_POLICY_DOCUMENTS, "documents"},
+ {CSC_POLICY_PROGRAMS, "programs"},
+ {CSC_POLICY_DISABLE, "disable"},
+ {-1, NULL}
+};
+
+/* SMB signing types. */
+static const struct enum_list enum_smb_signing_vals[] = {
+ {SMB_SIGNING_OFF, "No"},
+ {SMB_SIGNING_OFF, "False"},
+ {SMB_SIGNING_OFF, "0"},
+ {SMB_SIGNING_OFF, "Off"},
+ {SMB_SIGNING_OFF, "disabled"},
+ {SMB_SIGNING_SUPPORTED, "Yes"},
+ {SMB_SIGNING_SUPPORTED, "True"},
+ {SMB_SIGNING_SUPPORTED, "1"},
+ {SMB_SIGNING_SUPPORTED, "On"},
+ {SMB_SIGNING_SUPPORTED, "enabled"},
+ {SMB_SIGNING_REQUIRED, "required"},
+ {SMB_SIGNING_REQUIRED, "mandatory"},
+ {SMB_SIGNING_REQUIRED, "force"},
+ {SMB_SIGNING_REQUIRED, "forced"},
+ {SMB_SIGNING_REQUIRED, "enforced"},
+ {SMB_SIGNING_AUTO, "auto"},
+ {-1, NULL}
+};
+
+static const struct enum_list enum_server_role[] = {
+ {ROLE_STANDALONE, "standalone"},
+ {ROLE_DOMAIN_MEMBER, "member server"},
+ {ROLE_DOMAIN_MEMBER, "member"},
+ {ROLE_DOMAIN_CONTROLLER, "domain controller"},
+ {ROLE_DOMAIN_CONTROLLER, "dc"},
+ {-1, NULL}
+};
+
+
+#define GLOBAL_VAR(name) offsetof(struct loadparm_global, name)
+#define LOCAL_VAR(name) offsetof(struct loadparm_service, name)
+
+static struct parm_struct parm_table[] = {
+ {"server role", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_role), NULL, enum_server_role},
+
+ {"dos charset", P_STRING, P_GLOBAL, GLOBAL_VAR(dos_charset), NULL, NULL},
+ {"unix charset", P_STRING, P_GLOBAL, GLOBAL_VAR(unix_charset), NULL, NULL},
+ {"ncalrpc dir", P_STRING, P_GLOBAL, GLOBAL_VAR(ncalrpc_dir), NULL, NULL},
+ {"display charset", P_STRING, P_GLOBAL, GLOBAL_VAR(display_charset), NULL, NULL},
+ {"comment", P_STRING, P_LOCAL, LOCAL_VAR(comment), NULL, NULL},
+ {"path", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
+ {"directory", P_STRING, P_LOCAL, LOCAL_VAR(szPath), NULL, NULL},
+ {"workgroup", P_USTRING, P_GLOBAL, GLOBAL_VAR(szWorkgroup), NULL, NULL},
+ {"realm", P_STRING, P_GLOBAL, GLOBAL_VAR(szRealm), NULL, NULL},
+ {"netbios name", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosName), NULL, NULL},
+ {"netbios aliases", P_LIST, P_GLOBAL, GLOBAL_VAR(szNetbiosAliases), NULL, NULL},
+ {"netbios scope", P_USTRING, P_GLOBAL, GLOBAL_VAR(szNetbiosScope), NULL, NULL},
+ {"server string", P_STRING, P_GLOBAL, GLOBAL_VAR(szServerString), NULL, NULL},
+ {"interfaces", P_LIST, P_GLOBAL, GLOBAL_VAR(szInterfaces), NULL, NULL},
+ {"bind interfaces only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bBindInterfacesOnly), NULL, NULL},
+ {"ntvfs handler", P_LIST, P_LOCAL, LOCAL_VAR(ntvfs_handler), NULL, NULL},
+ {"ntptr providor", P_STRING, P_GLOBAL, GLOBAL_VAR(ntptr_providor), NULL, NULL},
+ {"dcerpc endpoint servers", P_LIST, P_GLOBAL, GLOBAL_VAR(dcerpc_ep_servers), NULL, NULL},
+ {"server services", P_LIST, P_GLOBAL, GLOBAL_VAR(server_services), NULL, NULL},
+
+ {"security", P_ENUM, P_GLOBAL, GLOBAL_VAR(security), NULL, enum_security},
+ {"encrypt passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bEncryptPasswords), NULL, NULL},
+ {"null passwords", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNullPasswords), NULL, NULL},
+ {"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL},
+ {"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL},
+ {"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL},
+ {"idmap database", P_STRING, P_GLOBAL, GLOBAL_VAR(szIDMAP_URL), NULL, NULL},
+ {"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL},
+ {"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL},
+ {"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL},
+ {"wins database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_URL), NULL, NULL},
+ {"private dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szPrivateDir), NULL, NULL},
+ {"passwd chat", P_STRING, P_GLOBAL, GLOBAL_VAR(szPasswdChat), NULL, NULL},
+ {"password level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(pwordlevel), NULL, NULL},
+ {"lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLanmanAuth), NULL, NULL},
+ {"ntlm auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTLMAuth), NULL, NULL},
+ {"client NTLMv2 auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientNTLMv2Auth), NULL, NULL},
+ {"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},
+ {"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},
+ {"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},
+
+ {"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},
+
+ {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
+ {"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL},
+ {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
+ {"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL},
+
+ {"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},
+ {"hosts deny", P_LIST, P_LOCAL, LOCAL_VAR(szHostsdeny), NULL, NULL},
+
+ {"log level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
+ {"debuglevel", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
+ {"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},
+
+ {"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},
+ {"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},
+ {"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},
+ {"cldap port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(cldap_port), NULL, NULL},
+ {"krb5 port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(krb5_port), NULL, NULL},
+ {"kpasswd port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(kpasswd_port), NULL, NULL},
+ {"web port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(web_port), NULL, NULL},
+ {"tls enabled", P_BOOL, P_GLOBAL, GLOBAL_VAR(tls_enabled), NULL, NULL},
+ {"tls keyfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_keyfile), NULL, NULL},
+ {"tls certfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_certfile), NULL, NULL},
+ {"tls cafile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_cafile), NULL, NULL},
+ {"tls crlfile", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_crlfile), NULL, NULL},
+ {"tls dh params file", P_STRING, P_GLOBAL, GLOBAL_VAR(tls_dhpfile), NULL, NULL},
+ {"swat directory", P_STRING, P_GLOBAL, GLOBAL_VAR(swat_directory), NULL, NULL},
+ {"large readwrite", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLargeReadwrite), NULL, NULL},
+ {"server max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_maxprotocol), NULL, enum_protocol},
+ {"server min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(srv_minprotocol), NULL, enum_protocol},
+ {"client max protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_maxprotocol), NULL, enum_protocol},
+ {"client min protocol", P_ENUM, P_GLOBAL, GLOBAL_VAR(cli_minprotocol), NULL, enum_protocol},
+ {"unicode", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnicode), NULL, NULL},
+ {"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},
+ {"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},
+ {"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},
+
+ {"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},
+
+ {"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},
+ {"announce as", P_ENUM, P_GLOBAL, GLOBAL_VAR(announce_as), NULL, enum_announce_as},
+ {"max mux", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_mux), NULL, NULL},
+ {"max xmit", P_BYTES, P_GLOBAL, GLOBAL_VAR(max_xmit), NULL, NULL},
+
+ {"name resolve order", P_LIST, P_GLOBAL, GLOBAL_VAR(szNameResolveOrder), NULL, NULL},
+ {"max wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(max_wins_ttl), NULL, NULL},
+ {"min wins ttl", P_INTEGER, P_GLOBAL, GLOBAL_VAR(min_wins_ttl), NULL, NULL},
+ {"time server", P_BOOL, P_GLOBAL, GLOBAL_VAR(bTimeServer), NULL, NULL},
+ {"unix extensions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUnixExtensions), NULL, NULL},
+ {"use spnego", P_BOOL, P_GLOBAL, GLOBAL_VAR(bUseSpnego), NULL, NULL},
+ {"server signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(server_signing), NULL, enum_smb_signing_vals},
+ {"client signing", P_ENUM, P_GLOBAL, GLOBAL_VAR(client_signing), NULL, enum_smb_signing_vals},
+ {"rpc big endian", P_BOOL, P_GLOBAL, GLOBAL_VAR(bRpcBigEndian), NULL, NULL},
+
+ {"max connections", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxConnections), NULL, NULL},
+ {"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},
+ {"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},
+
+ {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
+ {"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL},
+
+ {"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL},
+ {"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
+ {"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
+
+ {"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
+ {"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
+
+ {"map system", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_system), NULL, NULL},
+ {"map hidden", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_hidden), NULL, NULL},
+ {"map archive", P_BOOL, P_LOCAL, LOCAL_VAR(bMap_archive), NULL, NULL},
+
+ {"preferred master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto},
+ {"prefered master", P_ENUM, P_GLOBAL, GLOBAL_VAR(bPreferredMaster), NULL, enum_bool_auto},
+ {"local master", P_BOOL, P_GLOBAL, GLOBAL_VAR(bLocalMaster), NULL, NULL},
+ {"browseable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL},
+ {"browsable", P_BOOL, P_LOCAL, LOCAL_VAR(bBrowseable), NULL, NULL},
+
+ {"wins server", P_LIST, P_GLOBAL, GLOBAL_VAR(szWINSservers), NULL, NULL},
+ {"wins support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSsupport), NULL, NULL},
+ {"dns proxy", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWINSdnsProxy), NULL, NULL},
+ {"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL},
+
+ {"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy},
+
+ {"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL},
+ {"oplocks", P_BOOL, P_LOCAL, LOCAL_VAR(bOplocks), NULL, NULL},
+
+ {"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL},
+ {"preload", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL},
+ {"auto services", P_STRING, P_GLOBAL, GLOBAL_VAR(szAutoServices), NULL, NULL},
+ {"lock dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL},
+ {"lock directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szLockDir), NULL, NULL},
+ {"modules dir", P_STRING, P_GLOBAL, GLOBAL_VAR(szModulesDir), NULL, NULL},
+ {"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL},
+ {"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL},
+ {"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL},
+
+ {"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL},
+ {"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL},
+ {"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL},
+
+ {"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL},
+ {"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL },
+ {"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL},
+
+ {"panic action", P_STRING, P_GLOBAL, GLOBAL_VAR(panic_action), NULL, NULL},
+
+ {"msdfs root", P_BOOL, P_LOCAL, LOCAL_VAR(bMSDfsRoot), NULL, NULL},
+ {"host msdfs", P_BOOL, P_GLOBAL, GLOBAL_VAR(bHostMSDfs), NULL, NULL},
+ {"winbind separator", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbindSeparator), NULL, NULL },
+ {"winbindd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddSocketDirectory), NULL, NULL },
+ {"winbindd privileged socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szWinbinddPrivilegedSocketDirectory), NULL, NULL },
+ {"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL },
+ {"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL },
+ {"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL },
+ {"idmap trusted only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bIdmapTrustedOnly), NULL, NULL},
+
+ {"ntp signd socket directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szNTPSignDSocketDirectory), NULL, NULL },
+
+ {NULL, P_BOOL, P_NONE, 0, NULL, NULL}
+};
+
+
+/* local variables */
+struct loadparm_context {
+ const char *szConfigFile;
+ struct loadparm_global *globals;
+ struct loadparm_service **services;
+ struct loadparm_service *sDefault;
+ int iNumServices;
+ struct loadparm_service *currentService;
+ bool bInGlobalSection;
+ struct file_lists {
+ struct file_lists *next;
+ char *name;
+ char *subfname;
+ time_t modtime;
+ } *file_lists;
+ unsigned int flags[NUMPARAMETERS];
+ struct smb_iconv_convenience *iconv_convenience;
+};
+
+
+struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx)
+{
+ return lp_ctx->sDefault;
+}
+
+/*
+ return the parameter table
+*/
+struct parm_struct *lp_parm_table(void)
+{
+ return parm_table;
+}
+
+/**
+ * Convenience routine to grab string parameters into temporary memory
+ * and run standard_sub_basic on them.
+ *
+ * The buffers can be written to by
+ * callers without affecting the source string.
+ */
+
+static const char *lp_string(const char *s)
+{
+#if 0 /* until REWRITE done to make thread-safe */
+ size_t len = s ? strlen(s) : 0;
+ char *ret;
+#endif
+
+ /* The follow debug is useful for tracking down memory problems
+ especially if you have an inner loop that is calling a lp_*()
+ function that returns a string. Perhaps this debug should be
+ present all the time? */
+
+#if 0
+ DEBUG(10, ("lp_string(%s)\n", s));
+#endif
+
+#if 0 /* until REWRITE done to make thread-safe */
+ if (!lp_talloc)
+ lp_talloc = talloc_init("lp_talloc");
+
+ ret = talloc_array(lp_talloc, char, len + 100); /* leave room for substitution */
+
+ if (!ret)
+ return NULL;
+
+ if (!s)
+ *ret = 0;
+ else
+ strlcpy(ret, s, len);
+
+ if (trim_string(ret, "\"", "\"")) {
+ if (strchr(ret,'"') != NULL)
+ strlcpy(ret, s, len);
+ }
+
+ standard_sub_basic(ret,len+100);
+ return (ret);
+#endif
+ return s;
+}
+
+/*
+ In this section all the functions that are used to access the
+ parameters from the rest of the program are defined
+*/
+
+#define FN_GLOBAL_STRING(fn_name,var_name) \
+ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_string(lp_ctx->globals->var_name) : "";}
+#define FN_GLOBAL_CONST_STRING(fn_name,var_name) \
+ const char *fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name ? lp_ctx->globals->var_name : "";}
+#define FN_GLOBAL_LIST(fn_name,var_name) \
+ const char **fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return NULL; return lp_ctx->globals->var_name;}
+#define FN_GLOBAL_BOOL(fn_name,var_name) \
+ bool fn_name(struct loadparm_context *lp_ctx) {if (lp_ctx == NULL) return false; return lp_ctx->globals->var_name;}
+#if 0 /* unused */
+#define FN_GLOBAL_CHAR(fn_name,ptr) \
+ char fn_name(void) {return(*(char *)(ptr));}
+#endif
+#define FN_GLOBAL_INTEGER(fn_name,var_name) \
+ int fn_name(struct loadparm_context *lp_ctx) {return lp_ctx->globals->var_name;}
+
+#define FN_LOCAL_STRING(fn_name,val) \
+ const char *fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(lp_string((const char *)((service != NULL && service->val != NULL) ? service->val : sDefault->val)));}
+#define FN_LOCAL_LIST(fn_name,val) \
+ const char **fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return(const char **)(service != NULL && service->val != NULL? service->val : sDefault->val);}
+#define FN_LOCAL_BOOL(fn_name,val) \
+ bool fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}
+#define FN_LOCAL_INTEGER(fn_name,val) \
+ int fn_name(struct loadparm_service *service, struct loadparm_service *sDefault) {return((service != NULL)? service->val : sDefault->val);}
+
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_role, server_role)
+_PUBLIC_ FN_GLOBAL_LIST(lp_smb_ports, smb_ports)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_nbt_port, nbt_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_dgram_port, dgram_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cldap_port, cldap_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_krb5_port, krb5_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, kpasswd_port)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, web_port)
+_PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, swat_directory)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, tls_enabled)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, tls_keyfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, tls_certfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, tls_cafile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)
+_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)
+_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, szSECRETS_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, szSPOOLSS_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, szWINS_CONFIG_URL)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_url, szWINS_URL)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbind_separator, szWinbindSeparator)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, szWinbinddSocketDirectory)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_privileged_socket_directory, szWinbinddPrivilegedSocketDirectory)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, bWinbindSealedPipes)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_idmap_trusted_only, bIdmapTrustedOnly)
+_PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, szPrivateDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, szServerString)
+_PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, szLockDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_modulesdir, szModulesDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_setupdir, szSetupDir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_ncalrpc_dir, ncalrpc_dir)
+_PUBLIC_ FN_GLOBAL_STRING(lp_dos_charset, dos_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_unix_charset, unix_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_display_charset, display_charset)
+_PUBLIC_ FN_GLOBAL_STRING(lp_piddir, szPidDir)
+_PUBLIC_ FN_GLOBAL_LIST(lp_dcerpc_endpoint_servers, dcerpc_ep_servers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_server_services, server_services)
+_PUBLIC_ FN_GLOBAL_STRING(lp_ntptr_providor, ntptr_providor)
+_PUBLIC_ FN_GLOBAL_STRING(lp_auto_services, szAutoServices)
+_PUBLIC_ FN_GLOBAL_STRING(lp_passwd_chat, szPasswdChat)
+_PUBLIC_ FN_GLOBAL_LIST(lp_passwordserver, szPasswordServers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_name_resolve_order, szNameResolveOrder)
+_PUBLIC_ FN_GLOBAL_STRING(lp_realm, szRealm)
+_PUBLIC_ FN_GLOBAL_STRING(lp_socket_options, socket_options)
+_PUBLIC_ FN_GLOBAL_STRING(lp_workgroup, szWorkgroup)
+_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_name, szNetbiosName)
+_PUBLIC_ FN_GLOBAL_STRING(lp_netbios_scope, szNetbiosScope)
+_PUBLIC_ FN_GLOBAL_LIST(lp_wins_server_list, szWINSservers)
+_PUBLIC_ FN_GLOBAL_LIST(lp_interfaces, szInterfaces)
+_PUBLIC_ FN_GLOBAL_STRING(lp_socket_address, szSocketAddress)
+_PUBLIC_ FN_GLOBAL_LIST(lp_netbios_aliases, szNetbiosAliases)
+
+_PUBLIC_ FN_GLOBAL_BOOL(lp_disable_netbios, bDisableNetbios)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_support, bWINSsupport)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_wins_dns_proxy, bWINSdnsProxy)
+_PUBLIC_ FN_GLOBAL_STRING(lp_wins_hook, szWINSHook)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_local_master, bLocalMaster)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_readraw, bReadRaw)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_large_readwrite, bLargeReadwrite)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_writeraw, bWriteRaw)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_null_passwords, bNullPasswords)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_obey_pam_restrictions, bObeyPamRestrictions)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_encrypted_passwords, bEncryptPasswords)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_time_server, bTimeServer)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_bind_interfaces_only, bBindInterfacesOnly)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_unicode, bUnicode)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_nt_status_support, bNTStatusSupport)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_lanman_auth, bLanmanAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_ntlm_auth, bNTLMAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_plaintext_auth, bClientPlaintextAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_lanman_auth, bClientLanManAuth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_ntlmv2_auth, bClientNTLMv2Auth)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_client_use_spnego_principal, client_use_spnego_principal)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_host_msdfs, bHostMSDfs)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_unix_extensions, bUnixExtensions)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_use_spnego, bUseSpnego)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_rpc_big_endian, bRpcBigEndian)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_wins_ttl, max_wins_ttl)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_min_wins_ttl, min_wins_ttl)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_maxmux, max_mux)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_max_xmit, max_xmit)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_passwordlevel, pwordlevel)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_maxprotocol, srv_maxprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_srv_minprotocol, srv_minprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_maxprotocol, cli_maxprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_cli_minprotocol, cli_minprotocol)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_security, security)
+_PUBLIC_ FN_GLOBAL_BOOL(lp_paranoid_server_security, paranoid_server_security)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_announce_as, announce_as)
+_PUBLIC_ FN_GLOBAL_LIST(lp_js_include, jsInclude)
+const char *lp_servicename(const struct loadparm_service *service)
+{
+ return lp_string((const char *)service->szService);
+}
+
+_PUBLIC_ FN_LOCAL_STRING(lp_pathname, szPath)
+static FN_LOCAL_STRING(_lp_printername, szPrintername)
+_PUBLIC_ FN_LOCAL_LIST(lp_hostsallow, szHostsallow)
+_PUBLIC_ FN_LOCAL_LIST(lp_hostsdeny, szHostsdeny)
+_PUBLIC_ FN_LOCAL_STRING(lp_comment, comment)
+_PUBLIC_ FN_LOCAL_STRING(lp_fstype, fstype)
+static FN_LOCAL_STRING(lp_volume, volume)
+_PUBLIC_ FN_LOCAL_LIST(lp_ntvfs_handler, ntvfs_handler)
+_PUBLIC_ FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
+_PUBLIC_ FN_LOCAL_BOOL(lp_browseable, bBrowseable)
+_PUBLIC_ FN_LOCAL_BOOL(lp_readonly, bRead_only)
+_PUBLIC_ FN_LOCAL_BOOL(lp_print_ok, bPrint_ok)
+_PUBLIC_ FN_LOCAL_BOOL(lp_map_hidden, bMap_hidden)
+_PUBLIC_ FN_LOCAL_BOOL(lp_map_archive, bMap_archive)
+_PUBLIC_ FN_LOCAL_BOOL(lp_strict_locking, bStrictLocking)
+_PUBLIC_ FN_LOCAL_BOOL(lp_oplocks, bOplocks)
+_PUBLIC_ FN_LOCAL_BOOL(lp_strict_sync, bStrictSync)
+_PUBLIC_ FN_LOCAL_BOOL(lp_ci_filesystem, bCIFileSystem)
+_PUBLIC_ FN_LOCAL_BOOL(lp_map_system, bMap_system)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_max_connections, iMaxConnections)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_csc_policy, iCSCPolicy)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_create_mask, iCreate_mask)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_force_create_mode, iCreate_force_mode)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_dir_mask, iDir_mask)
+_PUBLIC_ FN_LOCAL_INTEGER(lp_force_dir_mode, iDir_force_mode)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_server_signing, server_signing)
+_PUBLIC_ FN_GLOBAL_INTEGER(lp_client_signing, client_signing)
+
+_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_ntp_signd_socket_directory, szNTPSignDSocketDirectory)
+
+/* local prototypes */
+static int map_parameter(const char *pszParmName);
+static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
+ const char *pszServiceName);
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
+ int *pcopymapDest);
+static bool service_ok(struct loadparm_service *service);
+static bool do_section(const char *pszSectionName, void *);
+static void init_copymap(struct loadparm_service *pservice);
+
+/* This is a helper function for parametrical options support. */
+/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
+/* Actual parametrical functions are quite simple */
+const char *lp_get_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type, const char *option)
+{
+ char *vfskey;
+ struct param_opt *data;
+
+ if (lp_ctx == NULL)
+ return NULL;
+
+ data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
+
+ asprintf(&vfskey, "%s:%s", type, option);
+ strlower(vfskey);
+
+ while (data) {
+ if (strcmp(data->key, vfskey) == 0) {
+ free(vfskey);
+ return data->value;
+ }
+ data = data->next;
+ }
+
+ if (service != NULL) {
+ /* Try to fetch the same option but from globals */
+ /* but only if we are not already working with globals */
+ for (data = lp_ctx->globals->param_opt; data;
+ data = data->next) {
+ if (strcmp(data->key, vfskey) == 0) {
+ free(vfskey);
+ return data->value;
+ }
+ }
+ }
+
+ free(vfskey);
+
+ return NULL;
+}
+
+
+/**
+ * convenience routine to return int parameters.
+ */
+static int lp_int(const char *s)
+{
+
+ if (!s) {
+ DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
+ return -1;
+ }
+
+ return strtol(s, NULL, 0);
+}
+
+/**
+ * convenience routine to return unsigned long parameters.
+ */
+static int lp_ulong(const char *s)
+{
+
+ if (!s) {
+ DEBUG(0,("lp_int(%s): is called with NULL!\n",s));
+ return -1;
+ }
+
+ return strtoul(s, NULL, 0);
+}
+
+/**
+ * convenience routine to return unsigned long parameters.
+ */
+static double lp_double(const char *s)
+{
+
+ if (!s) {
+ DEBUG(0,("lp_double(%s): is called with NULL!\n",s));
+ return -1;
+ }
+
+ return strtod(s, NULL);
+}
+
+/**
+ * convenience routine to return boolean parameters.
+ */
+static bool lp_bool(const char *s)
+{
+ bool ret = false;
+
+ if (!s) {
+ DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
+ return false;
+ }
+
+ if (!set_boolean(s, &ret)) {
+ DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
+ return false;
+ }
+
+ return ret;
+}
+
+
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ * Returned value is allocated in 'lp_talloc' context
+ */
+
+const char *lp_parm_string(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value)
+ return lp_string(value);
+
+ return NULL;
+}
+
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ * Returned value is allocated in 'lp_talloc' context
+ */
+
+const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type,
+ const char *option, const char *separator)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value != NULL)
+ return str_list_make(mem_ctx, value, separator);
+
+ return NULL;
+}
+
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
+
+int lp_parm_int(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value)
+ return lp_int(value);
+
+ return default_v;
+}
+
+/**
+ * Return parametric option from a given service. Type is a part of
+ * option before ':'.
+ * Parametric option has following syntax: 'Type: option = value'.
+ */
+
+int lp_parm_bytes(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v)
+{
+ uint64_t bval;
+
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value && conv_str_size(value, &bval)) {
+ if (bval <= INT_MAX) {
+ return (int)bval;
+ }
+ }
+
+ return default_v;
+}
+
+/**
+ * Return parametric option from a given service.
+ * Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
+unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, unsigned long default_v)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value)
+ return lp_ulong(value);
+
+ return default_v;
+}
+
+
+double lp_parm_double(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, double default_v)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value != NULL)
+ return lp_double(value);
+
+ return default_v;
+}
+
+/**
+ * Return parametric option from a given service. Type is a part of option before ':'
+ * Parametric option has following syntax: 'Type: option = value'
+ */
+
+bool lp_parm_bool(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, bool default_v)
+{
+ const char *value = lp_get_parametric(lp_ctx, service, type, option);
+
+ if (value != NULL)
+ return lp_bool(value);
+
+ return default_v;
+}
+
+
+/**
+ * Initialise a service to the defaults.
+ */
+
+static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx, struct loadparm_service *sDefault)
+{
+ struct loadparm_service *pservice =
+ talloc_zero(mem_ctx, struct loadparm_service);
+ copy_service(pservice, sDefault, NULL);
+ return pservice;
+}
+
+/**
+ * Set a string value, deallocating any existing space, and allocing the space
+ * for the string
+ */
+static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
+{
+ talloc_free(*dest);
+
+ if (src == NULL)
+ src = "";
+
+ *dest = talloc_strdup(mem_ctx, src);
+ if ((*dest) == NULL) {
+ DEBUG(0,("Out of memory in string_init\n"));
+ return false;
+ }
+
+ return true;
+}
+
+
+
+/**
+ * Add a new service to the services array initialising it with the given
+ * service.
+ */
+
+struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
+ const struct loadparm_service *pservice,
+ const char *name)
+{
+ int i;
+ struct loadparm_service tservice;
+ int num_to_alloc = lp_ctx->iNumServices + 1;
+ struct param_opt *data, *pdata;
+
+ tservice = *pservice;
+
+ /* it might already exist */
+ if (name) {
+ struct loadparm_service *service = getservicebyname(lp_ctx,
+ name);
+ if (service != NULL) {
+ /* Clean all parametric options for service */
+ /* They will be added during parsing again */
+ data = service->param_opt;
+ while (data) {
+ pdata = data->next;
+ talloc_free(data);
+ data = pdata;
+ }
+ service->param_opt = NULL;
+ return service;
+ }
+ }
+
+ /* find an invalid one */
+ for (i = 0; i < lp_ctx->iNumServices; i++)
+ if (lp_ctx->services[i] == NULL)
+ break;
+
+ /* if not, then create one */
+ if (i == lp_ctx->iNumServices) {
+ struct loadparm_service **tsp;
+
+ tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
+
+ if (!tsp) {
+ DEBUG(0,("lp_add_service: failed to enlarge services!\n"));
+ return NULL;
+ } else {
+ lp_ctx->services = tsp;
+ lp_ctx->services[lp_ctx->iNumServices] = NULL;
+ }
+
+ lp_ctx->iNumServices++;
+ }
+
+ lp_ctx->services[i] = init_service(lp_ctx->services, lp_ctx->sDefault);
+ if (lp_ctx->services[i] == NULL) {
+ DEBUG(0,("lp_add_service: out of memory!\n"));
+ return NULL;
+ }
+ copy_service(lp_ctx->services[i], &tservice, NULL);
+ if (name != NULL)
+ string_set(lp_ctx->services[i], &lp_ctx->services[i]->szService, name);
+ return lp_ctx->services[i];
+}
+
+/**
+ * Add a new home service, with the specified home directory, defaults coming
+ * from service ifrom.
+ */
+
+bool lp_add_home(struct loadparm_context *lp_ctx,
+ const char *pszHomename,
+ struct loadparm_service *default_service,
+ const char *user, const char *pszHomedir)
+{
+ struct loadparm_service *service;
+
+ service = lp_add_service(lp_ctx, default_service, pszHomename);
+
+ if (service == NULL)
+ return false;
+
+ if (!(*(default_service->szPath))
+ || strequal(default_service->szPath, lp_ctx->sDefault->szPath)) {
+ service->szPath = talloc_strdup(service, pszHomedir);
+ } else {
+ service->szPath = string_sub_talloc(service, lp_pathname(default_service, lp_ctx->sDefault), "%H", pszHomedir);
+ }
+
+ if (!(*(service->comment))) {
+ service->comment = talloc_asprintf(service, "Home directory of %s", user);
+ }
+ service->bAvailable = default_service->bAvailable;
+ service->bBrowseable = default_service->bBrowseable;
+
+ DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
+ pszHomename, user, service->szPath));
+
+ return true;
+}
+
+/**
+ * Add the IPC service.
+ */
+
+static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
+ const char *fstype)
+{
+ struct loadparm_service *service = lp_add_service(lp_ctx, lp_ctx->sDefault, name);
+
+ if (service == NULL)
+ return false;
+
+ string_set(service, &service->szPath, tmpdir());
+
+ service->comment = talloc_asprintf(service, "%s Service (%s)",
+ fstype, lp_ctx->globals->szServerString);
+ string_set(service, &service->fstype, fstype);
+ service->iMaxConnections = -1;
+ service->bAvailable = true;
+ service->bRead_only = true;
+ service->bPrint_ok = false;
+ service->bBrowseable = false;
+
+ if (strcasecmp(fstype, "IPC") == 0) {
+ lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
+ "default");
+ }
+
+ DEBUG(3, ("adding hidden service %s\n", name));
+
+ return true;
+}
+
+/**
+ * Add a new printer service, with defaults coming from service iFrom.
+ */
+
+bool lp_add_printer(struct loadparm_context *lp_ctx,
+ const char *pszPrintername,
+ struct loadparm_service *default_service)
+{
+ const char *comment = "From Printcap";
+ struct loadparm_service *service;
+ service = lp_add_service(lp_ctx, default_service, pszPrintername);
+
+ if (service == NULL)
+ return false;
+
+ /* note that we do NOT default the availability flag to True - */
+ /* we take it from the default service passed. This allows all */
+ /* dynamic printers to be disabled by disabling the [printers] */
+ /* entry (if/when the 'available' keyword is implemented!). */
+
+ /* the printer name is set to the service name. */
+ string_set(service, &service->szPrintername, pszPrintername);
+ string_set(service, &service->comment, comment);
+ service->bBrowseable = default_service->bBrowseable;
+ /* Printers cannot be read_only. */
+ service->bRead_only = false;
+ /* Printer services must be printable. */
+ service->bPrint_ok = true;
+
+ DEBUG(3, ("adding printer service %s\n", pszPrintername));
+
+ return true;
+}
+
+/**
+ * Map a parameter's string representation to something we can use.
+ * Returns False if the parameter string is not recognised, else TRUE.
+ */
+
+static int map_parameter(const char *pszParmName)
+{
+ int iIndex;
+
+ if (*pszParmName == '-')
+ return -1;
+
+ for (iIndex = 0; parm_table[iIndex].label; iIndex++)
+ if (strwicmp(parm_table[iIndex].label, pszParmName) == 0)
+ return iIndex;
+
+ /* Warn only if it isn't parametric option */
+ if (strchr(pszParmName, ':') == NULL)
+ DEBUG(0, ("Unknown parameter encountered: \"%s\"\n", pszParmName));
+ /* We do return 'fail' for parametric options as well because they are
+ stored in different storage
+ */
+ return -1;
+}
+
+
+/**
+ return the parameter structure for a parameter
+*/
+struct parm_struct *lp_parm_struct(const char *name)
+{
+ int parmnum = map_parameter(name);
+ if (parmnum == -1) return NULL;
+ return &parm_table[parmnum];
+}
+
+/**
+ return the parameter pointer for a parameter
+*/
+void *lp_parm_ptr(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, struct parm_struct *parm)
+{
+ if (service == NULL) {
+ if (parm->class == P_LOCAL)
+ return ((char *)lp_ctx->sDefault)+parm->offset;
+ else if (parm->class == P_GLOBAL)
+ return ((char *)lp_ctx->globals)+parm->offset;
+ else return NULL;
+ } else {
+ return ((char *)service) + parm->offset;
+ }
+}
+
+/**
+ * Find a service by name. Otherwise works like get_service.
+ */
+
+static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
+ const char *pszServiceName)
+{
+ int iService;
+
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--)
+ if (lp_ctx->services[iService] != NULL &&
+ strwicmp(lp_ctx->services[iService]->szService, pszServiceName) == 0) {
+ return lp_ctx->services[iService];
+ }
+
+ return NULL;
+}
+
+/**
+ * Copy a service structure to another.
+ * If pcopymapDest is NULL then copy all fields
+ */
+
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
+ int *pcopymapDest)
+{
+ int i;
+ bool bcopyall = (pcopymapDest == NULL);
+ struct param_opt *data, *pdata, *paramo;
+ bool not_added;
+
+ for (i = 0; parm_table[i].label; i++)
+ if (parm_table[i].offset != -1 && parm_table[i].class == P_LOCAL &&
+ (bcopyall || pcopymapDest[i])) {
+ void *src_ptr =
+ ((char *)pserviceSource) + parm_table[i].offset;
+ void *dest_ptr =
+ ((char *)pserviceDest) + parm_table[i].offset;
+
+ switch (parm_table[i].type) {
+ case P_BOOL:
+ *(int *)dest_ptr = *(int *)src_ptr;
+ break;
+
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_ENUM:
+ *(int *)dest_ptr = *(int *)src_ptr;
+ break;
+
+ case P_STRING:
+ string_set(pserviceDest,
+ (char **)dest_ptr,
+ *(char **)src_ptr);
+ break;
+
+ case P_USTRING:
+ string_set(pserviceDest,
+ (char **)dest_ptr,
+ *(char **)src_ptr);
+ strupper(*(char **)dest_ptr);
+ break;
+ case P_LIST:
+ *(const char ***)dest_ptr = str_list_copy(pserviceDest,
+ *(const char ***)src_ptr);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (bcopyall) {
+ init_copymap(pserviceDest);
+ if (pserviceSource->copymap)
+ memcpy((void *)pserviceDest->copymap,
+ (void *)pserviceSource->copymap,
+ sizeof(int) * NUMPARAMETERS);
+ }
+
+ data = pserviceSource->param_opt;
+ while (data) {
+ not_added = true;
+ pdata = pserviceDest->param_opt;
+ /* Traverse destination */
+ while (pdata) {
+ /* If we already have same option, override it */
+ if (strcmp(pdata->key, data->key) == 0) {
+ talloc_free(pdata->value);
+ pdata->value = talloc_reference(pdata,
+ data->value);
+ not_added = false;
+ break;
+ }
+ pdata = pdata->next;
+ }
+ if (not_added) {
+ paramo = talloc(pserviceDest, struct param_opt);
+ if (paramo == NULL)
+ smb_panic("OOM");
+ paramo->key = talloc_reference(paramo, data->key);
+ paramo->value = talloc_reference(paramo, data->value);
+ DLIST_ADD(pserviceDest->param_opt, paramo);
+ }
+ data = data->next;
+ }
+}
+
+/**
+ * Check a service for consistency. Return False if the service is in any way
+ * incomplete or faulty, else True.
+ */
+static bool service_ok(struct loadparm_service *service)
+{
+ bool bRetval;
+
+ bRetval = true;
+ if (service->szService[0] == '\0') {
+ DEBUG(0, ("The following message indicates an internal error:\n"));
+ DEBUG(0, ("No service name in service entry.\n"));
+ bRetval = false;
+ }
+
+ /* The [printers] entry MUST be printable. I'm all for flexibility, but */
+ /* I can't see why you'd want a non-printable printer service... */
+ if (strwicmp(service->szService, PRINTERS_NAME) == 0) {
+ if (!service->bPrint_ok) {
+ DEBUG(0, ("WARNING: [%s] service MUST be printable!\n",
+ service->szService));
+ service->bPrint_ok = true;
+ }
+ /* [printers] service must also be non-browsable. */
+ if (service->bBrowseable)
+ service->bBrowseable = false;
+ }
+
+ /* If a service is flagged unavailable, log the fact at level 0. */
+ if (!service->bAvailable)
+ DEBUG(1, ("NOTE: Service %s is flagged unavailable.\n",
+ service->szService));
+
+ return bRetval;
+}
+
+
+/*******************************************************************
+ Keep a linked list of all config files so we know when one has changed
+ it's date and needs to be reloaded.
+********************************************************************/
+
+static void add_to_file_list(struct loadparm_context *lp_ctx,
+ const char *fname, const char *subfname)
+{
+ struct file_lists *f = lp_ctx->file_lists;
+
+ while (f) {
+ if (f->name && !strcmp(f->name, fname))
+ break;
+ f = f->next;
+ }
+
+ if (!f) {
+ f = talloc(lp_ctx, struct file_lists);
+ if (!f)
+ return;
+ f->next = lp_ctx->file_lists;
+ f->name = talloc_strdup(f, fname);
+ if (!f->name) {
+ talloc_free(f);
+ return;
+ }
+ f->subfname = talloc_strdup(f, subfname);
+ if (!f->subfname) {
+ talloc_free(f);
+ return;
+ }
+ lp_ctx->file_lists = f;
+ f->modtime = file_modtime(subfname);
+ } else {
+ time_t t = file_modtime(subfname);
+ if (t)
+ f->modtime = t;
+ }
+}
+
+/*******************************************************************
+ Check if a config file has changed date.
+********************************************************************/
+bool lp_file_list_changed(struct loadparm_context *lp_ctx)
+{
+ struct file_lists *f;
+ DEBUG(6, ("lp_file_list_changed()\n"));
+
+ for (f = lp_ctx->file_lists; f != NULL; f = f->next) {
+ char *n2;
+ time_t mod_time;
+
+ n2 = standard_sub_basic(lp_ctx, f->name);
+
+ DEBUGADD(6, ("file %s -> %s last mod_time: %s\n",
+ f->name, n2, ctime(&f->modtime)));
+
+ mod_time = file_modtime(n2);
+
+ if (mod_time && ((f->modtime != mod_time) || (f->subfname == NULL) || (strcmp(n2, f->subfname) != 0))) {
+ DEBUGADD(6, ("file %s modified: %s\n", n2,
+ ctime(&mod_time)));
+ f->modtime = mod_time;
+ talloc_free(f->subfname);
+ f->subfname = talloc_strdup(f, n2);
+ return true;
+ }
+ }
+ return false;
+}
+
+/***************************************************************************
+ Handle the include operation.
+***************************************************************************/
+
+static bool handle_include(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
+{
+ char *fname = standard_sub_basic(lp_ctx, pszParmValue);
+
+ add_to_file_list(lp_ctx, pszParmValue, fname);
+
+ string_set(lp_ctx, ptr, fname);
+
+ if (file_exist(fname))
+ return pm_process(fname, do_section, do_parameter, lp_ctx);
+
+ DEBUG(2, ("Can't find include file %s\n", fname));
+
+ return false;
+}
+
+/***************************************************************************
+ Handle the interpretation of the copy parameter.
+***************************************************************************/
+
+static bool handle_copy(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
+{
+ bool bRetval;
+ struct loadparm_service *serviceTemp;
+
+ string_set(lp_ctx, ptr, pszParmValue);
+
+ bRetval = false;
+
+ DEBUG(3, ("Copying service from service %s\n", pszParmValue));
+
+ if ((serviceTemp = getservicebyname(lp_ctx, pszParmValue)) != NULL) {
+ if (serviceTemp == lp_ctx->currentService) {
+ DEBUG(0, ("Can't copy service %s - unable to copy self!\n", pszParmValue));
+ } else {
+ copy_service(lp_ctx->currentService,
+ serviceTemp,
+ lp_ctx->currentService->copymap);
+ bRetval = true;
+ }
+ } else {
+ DEBUG(0, ("Unable to copy service - source not found: %s\n",
+ pszParmValue));
+ bRetval = false;
+ }
+
+ return bRetval;
+}
+
+static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
+{
+ DEBUGLEVEL = atoi(pszParmValue);
+
+ return true;
+}
+
+static bool handle_logfile(struct loadparm_context *lp_ctx,
+ const char *pszParmValue, char **ptr)
+{
+ logfile = pszParmValue;
+ return true;
+}
+
+/***************************************************************************
+ Initialise a copymap.
+***************************************************************************/
+
+static void init_copymap(struct loadparm_service *pservice)
+{
+ int i;
+ talloc_free(pservice->copymap);
+ pservice->copymap = talloc_array(pservice, int, NUMPARAMETERS);
+ if (pservice->copymap == NULL) {
+ DEBUG(0,
+ ("Couldn't allocate copymap!! (size %d)\n",
+ (int)NUMPARAMETERS));
+ return;
+ }
+ for (i = 0; i < NUMPARAMETERS; i++)
+ pservice->copymap[i] = true;
+}
+
+/**
+ * Process a parametric option
+ */
+static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName,
+ const char *pszParmValue, int flags)
+{
+ struct param_opt *paramo, *data;
+ char *name;
+ TALLOC_CTX *mem_ctx;
+
+ while (isspace((unsigned char)*pszParmName)) {
+ pszParmName++;
+ }
+
+ name = strdup(pszParmName);
+ if (!name) return false;
+
+ strlower(name);
+
+ if (service == NULL) {
+ data = lp_ctx->globals->param_opt;
+ mem_ctx = lp_ctx->globals;
+ } else {
+ data = service->param_opt;
+ mem_ctx = service;
+ }
+
+ /* Traverse destination */
+ for (paramo=data; paramo; paramo=paramo->next) {
+ /* If we already have the option set, override it unless
+ it was a command line option and the new one isn't */
+ if (strcmp(paramo->key, name) == 0) {
+ if ((paramo->flags & FLAG_CMDLINE) &&
+ !(flags & FLAG_CMDLINE)) {
+ return true;
+ }
+
+ talloc_free(paramo->value);
+ paramo->value = talloc_strdup(paramo, pszParmValue);
+ paramo->flags = flags;
+ free(name);
+ return true;
+ }
+ }
+
+ paramo = talloc(mem_ctx, struct param_opt);
+ if (!paramo)
+ smb_panic("OOM");
+ paramo->key = talloc_strdup(paramo, name);
+ paramo->value = talloc_strdup(paramo, pszParmValue);
+ paramo->flags = flags;
+ if (service == NULL) {
+ DLIST_ADD(lp_ctx->globals->param_opt, paramo);
+ } else {
+ DLIST_ADD(service->param_opt, paramo);
+ }
+
+ free(name);
+
+ return true;
+}
+
+static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
+ const char *pszParmName, const char *pszParmValue,
+ struct loadparm_context *lp_ctx)
+{
+ int i;
+ /* if it is a special case then go ahead */
+ if (parm_table[parmnum].special) {
+ parm_table[parmnum].special(lp_ctx, pszParmValue,
+ (char **)parm_ptr);
+ return true;
+ }
+
+ /* now switch on the type of variable it is */
+ switch (parm_table[parmnum].type)
+ {
+ case P_BOOL: {
+ bool b;
+ if (!set_boolean(pszParmValue, &b)) {
+ DEBUG(0,("lp_do_parameter(%s): value is not boolean!\n", pszParmValue));
+ return false;
+ }
+ *(int *)parm_ptr = b;
+ }
+ break;
+
+ case P_INTEGER:
+ *(int *)parm_ptr = atoi(pszParmValue);
+ break;
+
+ case P_OCTAL:
+ *(int *)parm_ptr = strtol(pszParmValue, NULL, 8);
+ break;
+
+ case P_BYTES:
+ {
+ uint64_t val;
+ if (conv_str_size(pszParmValue, &val)) {
+ if (val <= INT_MAX) {
+ *(int *)parm_ptr = (int)val;
+ break;
+ }
+ }
+
+ DEBUG(0,("lp_do_parameter(%s): value is not "
+ "a valid size specifier!\n", pszParmValue));
+ return false;
+ }
+
+ case P_LIST:
+ *(const char ***)parm_ptr = str_list_make(mem_ctx,
+ pszParmValue, NULL);
+ break;
+
+ case P_STRING:
+ string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
+ break;
+
+ case P_USTRING:
+ string_set(mem_ctx, (char **)parm_ptr, pszParmValue);
+ strupper(*(char **)parm_ptr);
+ break;
+
+ case P_ENUM:
+ for (i = 0; parm_table[parmnum].enum_list[i].name; i++) {
+ if (strequal
+ (pszParmValue,
+ parm_table[parmnum].enum_list[i].name)) {
+ *(int *)parm_ptr =
+ parm_table[parmnum].
+ enum_list[i].value;
+ break;
+ }
+ }
+ if (!parm_table[parmnum].enum_list[i].name) {
+ DEBUG(0,("Unknown enumerated value '%s' for '%s'\n",
+ pszParmValue, pszParmName));
+ return false;
+ }
+ break;
+ }
+
+ if (lp_ctx->flags[parmnum] & FLAG_DEFAULT) {
+ lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
+ /* we have to also unset FLAG_DEFAULT on aliases */
+ for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
+ lp_ctx->flags[i] &= ~FLAG_DEFAULT;
+ }
+ for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
+ lp_ctx->flags[i] &= ~FLAG_DEFAULT;
+ }
+ }
+ return true;
+}
+
+
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *pszParmValue)
+{
+ int parmnum = map_parameter(pszParmName);
+ void *parm_ptr;
+
+ if (parmnum < 0) {
+ if (strchr(pszParmName, ':')) {
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName, pszParmValue, 0);
+ }
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ return true;
+ }
+
+ /* if the flag has been set on the command line, then don't allow override,
+ but don't report an error */
+ if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
+ return true;
+ }
+
+ parm_ptr = lp_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
+
+ return set_variable(lp_ctx, parmnum, parm_ptr,
+ pszParmName, pszParmValue, lp_ctx);
+}
+
+bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName, const char *pszParmValue)
+{
+ void *parm_ptr;
+ int i;
+ int parmnum = map_parameter(pszParmName);
+
+ if (parmnum < 0) {
+ if (strchr(pszParmName, ':')) {
+ return lp_do_parameter_parametric(lp_ctx, service, pszParmName, pszParmValue, 0);
+ }
+ DEBUG(0, ("Ignoring unknown parameter \"%s\"\n", pszParmName));
+ return true;
+ }
+
+ /* if the flag has been set on the command line, then don't allow override,
+ but don't report an error */
+ if (lp_ctx->flags[parmnum] & FLAG_CMDLINE) {
+ return true;
+ }
+
+ if (parm_table[parmnum].class == P_GLOBAL) {
+ DEBUG(0,
+ ("Global parameter %s found in service section!\n",
+ pszParmName));
+ return true;
+ }
+ parm_ptr = ((char *)service) + parm_table[parmnum].offset;
+
+ if (!service->copymap)
+ init_copymap(service);
+
+ /* this handles the aliases - set the copymap for other
+ * entries with the same data pointer */
+ for (i = 0; parm_table[i].label; i++)
+ if (parm_table[i].offset == parm_table[parmnum].offset &&
+ parm_table[i].class == parm_table[parmnum].class)
+ service->copymap[i] = false;
+
+ return set_variable(service, parmnum, parm_ptr, pszParmName,
+ pszParmValue, lp_ctx);
+}
+
+/**
+ * Process a parameter.
+ */
+
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+ void *userdata)
+{
+ struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
+
+ if (lp_ctx->bInGlobalSection)
+ return lp_do_global_parameter(lp_ctx, pszParmName,
+ pszParmValue);
+ else
+ return lp_do_service_parameter(lp_ctx, lp_ctx->currentService,
+ pszParmName, pszParmValue);
+}
+
+/*
+ variable argument do parameter
+*/
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...)
+{
+ char *s;
+ bool ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ s = talloc_vasprintf(NULL, fmt, ap);
+ va_end(ap);
+ ret = lp_do_global_parameter(lp_ctx, pszParmName, s);
+ talloc_free(s);
+ return ret;
+}
+
+
+/*
+ set a parameter from the commandline - this is called from command line parameter
+ parsing code. It sets the parameter then marks the parameter as unable to be modified
+ by smb.conf processing
+*/
+bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
+ const char *pszParmValue)
+{
+ int parmnum = map_parameter(pszParmName);
+ int i;
+
+ while (isspace((unsigned char)*pszParmValue)) pszParmValue++;
+
+
+ if (parmnum < 0 && strchr(pszParmName, ':')) {
+ /* set a parametric option */
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
+ pszParmValue, FLAG_CMDLINE);
+ }
+
+ if (parmnum < 0) {
+ DEBUG(0,("Unknown option '%s'\n", pszParmName));
+ return false;
+ }
+
+ /* reset the CMDLINE flag in case this has been called before */
+ lp_ctx->flags[parmnum] &= ~FLAG_CMDLINE;
+
+ if (!lp_do_global_parameter(lp_ctx, pszParmName, pszParmValue)) {
+ return false;
+ }
+
+ lp_ctx->flags[parmnum] |= FLAG_CMDLINE;
+
+ /* we have to also set FLAG_CMDLINE on aliases */
+ for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
+ lp_ctx->flags[i] |= FLAG_CMDLINE;
+ }
+ for (i=parmnum+1;i<NUMPARAMETERS && parm_table[i].offset == parm_table[parmnum].offset;i++) {
+ lp_ctx->flags[i] |= FLAG_CMDLINE;
+ }
+
+ return true;
+}
+
+/*
+ set a option from the commandline in 'a=b' format. Use to support --option
+*/
+bool lp_set_option(struct loadparm_context *lp_ctx, const char *option)
+{
+ char *p, *s;
+ bool ret;
+
+ s = strdup(option);
+ if (!s) {
+ return false;
+ }
+
+ p = strchr(s, '=');
+ if (!p) {
+ free(s);
+ return false;
+ }
+
+ *p = 0;
+
+ ret = lp_set_cmdline(lp_ctx, s, p+1);
+ free(s);
+ return ret;
+}
+
+
+#define BOOLSTR(b) ((b) ? "Yes" : "No")
+
+/**
+ * Print a parameter of the specified type.
+ */
+
+static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
+{
+ int i;
+ switch (p->type)
+ {
+ case P_ENUM:
+ for (i = 0; p->enum_list[i].name; i++) {
+ if (*(int *)ptr == p->enum_list[i].value) {
+ fprintf(f, "%s",
+ p->enum_list[i].name);
+ break;
+ }
+ }
+ break;
+
+ case P_BOOL:
+ fprintf(f, "%s", BOOLSTR((bool)*(int *)ptr));
+ break;
+
+ case P_INTEGER:
+ case P_BYTES:
+ fprintf(f, "%d", *(int *)ptr);
+ break;
+
+ case P_OCTAL:
+ fprintf(f, "0%o", *(int *)ptr);
+ break;
+
+ case P_LIST:
+ if ((char ***)ptr && *(char ***)ptr) {
+ char **list = *(char ***)ptr;
+
+ for (; *list; list++)
+ fprintf(f, "%s%s", *list,
+ ((*(list+1))?", ":""));
+ }
+ break;
+
+ case P_STRING:
+ case P_USTRING:
+ if (*(char **)ptr) {
+ fprintf(f, "%s", *(char **)ptr);
+ }
+ break;
+ }
+}
+
+/**
+ * Check if two parameters are equal.
+ */
+
+static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
+{
+ switch (type) {
+ case P_BOOL:
+ return (*((int *)ptr1) == *((int *)ptr2));
+
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ case P_ENUM:
+ return (*((int *)ptr1) == *((int *)ptr2));
+
+ case P_LIST:
+ return str_list_equal((const char **)(*(char ***)ptr1),
+ (const char **)(*(char ***)ptr2));
+
+ case P_STRING:
+ case P_USTRING:
+ {
+ char *p1 = *(char **)ptr1, *p2 = *(char **)ptr2;
+ if (p1 && !*p1)
+ p1 = NULL;
+ if (p2 && !*p2)
+ p2 = NULL;
+ return (p1 == p2 || strequal(p1, p2));
+ }
+ }
+ return false;
+}
+
+/**
+ * Process a new section (service).
+ *
+ * At this stage all sections are services.
+ * Later we'll have special sections that permit server parameters to be set.
+ * Returns True on success, False on failure.
+ */
+
+static bool do_section(const char *pszSectionName, void *userdata)
+{
+ struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
+ bool bRetval;
+ bool isglobal = ((strwicmp(pszSectionName, GLOBAL_NAME) == 0) ||
+ (strwicmp(pszSectionName, GLOBAL_NAME2) == 0));
+ bRetval = false;
+
+ /* if we've just struck a global section, note the fact. */
+ lp_ctx->bInGlobalSection = isglobal;
+
+ /* check for multiple global sections */
+ if (lp_ctx->bInGlobalSection) {
+ DEBUG(3, ("Processing section \"[%s]\"\n", pszSectionName));
+ return true;
+ }
+
+ /* if we have a current service, tidy it up before moving on */
+ bRetval = true;
+
+ if (lp_ctx->currentService != NULL)
+ bRetval = service_ok(lp_ctx->currentService);
+
+ /* if all is still well, move to the next record in the services array */
+ if (bRetval) {
+ /* We put this here to avoid an odd message order if messages are */
+ /* issued by the post-processing of a previous section. */
+ DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
+
+ if ((lp_ctx->currentService = lp_add_service(lp_ctx, lp_ctx->sDefault,
+ pszSectionName))
+ == NULL) {
+ DEBUG(0, ("Failed to add a new service\n"));
+ return false;
+ }
+ }
+
+ return bRetval;
+}
+
+
+/**
+ * Determine if a particular base parameter is currently set to the default value.
+ */
+
+static bool is_default(struct loadparm_service *sDefault, int i)
+{
+ void *def_ptr = ((char *)sDefault) + parm_table[i].offset;
+ if (!defaults_saved)
+ return false;
+ switch (parm_table[i].type) {
+ case P_LIST:
+ return str_list_equal((const char **)parm_table[i].def.lvalue,
+ (const char **)def_ptr);
+ case P_STRING:
+ case P_USTRING:
+ return strequal(parm_table[i].def.svalue,
+ *(char **)def_ptr);
+ case P_BOOL:
+ return parm_table[i].def.bvalue ==
+ *(int *)def_ptr;
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ case P_ENUM:
+ return parm_table[i].def.ivalue ==
+ *(int *)def_ptr;
+ }
+ return false;
+}
+
+/**
+ *Display the contents of the global structure.
+ */
+
+static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
+ bool show_defaults)
+{
+ int i;
+ struct param_opt *data;
+
+ fprintf(f, "# Global parameters\n[global]\n");
+
+ for (i = 0; parm_table[i].label; i++)
+ if (parm_table[i].class == P_GLOBAL &&
+ parm_table[i].offset != -1 &&
+ (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
+ if (!show_defaults && (lp_ctx->flags[i] & FLAG_DEFAULT))
+ continue;
+ fprintf(f, "\t%s = ", parm_table[i].label);
+ print_parameter(&parm_table[i], lp_parm_ptr(lp_ctx, NULL, &parm_table[i]), f);
+ fprintf(f, "\n");
+ }
+ if (lp_ctx->globals->param_opt != NULL) {
+ for (data = lp_ctx->globals->param_opt; data;
+ data = data->next) {
+ fprintf(f, "\t%s = %s\n", data->key, data->value);
+ }
+ }
+
+}
+
+/**
+ * Display the contents of a single services record.
+ */
+
+static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f)
+{
+ int i;
+ struct param_opt *data;
+
+ if (pService != sDefault)
+ fprintf(f, "\n[%s]\n", pService->szService);
+
+ for (i = 0; parm_table[i].label; i++)
+ if (parm_table[i].class == P_LOCAL &&
+ parm_table[i].offset != -1 &&
+ (*parm_table[i].label != '-') &&
+ (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) {
+ if (pService == sDefault) {
+ if (defaults_saved && is_default(sDefault, i))
+ continue;
+ } else {
+ if (equal_parameter(parm_table[i].type,
+ ((char *)pService) +
+ parm_table[i].offset,
+ ((char *)sDefault) +
+ parm_table[i].offset))
+ continue;
+ }
+
+ fprintf(f, "\t%s = ", parm_table[i].label);
+ print_parameter(&parm_table[i],
+ ((char *)pService) + parm_table[i].offset, f);
+ fprintf(f, "\n");
+ }
+ if (pService->param_opt != NULL) {
+ for (data = pService->param_opt; data; data = data->next) {
+ fprintf(f, "\t%s = %s\n", data->key, data->value);
+ }
+ }
+}
+
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *parm_name, FILE * f)
+{
+ struct parm_struct *parm;
+ void *ptr;
+
+ parm = lp_parm_struct(parm_name);
+ if (!parm) {
+ return false;
+ }
+
+ ptr = lp_parm_ptr(lp_ctx, service,parm);
+
+ print_parameter(parm, ptr, f);
+ fprintf(f, "\n");
+ return true;
+}
+
+/**
+ * Return info about the next service in a service. snum==-1 gives the globals.
+ * Return NULL when out of parameters.
+ */
+
+struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
+ int allparameters)
+{
+ if (snum == -1) {
+ /* do the globals */
+ for (; parm_table[*i].label; (*i)++) {
+ if (parm_table[*i].offset == -1
+ || (*parm_table[*i].label == '-'))
+ continue;
+
+ if ((*i) > 0
+ && (parm_table[*i].offset ==
+ parm_table[(*i) - 1].offset))
+ continue;
+
+ return &parm_table[(*i)++];
+ }
+ } else {
+ struct loadparm_service *pService = lp_ctx->services[snum];
+
+ for (; parm_table[*i].label; (*i)++) {
+ if (parm_table[*i].class == P_LOCAL &&
+ parm_table[*i].offset != -1 &&
+ (*parm_table[*i].label != '-') &&
+ ((*i) == 0 ||
+ (parm_table[*i].offset !=
+ parm_table[(*i) - 1].offset)))
+ {
+ if (allparameters ||
+ !equal_parameter(parm_table[*i].type,
+ ((char *)pService) +
+ parm_table[*i].offset,
+ ((char *)lp_ctx->sDefault) +
+ parm_table[*i].offset))
+ {
+ return &parm_table[(*i)++];
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ * Auto-load some home services.
+ */
+static void lp_add_auto_services(struct loadparm_context *lp_ctx,
+ const char *str)
+{
+ return;
+}
+
+
+/**
+ * Unload unused services.
+ */
+
+void lp_killunused(struct loadparm_context *lp_ctx,
+ struct smbsrv_connection *smb,
+ bool (*snumused) (struct smbsrv_connection *, int))
+{
+ int i;
+ for (i = 0; i < lp_ctx->iNumServices; i++) {
+ if (lp_ctx->services[i] == NULL)
+ continue;
+
+ if (!snumused || !snumused(smb, i)) {
+ talloc_free(lp_ctx->services[i]);
+ lp_ctx->services[i] = NULL;
+ }
+ }
+}
+
+
+static int lp_destructor(struct loadparm_context *lp_ctx)
+{
+ struct param_opt *data;
+
+ if (lp_ctx->globals->param_opt != NULL) {
+ struct param_opt *next;
+ for (data = lp_ctx->globals->param_opt; data; data=next) {
+ next = data->next;
+ if (data->flags & FLAG_CMDLINE) continue;
+ DLIST_REMOVE(lp_ctx->globals->param_opt, data);
+ talloc_free(data);
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * Initialise the global parameter structure.
+ */
+struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
+{
+ int i;
+ char *myname;
+ struct loadparm_context *lp_ctx;
+
+ lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
+ if (lp_ctx == NULL)
+ return NULL;
+
+ talloc_set_destructor(lp_ctx, lp_destructor);
+ lp_ctx->bInGlobalSection = true;
+ lp_ctx->globals = talloc_zero(lp_ctx, struct loadparm_global);
+ lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
+
+ lp_ctx->sDefault->iMaxPrintJobs = 1000;
+ lp_ctx->sDefault->bAvailable = true;
+ lp_ctx->sDefault->bBrowseable = true;
+ lp_ctx->sDefault->bRead_only = true;
+ lp_ctx->sDefault->bMap_archive = true;
+ lp_ctx->sDefault->bStrictLocking = true;
+ lp_ctx->sDefault->bOplocks = true;
+ lp_ctx->sDefault->iCreate_mask = 0744;
+ lp_ctx->sDefault->iCreate_force_mode = 0000;
+ lp_ctx->sDefault->iDir_mask = 0755;
+ lp_ctx->sDefault->iDir_force_mode = 0000;
+
+ DEBUG(3, ("Initialising global parameters\n"));
+
+ for (i = 0; parm_table[i].label; i++) {
+ if ((parm_table[i].type == P_STRING ||
+ parm_table[i].type == P_USTRING) &&
+ parm_table[i].offset != -1 &&
+ !(lp_ctx->flags[i] & FLAG_CMDLINE)) {
+ char **r;
+ if (parm_table[i].class == P_LOCAL) {
+ r = (char **)(((char *)lp_ctx->sDefault) + parm_table[i].offset);
+ } else {
+ r = (char **)(((char *)lp_ctx->globals) + parm_table[i].offset);
+ }
+ *r = talloc_strdup(lp_ctx, "");
+ }
+ }
+
+ lp_do_global_parameter(lp_ctx, "share backend", "classic");
+
+ lp_do_global_parameter(lp_ctx, "server role", "standalone");
+
+ /* options that can be set on the command line must be initialised via
+ the slower lp_do_global_parameter() to ensure that FLAG_CMDLINE is obeyed */
+#ifdef TCP_NODELAY
+ lp_do_global_parameter(lp_ctx, "socket options", "TCP_NODELAY");
+#endif
+ lp_do_global_parameter(lp_ctx, "workgroup", DEFAULT_WORKGROUP);
+ myname = get_myname();
+ lp_do_global_parameter(lp_ctx, "netbios name", myname);
+ SAFE_FREE(myname);
+ lp_do_global_parameter(lp_ctx, "name resolve order", "wins host bcast");
+
+ lp_do_global_parameter(lp_ctx, "fstype", FSTYPE_STRING);
+ lp_do_global_parameter(lp_ctx, "ntvfs handler", "unixuid default");
+ lp_do_global_parameter(lp_ctx, "max connections", "-1");
+
+ lp_do_global_parameter(lp_ctx, "dcerpc endpoint servers", "epmapper srvsvc wkssvc rpcecho samr netlogon lsarpc spoolss drsuapi winreg dssetup unixinfo");
+ lp_do_global_parameter(lp_ctx, "server services", "smb rpc nbt wrepl ldap cldap kdc drepl winbind ntp_signd");
+ lp_do_global_parameter(lp_ctx, "ntptr providor", "simple_ldb");
+ lp_do_global_parameter(lp_ctx, "auth methods:domain controller", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "auth methods:member server", "anonymous sam winbind");
+ lp_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain");
+ lp_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
+ lp_do_global_parameter(lp_ctx, "sam database", "sam.ldb");
+ lp_do_global_parameter(lp_ctx, "idmap database", "idmap.ldb");
+ lp_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb");
+ lp_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
+ lp_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
+ lp_do_global_parameter(lp_ctx, "wins database", "wins.ldb");
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_LOCAL_MACHINE", "hklm.ldb");
+
+ /* This hive should be dynamically generated by Samba using
+ data from the sam, but for the moment leave it in a tdb to
+ keep regedt32 from popping up an annoying dialog. */
+ lp_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
+
+ /* using UTF8 by default allows us to support all chars */
+ lp_do_global_parameter(lp_ctx, "unix charset", "UTF8");
+
+ /* Use codepage 850 as a default for the dos character set */
+ lp_do_global_parameter(lp_ctx, "dos charset", "CP850");
+
+ /*
+ * Allow the default PASSWD_CHAT to be overridden in local.h.
+ */
+ lp_do_global_parameter(lp_ctx, "passwd chat", DEFAULT_PASSWD_CHAT);
+
+ lp_do_global_parameter(lp_ctx, "pid directory", dyn_PIDDIR);
+ lp_do_global_parameter(lp_ctx, "lock dir", dyn_LOCKDIR);
+ lp_do_global_parameter(lp_ctx, "modules dir", dyn_MODULESDIR);
+ lp_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
+
+ lp_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
+ lp_do_global_parameter_var(lp_ctx, "server string",
+ "Samba %s", SAMBA_VERSION_STRING);
+
+ lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
+ DEFAULT_MAJOR_VERSION,
+ DEFAULT_MINOR_VERSION);
+
+ lp_do_global_parameter(lp_ctx, "password server", "*");
+
+ lp_do_global_parameter(lp_ctx, "max mux", "50");
+ lp_do_global_parameter(lp_ctx, "max xmit", "12288");
+ lp_do_global_parameter(lp_ctx, "password level", "0");
+ lp_do_global_parameter(lp_ctx, "LargeReadwrite", "True");
+ lp_do_global_parameter(lp_ctx, "server min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "server max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "client min protocol", "CORE");
+ lp_do_global_parameter(lp_ctx, "client max protocol", "NT1");
+ lp_do_global_parameter(lp_ctx, "security", "USER");
+ lp_do_global_parameter(lp_ctx, "paranoid server security", "True");
+ lp_do_global_parameter(lp_ctx, "EncryptPasswords", "True");
+ lp_do_global_parameter(lp_ctx, "ReadRaw", "True");
+ lp_do_global_parameter(lp_ctx, "WriteRaw", "True");
+ lp_do_global_parameter(lp_ctx, "NullPasswords", "False");
+ lp_do_global_parameter(lp_ctx, "ObeyPamRestrictions", "False");
+ lp_do_global_parameter(lp_ctx, "announce as", "NT SERVER");
+
+ lp_do_global_parameter(lp_ctx, "TimeServer", "False");
+ lp_do_global_parameter(lp_ctx, "BindInterfacesOnly", "False");
+ lp_do_global_parameter(lp_ctx, "Unicode", "True");
+ lp_do_global_parameter(lp_ctx, "ClientLanManAuth", "True");
+ lp_do_global_parameter(lp_ctx, "LanmanAuth", "True");
+ lp_do_global_parameter(lp_ctx, "NTLMAuth", "True");
+ lp_do_global_parameter(lp_ctx, "client use spnego principal", "False");
+
+ lp_do_global_parameter(lp_ctx, "UnixExtensions", "False");
+
+ lp_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
+ lp_do_global_parameter(lp_ctx, "LocalMaster", "True");
+
+ lp_do_global_parameter(lp_ctx, "wins support", "False");
+ lp_do_global_parameter(lp_ctx, "dns proxy", "True");
+
+ lp_do_global_parameter(lp_ctx, "winbind separator", "\\");
+ lp_do_global_parameter(lp_ctx, "winbind sealed pipes", "True");
+ lp_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
+ lp_do_global_parameter(lp_ctx, "winbindd privileged socket directory", dyn_WINBINDD_PRIVILEGED_SOCKET_DIR);
+ lp_do_global_parameter(lp_ctx, "template shell", "/bin/false");
+ lp_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
+ lp_do_global_parameter(lp_ctx, "idmap trusted only", "False");
+
+ lp_do_global_parameter(lp_ctx, "client signing", "Yes");
+ lp_do_global_parameter(lp_ctx, "server signing", "auto");
+
+ lp_do_global_parameter(lp_ctx, "use spnego", "True");
+
+ lp_do_global_parameter(lp_ctx, "smb ports", "445 139");
+ lp_do_global_parameter(lp_ctx, "nbt port", "137");
+ lp_do_global_parameter(lp_ctx, "dgram port", "138");
+ lp_do_global_parameter(lp_ctx, "cldap port", "389");
+ lp_do_global_parameter(lp_ctx, "krb5 port", "88");
+ lp_do_global_parameter(lp_ctx, "kpasswd port", "464");
+ lp_do_global_parameter(lp_ctx, "web port", "901");
+ lp_do_global_parameter(lp_ctx, "swat directory", dyn_SWATDIR);
+
+ lp_do_global_parameter(lp_ctx, "nt status support", "True");
+
+ lp_do_global_parameter(lp_ctx, "max wins ttl", "518400"); /* 6 days */
+ lp_do_global_parameter(lp_ctx, "min wins ttl", "10");
+
+ lp_do_global_parameter(lp_ctx, "tls enabled", "True");
+ lp_do_global_parameter(lp_ctx, "tls keyfile", "tls/key.pem");
+ lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
+ lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
+ lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR);
+ lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
+ dyn_SETUPDIR);
+
+ lp_do_global_parameter(lp_ctx, "prefork children:smb", "4");
+
+ lp_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
+
+ for (i = 0; parm_table[i].label; i++) {
+ if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
+ lp_ctx->flags[i] |= FLAG_DEFAULT;
+ }
+ }
+
+ return lp_ctx;
+}
+
+const char *lp_configfile(struct loadparm_context *lp_ctx)
+{
+ return lp_ctx->szConfigFile;
+}
+
+bool lp_load_default(struct loadparm_context *lp_ctx)
+{
+ return lp_load(lp_ctx, dyn_CONFIGFILE);
+}
+
+/**
+ * Load the services array from the services file.
+ *
+ * Return True on success, False on failure.
+ */
+bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
+{
+ char *n2;
+ bool bRetval;
+
+ filename = talloc_strdup(lp_ctx, filename);
+
+ lp_ctx->szConfigFile = filename;
+
+ lp_ctx->bInGlobalSection = true;
+ n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
+ DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
+
+ add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
+
+ /* We get sections first, so have to start 'behind' to make up */
+ lp_ctx->currentService = NULL;
+ bRetval = pm_process(n2, do_section, do_parameter, lp_ctx);
+
+ /* finish up the last section */
+ DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval)));
+ if (bRetval)
+ if (lp_ctx->currentService != NULL)
+ bRetval = service_ok(lp_ctx->currentService);
+
+ lp_add_auto_services(lp_ctx, lp_auto_services(lp_ctx));
+
+ lp_add_hidden(lp_ctx, "IPC$", "IPC");
+ lp_add_hidden(lp_ctx, "ADMIN$", "DISK");
+
+ if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
+ lp_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
+ }
+
+ panic_action = lp_ctx->globals->panic_action;
+
+ reload_charcnv(lp_ctx);
+
+ /* FIXME: Check locale in environment for this: */
+ if (strcmp(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)) != 0)
+ d_set_iconv(smb_iconv_open(lp_display_charset(lp_ctx), lp_unix_charset(lp_ctx)));
+ else
+ d_set_iconv((smb_iconv_t)-1);
+
+ return bRetval;
+}
+
+/**
+ * Return the max number of services.
+ */
+
+int lp_numservices(struct loadparm_context *lp_ctx)
+{
+ return lp_ctx->iNumServices;
+}
+
+/**
+ * Display the contents of the services array in human-readable form.
+ */
+
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+ int maxtoprint)
+{
+ int iService;
+
+ if (show_defaults)
+ defaults_saved = false;
+
+ dump_globals(lp_ctx, f, show_defaults);
+
+ dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f);
+
+ for (iService = 0; iService < maxtoprint; iService++)
+ lp_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
+}
+
+/**
+ * Display the contents of one service in human-readable form.
+ */
+void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault)
+{
+ if (service != NULL) {
+ if (service->szService[0] == '\0')
+ return;
+ dump_a_service(service, sDefault, f);
+ }
+}
+
+struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
+ int snum)
+{
+ return lp_ctx->services[snum];
+}
+
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+ const char *service_name)
+{
+ int iService;
+ char *serviceName;
+
+ for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
+ if (lp_ctx->services[iService] &&
+ lp_ctx->services[iService]->szService) {
+ /*
+ * The substitution here is used to support %U is
+ * service names
+ */
+ serviceName = standard_sub_basic(
+ lp_ctx->services[iService],
+ lp_ctx->services[iService]->szService);
+ if (strequal(serviceName, service_name))
+ return lp_ctx->services[iService];
+ }
+ }
+
+ DEBUG(7,("lp_servicenumber: couldn't find %s\n", service_name));
+ return NULL;
+}
+
+
+/**
+ * A useful volume label function.
+ */
+const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault)
+{
+ const char *ret = lp_volume(service, sDefault);
+ if (!*ret)
+ return lp_servicename(service);
+ return ret;
+}
+
+
+/**
+ * If we are PDC then prefer us as DMB
+ */
+const char *lp_printername(struct loadparm_service *service, struct loadparm_service *sDefault)
+{
+ const char *ret = _lp_printername(service, sDefault);
+ if (ret == NULL || (ret != NULL && *ret == '\0'))
+ ret = lp_servicename(service);
+
+ return ret;
+}
+
+
+/**
+ * Return the max print jobs per queue.
+ */
+int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault)
+{
+ int maxjobs = (service != NULL) ? service->iMaxPrintJobs : sDefault->iMaxPrintJobs;
+ if (maxjobs <= 0 || maxjobs >= PRINT_MAX_JOBID)
+ maxjobs = PRINT_MAX_JOBID - 1;
+
+ return maxjobs;
+}
+
+struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx)
+{
+ if (lp_ctx == NULL) {
+ static struct smb_iconv_convenience *fallback_ic = NULL;
+ if (fallback_ic == NULL)
+ fallback_ic = smb_iconv_convenience_init(talloc_autofree_context(),
+ "CP850", "UTF8", true);
+ return fallback_ic;
+ }
+ return lp_ctx->iconv_convenience;
+}
+
+_PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
+{
+ talloc_free(lp_ctx->iconv_convenience);
+ lp_ctx->iconv_convenience = smb_iconv_convenience_init_lp(lp_ctx, lp_ctx);
+}
+
+void lp_smbcli_options(struct loadparm_context *lp_ctx,
+ struct smbcli_options *options)
+{
+ options->max_xmit = lp_max_xmit(lp_ctx);
+ options->max_mux = lp_maxmux(lp_ctx);
+ options->use_spnego = lp_nt_status_support(lp_ctx) && lp_use_spnego(lp_ctx);
+ options->signing = lp_client_signing(lp_ctx);
+ options->request_timeout = SMB_REQUEST_TIMEOUT;
+ options->ntstatus_support = lp_nt_status_support(lp_ctx);
+ options->max_protocol = lp_cli_maxprotocol(lp_ctx);
+ options->unicode = lp_unicode(lp_ctx);
+ options->use_oplocks = true;
+ options->use_level2_oplocks = true;
+}
diff --git a/source4/param/loadparm.h b/source4/param/loadparm.h
new file mode 100644
index 0000000000..cd3c0b9595
--- /dev/null
+++ b/source4/param/loadparm.h
@@ -0,0 +1,75 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ type definitions for loadparm
+
+ Copyright (C) Karl Auer 1993-1998
+
+ Largely re-written by Andrew Tridgell, September 1994
+
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Alexander Bokovoy 2002
+ Copyright (C) Stefan (metze) Metzmacher 2002
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
+ Copyright (C) James Myers 2003 <myersjj@samba.org>
+
+ 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/>.
+*/
+
+/* the following are used by loadparm for option lists */
+typedef enum {
+ P_BOOL,P_INTEGER,P_OCTAL,P_BYTES,P_LIST,P_STRING,P_USTRING,P_ENUM
+} parm_type;
+
+typedef enum {
+ P_LOCAL,P_GLOBAL,P_NONE
+} parm_class;
+
+struct enum_list {
+ int value;
+ const char *name;
+};
+
+struct loadparm_context;
+
+struct parm_struct {
+ const char *label;
+ parm_type type;
+ parm_class class;
+ int offset;
+ bool (*special)(struct loadparm_context *, const char *, char **);
+ const struct enum_list *enum_list;
+ union {
+ int bvalue;
+ int ivalue;
+ char *svalue;
+ char cvalue;
+ const char **lvalue;
+ } def;
+};
+
+
+
+
+#define FLAG_DEFAULT 0x0001 /* this option was a default */
+#define FLAG_CMDLINE 0x0002 /* this option was set from the command line */
+
+#ifndef PRINTERS_NAME
+#define PRINTERS_NAME "printers"
+#endif
+
+#ifndef HOMES_NAME
+#define HOMES_NAME "homes"
+#endif
+
diff --git a/source4/param/param.h b/source4/param/param.h
new file mode 100644
index 0000000000..4ed2654692
--- /dev/null
+++ b/source4/param/param.h
@@ -0,0 +1,430 @@
+/*
+ Unix SMB/CIFS implementation.
+ Generic parameter parsing interface
+ Copyright (C) Jelmer Vernooij 2005
+
+ 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 _PARAM_H /* _PARAM_H */
+#define _PARAM_H
+
+struct param_opt {
+ struct param_opt *prev, *next;
+ char *key;
+ char *value;
+ int flags;
+};
+
+struct param_context {
+ struct param_section *sections;
+};
+
+struct param_section {
+ const char *name;
+ struct param_section *prev, *next;
+ struct param_opt *parameters;
+};
+
+struct param_context;
+struct smbsrv_connection;
+
+#define Auto (2)
+
+typedef NTSTATUS (*init_module_fn) (void);
+
+enum server_role {
+ ROLE_STANDALONE=0,
+ ROLE_DOMAIN_MEMBER=1,
+ ROLE_DOMAIN_CONTROLLER=2,
+};
+
+enum announce_as {/* Types of machine we can announce as. */
+ ANNOUNCE_AS_NT_SERVER=1,
+ ANNOUNCE_AS_WIN95=2,
+ ANNOUNCE_AS_WFW=3,
+ ANNOUNCE_AS_NT_WORKSTATION=4
+};
+
+struct loadparm_context;
+struct loadparm_service;
+struct smbcli_options;
+
+void reload_charcnv(struct loadparm_context *lp_ctx);
+
+extern struct loadparm_context *global_loadparm;
+
+struct loadparm_service *lp_default_service(struct loadparm_context *lp_ctx);
+struct parm_struct *lp_parm_table(void);
+int lp_server_role(struct loadparm_context *);
+const char **lp_smb_ports(struct loadparm_context *);
+int lp_nbt_port(struct loadparm_context *);
+int lp_dgram_port(struct loadparm_context *);
+int lp_cldap_port(struct loadparm_context *);
+int lp_krb5_port(struct loadparm_context *);
+int lp_kpasswd_port(struct loadparm_context *);
+int lp_web_port(struct loadparm_context *);
+const char *lp_swat_directory(struct loadparm_context *);
+bool lp_tls_enabled(struct loadparm_context *);
+const char *lp_tls_keyfile(struct loadparm_context *);
+const char *lp_tls_certfile(struct loadparm_context *);
+const char *lp_tls_cafile(struct loadparm_context *);
+const char *lp_tls_crlfile(struct loadparm_context *);
+const char *lp_tls_dhpfile(struct loadparm_context *);
+const char *lp_share_backend(struct loadparm_context *);
+const char *lp_sam_url(struct loadparm_context *);
+const char *lp_idmap_url(struct loadparm_context *);
+const char *lp_secrets_url(struct loadparm_context *);
+const char *lp_spoolss_url(struct loadparm_context *);
+const char *lp_wins_config_url(struct loadparm_context *);
+const char *lp_wins_url(struct loadparm_context *);
+const char *lp_winbind_separator(struct loadparm_context *);
+const char *lp_winbindd_socket_directory(struct loadparm_context *);
+const char *lp_winbindd_privileged_socket_directory(struct loadparm_context *);
+const char *lp_template_shell(struct loadparm_context *);
+const char *lp_template_homedir(struct loadparm_context *);
+bool lp_winbind_sealed_pipes(struct loadparm_context *);
+bool lp_idmap_trusted_only(struct loadparm_context *);
+const char *lp_private_dir(struct loadparm_context *);
+const char *lp_serverstring(struct loadparm_context *);
+const char *lp_lockdir(struct loadparm_context *);
+const char *lp_modulesdir(struct loadparm_context *);
+const char *lp_setupdir(struct loadparm_context *);
+const char *lp_ncalrpc_dir(struct loadparm_context *);
+const char *lp_dos_charset(struct loadparm_context *);
+const char *lp_unix_charset(struct loadparm_context *);
+const char *lp_display_charset(struct loadparm_context *);
+const char *lp_piddir(struct loadparm_context *);
+const char **lp_dcerpc_endpoint_servers(struct loadparm_context *);
+const char **lp_server_services(struct loadparm_context *);
+const char *lp_ntptr_providor(struct loadparm_context *);
+const char *lp_auto_services(struct loadparm_context *);
+const char *lp_passwd_chat(struct loadparm_context *);
+const char **lp_passwordserver(struct loadparm_context *);
+const char **lp_name_resolve_order(struct loadparm_context *);
+const char *lp_realm(struct loadparm_context *);
+const char *lp_socket_options(struct loadparm_context *);
+const char *lp_workgroup(struct loadparm_context *);
+const char *lp_netbios_name(struct loadparm_context *);
+const char *lp_netbios_scope(struct loadparm_context *);
+const char **lp_wins_server_list(struct loadparm_context *);
+const char **lp_interfaces(struct loadparm_context *);
+const char *lp_socket_address(struct loadparm_context *);
+const char **lp_netbios_aliases(struct loadparm_context *);
+bool lp_disable_netbios(struct loadparm_context *);
+bool lp_wins_support(struct loadparm_context *);
+bool lp_wins_dns_proxy(struct loadparm_context *);
+const char *lp_wins_hook(struct loadparm_context *);
+bool lp_local_master(struct loadparm_context *);
+bool lp_readraw(struct loadparm_context *);
+bool lp_large_readwrite(struct loadparm_context *);
+bool lp_writeraw(struct loadparm_context *);
+bool lp_null_passwords(struct loadparm_context *);
+bool lp_obey_pam_restrictions(struct loadparm_context *);
+bool lp_encrypted_passwords(struct loadparm_context *);
+bool lp_time_server(struct loadparm_context *);
+bool lp_bind_interfaces_only(struct loadparm_context *);
+bool lp_unicode(struct loadparm_context *);
+bool lp_nt_status_support(struct loadparm_context *);
+bool lp_lanman_auth(struct loadparm_context *);
+bool lp_ntlm_auth(struct loadparm_context *);
+bool lp_client_plaintext_auth(struct loadparm_context *);
+bool lp_client_lanman_auth(struct loadparm_context *);
+bool lp_client_ntlmv2_auth(struct loadparm_context *);
+bool lp_client_use_spnego_principal(struct loadparm_context *);
+bool lp_host_msdfs(struct loadparm_context *);
+bool lp_unix_extensions(struct loadparm_context *);
+bool lp_use_spnego(struct loadparm_context *);
+bool lp_rpc_big_endian(struct loadparm_context *);
+int lp_max_wins_ttl(struct loadparm_context *);
+int lp_min_wins_ttl(struct loadparm_context *);
+int lp_maxmux(struct loadparm_context *);
+int lp_max_xmit(struct loadparm_context *);
+int lp_passwordlevel(struct loadparm_context *);
+int lp_srv_maxprotocol(struct loadparm_context *);
+int lp_srv_minprotocol(struct loadparm_context *);
+int lp_cli_maxprotocol(struct loadparm_context *);
+int lp_cli_minprotocol(struct loadparm_context *);
+int lp_security(struct loadparm_context *);
+bool lp_paranoid_server_security(struct loadparm_context *);
+int lp_announce_as(struct loadparm_context *);
+const char **lp_js_include(struct loadparm_context *);
+
+const char *lp_servicename(const struct loadparm_service *service);
+const char *lp_pathname(struct loadparm_service *, struct loadparm_service *);
+const char **lp_hostsallow(struct loadparm_service *, struct loadparm_service *);
+const char **lp_hostsdeny(struct loadparm_service *, struct loadparm_service *);
+const char *lp_comment(struct loadparm_service *, struct loadparm_service *);
+const char *lp_fstype(struct loadparm_service *, struct loadparm_service *);
+const char **lp_ntvfs_handler(struct loadparm_service *, struct loadparm_service *);
+bool lp_msdfs_root(struct loadparm_service *, struct loadparm_service *);
+bool lp_browseable(struct loadparm_service *, struct loadparm_service *);
+bool lp_readonly(struct loadparm_service *, struct loadparm_service *);
+bool lp_print_ok(struct loadparm_service *, struct loadparm_service *);
+bool lp_map_hidden(struct loadparm_service *, struct loadparm_service *);
+bool lp_map_archive(struct loadparm_service *, struct loadparm_service *);
+bool lp_strict_locking(struct loadparm_service *, struct loadparm_service *);
+bool lp_oplocks(struct loadparm_service *, struct loadparm_service *);
+bool lp_strict_sync(struct loadparm_service *, struct loadparm_service *);
+bool lp_ci_filesystem(struct loadparm_service *, struct loadparm_service *);
+bool lp_map_system(struct loadparm_service *, struct loadparm_service *);
+int lp_max_connections(struct loadparm_service *, struct loadparm_service *);
+int lp_csc_policy(struct loadparm_service *, struct loadparm_service *);
+int lp_create_mask(struct loadparm_service *, struct loadparm_service *);
+int lp_force_create_mode(struct loadparm_service *, struct loadparm_service *);
+int lp_dir_mask(struct loadparm_service *, struct loadparm_service *);
+int lp_force_dir_mode(struct loadparm_service *, struct loadparm_service *);
+int lp_server_signing(struct loadparm_context *);
+int lp_client_signing(struct loadparm_context *);
+const char *lp_ntp_signd_socket_directory(struct loadparm_context *);
+
+const char *lp_get_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type, const char *option);
+
+const char *lp_parm_string(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option);
+const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type,
+ const char *option, const char *separator);
+int lp_parm_int(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v);
+int lp_parm_bytes(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, int default_v);
+unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, unsigned long default_v);
+double lp_parm_double(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, double default_v);
+bool lp_parm_bool(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
+ const char *option, bool default_v);
+struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
+ const struct loadparm_service *pservice,
+ const char *name);
+bool lp_add_home(struct loadparm_context *lp_ctx,
+ const char *pszHomename,
+ struct loadparm_service *default_service,
+ const char *user, const char *pszHomedir);
+bool lp_add_printer(struct loadparm_context *lp_ctx,
+ const char *pszPrintername,
+ struct loadparm_service *default_service);
+struct parm_struct *lp_parm_struct(const char *name);
+void *lp_parm_ptr(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, struct parm_struct *parm);
+bool lp_file_list_changed(struct loadparm_context *lp_ctx);
+
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *pszParmValue);
+bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName, const char *pszParmValue);
+
+/**
+ * Process a parameter.
+ */
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...);
+bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
+ const char *pszParmValue);
+bool lp_set_option(struct loadparm_context *lp_ctx, const char *option);
+
+/**
+ * Display the contents of a single services record.
+ */
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *parm_name, FILE * f);
+
+/**
+ * Return info about the next service in a service. snum==-1 gives the globals.
+ * Return NULL when out of parameters.
+ */
+struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum, int *i,
+ int allparameters);
+
+/**
+ * Unload unused services.
+ */
+void lp_killunused(struct loadparm_context *lp_ctx,
+ struct smbsrv_connection *smb,
+ bool (*snumused) (struct smbsrv_connection *, int));
+
+/**
+ * Initialise the global parameter structure.
+ */
+struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
+const char *lp_configfile(struct loadparm_context *lp_ctx);
+bool lp_load_default(struct loadparm_context *lp_ctx);
+
+/**
+ * Load the services array from the services file.
+ *
+ * Return True on success, False on failure.
+ */
+bool lp_load(struct loadparm_context *lp_ctx, const char *filename);
+
+/**
+ * Return the max number of services.
+ */
+int lp_numservices(struct loadparm_context *lp_ctx);
+
+/**
+ * Display the contents of the services array in human-readable form.
+ */
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+ int maxtoprint);
+
+/**
+ * Display the contents of one service in human-readable form.
+ */
+void lp_dump_one(FILE *f, bool show_defaults, struct loadparm_service *service, struct loadparm_service *sDefault);
+struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
+ int snum);
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+ const char *service_name);
+
+/**
+ * A useful volume label function.
+ */
+const char *volume_label(struct loadparm_service *service, struct loadparm_service *sDefault);
+
+/**
+ * If we are PDC then prefer us as DMB
+ */
+const char *lp_printername(struct loadparm_service *service, struct loadparm_service *sDefault);
+
+/**
+ * Return the max print jobs per queue.
+ */
+int lp_maxprintjobs(struct loadparm_service *service, struct loadparm_service *sDefault);
+struct smb_iconv_convenience *lp_iconv_convenience(struct loadparm_context *lp_ctx);
+void lp_smbcli_options(struct loadparm_context *lp_ctx,
+ struct smbcli_options *options);
+
+/* The following definitions come from param/generic.c */
+
+struct param_section *param_get_section(struct param_context *ctx, const char *name);
+struct param_opt *param_section_get(struct param_section *section,
+ const char *name);
+struct param_opt *param_get (struct param_context *ctx, const char *name, const char *section_name);
+struct param_section *param_add_section(struct param_context *ctx, const char *section_name);
+struct param_opt *param_get_add(struct param_context *ctx, const char *name, const char *section_name);
+const char *param_get_string(struct param_context *ctx, const char *param, const char *section);
+int param_set_string(struct param_context *ctx, const char *param, const char *value, const char *section);
+const char **param_get_string_list(struct param_context *ctx, const char *param, const char *separator, const char *section);
+int param_set_string_list(struct param_context *ctx, const char *param, const char **list, const char *section);
+int param_get_int(struct param_context *ctx, const char *param, int default_v, const char *section);
+void param_set_int(struct param_context *ctx, const char *param, int value, const char *section);
+unsigned long param_get_ulong(struct param_context *ctx, const char *param, unsigned long default_v, const char *section);
+void param_set_ulong(struct param_context *ctx, const char *name, unsigned long value, const char *section);
+struct param_context *param_init(TALLOC_CTX *mem_ctx);
+int param_read(struct param_context *ctx, const char *fn);
+int param_use(struct loadparm_context *lp_ctx, struct param_context *ctx);
+int param_write(struct param_context *ctx, const char *fn);
+
+/* The following definitions come from param/util.c */
+
+
+/**
+ * @file
+ * @brief Misc utility functions
+ */
+bool lp_is_mydomain(struct loadparm_context *lp_ctx,
+ const char *domain);
+
+/**
+ see if a string matches either our primary or one of our secondary
+ netbios aliases. do a case insensitive match
+*/
+bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name);
+
+/**
+ A useful function for returning a path in the Samba lock directory.
+**/
+char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name);
+
+/**
+ * @brief Returns an absolute path to a file in the directory containing the current config file
+ *
+ * @param name File to find, relative to the config file directory.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name);
+
+/**
+ * @brief Returns an absolute path to a file in the Samba private directory.
+ *
+ * @param name File to find, relative to PRIVATEDIR.
+ * if name is not relative, then use it as-is
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+char *private_path(TALLOC_CTX* mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name);
+
+/**
+ return a path in the smbd.tmp directory, where all temporary file
+ for smbd go. If NULL is passed for name then return the directory
+ path itself
+*/
+char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name);
+
+/**
+ * Obtain the init function from a shared library file
+ */
+init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path);
+
+/**
+ * Obtain list of init functions from the modules in the specified
+ * directory
+ */
+init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path);
+
+/**
+ * Run the specified init functions.
+ *
+ * @return true if all functions ran successfully, false otherwise
+ */
+bool run_init_functions(init_module_fn *fns);
+
+/**
+ * Load the initialization functions from DSO files for a specific subsystem.
+ *
+ * Will return an array of function pointers to initialization functions
+ */
+init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem);
+const char *lp_messaging_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx);
+struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx);
+
+/* The following definitions come from lib/version.c */
+
+const char *samba_version_string(void);
+
+
+#endif /* _PARAM_H */
diff --git a/source4/param/param.i b/source4/param/param.i
new file mode 100644
index 0000000000..ad42919998
--- /dev/null
+++ b/source4/param/param.i
@@ -0,0 +1,350 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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/>.
+*/
+
+%module(docstring="Parsing and writing Samba configuration files.",package="samba.param") param
+
+%{
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "includes.h"
+#include "param/param.h"
+#include "param/loadparm.h"
+
+typedef struct param_context param;
+typedef struct loadparm_context loadparm_context;
+typedef struct loadparm_service loadparm_service;
+typedef struct param_section param_section;
+typedef struct param_opt param_opt;
+%}
+
+%import "stdint.i"
+%import "carrays.i"
+%import "typemaps.i"
+%import "../lib/talloc/talloc.i"
+
+%typemap(default,noblock=1) struct loadparm_context * {
+ $1 = loadparm_init(NULL);
+}
+
+%rename(LoadParm) loadparm_context;
+
+%talloctype(loadparm_context);
+
+typedef struct loadparm_context {
+ %extend {
+ loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); }
+ struct loadparm_service *default_service() { return lp_default_service($self); }
+ %feature("docstring") load "S.load(filename) -> None\n" \
+ "Load specified file.";
+ bool load(const char *filename) { return lp_load($self, filename); }
+ %feature("docstring") load_default "S.load_default() -> None\n" \
+ "Load default smb.conf file.";
+ bool load_default() { return lp_load_default($self); }
+#ifdef SWIGPYTHON
+ int __len__() { return lp_numservices($self); }
+ struct loadparm_service *__getitem__(const char *name) { return lp_service($self, name); }
+#endif
+ %feature("docstring") configfile "S.configfile() -> string\n" \
+ "Return name of last config file that was loaded.";
+ const char *configfile() { return lp_configfile($self); }
+ %feature("docstring") is_mydomain "S.is_mydomain(domain_name) -> bool\n" \
+ "Check whether the specified name matches our domain name.";
+ bool is_mydomain(const char *domain) { return lp_is_mydomain($self, domain); }
+ %feature("docstring") is_myname "S.is_myname(netbios_name) -> bool\n" \
+ "Check whether the specified name matches one of our netbios names.";
+ bool is_myname(const char *name) { return lp_is_myname($self, name); }
+ int use(struct param_context *param_ctx) { return param_use($self, param_ctx); }
+ %feature("docstring") set "S.set(name, value) -> bool\n" \
+ "Change a parameter.";
+ bool set(const char *parm_name, const char *parm_value) {
+ if (parm_value == NULL)
+ return false;
+ return lp_set_cmdline($self, parm_name, parm_value);
+ }
+
+ %feature("docstring") set "S.get(name, service_name) -> value\n" \
+ "Find specified parameter.";
+ PyObject *get(const char *param_name, const char *service_name)
+ {
+ struct parm_struct *parm = NULL;
+ void *parm_ptr = NULL;
+ int i;
+
+ if (service_name != NULL) {
+ struct loadparm_service *service;
+ /* its a share parameter */
+ service = lp_service($self, service_name);
+ if (service == NULL) {
+ return Py_None;
+ }
+ if (strchr(param_name, ':')) {
+ /* its a parametric option on a share */
+ const char *type = talloc_strndup($self,
+ param_name,
+ strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric($self, service, type, option);
+ if (value == NULL) {
+ return Py_None;
+ }
+ return PyString_FromString(value);
+ }
+
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL || parm->class == P_GLOBAL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr($self, service, parm);
+ } else if (strchr(param_name, ':')) {
+ /* its a global parametric option */
+ const char *type = talloc_strndup($self,
+ param_name, strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric($self, NULL, type, option);
+ if (value == NULL)
+ return Py_None;
+ return PyString_FromString(value);
+ } else {
+ /* its a global parameter */
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr($self, NULL, parm);
+ }
+
+ if (parm == NULL || parm_ptr == NULL) {
+ return Py_None;
+ }
+
+ /* construct and return the right type of python object */
+ switch (parm->type) {
+ case P_STRING:
+ case P_USTRING:
+ return PyString_FromString(*(char **)parm_ptr);
+ case P_BOOL:
+ return PyBool_FromLong(*(bool *)parm_ptr);
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ return PyLong_FromLong(*(int *)parm_ptr);
+ case P_ENUM:
+ for (i=0; parm->enum_list[i].name; i++) {
+ if (*(int *)parm_ptr == parm->enum_list[i].value) {
+ return PyString_FromString(parm->enum_list[i].name);
+ }
+ }
+ return Py_None;
+ case P_LIST:
+ {
+ int j;
+ const char **strlist = *(const char ***)parm_ptr;
+ PyObject *pylist = PyList_New(str_list_length(strlist));
+ for (j = 0; strlist[j]; j++)
+ PyList_SetItem(pylist, j,
+ PyString_FromString(strlist[j]));
+ return pylist;
+ }
+
+ break;
+ }
+ return Py_None;
+ }
+ }
+} loadparm_context;
+
+%nodefaultctor loadparm_service;
+%nodefaultdtor loadparm_service;
+
+typedef struct loadparm_service {
+ %extend {
+ const char *volume_label(struct loadparm_service *sDefault) { return volume_label($self, sDefault); }
+ const char *printername(struct loadparm_service *sDefault) { return lp_printername($self, sDefault); }
+ int maxprintjobs(struct loadparm_service *sDefault) { return lp_maxprintjobs($self, sDefault); }
+ }
+} loadparm_service;
+
+%rename(ParamFile) param_context;
+
+%talloctype(param_context);
+typedef struct param_context {
+ %extend {
+ param(TALLOC_CTX *mem_ctx) { return param_init(mem_ctx); }
+ %feature("docstring") add_section "S.get_section(name) -> section\n"
+ "Get an existing section.";
+ struct param_section *get_section(const char *name);
+ %feature("docstring") add_section "S.add_section(name) -> section\n"
+ "Add a new section.";
+ struct param_section *add_section(const char *name);
+ struct param_opt *get(const char *name, const char *section_name="global");
+ const char *get_string(const char *name, const char *section_name="global");
+ int set_string(const char *param, const char *value, const char *section="global");
+#ifdef SWIGPYTHON
+ int set(const char *parameter, PyObject *ob, const char *section_name="global")
+ {
+ struct param_opt *opt = param_get_add($self, parameter, section_name);
+
+ talloc_free(opt->value);
+ opt->value = talloc_strdup(opt, PyString_AsString(PyObject_Str(ob)));
+
+ return 0;
+ }
+
+#endif
+
+ %feature("docstring") first_section "S.first_section() -> section\n"
+ "Find first section";
+ struct param_section *first_section() { return $self->sections; }
+ %feature("docstring") next_section "S.next_section(prev) -> section\n"
+ "Find next section";
+ struct param_section *next_section(struct param_section *s) { return s->next; }
+
+ %feature("docstring") read "S.read(filename) -> bool\n"
+ "Read a filename.";
+ int read(const char *fn);
+ %feature("docstring") read "S.write(filename) -> bool\n"
+ "Write this object to a file.";
+ int write(const char *fn);
+ }
+ %pythoncode {
+ def __getitem__(self, name):
+ ret = self.get_section(name)
+ if ret is None:
+ raise KeyError("No such section %s" % name)
+ return ret
+
+ class SectionIterator:
+ def __init__(self, param):
+ self.param = param
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.param.first_section()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.param.next_section(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.SectionIterator(self)
+ }
+} param;
+
+%talloctype(param_opt);
+
+typedef struct param_opt {
+ %immutable key;
+ %immutable value;
+ const char *key, *value;
+ %extend {
+#ifdef SWIGPYTHON
+ const char *__str__() { return $self->value; }
+#endif
+ }
+} param_opt;
+
+%talloctype(param);
+typedef struct param_section {
+ %immutable name;
+ const char *name;
+ %extend {
+ struct param_opt *get(const char *name);
+ struct param_opt *first_parameter() { return $self->parameters; }
+ struct param_opt *next_parameter(struct param_opt *s) { return s->next; }
+ }
+ %pythoncode {
+ def __getitem__(self, name):
+ ret = self.get(name)
+ if ret is None:
+ raise KeyError("No such option %s" % name)
+ return ret
+
+ class ParamIterator:
+ def __init__(self, section):
+ self.section = section
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.section.first_parameter()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.section.next_parameter(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.ParamIterator(self)
+ }
+} param_section;
+
+%rename(default_config) global_loadparm;
+struct loadparm_context *global_loadparm;
+
+%{
+
+struct loadparm_context *lp_from_py_object(PyObject *py_obj)
+{
+ struct loadparm_context *lp_ctx;
+ if (PyString_Check(py_obj)) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load(lp_ctx, PyString_AsString(py_obj))) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
+ if (py_obj == Py_None) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load_default(lp_ctx)) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
+ if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0)
+ return NULL;
+ return lp_ctx;
+}
+
+%}
diff --git a/source4/param/param.py b/source4/param/param.py
new file mode 100644
index 0000000000..46c75cef97
--- /dev/null
+++ b/source4/param/param.py
@@ -0,0 +1,267 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.35
+#
+# Don't modify this file, modify the SWIG interface instead.
+
+"""
+Parsing and writing Samba configuration files.
+"""
+
+import _param
+import new
+new_instancemethod = new.instancemethod
+try:
+ _swig_property = property
+except NameError:
+ pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+ if (name == "thisown"): return self.this.own(value)
+ if (name == "this"):
+ if type(value).__name__ == 'PySwigObject':
+ self.__dict__[name] = value
+ return
+ method = class_type.__swig_setmethods__.get(name,None)
+ if method: return method(self,value)
+ if (not static) or hasattr(self,name):
+ self.__dict__[name] = value
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+ return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+ if (name == "thisown"): return self.this.own()
+ method = class_type.__swig_getmethods__.get(name,None)
+ if method: return method(self)
+ raise AttributeError,name
+
+def _swig_repr(self):
+ try: strthis = "proxy of " + self.this.__repr__()
+ except: strthis = ""
+ return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+import types
+try:
+ _object = types.ObjectType
+ _newclass = 1
+except AttributeError:
+ class _object : pass
+ _newclass = 0
+del types
+
+
+def _swig_setattr_nondynamic_method(set):
+ def set_attr(self,name,value):
+ if (name == "thisown"): return self.this.own(value)
+ if hasattr(self,name) or (name == "this"):
+ set(self,name,value)
+ else:
+ raise AttributeError("You cannot add attributes to %s" % self)
+ return set_attr
+
+
+class LoadParm(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ __repr__ = _swig_repr
+ def __init__(self, *args, **kwargs):
+ _param.LoadParm_swiginit(self,_param.new_LoadParm(*args, **kwargs))
+ def load(*args, **kwargs):
+ """
+ S.load(filename) -> None
+ Load specified file.
+ """
+ return _param.LoadParm_load(*args, **kwargs)
+
+ def load_default(*args, **kwargs):
+ """
+ S.load_default() -> None
+ Load default smb.conf file.
+ """
+ return _param.LoadParm_load_default(*args, **kwargs)
+
+ def configfile(*args, **kwargs):
+ """
+ S.configfile() -> string
+ Return name of last config file that was loaded.
+ """
+ return _param.LoadParm_configfile(*args, **kwargs)
+
+ def is_mydomain(*args, **kwargs):
+ """
+ S.is_mydomain(domain_name) -> bool
+ Check whether the specified name matches our domain name.
+ """
+ return _param.LoadParm_is_mydomain(*args, **kwargs)
+
+ def is_myname(*args, **kwargs):
+ """
+ S.is_myname(netbios_name) -> bool
+ Check whether the specified name matches one of our netbios names.
+ """
+ return _param.LoadParm_is_myname(*args, **kwargs)
+
+ def set(*args, **kwargs):
+ """
+ S.set(name, value) -> bool
+ Change a parameter.
+ """
+ return _param.LoadParm_set(*args, **kwargs)
+
+ __swig_destroy__ = _param.delete_LoadParm
+LoadParm.default_service = new_instancemethod(_param.LoadParm_default_service,None,LoadParm)
+LoadParm.load = new_instancemethod(_param.LoadParm_load,None,LoadParm)
+LoadParm.load_default = new_instancemethod(_param.LoadParm_load_default,None,LoadParm)
+LoadParm.__len__ = new_instancemethod(_param.LoadParm___len__,None,LoadParm)
+LoadParm.__getitem__ = new_instancemethod(_param.LoadParm___getitem__,None,LoadParm)
+LoadParm.configfile = new_instancemethod(_param.LoadParm_configfile,None,LoadParm)
+LoadParm.is_mydomain = new_instancemethod(_param.LoadParm_is_mydomain,None,LoadParm)
+LoadParm.is_myname = new_instancemethod(_param.LoadParm_is_myname,None,LoadParm)
+LoadParm.use = new_instancemethod(_param.LoadParm_use,None,LoadParm)
+LoadParm.set = new_instancemethod(_param.LoadParm_set,None,LoadParm)
+LoadParm.get = new_instancemethod(_param.LoadParm_get,None,LoadParm)
+LoadParm_swigregister = _param.LoadParm_swigregister
+LoadParm_swigregister(LoadParm)
+
+class loadparm_service(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
+ __repr__ = _swig_repr
+loadparm_service.volume_label = new_instancemethod(_param.loadparm_service_volume_label,None,loadparm_service)
+loadparm_service.printername = new_instancemethod(_param.loadparm_service_printername,None,loadparm_service)
+loadparm_service.maxprintjobs = new_instancemethod(_param.loadparm_service_maxprintjobs,None,loadparm_service)
+loadparm_service_swigregister = _param.loadparm_service_swigregister
+loadparm_service_swigregister(loadparm_service)
+
+class ParamFile(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ __repr__ = _swig_repr
+ def __init__(self, *args, **kwargs):
+ _param.ParamFile_swiginit(self,_param.new_ParamFile(*args, **kwargs))
+ def add_section(*args, **kwargs):
+ """
+ S.add_section(name) -> section
+ Add a new section.
+ """
+ return _param.ParamFile_add_section(*args, **kwargs)
+
+ def first_section(*args, **kwargs):
+ """
+ S.first_section() -> section
+ Find first section
+ """
+ return _param.ParamFile_first_section(*args, **kwargs)
+
+ def next_section(*args, **kwargs):
+ """
+ S.next_section(prev) -> section
+ Find next section
+ """
+ return _param.ParamFile_next_section(*args, **kwargs)
+
+ def read(*args, **kwargs):
+ """
+ S.read(filename) -> bool
+ Read a filename.
+ """
+ return _param.ParamFile_read(*args, **kwargs)
+
+ def __getitem__(self, name):
+ ret = self.get_section(name)
+ if ret is None:
+ raise KeyError("No such section %s" % name)
+ return ret
+
+ class SectionIterator:
+ def __init__(self, param):
+ self.param = param
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.param.first_section()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.param.next_section(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.SectionIterator(self)
+
+ __swig_destroy__ = _param.delete_ParamFile
+ParamFile.get_section = new_instancemethod(_param.ParamFile_get_section,None,ParamFile)
+ParamFile.add_section = new_instancemethod(_param.ParamFile_add_section,None,ParamFile)
+ParamFile.get = new_instancemethod(_param.ParamFile_get,None,ParamFile)
+ParamFile.get_string = new_instancemethod(_param.ParamFile_get_string,None,ParamFile)
+ParamFile.set_string = new_instancemethod(_param.ParamFile_set_string,None,ParamFile)
+ParamFile.set = new_instancemethod(_param.ParamFile_set,None,ParamFile)
+ParamFile.first_section = new_instancemethod(_param.ParamFile_first_section,None,ParamFile)
+ParamFile.next_section = new_instancemethod(_param.ParamFile_next_section,None,ParamFile)
+ParamFile.read = new_instancemethod(_param.ParamFile_read,None,ParamFile)
+ParamFile.write = new_instancemethod(_param.ParamFile_write,None,ParamFile)
+ParamFile_swigregister = _param.ParamFile_swigregister
+ParamFile_swigregister(ParamFile)
+
+class param_opt(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
+ __repr__ = _swig_repr
+ key = _swig_property(_param.param_opt_key_get)
+ value = _swig_property(_param.param_opt_value_get)
+ __swig_destroy__ = _param.delete_param_opt
+param_opt.__str__ = new_instancemethod(_param.param_opt___str__,None,param_opt)
+param_opt_swigregister = _param.param_opt_swigregister
+param_opt_swigregister(param_opt)
+
+class param_section(object):
+ thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ __repr__ = _swig_repr
+ name = _swig_property(_param.param_section_name_get)
+ def __getitem__(self, name):
+ ret = self.get(name)
+ if ret is None:
+ raise KeyError("No such option %s" % name)
+ return ret
+
+ class ParamIterator:
+ def __init__(self, section):
+ self.section = section
+ self.key = None
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.key is None:
+ self.key = self.section.first_parameter()
+ if self.key is None:
+ raise StopIteration
+ return self.key
+ else:
+ self.key = self.section.next_parameter(self.key)
+ if self.key is None:
+ raise StopIteration
+ return self.key
+
+ def __iter__(self):
+ return self.ParamIterator(self)
+
+ def __init__(self, *args, **kwargs):
+ _param.param_section_swiginit(self,_param.new_param_section(*args, **kwargs))
+ __swig_destroy__ = _param.delete_param_section
+param_section.get = new_instancemethod(_param.param_section_get,None,param_section)
+param_section.first_parameter = new_instancemethod(_param.param_section_first_parameter,None,param_section)
+param_section.next_parameter = new_instancemethod(_param.param_section_next_parameter,None,param_section)
+param_section_swigregister = _param.param_section_swigregister
+param_section_swigregister(param_section)
+
+
+cvar = _param.cvar
+
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
new file mode 100644
index 0000000000..48fd752f0e
--- /dev/null
+++ b/source4/param/param_wrap.c
@@ -0,0 +1,4849 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * This file is not intended to be easily readable and contains a number of
+ * coding conventions designed to improve portability and efficiency. Do not make
+ * changes to this file unless you know what you are doing--modify the SWIG
+ * interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+#define SWIGPYTHON
+#define SWIG_PYTHON_NO_BUILD_NONE
+/* -----------------------------------------------------------------------------
+ * This section contains generic SWIG labels for method/variable
+ * declarations/attributes, and other compiler dependent labels.
+ * ----------------------------------------------------------------------------- */
+
+/* template workaround for compilers that cannot correctly implement the C++ standard */
+#ifndef SWIGTEMPLATEDISAMBIGUATOR
+# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# elif defined(__HP_aCC)
+/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
+/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
+#endif
+
+/* inline attribute */
+#ifndef SWIGINLINE
+# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define SWIGINLINE inline
+# else
+# define SWIGINLINE
+# endif
+#endif
+
+/* attribute recognised by some compilers to avoid 'unused' warnings */
+#ifndef SWIGUNUSED
+# if defined(__GNUC__)
+# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+# elif defined(__ICC)
+# define SWIGUNUSED __attribute__ ((__unused__))
+# else
+# define SWIGUNUSED
+# endif
+#endif
+
+#ifndef SWIGUNUSEDPARM
+# ifdef __cplusplus
+# define SWIGUNUSEDPARM(p)
+# else
+# define SWIGUNUSEDPARM(p) p SWIGUNUSED
+# endif
+#endif
+
+/* internal SWIG method */
+#ifndef SWIGINTERN
+# define SWIGINTERN static SWIGUNUSED
+#endif
+
+/* internal inline SWIG method */
+#ifndef SWIGINTERNINLINE
+# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
+#endif
+
+/* exporting methods */
+#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+# ifndef GCC_HASCLASSVISIBILITY
+# define GCC_HASCLASSVISIBILITY
+# endif
+#endif
+
+#ifndef SWIGEXPORT
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# if defined(STATIC_LINKED)
+# define SWIGEXPORT
+# else
+# define SWIGEXPORT __declspec(dllexport)
+# endif
+# else
+# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
+# define SWIGEXPORT __attribute__ ((visibility("default")))
+# else
+# define SWIGEXPORT
+# endif
+# endif
+#endif
+
+/* calling conventions for Windows */
+#ifndef SWIGSTDCALL
+# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# define SWIGSTDCALL __stdcall
+# else
+# define SWIGSTDCALL
+# endif
+#endif
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
+#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
+# define _SCL_SECURE_NO_DEPRECATE
+#endif
+
+
+
+/* Python.h has to appear first */
+#include <Python.h>
+
+/* -----------------------------------------------------------------------------
+ * swigrun.swg
+ *
+ * This file contains generic CAPI SWIG runtime support for pointer
+ * type checking.
+ * ----------------------------------------------------------------------------- */
+
+/* This should only be incremented when either the layout of swig_type_info changes,
+ or for whatever reason, the runtime changes incompatibly */
+#define SWIG_RUNTIME_VERSION "4"
+
+/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
+#ifdef SWIG_TYPE_TABLE
+# define SWIG_QUOTE_STRING(x) #x
+# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
+# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
+#else
+# define SWIG_TYPE_TABLE_NAME
+#endif
+
+/*
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
+ creating a static or dynamic library from the swig runtime code.
+ In 99.9% of the cases, swig just needs to declare them as 'static'.
+
+ But only do this if is strictly necessary, ie, if you have problems
+ with your compiler or so.
+*/
+
+#ifndef SWIGRUNTIME
+# define SWIGRUNTIME SWIGINTERN
+#endif
+
+#ifndef SWIGRUNTIMEINLINE
+# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
+#endif
+
+/* Generic buffer size */
+#ifndef SWIG_BUFFER_SIZE
+# define SWIG_BUFFER_SIZE 1024
+#endif
+
+/* Flags for pointer conversions */
+#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_OWN 0x1
+
+
+/*
+ Flags/methods for returning states.
+
+ The swig conversion methods, as ConvertPtr, return and integer
+ that tells if the conversion was successful or not. And if not,
+ an error code can be returned (see swigerrors.swg for the codes).
+
+ Use the following macros/flags to set or process the returning
+ states.
+
+ In old swig versions, you usually write code as:
+
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
+ // success code
+ } else {
+ //fail code
+ }
+
+ Now you can be more explicit as:
+
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ } else {
+ // fail code
+ }
+
+ that seems to be the same, but now you can also do
+
+ Type *ptr;
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
+ if (SWIG_IsOK(res)) {
+ // success code
+ if (SWIG_IsNewObj(res) {
+ ...
+ delete *ptr;
+ } else {
+ ...
+ }
+ } else {
+ // fail code
+ }
+
+ I.e., now SWIG_ConvertPtr can return new objects and you can
+ identify the case and take care of the deallocation. Of course that
+ requires also to SWIG_ConvertPtr to return new result values, as
+
+ int SWIG_ConvertPtr(obj, ptr,...) {
+ if (<obj is ok>) {
+ if (<need new object>) {
+ *ptr = <ptr to new allocated object>;
+ return SWIG_NEWOBJ;
+ } else {
+ *ptr = <ptr to old object>;
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_BADOBJ;
+ }
+ }
+
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
+ swig errors code.
+
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
+ allows to return the 'cast rank', for example, if you have this
+
+ int food(double)
+ int fooi(int);
+
+ and you call
+
+ food(1) // cast rank '1' (1 -> 1.0)
+ fooi(1) // cast rank '0'
+
+ just use the SWIG_AddCast()/SWIG_CheckState()
+
+
+ */
+#define SWIG_OK (0)
+#define SWIG_ERROR (-1)
+#define SWIG_IsOK(r) (r >= 0)
+#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+
+/* The CastRankLimit says how many bits are used for the cast rank */
+#define SWIG_CASTRANKLIMIT (1 << 8)
+/* The NewMask denotes the object was created (using new/malloc) */
+#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
+/* The TmpMask is for in/out typemaps that use temporal objects */
+#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
+/* Simple returning values */
+#define SWIG_BADOBJ (SWIG_ERROR)
+#define SWIG_OLDOBJ (SWIG_OK)
+#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
+#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
+/* Check, add and del mask methods */
+#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
+#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
+#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
+#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
+#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
+#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
+
+
+/* Cast-Rank Mode */
+#if defined(SWIG_CASTRANK_MODE)
+# ifndef SWIG_TypeRank
+# define SWIG_TypeRank unsigned long
+# endif
+# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
+# define SWIG_MAXCASTRANK (2)
+# endif
+# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
+# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
+SWIGINTERNINLINE int SWIG_AddCast(int r) {
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
+}
+SWIGINTERNINLINE int SWIG_CheckState(int r) {
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+}
+#else /* no cast-rank mode */
+# define SWIG_AddCast
+# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
+#endif
+
+
+
+
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void *(*swig_converter_func)(void *, int *);
+typedef struct swig_type_info *(*swig_dycast_func)(void **);
+
+/* Structure to store information on one type */
+typedef struct swig_type_info {
+ const char *name; /* mangled name of this type */
+ const char *str; /* human readable name of this type */
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
+ void *clientdata; /* language specific type data */
+ int owndata; /* flag if the structure owns the clientdata */
+} swig_type_info;
+
+/* Structure to store a type and conversion function used for casting */
+typedef struct swig_cast_info {
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
+ swig_converter_func converter; /* function to cast the void pointers */
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
+ struct swig_cast_info *prev; /* pointer to the previous cast */
+} swig_cast_info;
+
+/* Structure used to store module information
+ * Each module generates one structure like this, and the runtime collects
+ * all of these structures and stores them in a circularly linked list.*/
+typedef struct swig_module_info {
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
+ size_t size; /* Number of types in this module */
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
+ swig_type_info **type_initial; /* Array of initially generated type structures */
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
+ void *clientdata; /* Language specific module data */
+} swig_module_info;
+
+/*
+ Compare two type names skipping the space characters, therefore
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
+
+ Return 0 when the two name types are equivalent, as in
+ strncmp, but skipping ' '.
+*/
+SWIGRUNTIME int
+SWIG_TypeNameComp(const char *f1, const char *l1,
+ const char *f2, const char *l2) {
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
+ }
+ return (int)((l1 - f1) - (l2 - f2));
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if not equal, 1 if equal
+*/
+SWIGRUNTIME int
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+/*
+ Check type equivalence in a name list like <name1>|<name2>|...
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+*/
+SWIGRUNTIME int
+SWIG_TypeCompare(const char *nb, const char *tb) {
+ int equiv = 0;
+ const char* te = tb + strlen(tb);
+ const char* ne = nb;
+ while (!equiv && *ne) {
+ for (nb = ne; *ne; ++ne) {
+ if (*ne == '|') break;
+ }
+ equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+ if (*ne) ++ne;
+ }
+ return equiv;
+}
+
+
+/* think of this as a c++ template<> or a scheme macro */
+#define SWIG_TypeCheck_Template(comparison, ty) \
+ if (ty) { \
+ swig_cast_info *iter = ty->cast; \
+ while (iter) { \
+ if (comparison) { \
+ if (iter == ty->cast) return iter; \
+ /* Move iter to the top of the linked list */ \
+ iter->prev->next = iter->next; \
+ if (iter->next) \
+ iter->next->prev = iter->prev; \
+ iter->next = ty->cast; \
+ iter->prev = 0; \
+ if (ty->cast) ty->cast->prev = iter; \
+ ty->cast = iter; \
+ return iter; \
+ } \
+ iter = iter->next; \
+ } \
+ } \
+ return 0
+
+/*
+ Check the typename
+*/
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheck(const char *c, swig_type_info *ty) {
+ SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+}
+
+/* Same as previous function, except strcmp is replaced with a pointer comparison */
+SWIGRUNTIME swig_cast_info *
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
+ SWIG_TypeCheck_Template(iter->type == from, into);
+}
+
+/*
+ Cast a pointer up an inheritance hierarchy
+*/
+SWIGRUNTIMEINLINE void *
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+}
+
+/*
+ Dynamic pointer casting. Down an inheritance hierarchy
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
+ swig_type_info *lastty = ty;
+ if (!ty || !ty->dcast) return ty;
+ while (ty && (ty->dcast)) {
+ ty = (*ty->dcast)(ptr);
+ if (ty) lastty = ty;
+ }
+ return lastty;
+}
+
+/*
+ Return the name associated with this type
+*/
+SWIGRUNTIMEINLINE const char *
+SWIG_TypeName(const swig_type_info *ty) {
+ return ty->name;
+}
+
+/*
+ Return the pretty name associated with this type,
+ that is an unmangled type name in a form presentable to the user.
+*/
+SWIGRUNTIME const char *
+SWIG_TypePrettyName(const swig_type_info *type) {
+ /* The "str" field contains the equivalent pretty names of the
+ type, separated by vertical-bar characters. We choose
+ to print the last name, as it is often (?) the most
+ specific. */
+ if (!type) return NULL;
+ if (type->str != NULL) {
+ const char *last_name = type->str;
+ const char *s;
+ for (s = type->str; *s; s++)
+ if (*s == '|') last_name = s+1;
+ return last_name;
+ }
+ else
+ return type->name;
+}
+
+/*
+ Set the clientdata field for a type
+*/
+SWIGRUNTIME void
+SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
+ swig_cast_info *cast = ti->cast;
+ /* if (ti->clientdata == clientdata) return; */
+ ti->clientdata = clientdata;
+
+ while (cast) {
+ if (!cast->converter) {
+ swig_type_info *tc = cast->type;
+ if (!tc->clientdata) {
+ SWIG_TypeClientData(tc, clientdata);
+ }
+ }
+ cast = cast->next;
+ }
+}
+SWIGRUNTIME void
+SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
+ SWIG_TypeClientData(ti, clientdata);
+ ti->owndata = 1;
+}
+
+/*
+ Search for a swig_type_info structure only by mangled name
+ Search is a O(log #types)
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_MangledTypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ swig_module_info *iter = start;
+ do {
+ if (iter->size) {
+ register size_t l = 0;
+ register size_t r = iter->size - 1;
+ do {
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
+ register size_t i = (l + r) >> 1;
+ const char *iname = iter->types[i]->name;
+ if (iname) {
+ register int compare = strcmp(name, iname);
+ if (compare == 0) {
+ return iter->types[i];
+ } else if (compare < 0) {
+ if (i) {
+ r = i - 1;
+ } else {
+ break;
+ }
+ } else if (compare > 0) {
+ l = i + 1;
+ }
+ } else {
+ break; /* should never happen */
+ }
+ } while (l <= r);
+ }
+ iter = iter->next;
+ } while (iter != end);
+ return 0;
+}
+
+/*
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
+ It first searches the mangled names of the types, which is a O(log #types)
+ If a type is not found it then searches the human readable names, which is O(#types).
+
+ We start searching at module start, and finish searching when start == end.
+ Note: if start == end at the beginning of the function, we go all the way around
+ the circular list.
+*/
+SWIGRUNTIME swig_type_info *
+SWIG_TypeQueryModule(swig_module_info *start,
+ swig_module_info *end,
+ const char *name) {
+ /* STEP 1: Search the name field using binary search */
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
+ if (ret) {
+ return ret;
+ } else {
+ /* STEP 2: If the type hasn't been found, do a complete search
+ of the str field (the human readable name) */
+ swig_module_info *iter = start;
+ do {
+ register size_t i = 0;
+ for (; i < iter->size; ++i) {
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
+ return iter->types[i];
+ }
+ iter = iter->next;
+ } while (iter != end);
+ }
+
+ /* neither found a match */
+ return 0;
+}
+
+/*
+ Pack binary data into a string
+*/
+SWIGRUNTIME char *
+SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ register const unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register unsigned char uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+
+/*
+ Unpack binary data from a string
+*/
+SWIGRUNTIME const char *
+SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register char d = *(c++);
+ register unsigned char uu;
+ if ((d >= '0') && (d <= '9'))
+ uu = ((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
+ *u = uu;
+ }
+ return c;
+}
+
+/*
+ Pack 'void *' into a string buffer.
+*/
+SWIGRUNTIME char *
+SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
+ char *r = buff;
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
+ strcpy(r,name);
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ *ptr = (void *) 0;
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
+}
+
+SWIGRUNTIME char *
+SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
+ char *r = buff;
+ size_t lname = (name ? strlen(name) : 0);
+ if ((2*sz + 2 + lname) > bsz) return 0;
+ *(r++) = '_';
+ r = SWIG_PackData(r,ptr,sz);
+ if (lname) {
+ strncpy(r,name,lname+1);
+ } else {
+ *r = 0;
+ }
+ return buff;
+}
+
+SWIGRUNTIME const char *
+SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
+ if (*c != '_') {
+ if (strcmp(c,"NULL") == 0) {
+ memset(ptr,0,sz);
+ return name;
+ } else {
+ return 0;
+ }
+ }
+ return SWIG_UnpackData(++c,ptr,sz);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* Errors in SWIG */
+#define SWIG_UnknownError -1
+#define SWIG_IOError -2
+#define SWIG_RuntimeError -3
+#define SWIG_IndexError -4
+#define SWIG_TypeError -5
+#define SWIG_DivisionByZero -6
+#define SWIG_OverflowError -7
+#define SWIG_SyntaxError -8
+#define SWIG_ValueError -9
+#define SWIG_SystemError -10
+#define SWIG_AttributeError -11
+#define SWIG_MemoryError -12
+#define SWIG_NullReferenceError -13
+
+
+
+
+/* Add PyOS_snprintf for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
+# define PyOS_snprintf _snprintf
+# else
+# define PyOS_snprintf snprintf
+# endif
+#endif
+
+/* A crude PyString_FromFormat implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+
+#ifndef SWIG_PYBUFFER_SIZE
+# define SWIG_PYBUFFER_SIZE 1024
+#endif
+
+static PyObject *
+PyString_FromFormat(const char *fmt, ...) {
+ va_list ap;
+ char buf[SWIG_PYBUFFER_SIZE * 2];
+ int res;
+ va_start(ap, fmt);
+ res = vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
+}
+#endif
+
+/* Add PyObject_Del for old Pythons */
+#if PY_VERSION_HEX < 0x01060000
+# define PyObject_Del(op) PyMem_DEL((op))
+#endif
+#ifndef PyObject_DEL
+# define PyObject_DEL PyObject_Del
+#endif
+
+/* A crude PyExc_StopIteration exception for old Pythons */
+#if PY_VERSION_HEX < 0x02020000
+# ifndef PyExc_StopIteration
+# define PyExc_StopIteration PyExc_RuntimeError
+# endif
+# ifndef PyObject_GenericGetAttr
+# define PyObject_GenericGetAttr 0
+# endif
+#endif
+/* Py_NotImplemented is defined in 2.1 and up. */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef Py_NotImplemented
+# define Py_NotImplemented PyExc_RuntimeError
+# endif
+#endif
+
+
+/* A crude PyString_AsStringAndSize implementation for old Pythons */
+#if PY_VERSION_HEX < 0x02010000
+# ifndef PyString_AsStringAndSize
+# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
+# endif
+#endif
+
+/* PySequence_Size for old Pythons */
+#if PY_VERSION_HEX < 0x02000000
+# ifndef PySequence_Size
+# define PySequence_Size PySequence_Length
+# endif
+#endif
+
+
+/* PyBool_FromLong for old Pythons */
+#if PY_VERSION_HEX < 0x02030000
+static
+PyObject *PyBool_FromLong(long ok)
+{
+ PyObject *result = ok ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
+}
+#endif
+
+/* Py_ssize_t for old Pythons */
+/* This code is as recommended by: */
+/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+# define PY_SSIZE_T_MAX INT_MAX
+# define PY_SSIZE_T_MIN INT_MIN
+#endif
+
+/* -----------------------------------------------------------------------------
+ * error manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIME PyObject*
+SWIG_Python_ErrorType(int code) {
+ PyObject* type = 0;
+ switch(code) {
+ case SWIG_MemoryError:
+ type = PyExc_MemoryError;
+ break;
+ case SWIG_IOError:
+ type = PyExc_IOError;
+ break;
+ case SWIG_RuntimeError:
+ type = PyExc_RuntimeError;
+ break;
+ case SWIG_IndexError:
+ type = PyExc_IndexError;
+ break;
+ case SWIG_TypeError:
+ type = PyExc_TypeError;
+ break;
+ case SWIG_DivisionByZero:
+ type = PyExc_ZeroDivisionError;
+ break;
+ case SWIG_OverflowError:
+ type = PyExc_OverflowError;
+ break;
+ case SWIG_SyntaxError:
+ type = PyExc_SyntaxError;
+ break;
+ case SWIG_ValueError:
+ type = PyExc_ValueError;
+ break;
+ case SWIG_SystemError:
+ type = PyExc_SystemError;
+ break;
+ case SWIG_AttributeError:
+ type = PyExc_AttributeError;
+ break;
+ default:
+ type = PyExc_RuntimeError;
+ }
+ return type;
+}
+
+
+SWIGRUNTIME void
+SWIG_Python_AddErrorMsg(const char* mesg)
+{
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+
+ if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ PyObject *old_str = PyObject_Str(value);
+ PyErr_Clear();
+ Py_XINCREF(type);
+ PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+ Py_DECREF(old_str);
+ Py_DECREF(value);
+ } else {
+ PyErr_SetString(PyExc_RuntimeError, mesg);
+ }
+}
+
+
+
+#if defined(SWIG_PYTHON_NO_THREADS)
+# if defined(SWIG_PYTHON_THREADS)
+# undef SWIG_PYTHON_THREADS
+# endif
+#endif
+#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
+# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
+# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
+# define SWIG_PYTHON_USE_GIL
+# endif
+# endif
+# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
+# ifndef SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
+# endif
+# ifdef __cplusplus /* C++ code */
+ class SWIG_Python_Thread_Block {
+ bool status;
+ PyGILState_STATE state;
+ public:
+ void end() { if (status) { PyGILState_Release(state); status = false;} }
+ SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
+ ~SWIG_Python_Thread_Block() { end(); }
+ };
+ class SWIG_Python_Thread_Allow {
+ bool status;
+ PyThreadState *save;
+ public:
+ void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
+ SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
+ ~SWIG_Python_Thread_Allow() { end(); }
+ };
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
+# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
+# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
+# else /* C code */
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
+# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
+# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
+# endif
+# else /* Old thread way, not implemented, user must provide it */
+# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# endif
+# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# endif
+# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
+# define SWIG_PYTHON_THREAD_END_ALLOW
+# endif
+# endif
+#else /* No thread support */
+# define SWIG_PYTHON_INITIALIZE_THREADS
+# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
+# define SWIG_PYTHON_THREAD_END_BLOCK
+# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
+# define SWIG_PYTHON_THREAD_END_ALLOW
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Python API portion that goes into the runtime
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Constant declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Constant Types */
+#define SWIG_PY_POINTER 4
+#define SWIG_PY_BINARY 5
+
+/* Constant information structure */
+typedef struct swig_const_info {
+ int type;
+ char *name;
+ long lvalue;
+ double dvalue;
+ void *pvalue;
+ swig_type_info **ptype;
+} swig_const_info;
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
+
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * pyrun.swg
+ *
+ * This file contains the runtime support for Python modules
+ * and includes code for managing global variables and pointer
+ * type checking.
+ *
+ * ----------------------------------------------------------------------------- */
+
+/* Common SWIG API */
+
+/* for raw pointers */
+#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
+#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
+#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
+#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
+#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
+#define swig_owntype int
+
+/* for raw packed data */
+#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+/* for class or struct pointers */
+#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
+#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
+
+/* for C or C++ function pointers */
+#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
+#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
+
+/* for C++ member pointers, ie, member methods */
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
+#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
+
+
+/* Runtime API */
+
+#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
+#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
+
+#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
+#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
+#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
+#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
+#define SWIG_fail goto fail
+
+
+/* Runtime API implementation */
+
+/* Error manipulation */
+
+SWIGINTERN void
+SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetObject(errtype, obj);
+ Py_DECREF(obj);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+SWIGINTERN void
+SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyErr_SetString(errtype, (char *) msg);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+}
+
+#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
+
+/* Set a constant value */
+
+SWIGINTERN void
+SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
+ PyDict_SetItemString(d, (char*) name, obj);
+ Py_DECREF(obj);
+}
+
+/* Append a value to the result obj */
+
+SWIGINTERN PyObject*
+SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
+#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyList_Check(result)) {
+ PyObject *o2 = result;
+ result = PyList_New(1);
+ PyList_SetItem(result, 0, o2);
+ }
+ PyList_Append(result,obj);
+ Py_DECREF(obj);
+ }
+ return result;
+#else
+ PyObject* o2;
+ PyObject* o3;
+ if (!result) {
+ result = obj;
+ } else if (result == Py_None) {
+ Py_DECREF(result);
+ result = obj;
+ } else {
+ if (!PyTuple_Check(result)) {
+ o2 = result;
+ result = PyTuple_New(1);
+ PyTuple_SET_ITEM(result, 0, o2);
+ }
+ o3 = PyTuple_New(1);
+ PyTuple_SET_ITEM(o3, 0, obj);
+ o2 = result;
+ result = PySequence_Concat(o2, o3);
+ Py_DECREF(o2);
+ Py_DECREF(o3);
+ }
+ return result;
+#endif
+}
+
+/* Unpack the argument tuple */
+
+SWIGINTERN int
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+{
+ if (!args) {
+ if (!min && !max) {
+ return 1;
+ } else {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
+ name, (min == max ? "" : "at least "), (int)min);
+ return 0;
+ }
+ }
+ if (!PyTuple_Check(args)) {
+ PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
+ return 0;
+ } else {
+ register Py_ssize_t l = PyTuple_GET_SIZE(args);
+ if (l < min) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at least "), (int)min, (int)l);
+ return 0;
+ } else if (l > max) {
+ PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
+ name, (min == max ? "" : "at most "), (int)max, (int)l);
+ return 0;
+ } else {
+ register int i;
+ for (i = 0; i < l; ++i) {
+ objs[i] = PyTuple_GET_ITEM(args, i);
+ }
+ for (; l < max; ++l) {
+ objs[l] = 0;
+ }
+ return i + 1;
+ }
+ }
+}
+
+/* A functor is a function object with one single object argument */
+#if PY_VERSION_HEX >= 0x02020000
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
+#else
+#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
+#endif
+
+/*
+ Helper for static pointer initialization for both C and C++ code, for example
+ static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
+*/
+#ifdef __cplusplus
+#define SWIG_STATIC_POINTER(var) var
+#else
+#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
+#endif
+
+/* -----------------------------------------------------------------------------
+ * Pointer declarations
+ * ----------------------------------------------------------------------------- */
+
+/* Flags for new pointer objects */
+#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
+#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
+
+#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* cc-mode */
+#endif
+#endif
+
+/* How to access Py_None */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+# ifndef SWIG_PYTHON_NO_BUILD_NONE
+# ifndef SWIG_PYTHON_BUILD_NONE
+# define SWIG_PYTHON_BUILD_NONE
+# endif
+# endif
+#endif
+
+#ifdef SWIG_PYTHON_BUILD_NONE
+# ifdef Py_None
+# undef Py_None
+# define Py_None SWIG_Py_None()
+# endif
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_Py_None(void)
+{
+ PyObject *none = Py_BuildValue((char*)"");
+ Py_DECREF(none);
+ return none;
+}
+SWIGRUNTIME PyObject *
+SWIG_Py_None(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
+ return none;
+}
+#endif
+
+/* The python void return value */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Py_Void(void)
+{
+ PyObject *none = Py_None;
+ Py_INCREF(none);
+ return none;
+}
+
+/* PySwigClientData */
+
+typedef struct {
+ PyObject *klass;
+ PyObject *newraw;
+ PyObject *newargs;
+ PyObject *destroy;
+ int delargs;
+ int implicitconv;
+} PySwigClientData;
+
+SWIGRUNTIMEINLINE int
+SWIG_Python_CheckImplicit(swig_type_info *ty)
+{
+ PySwigClientData *data = (PySwigClientData *)ty->clientdata;
+ return data ? data->implicitconv : 0;
+}
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_ExceptionType(swig_type_info *desc) {
+ PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
+ PyObject *klass = data ? data->klass : 0;
+ return (klass ? klass : PyExc_RuntimeError);
+}
+
+
+SWIGRUNTIME PySwigClientData *
+PySwigClientData_New(PyObject* obj)
+{
+ if (!obj) {
+ return 0;
+ } else {
+ PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
+ /* the klass element */
+ data->klass = obj;
+ Py_INCREF(data->klass);
+ /* the newraw method and newargs arguments used to create a new raw instance */
+ if (PyClass_Check(obj)) {
+ data->newraw = 0;
+ data->newargs = obj;
+ Py_INCREF(obj);
+ } else {
+#if (PY_VERSION_HEX < 0x02020000)
+ data->newraw = 0;
+#else
+ data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
+#endif
+ if (data->newraw) {
+ Py_INCREF(data->newraw);
+ data->newargs = PyTuple_New(1);
+ PyTuple_SetItem(data->newargs, 0, obj);
+ } else {
+ data->newargs = obj;
+ }
+ Py_INCREF(data->newargs);
+ }
+ /* the destroy method, aka as the C++ delete method */
+ data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ data->destroy = 0;
+ }
+ if (data->destroy) {
+ int flags;
+ Py_INCREF(data->destroy);
+ flags = PyCFunction_GET_FLAGS(data->destroy);
+#ifdef METH_O
+ data->delargs = !(flags & (METH_O));
+#else
+ data->delargs = 0;
+#endif
+ } else {
+ data->delargs = 0;
+ }
+ data->implicitconv = 0;
+ return data;
+ }
+}
+
+SWIGRUNTIME void
+PySwigClientData_Del(PySwigClientData* data)
+{
+ Py_XDECREF(data->newraw);
+ Py_XDECREF(data->newargs);
+ Py_XDECREF(data->destroy);
+}
+
+/* =============== PySwigObject =====================*/
+
+typedef struct {
+ PyObject_HEAD
+ void *ptr;
+ swig_type_info *ty;
+ int own;
+ PyObject *next;
+} PySwigObject;
+
+SWIGRUNTIME PyObject *
+PySwigObject_long(PySwigObject *v)
+{
+ return PyLong_FromVoidPtr(v->ptr);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_format(const char* fmt, PySwigObject *v)
+{
+ PyObject *res = NULL;
+ PyObject *args = PyTuple_New(1);
+ if (args) {
+ if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
+ PyObject *ofmt = PyString_FromString(fmt);
+ if (ofmt) {
+ res = PyString_Format(ofmt,args);
+ Py_DECREF(ofmt);
+ }
+ Py_DECREF(args);
+ }
+ }
+ return res;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_oct(PySwigObject *v)
+{
+ return PySwigObject_format("%o",v);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_hex(PySwigObject *v)
+{
+ return PySwigObject_format("%x",v);
+}
+
+SWIGRUNTIME PyObject *
+#ifdef METH_NOARGS
+PySwigObject_repr(PySwigObject *v)
+#else
+PySwigObject_repr(PySwigObject *v, PyObject *args)
+#endif
+{
+ const char *name = SWIG_TypePrettyName(v->ty);
+ PyObject *hex = PySwigObject_hex(v);
+ PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
+ Py_DECREF(hex);
+ if (v->next) {
+#ifdef METH_NOARGS
+ PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
+#else
+ PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
+#endif
+ PyString_ConcatAndDel(&repr,nrep);
+ }
+ return repr;
+}
+
+SWIGRUNTIME int
+PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+#ifdef METH_NOARGS
+ PyObject *repr = PySwigObject_repr(v);
+#else
+ PyObject *repr = PySwigObject_repr(v, NULL);
+#endif
+ if (repr) {
+ fputs(PyString_AsString(repr), fp);
+ Py_DECREF(repr);
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_str(PySwigObject *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+ PyString_FromString(result) : 0;
+}
+
+SWIGRUNTIME int
+PySwigObject_compare(PySwigObject *v, PySwigObject *w)
+{
+ void *i = v->ptr;
+ void *j = w->ptr;
+ return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigObject_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigObject_Check(PyObject *op) {
+ return ((op)->ob_type == PySwigObject_type())
+ || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own);
+
+SWIGRUNTIME void
+PySwigObject_dealloc(PyObject *v)
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+ PyObject *next = sobj->next;
+ if (sobj->own == SWIG_POINTER_OWN) {
+ swig_type_info *ty = sobj->ty;
+ PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ PyObject *destroy = data ? data->destroy : 0;
+ if (destroy) {
+ /* destroy is always a VARARGS method */
+ PyObject *res;
+ if (data->delargs) {
+ /* we need to create a temporal object to carry the destroy operation */
+ PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
+ res = SWIG_Python_CallFunctor(destroy, tmp);
+ Py_DECREF(tmp);
+ } else {
+ PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
+ PyObject *mself = PyCFunction_GET_SELF(destroy);
+ res = ((*meth)(mself, v));
+ }
+ Py_XDECREF(res);
+ }
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
+ }
+#endif
+ }
+ Py_XDECREF(next);
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyObject*
+PySwigObject_append(PyObject* v, PyObject* next)
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+#ifndef METH_O
+ PyObject *tmp = 0;
+ if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
+ next = tmp;
+#endif
+ if (!PySwigObject_Check(next)) {
+ return NULL;
+ }
+ sobj->next = next;
+ Py_INCREF(next);
+ return SWIG_Py_Void();
+}
+
+SWIGRUNTIME PyObject*
+#ifdef METH_NOARGS
+PySwigObject_next(PyObject* v)
+#else
+PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *) v;
+ if (sobj->next) {
+ Py_INCREF(sobj->next);
+ return sobj->next;
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_disown(PyObject *v)
+#else
+PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *)v;
+ sobj->own = 0;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+#ifdef METH_NOARGS
+PySwigObject_acquire(PyObject *v)
+#else
+PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+#endif
+{
+ PySwigObject *sobj = (PySwigObject *)v;
+ sobj->own = SWIG_POINTER_OWN;
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject*
+PySwigObject_own(PyObject *v, PyObject *args)
+{
+ PyObject *val = 0;
+#if (PY_VERSION_HEX < 0x02020000)
+ if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
+#else
+ if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
+#endif
+ {
+ return NULL;
+ }
+ else
+ {
+ PySwigObject *sobj = (PySwigObject *)v;
+ PyObject *obj = PyBool_FromLong(sobj->own);
+ if (val) {
+#ifdef METH_NOARGS
+ if (PyObject_IsTrue(val)) {
+ PySwigObject_acquire(v);
+ } else {
+ PySwigObject_disown(v);
+ }
+#else
+ if (PyObject_IsTrue(val)) {
+ PySwigObject_acquire(v,args);
+ } else {
+ PySwigObject_disown(v,args);
+ }
+#endif
+ }
+ return obj;
+ }
+}
+
+#ifdef METH_O
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#else
+static PyMethodDef
+swigobject_methods[] = {
+ {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {0, 0, 0, 0}
+};
+#endif
+
+#if PY_VERSION_HEX < 0x02020000
+SWIGINTERN PyObject *
+PySwigObject_getattr(PySwigObject *sobj,char *name)
+{
+ return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
+}
+#endif
+
+SWIGRUNTIME PyTypeObject*
+_PySwigObject_type(void) {
+ static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
+
+ static PyNumberMethods PySwigObject_as_number = {
+ (binaryfunc)0, /*nb_add*/
+ (binaryfunc)0, /*nb_subtract*/
+ (binaryfunc)0, /*nb_multiply*/
+ (binaryfunc)0, /*nb_divide*/
+ (binaryfunc)0, /*nb_remainder*/
+ (binaryfunc)0, /*nb_divmod*/
+ (ternaryfunc)0,/*nb_power*/
+ (unaryfunc)0, /*nb_negative*/
+ (unaryfunc)0, /*nb_positive*/
+ (unaryfunc)0, /*nb_absolute*/
+ (inquiry)0, /*nb_nonzero*/
+ 0, /*nb_invert*/
+ 0, /*nb_lshift*/
+ 0, /*nb_rshift*/
+ 0, /*nb_and*/
+ 0, /*nb_xor*/
+ 0, /*nb_or*/
+ (coercion)0, /*nb_coerce*/
+ (unaryfunc)PySwigObject_long, /*nb_int*/
+ (unaryfunc)PySwigObject_long, /*nb_long*/
+ (unaryfunc)0, /*nb_float*/
+ (unaryfunc)PySwigObject_oct, /*nb_oct*/
+ (unaryfunc)PySwigObject_hex, /*nb_hex*/
+#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
+#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+ 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
+#endif
+ };
+
+ static PyTypeObject pyswigobject_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ (char *)"PySwigObject", /* tp_name */
+ sizeof(PySwigObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)PySwigObject_dealloc, /* tp_dealloc */
+ (printfunc)PySwigObject_print, /* tp_print */
+#if PY_VERSION_HEX < 0x02020000
+ (getattrfunc)PySwigObject_getattr, /* tp_getattr */
+#else
+ (getattrfunc)0, /* tp_getattr */
+#endif
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)PySwigObject_compare, /* tp_compare */
+ (reprfunc)PySwigObject_repr, /* tp_repr */
+ &PySwigObject_as_number, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)PySwigObject_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigobject_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ swigobject_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ pyswigobject_type = tmp;
+ pyswigobject_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &pyswigobject_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigObject_New(void *ptr, swig_type_info *ty, int own)
+{
+ PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
+ if (sobj) {
+ sobj->ptr = ptr;
+ sobj->ty = ty;
+ sobj->own = own;
+ sobj->next = 0;
+ }
+ return (PyObject *)sobj;
+}
+
+/* -----------------------------------------------------------------------------
+ * Implements a simple Swig Packed type, and use it instead of string
+ * ----------------------------------------------------------------------------- */
+
+typedef struct {
+ PyObject_HEAD
+ void *pack;
+ swig_type_info *ty;
+ size_t size;
+} PySwigPacked;
+
+SWIGRUNTIME int
+PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+{
+ char result[SWIG_BUFFER_SIZE];
+ fputs("<Swig Packed ", fp);
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ fputs("at ", fp);
+ fputs(result, fp);
+ }
+ fputs(v->ty->name,fp);
+ fputs(">", fp);
+ return 0;
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_repr(PySwigPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
+ return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+ } else {
+ return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
+ }
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_str(PySwigPacked *v)
+{
+ char result[SWIG_BUFFER_SIZE];
+ if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
+ return PyString_FromFormat("%s%s", result, v->ty->name);
+ } else {
+ return PyString_FromString(v->ty->name);
+ }
+}
+
+SWIGRUNTIME int
+PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
+{
+ size_t i = v->size;
+ size_t j = w->size;
+ int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
+ return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
+}
+
+SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
+
+SWIGRUNTIME PyTypeObject*
+PySwigPacked_type(void) {
+ static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
+ return type;
+}
+
+SWIGRUNTIMEINLINE int
+PySwigPacked_Check(PyObject *op) {
+ return ((op)->ob_type == _PySwigPacked_type())
+ || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
+}
+
+SWIGRUNTIME void
+PySwigPacked_dealloc(PyObject *v)
+{
+ if (PySwigPacked_Check(v)) {
+ PySwigPacked *sobj = (PySwigPacked *) v;
+ free(sobj->pack);
+ }
+ PyObject_DEL(v);
+}
+
+SWIGRUNTIME PyTypeObject*
+_PySwigPacked_type(void) {
+ static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
+ static PyTypeObject pyswigpacked_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ (char *)"PySwigPacked", /* tp_name */
+ sizeof(PySwigPacked), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ (destructor)PySwigPacked_dealloc, /* tp_dealloc */
+ (printfunc)PySwigPacked_print, /* tp_print */
+ (getattrfunc)0, /* tp_getattr */
+ (setattrfunc)0, /* tp_setattr */
+ (cmpfunc)PySwigPacked_compare, /* tp_compare */
+ (reprfunc)PySwigPacked_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)PySwigPacked_str, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ swigpacked_doc, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+ 0, /* tp_bases */
+ 0, /* tp_mro */
+ 0, /* tp_cache */
+ 0, /* tp_subclasses */
+ 0, /* tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ pyswigpacked_type = tmp;
+ pyswigpacked_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &pyswigpacked_type;
+}
+
+SWIGRUNTIME PyObject *
+PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
+{
+ PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
+ if (sobj) {
+ void *pack = malloc(size);
+ if (pack) {
+ memcpy(pack, ptr, size);
+ sobj->pack = pack;
+ sobj->ty = ty;
+ sobj->size = size;
+ } else {
+ PyObject_DEL((PyObject *) sobj);
+ sobj = 0;
+ }
+ }
+ return (PyObject *) sobj;
+}
+
+SWIGRUNTIME swig_type_info *
+PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+{
+ if (PySwigPacked_Check(obj)) {
+ PySwigPacked *sobj = (PySwigPacked *)obj;
+ if (sobj->size != size) return 0;
+ memcpy(ptr, sobj->pack, size);
+ return sobj->ty;
+ } else {
+ return 0;
+ }
+}
+
+/* -----------------------------------------------------------------------------
+ * pointers/data manipulation
+ * ----------------------------------------------------------------------------- */
+
+SWIGRUNTIMEINLINE PyObject *
+_SWIG_This(void)
+{
+ return PyString_FromString("this");
+}
+
+SWIGRUNTIME PyObject *
+SWIG_This(void)
+{
+ static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+ return swig_this;
+}
+
+/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
+
+SWIGRUNTIME PySwigObject *
+SWIG_Python_GetSwigThis(PyObject *pyobj)
+{
+ if (PySwigObject_Check(pyobj)) {
+ return (PySwigObject *) pyobj;
+ } else {
+ PyObject *obj = 0;
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+ if (PyInstance_Check(pyobj)) {
+ obj = _PyInstance_Lookup(pyobj, SWIG_This());
+ } else {
+ PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+ } else {
+#ifdef PyWeakref_CheckProxy
+ if (PyWeakref_CheckProxy(pyobj)) {
+ PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+ return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+ }
+#endif
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+ }
+ }
+#else
+ obj = PyObject_GetAttr(pyobj,SWIG_This());
+ if (obj) {
+ Py_DECREF(obj);
+ } else {
+ if (PyErr_Occurred()) PyErr_Clear();
+ return 0;
+ }
+#endif
+ if (obj && !PySwigObject_Check(obj)) {
+ /* a PyObject is called 'this', try to get the 'real this'
+ PySwigObject from it */
+ return SWIG_Python_GetSwigThis(obj);
+ }
+ return (PySwigObject *)obj;
+ }
+}
+
+/* Acquire a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_AcquirePtr(PyObject *obj, int own) {
+ if (own == SWIG_POINTER_OWN) {
+ PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (sobj) {
+ int oldown = sobj->own;
+ sobj->own = own;
+ return oldown;
+ }
+ }
+ return 0;
+}
+
+/* Convert a pointer value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
+ if (!obj) return SWIG_ERROR;
+ if (obj == Py_None) {
+ if (ptr) *ptr = 0;
+ return SWIG_OK;
+ } else {
+ PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
+ while (sobj) {
+ void *vptr = sobj->ptr;
+ if (ty) {
+ swig_type_info *to = sobj->ty;
+ if (to == ty) {
+ /* no type cast needed */
+ if (ptr) *ptr = vptr;
+ break;
+ } else {
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) {
+ sobj = (PySwigObject *)sobj->next;
+ } else {
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
+ break;
+ }
+ }
+ } else {
+ if (ptr) *ptr = vptr;
+ break;
+ }
+ }
+ if (sobj) {
+ if (own)
+ *own = *own | sobj->own;
+ if (flags & SWIG_POINTER_DISOWN) {
+ sobj->own = 0;
+ }
+ return SWIG_OK;
+ } else {
+ int res = SWIG_ERROR;
+ if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+ PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ if (data && !data->implicitconv) {
+ PyObject *klass = data->klass;
+ if (klass) {
+ PyObject *impconv;
+ data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+ impconv = SWIG_Python_CallFunctor(klass, obj);
+ data->implicitconv = 0;
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ impconv = 0;
+ }
+ if (impconv) {
+ PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
+ if (iobj) {
+ void *vptr;
+ res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+ if (SWIG_IsOK(res)) {
+ if (ptr) {
+ *ptr = vptr;
+ /* transfer the ownership to 'ptr' */
+ iobj->own = 0;
+ res = SWIG_AddCast(res);
+ res = SWIG_AddNewMask(res);
+ } else {
+ res = SWIG_AddCast(res);
+ }
+ }
+ }
+ Py_DECREF(impconv);
+ }
+ }
+ }
+ }
+ return res;
+ }
+ }
+}
+
+/* Convert a function ptr value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
+ if (!PyCFunction_Check(obj)) {
+ return SWIG_ConvertPtr(obj, ptr, ty, 0);
+ } else {
+ void *vptr = 0;
+
+ /* here we get the method pointer for callbacks */
+ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
+ const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
+ if (desc) {
+ desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
+ if (!desc) return SWIG_ERROR;
+ }
+ if (ty) {
+ swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
+ } else {
+ *ptr = vptr;
+ }
+ return SWIG_OK;
+ }
+}
+
+/* Convert a packed value value */
+
+SWIGRUNTIME int
+SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
+ swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
+ if (!to) return SWIG_ERROR;
+ if (ty) {
+ if (to != ty) {
+ /* check type cast? */
+ swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+ if (!tc) return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+/* -----------------------------------------------------------------------------
+ * Create a new pointer object
+ * ----------------------------------------------------------------------------- */
+
+/*
+ Create a new instance object, whitout calling __init__, and set the
+ 'this' attribute.
+*/
+
+SWIGRUNTIME PyObject*
+SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
+{
+#if (PY_VERSION_HEX >= 0x02020000)
+ PyObject *inst = 0;
+ PyObject *newraw = data->newraw;
+ if (newraw) {
+ inst = PyObject_Call(newraw, data->newargs, NULL);
+ if (inst) {
+#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ PyObject *dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ }
+ }
+#else
+ PyObject *key = SWIG_This();
+ PyObject_SetAttr(inst, key, swig_this);
+#endif
+ }
+ } else {
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ }
+ return inst;
+#else
+#if (PY_VERSION_HEX >= 0x02010000)
+ PyObject *inst;
+ PyObject *dict = PyDict_New();
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ inst = PyInstance_NewRaw(data->newargs, dict);
+ Py_DECREF(dict);
+ return (PyObject *) inst;
+#else
+ PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
+ if (inst == NULL) {
+ return NULL;
+ }
+ inst->in_class = (PyClassObject *)data->newargs;
+ Py_INCREF(inst->in_class);
+ inst->in_dict = PyDict_New();
+ if (inst->in_dict == NULL) {
+ Py_DECREF(inst);
+ return NULL;
+ }
+#ifdef Py_TPFLAGS_HAVE_WEAKREFS
+ inst->in_weakreflist = NULL;
+#endif
+#ifdef Py_TPFLAGS_GC
+ PyObject_GC_Init(inst);
+#endif
+ PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
+ return (PyObject *) inst;
+#endif
+#endif
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
+{
+ PyObject *dict;
+#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
+ PyObject **dictptr = _PyObject_GetDictPtr(inst);
+ if (dictptr != NULL) {
+ dict = *dictptr;
+ if (dict == NULL) {
+ dict = PyDict_New();
+ *dictptr = dict;
+ }
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ return;
+ }
+#endif
+ dict = PyObject_GetAttrString(inst, (char*)"__dict__");
+ PyDict_SetItem(dict, SWIG_This(), swig_this);
+ Py_DECREF(dict);
+}
+
+
+SWIGINTERN PyObject *
+SWIG_Python_InitShadowInstance(PyObject *args) {
+ PyObject *obj[2];
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
+ return NULL;
+ } else {
+ PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ if (sthis) {
+ PySwigObject_append((PyObject*) sthis, obj[1]);
+ } else {
+ SWIG_Python_SetSwigThis(obj[0], obj[1]);
+ }
+ return SWIG_Py_Void();
+ }
+}
+
+/* Create a new pointer object */
+
+SWIGRUNTIME PyObject *
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
+ if (!ptr) {
+ return SWIG_Py_Void();
+ } else {
+ int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+ PyObject *robj = PySwigObject_New(ptr, type, own);
+ PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
+ if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+ PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+ if (inst) {
+ Py_DECREF(robj);
+ robj = inst;
+ }
+ }
+ return robj;
+ }
+}
+
+/* Create a new packed object */
+
+SWIGRUNTIMEINLINE PyObject *
+SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
+ return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+}
+
+/* -----------------------------------------------------------------------------*
+ * Get type list
+ * -----------------------------------------------------------------------------*/
+
+#ifdef SWIG_LINK_RUNTIME
+void *SWIG_ReturnGlobalTypeList(void *);
+#endif
+
+SWIGRUNTIME swig_module_info *
+SWIG_Python_GetModule(void) {
+ static void *type_pointer = (void *)0;
+ /* first check if module already created */
+ if (!type_pointer) {
+#ifdef SWIG_LINK_RUNTIME
+ type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
+#else
+ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ type_pointer = (void *)0;
+ }
+#endif
+ }
+ return (swig_module_info *) type_pointer;
+}
+
+#if PY_MAJOR_VERSION < 2
+/* PyModule_AddObject function was introduced in Python 2.0. The following function
+ is copied out of Python/modsupport.c in python version 2.3.4 */
+SWIGINTERN int
+PyModule_AddObject(PyObject *m, char *name, PyObject *o)
+{
+ PyObject *dict;
+ if (!PyModule_Check(m)) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs module as first arg");
+ return SWIG_ERROR;
+ }
+ if (!o) {
+ PyErr_SetString(PyExc_TypeError,
+ "PyModule_AddObject() needs non-NULL value");
+ return SWIG_ERROR;
+ }
+
+ dict = PyModule_GetDict(m);
+ if (dict == NULL) {
+ /* Internal error -- modules must have a dict! */
+ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
+ PyModule_GetName(m));
+ return SWIG_ERROR;
+ }
+ if (PyDict_SetItemString(dict, name, o))
+ return SWIG_ERROR;
+ Py_DECREF(o);
+ return SWIG_OK;
+}
+#endif
+
+SWIGRUNTIME void
+SWIG_Python_DestroyModule(void *vptr)
+{
+ swig_module_info *swig_module = (swig_module_info *) vptr;
+ swig_type_info **types = swig_module->types;
+ size_t i;
+ for (i =0; i < swig_module->size; ++i) {
+ swig_type_info *ty = types[i];
+ if (ty->owndata) {
+ PySwigClientData *data = (PySwigClientData *) ty->clientdata;
+ if (data) PySwigClientData_Del(data);
+ }
+ }
+ Py_DECREF(SWIG_This());
+}
+
+SWIGRUNTIME void
+SWIG_Python_SetModule(swig_module_info *swig_module) {
+ static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+ PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+ swig_empty_runtime_method_table);
+ PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+ if (pointer && module) {
+ PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+ } else {
+ Py_XDECREF(pointer);
+ }
+}
+
+/* The python cached type query */
+SWIGRUNTIME PyObject *
+SWIG_Python_TypeCache(void) {
+ static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
+ return cache;
+}
+
+SWIGRUNTIME swig_type_info *
+SWIG_Python_TypeQuery(const char *type)
+{
+ PyObject *cache = SWIG_Python_TypeCache();
+ PyObject *key = PyString_FromString(type);
+ PyObject *obj = PyDict_GetItem(cache, key);
+ swig_type_info *descriptor;
+ if (obj) {
+ descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+ } else {
+ swig_module_info *swig_module = SWIG_Python_GetModule();
+ descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
+ if (descriptor) {
+ obj = PyCObject_FromVoidPtr(descriptor, NULL);
+ PyDict_SetItem(cache, key, obj);
+ Py_DECREF(obj);
+ }
+ }
+ Py_DECREF(key);
+ return descriptor;
+}
+
+/*
+ For backward compatibility only
+*/
+#define SWIG_POINTER_EXCEPTION 0
+#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
+#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
+
+SWIGRUNTIME int
+SWIG_Python_AddErrMesg(const char* mesg, int infront)
+{
+ if (PyErr_Occurred()) {
+ PyObject *type = 0;
+ PyObject *value = 0;
+ PyObject *traceback = 0;
+ PyErr_Fetch(&type, &value, &traceback);
+ if (value) {
+ PyObject *old_str = PyObject_Str(value);
+ Py_XINCREF(type);
+ PyErr_Clear();
+ if (infront) {
+ PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
+ } else {
+ PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+ }
+ Py_DECREF(old_str);
+ }
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIME int
+SWIG_Python_ArgFail(int argnum)
+{
+ if (PyErr_Occurred()) {
+ /* add information about failing argument */
+ char mesg[256];
+ PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
+ return SWIG_Python_AddErrMesg(mesg, 1);
+ } else {
+ return 0;
+ }
+}
+
+SWIGRUNTIMEINLINE const char *
+PySwigObject_GetDesc(PyObject *self)
+{
+ PySwigObject *v = (PySwigObject *)self;
+ swig_type_info *ty = v ? v->ty : 0;
+ return ty ? ty->str : (char*)"";
+}
+
+SWIGRUNTIME void
+SWIG_Python_TypeError(const char *type, PyObject *obj)
+{
+ if (type) {
+#if defined(SWIG_COBJECT_TYPES)
+ if (obj && PySwigObject_Check(obj)) {
+ const char *otype = (const char *) PySwigObject_GetDesc(obj);
+ if (otype) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
+ type, otype);
+ return;
+ }
+ } else
+#endif
+ {
+ const char *otype = (obj ? obj->ob_type->tp_name : 0);
+ if (otype) {
+ PyObject *str = PyObject_Str(obj);
+ const char *cstr = str ? PyString_AsString(str) : 0;
+ if (cstr) {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
+ type, otype, cstr);
+ } else {
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
+ type, otype);
+ }
+ Py_XDECREF(str);
+ return;
+ }
+ }
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
+ } else {
+ PyErr_Format(PyExc_TypeError, "unexpected type is received");
+ }
+}
+
+
+/* Convert a pointer value, signal an exception on a type mismatch */
+SWIGRUNTIME void *
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
+ void *result;
+ if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
+ PyErr_Clear();
+ if (flags & SWIG_POINTER_EXCEPTION) {
+ SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
+ SWIG_Python_ArgFail(argnum);
+ }
+ }
+ return result;
+}
+
+
+#ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
+}
+#endif
+
+
+
+#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
+
+#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
+
+
+
+/* -------- TYPES TABLE (BEGIN) -------- */
+
+#define SWIGTYPE_p_TALLOC_CTX swig_types[0]
+#define SWIGTYPE_p_char swig_types[1]
+#define SWIGTYPE_p_int swig_types[2]
+#define SWIGTYPE_p_loadparm_context swig_types[3]
+#define SWIGTYPE_p_loadparm_service swig_types[4]
+#define SWIGTYPE_p_long swig_types[5]
+#define SWIGTYPE_p_param_context swig_types[6]
+#define SWIGTYPE_p_param_opt swig_types[7]
+#define SWIGTYPE_p_param_section swig_types[8]
+#define SWIGTYPE_p_short swig_types[9]
+#define SWIGTYPE_p_signed_char swig_types[10]
+#define SWIGTYPE_p_unsigned_char swig_types[11]
+#define SWIGTYPE_p_unsigned_int swig_types[12]
+#define SWIGTYPE_p_unsigned_long swig_types[13]
+#define SWIGTYPE_p_unsigned_short swig_types[14]
+static swig_type_info *swig_types[16];
+static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
+#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
+#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
+
+/* -------- TYPES TABLE (END) -------- */
+
+#if (PY_VERSION_HEX <= 0x02000000)
+# if !defined(SWIG_PYTHON_CLASSIC)
+# error "This python version requires swig to be run with the '-classic' option"
+# endif
+#endif
+#if (PY_VERSION_HEX <= 0x02020000)
+# error "This python version requires swig to be run with the '-nomodern' option"
+#endif
+#if (PY_VERSION_HEX <= 0x02020000)
+# error "This python version requires swig to be run with the '-nomodernargs' option"
+#endif
+#ifndef METH_O
+# error "This python version requires swig to be run with the '-nofastunpack' option"
+#endif
+#ifdef SWIG_TypeQuery
+# undef SWIG_TypeQuery
+#endif
+#define SWIG_TypeQuery SWIG_Python_TypeQuery
+
+/*-----------------------------------------------
+ @(target):= _param.so
+ ------------------------------------------------*/
+#define SWIG_init init_param
+
+#define SWIG_name "_param"
+
+#define SWIGVERSION 0x010335
+#define SWIG_VERSION SWIGVERSION
+
+
+#define SWIG_as_voidptr(a) (void *)((const void *)(a))
+#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
+
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "includes.h"
+#include "param/param.h"
+#include "param/loadparm.h"
+
+typedef struct param_context param;
+typedef struct loadparm_context loadparm_context;
+typedef struct loadparm_service loadparm_service;
+typedef struct param_section param_section;
+typedef struct param_opt param_opt;
+
+SWIGINTERN loadparm_context *new_loadparm_context(TALLOC_CTX *mem_ctx){ return loadparm_init(mem_ctx); }
+SWIGINTERN struct loadparm_service *loadparm_context_default_service(loadparm_context *self){ return lp_default_service(self); }
+
+SWIGINTERN swig_type_info*
+SWIG_pchar_descriptor(void)
+{
+ static int init = 0;
+ static swig_type_info* info = 0;
+ if (!init) {
+ info = SWIG_TypeQuery("_p_char");
+ init = 1;
+ }
+ return info;
+}
+
+
+SWIGINTERN int
+SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
+{
+ if (PyString_Check(obj)) {
+ char *cstr; Py_ssize_t len;
+ PyString_AsStringAndSize(obj, &cstr, &len);
+ if (cptr) {
+ if (alloc) {
+ /*
+ In python the user should not be able to modify the inner
+ string representation. To warranty that, if you define
+ SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
+ buffer is always returned.
+
+ The default behavior is just to return the pointer value,
+ so, be careful.
+ */
+#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
+ if (*alloc != SWIG_OLDOBJ)
+#else
+ if (*alloc == SWIG_NEWOBJ)
+#endif
+ {
+ *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
+ *alloc = SWIG_NEWOBJ;
+ }
+ else {
+ *cptr = cstr;
+ *alloc = SWIG_OLDOBJ;
+ }
+ } else {
+ *cptr = PyString_AsString(obj);
+ }
+ }
+ if (psize) *psize = len + 1;
+ return SWIG_OK;
+ } else {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ if (pchar_descriptor) {
+ void* vptr = 0;
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
+ if (cptr) *cptr = (char *) vptr;
+ if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
+ if (alloc) *alloc = SWIG_OLDOBJ;
+ return SWIG_OK;
+ }
+ }
+ }
+ return SWIG_TypeError;
+}
+
+
+
+
+SWIGINTERN bool loadparm_context_load(loadparm_context *self,char const *filename){ return lp_load(self, filename); }
+
+SWIGINTERNINLINE PyObject*
+ SWIG_From_bool (bool value)
+{
+ return PyBool_FromLong(value ? 1 : 0);
+}
+
+SWIGINTERN bool loadparm_context_load_default(loadparm_context *self){ return lp_load_default(self); }
+SWIGINTERN int loadparm_context___len__(loadparm_context *self){ return lp_numservices(self); }
+
+ #define SWIG_From_long PyInt_FromLong
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_int (int value)
+{
+ return SWIG_From_long (value);
+}
+
+SWIGINTERN struct loadparm_service *loadparm_context___getitem__(loadparm_context *self,char const *name){ return lp_service(self, name); }
+SWIGINTERN char const *loadparm_context_configfile(loadparm_context *self){ return lp_configfile(self); }
+
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtrAndSize(const char* carray, size_t size)
+{
+ if (carray) {
+ if (size > INT_MAX) {
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
+ return pchar_descriptor ?
+ SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
+ } else {
+ return PyString_FromStringAndSize(carray, (int)(size));
+ }
+ } else {
+ return SWIG_Py_Void();
+ }
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_FromCharPtr(const char *cptr)
+{
+ return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
+}
+
+SWIGINTERN bool loadparm_context_is_mydomain(loadparm_context *self,char const *domain){ return lp_is_mydomain(self, domain); }
+SWIGINTERN bool loadparm_context_is_myname(loadparm_context *self,char const *name){ return lp_is_myname(self, name); }
+SWIGINTERN int loadparm_context_use(loadparm_context *self,struct param_context *param_ctx){ return param_use(self, param_ctx); }
+SWIGINTERN bool loadparm_context_set(loadparm_context *self,char const *parm_name,char const *parm_value){
+ if (parm_value == NULL)
+ return false;
+ return lp_set_cmdline(self, parm_name, parm_value);
+ }
+SWIGINTERN PyObject *loadparm_context_get(loadparm_context *self,char const *param_name,char const *service_name){
+ struct parm_struct *parm = NULL;
+ void *parm_ptr = NULL;
+ int i;
+
+ if (service_name != NULL) {
+ struct loadparm_service *service;
+ /* its a share parameter */
+ service = lp_service(self, service_name);
+ if (service == NULL) {
+ return Py_None;
+ }
+ if (strchr(param_name, ':')) {
+ /* its a parametric option on a share */
+ const char *type = talloc_strndup(self,
+ param_name,
+ strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric(self, service, type, option);
+ if (value == NULL) {
+ return Py_None;
+ }
+ return PyString_FromString(value);
+ }
+
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL || parm->class == P_GLOBAL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr(self, service, parm);
+ } else if (strchr(param_name, ':')) {
+ /* its a global parametric option */
+ const char *type = talloc_strndup(self,
+ param_name, strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric(self, NULL, type, option);
+ if (value == NULL)
+ return Py_None;
+ return PyString_FromString(value);
+ } else {
+ /* its a global parameter */
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr(self, NULL, parm);
+ }
+
+ if (parm == NULL || parm_ptr == NULL) {
+ return Py_None;
+ }
+
+ /* construct and return the right type of python object */
+ switch (parm->type) {
+ case P_STRING:
+ case P_USTRING:
+ return PyString_FromString(*(char **)parm_ptr);
+ case P_BOOL:
+ return PyBool_FromLong(*(bool *)parm_ptr);
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ return PyLong_FromLong(*(int *)parm_ptr);
+ case P_ENUM:
+ for (i=0; parm->enum_list[i].name; i++) {
+ if (*(int *)parm_ptr == parm->enum_list[i].value) {
+ return PyString_FromString(parm->enum_list[i].name);
+ }
+ }
+ return Py_None;
+ case P_LIST:
+ {
+ int j;
+ const char **strlist = *(const char ***)parm_ptr;
+ PyObject *pylist = PyList_New(str_list_length(strlist));
+ for (j = 0; strlist[j]; j++)
+ PyList_SetItem(pylist, j,
+ PyString_FromString(strlist[j]));
+ return pylist;
+ }
+
+ break;
+ }
+ return Py_None;
+ }
+SWIGINTERN void delete_loadparm_context(loadparm_context *self){ talloc_free(self); }
+SWIGINTERN char const *loadparm_service_volume_label(loadparm_service *self,struct loadparm_service *sDefault){ return volume_label(self, sDefault); }
+SWIGINTERN char const *loadparm_service_printername(loadparm_service *self,struct loadparm_service *sDefault){ return lp_printername(self, sDefault); }
+SWIGINTERN int loadparm_service_maxprintjobs(loadparm_service *self,struct loadparm_service *sDefault){ return lp_maxprintjobs(self, sDefault); }
+SWIGINTERN param *new_param(TALLOC_CTX *mem_ctx){ return param_init(mem_ctx); }
+SWIGINTERN int param_set(param *self,char const *parameter,PyObject *ob,char const *section_name){
+ struct param_opt *opt = param_get_add(self, parameter, section_name);
+
+ talloc_free(opt->value);
+ opt->value = talloc_strdup(opt, PyString_AsString(PyObject_Str(ob)));
+
+ return 0;
+ }
+SWIGINTERN struct param_section *param_first_section(param *self){ return self->sections; }
+SWIGINTERN struct param_section *param_next_section(param *self,struct param_section *s){ return s->next; }
+SWIGINTERN void delete_param(param *self){ talloc_free(self); }
+SWIGINTERN char const *param_opt___str__(param_opt *self){ return self->value; }
+SWIGINTERN void delete_param_opt(param_opt *self){ talloc_free(self); }
+SWIGINTERN struct param_opt *param_section_first_parameter(param_section *self){ return self->parameters; }
+SWIGINTERN struct param_opt *param_section_next_parameter(param_section *self,struct param_opt *s){ return s->next; }
+
+
+struct loadparm_context *lp_from_py_object(PyObject *py_obj)
+{
+ struct loadparm_context *lp_ctx;
+ if (PyString_Check(py_obj)) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load(lp_ctx, PyString_AsString(py_obj))) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
+ if (py_obj == Py_None) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load_default(lp_ctx)) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
+ if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0)
+ return NULL;
+ return lp_ctx;
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+SWIGINTERN PyObject *_wrap_new_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
+ loadparm_context *result = 0 ;
+
+ arg1 = NULL;
+ if (!SWIG_Python_UnpackTuple(args,"new_LoadParm",0,0,0)) SWIG_fail;
+ result = (loadparm_context *)new_loadparm_context(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_loadparm_context, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_default_service(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ struct loadparm_service *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_default_service",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_default_service" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ result = (struct loadparm_service *)loadparm_context_default_service(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_loadparm_service, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_load(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "filename", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_load",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_load" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_load" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ result = (bool)loadparm_context_load(arg1,(char const *)arg2);
+ resultobj = SWIG_From_bool((bool)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_load_default(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_load_default",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_load_default" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ result = (bool)loadparm_context_load_default(arg1);
+ resultobj = SWIG_From_bool((bool)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm___len__",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm___len__" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ result = (int)loadparm_context___len__(arg1);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ struct loadparm_service *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm___getitem__",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm___getitem__" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm___getitem__" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ result = (struct loadparm_service *)loadparm_context___getitem__(arg1,(char const *)arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_configfile(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:LoadParm_configfile",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_configfile" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ result = (char *)loadparm_context_configfile(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_is_mydomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "domain", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_mydomain",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_is_mydomain" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_is_mydomain" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ result = (bool)loadparm_context_is_mydomain(arg1,(char const *)arg2);
+ resultobj = SWIG_From_bool((bool)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_is_myname(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_is_myname",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_is_myname" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_is_myname" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ result = (bool)loadparm_context_is_myname(arg1,(char const *)arg2);
+ resultobj = SWIG_From_bool((bool)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_use(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ struct param_context *arg2 = (struct param_context *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "param_ctx", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:LoadParm_use",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_use" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_use" "', argument " "2"" of type '" "struct param_context *""'");
+ }
+ arg2 = (struct param_context *)(argp2);
+ }
+ result = (int)loadparm_context_use(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "parm_name",(char *) "parm_value", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_set" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_set" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "LoadParm_set" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (bool)loadparm_context_set(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = SWIG_From_bool((bool)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ PyObject *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "param_name",(char *) "service_name", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_get" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_get" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "LoadParm_get" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (PyObject *)loadparm_context_get(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = result;
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ char * kwnames[] = {
+ (char *) "self", NULL
+ };
+
+ arg1 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|O:delete_LoadParm",kwnames,&obj0)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_LoadParm" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ delete_loadparm_context(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *LoadParm_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_loadparm_context, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *LoadParm_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
+SWIGINTERN PyObject *_wrap_loadparm_service_volume_label(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_service *arg1 = (loadparm_service *) 0 ;
+ struct loadparm_service *arg2 = (struct loadparm_service *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "sDefault", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_volume_label",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_volume_label" "', argument " "1"" of type '" "loadparm_service *""'");
+ }
+ arg1 = (loadparm_service *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_volume_label" "', argument " "2"" of type '" "struct loadparm_service *""'");
+ }
+ arg2 = (struct loadparm_service *)(argp2);
+ result = (char *)loadparm_service_volume_label(arg1,arg2);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_loadparm_service_printername(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_service *arg1 = (loadparm_service *) 0 ;
+ struct loadparm_service *arg2 = (struct loadparm_service *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "sDefault", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_printername",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_printername" "', argument " "1"" of type '" "loadparm_service *""'");
+ }
+ arg1 = (loadparm_service *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_printername" "', argument " "2"" of type '" "struct loadparm_service *""'");
+ }
+ arg2 = (struct loadparm_service *)(argp2);
+ result = (char *)loadparm_service_printername(arg1,arg2);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_loadparm_service_maxprintjobs(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_service *arg1 = (loadparm_service *) 0 ;
+ struct loadparm_service *arg2 = (struct loadparm_service *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "sDefault", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:loadparm_service_maxprintjobs",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "loadparm_service_maxprintjobs" "', argument " "1"" of type '" "loadparm_service *""'");
+ }
+ arg1 = (loadparm_service *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_service, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "loadparm_service_maxprintjobs" "', argument " "2"" of type '" "struct loadparm_service *""'");
+ }
+ arg2 = (struct loadparm_service *)(argp2);
+ result = (int)loadparm_service_maxprintjobs(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *loadparm_service_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_loadparm_service, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_new_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
+ param *result = 0 ;
+
+ arg1 = NULL;
+ if (!SWIG_Python_UnpackTuple(args,"new_ParamFile",0,0,0)) SWIG_fail;
+ result = (param *)new_param(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_context, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_get_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_get_section",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_get_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_get_section" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ result = (struct param_section *)param_get_section(arg1,(char const *)arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_add_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_add_section",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_add_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_add_section" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ result = (struct param_section *)param_add_section(arg1,(char const *)arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) "global" ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name",(char *) "section_name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:ParamFile_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_get" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_get" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ParamFile_get" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (struct param_opt *)param_get(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_get_string(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) "global" ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name",(char *) "section_name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|O:ParamFile_get_string",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_get_string" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_get_string" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ParamFile_get_string" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (char *)param_get_string(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_set_string(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) "global" ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "param",(char *) "value",(char *) "section", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:ParamFile_set_string",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_set_string" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_set_string" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ParamFile_set_string" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ if (obj3) {
+ res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ParamFile_set_string" "', argument " "4"" of type '" "char const *""'");
+ }
+ arg4 = (char *)(buf4);
+ }
+ result = (int)param_set_string(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4);
+ resultobj = SWIG_From_int((int)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ PyObject *arg3 = (PyObject *) 0 ;
+ char *arg4 = (char *) "global" ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "parameter",(char *) "ob",(char *) "section_name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:ParamFile_set",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_set" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_set" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ arg3 = obj2;
+ if (obj3) {
+ res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "ParamFile_set" "', argument " "4"" of type '" "char const *""'");
+ }
+ arg4 = (char *)(buf4);
+ }
+ result = (int)param_set(arg1,(char const *)arg2,arg3,(char const *)arg4);
+ resultobj = SWIG_From_int((int)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc4 == SWIG_NEWOBJ) free((char*)buf4);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_first_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_first_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ result = (struct param_section *)param_first_section(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_next_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ struct param_section *arg2 = (struct param_section *) 0 ;
+ struct param_section *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "s", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_next_section",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_next_section" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_next_section" "', argument " "2"" of type '" "struct param_section *""'");
+ }
+ arg2 = (struct param_section *)(argp2);
+ result = (struct param_section *)param_next_section(arg1,arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "fn", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_read",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_read" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_read" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ result = (int)param_read(arg1,(char const *)arg2);
+ resultobj = SWIG_From_int((int)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ParamFile_write(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ char *arg2 = (char *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "fn", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ParamFile_write",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ParamFile_write" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ParamFile_write" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ result = (int)param_write(arg1,(char const *)arg2);
+ resultobj = SWIG_From_int((int)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_ParamFile(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param *arg1 = (param *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_context, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ParamFile" "', argument " "1"" of type '" "param *""'");
+ }
+ arg1 = (param *)(argp1);
+ delete_param(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *ParamFile_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_param_context, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *ParamFile_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
+SWIGINTERN PyObject *_wrap_param_opt_key_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_opt_key_get" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ result = (char *) ((arg1)->key);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_opt_value_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_opt_value_get" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ result = (char *) ((arg1)->value);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_opt___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_opt___str__" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ result = (char *)param_opt___str__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_param_opt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_opt *arg1 = (param_opt *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_opt, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_param_opt" "', argument " "1"" of type '" "param_opt *""'");
+ }
+ arg1 = (param_opt *)(argp1);
+ delete_param_opt(arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *param_opt_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_param_opt, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_param_section_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_name_get" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ result = (char *) ((arg1)->name);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_section_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ char *arg2 = (char *) 0 ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "name", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:param_section_get",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_get" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "param_section_get" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ result = (struct param_opt *)param_section_get(arg1,(char const *)arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_section_first_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_first_parameter" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ result = (struct param_opt *)param_section_first_parameter(arg1);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_param_section_next_parameter(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ struct param_opt *arg2 = (struct param_opt *) 0 ;
+ struct param_opt *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "s", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:param_section_next_parameter",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_param_section, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "param_section_next_parameter" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_param_opt, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "param_section_next_parameter" "', argument " "2"" of type '" "struct param_opt *""'");
+ }
+ arg2 = (struct param_opt *)(argp2);
+ result = (struct param_opt *)param_section_next_parameter(arg1,arg2);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_opt, 0 | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_param_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *result = 0 ;
+
+ if (!SWIG_Python_UnpackTuple(args,"new_param_section",0,0,0)) SWIG_fail;
+ result = (param_section *)calloc(1, sizeof(param_section));
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, SWIG_POINTER_NEW | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_param_section(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ param_section *arg1 = (param_section *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_param_section, SWIG_POINTER_DISOWN | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_param_section" "', argument " "1"" of type '" "param_section *""'");
+ }
+ arg1 = (param_section *)(argp1);
+ free((char *) arg1);
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *param_section_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *obj;
+ if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
+ SWIG_TypeNewClientData(SWIGTYPE_p_param_section, SWIG_NewClientData(obj));
+ return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *param_section_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
+SWIGINTERN int Swig_var_default_config_set(PyObject *_val) {
+ {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_loadparm_context, 0 );
+ if (!SWIG_IsOK(res)) {
+ SWIG_exception_fail(SWIG_ArgError(res), "in variable '""global_loadparm""' of type '""struct loadparm_context *""'");
+ }
+ global_loadparm = (struct loadparm_context *)(argp);
+ }
+ return 0;
+fail:
+ return 1;
+}
+
+
+SWIGINTERN PyObject *Swig_var_default_config_get(void) {
+ PyObject *pyobj = 0;
+
+ pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(global_loadparm), SWIGTYPE_p_loadparm_context, 0 );
+ return pyobj;
+}
+
+
+static PyMethodDef SwigMethods[] = {
+ { (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL},
+ { (char *)"LoadParm_default_service", (PyCFunction) _wrap_LoadParm_default_service, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load(filename) -> None\n"
+ "Load specified file.\n"
+ ""},
+ { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load_default() -> None\n"
+ "Load default smb.conf file.\n"
+ ""},
+ { (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm___getitem__", (PyCFunction) _wrap_LoadParm___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.configfile() -> string\n"
+ "Return name of last config file that was loaded.\n"
+ ""},
+ { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_mydomain(domain_name) -> bool\n"
+ "Check whether the specified name matches our domain name.\n"
+ ""},
+ { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_myname(netbios_name) -> bool\n"
+ "Check whether the specified name matches one of our netbios names.\n"
+ ""},
+ { (char *)"LoadParm_use", (PyCFunction) _wrap_LoadParm_use, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set(name, value) -> bool\n"
+ "Change a parameter.\n"
+ ""},
+ { (char *)"LoadParm_get", (PyCFunction) _wrap_LoadParm_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
+ { (char *)"LoadParm_swiginit", LoadParm_swiginit, METH_VARARGS, NULL},
+ { (char *)"loadparm_service_volume_label", (PyCFunction) _wrap_loadparm_service_volume_label, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"loadparm_service_printername", (PyCFunction) _wrap_loadparm_service_printername, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"loadparm_service_maxprintjobs", (PyCFunction) _wrap_loadparm_service_maxprintjobs, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL},
+ { (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_section(name) -> section\n"
+ "Add a new section.\n"
+ ""},
+ { (char *)"ParamFile_get", (PyCFunction) _wrap_ParamFile_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_get_string", (PyCFunction) _wrap_ParamFile_get_string, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_set", (PyCFunction) _wrap_ParamFile_set, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, (char *)"\n"
+ "S.first_section() -> section\n"
+ "Find first section\n"
+ ""},
+ { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.next_section(prev) -> section\n"
+ "Find next section\n"
+ ""},
+ { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.read(filename) -> bool\n"
+ "Read a filename.\n"
+ ""},
+ { (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
+ { (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
+ { (char *)"ParamFile_swiginit", ParamFile_swiginit, METH_VARARGS, NULL},
+ { (char *)"param_opt_key_get", (PyCFunction)_wrap_param_opt_key_get, METH_O, NULL},
+ { (char *)"param_opt_value_get", (PyCFunction)_wrap_param_opt_value_get, METH_O, NULL},
+ { (char *)"param_opt___str__", (PyCFunction)_wrap_param_opt___str__, METH_O, NULL},
+ { (char *)"delete_param_opt", (PyCFunction)_wrap_delete_param_opt, METH_O, NULL},
+ { (char *)"param_opt_swigregister", param_opt_swigregister, METH_VARARGS, NULL},
+ { (char *)"param_section_name_get", (PyCFunction)_wrap_param_section_name_get, METH_O, NULL},
+ { (char *)"param_section_get", (PyCFunction) _wrap_param_section_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"param_section_first_parameter", (PyCFunction)_wrap_param_section_first_parameter, METH_O, NULL},
+ { (char *)"param_section_next_parameter", (PyCFunction) _wrap_param_section_next_parameter, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"new_param_section", (PyCFunction)_wrap_new_param_section, METH_NOARGS, NULL},
+ { (char *)"delete_param_section", (PyCFunction)_wrap_delete_param_section, METH_O, NULL},
+ { (char *)"param_section_swigregister", param_section_swigregister, METH_VARARGS, NULL},
+ { (char *)"param_section_swiginit", param_section_swiginit, METH_VARARGS, NULL},
+ { NULL, NULL, 0, NULL }
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+
+static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "int *|int_least32_t *|int32_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_long = {"_p_long", "intptr_t *|int_least64_t *|int_fast32_t *|int_fast64_t *|int64_t *|long *|int_fast16_t *|intmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uint_least32_t *|uint32_t *|unsigned int *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "uintptr_t *|uint_least64_t *|uint_fast32_t *|uint_fast64_t *|uint64_t *|unsigned long *|uint_fast16_t *|uintmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
+
+static swig_type_info *swig_type_initial[] = {
+ &_swigt__p_TALLOC_CTX,
+ &_swigt__p_char,
+ &_swigt__p_int,
+ &_swigt__p_loadparm_context,
+ &_swigt__p_loadparm_service,
+ &_swigt__p_long,
+ &_swigt__p_param_context,
+ &_swigt__p_param_opt,
+ &_swigt__p_param_section,
+ &_swigt__p_short,
+ &_swigt__p_signed_char,
+ &_swigt__p_unsigned_char,
+ &_swigt__p_unsigned_int,
+ &_swigt__p_unsigned_long,
+ &_swigt__p_unsigned_short,
+};
+
+static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
+
+static swig_cast_info *swig_cast_initial[] = {
+ _swigc__p_TALLOC_CTX,
+ _swigc__p_char,
+ _swigc__p_int,
+ _swigc__p_loadparm_context,
+ _swigc__p_loadparm_service,
+ _swigc__p_long,
+ _swigc__p_param_context,
+ _swigc__p_param_opt,
+ _swigc__p_param_section,
+ _swigc__p_short,
+ _swigc__p_signed_char,
+ _swigc__p_unsigned_char,
+ _swigc__p_unsigned_int,
+ _swigc__p_unsigned_long,
+ _swigc__p_unsigned_short,
+};
+
+
+/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
+
+static swig_const_info swig_const_table[] = {
+{0, 0, 0, 0.0, 0, 0}};
+
+#ifdef __cplusplus
+}
+#endif
+/* -----------------------------------------------------------------------------
+ * Type initialization:
+ * This problem is tough by the requirement that no dynamic
+ * memory is used. Also, since swig_type_info structures store pointers to
+ * swig_cast_info structures and swig_cast_info structures store pointers back
+ * to swig_type_info structures, we need some lookup code at initialization.
+ * The idea is that swig generates all the structures that are needed.
+ * The runtime then collects these partially filled structures.
+ * The SWIG_InitializeModule function takes these initial arrays out of
+ * swig_module, and does all the lookup, filling in the swig_module.types
+ * array with the correct data and linking the correct swig_cast_info
+ * structures together.
+ *
+ * The generated swig_type_info structures are assigned staticly to an initial
+ * array. We just loop through that array, and handle each type individually.
+ * First we lookup if this type has been already loaded, and if so, use the
+ * loaded structure instead of the generated one. Then we have to fill in the
+ * cast linked list. The cast data is initially stored in something like a
+ * two-dimensional array. Each row corresponds to a type (there are the same
+ * number of rows as there are in the swig_type_initial array). Each entry in
+ * a column is one of the swig_cast_info structures for that type.
+ * The cast_initial array is actually an array of arrays, because each row has
+ * a variable number of columns. So to actually build the cast linked list,
+ * we find the array of casts associated with the type, and loop through it
+ * adding the casts to the list. The one last trick we need to do is making
+ * sure the type pointer in the swig_cast_info struct is correct.
+ *
+ * First off, we lookup the cast->type name to see if it is already loaded.
+ * There are three cases to handle:
+ * 1) If the cast->type has already been loaded AND the type we are adding
+ * casting info to has not been loaded (it is in this module), THEN we
+ * replace the cast->type pointer with the type pointer that has already
+ * been loaded.
+ * 2) If BOTH types (the one we are adding casting info to, and the
+ * cast->type) are loaded, THEN the cast info has already been loaded by
+ * the previous module so we just ignore it.
+ * 3) Finally, if cast->type has not already been loaded, then we add that
+ * swig_cast_info to the linked list (because the cast->type) pointer will
+ * be correct.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+extern "C" {
+#if 0
+} /* c-mode */
+#endif
+#endif
+
+#if 0
+#define SWIGRUNTIME_DEBUG
+#endif
+
+
+SWIGRUNTIME void
+SWIG_InitializeModule(void *clientdata) {
+ size_t i;
+ swig_module_info *module_head, *iter;
+ int found, init;
+
+ clientdata = clientdata;
+
+ /* check to see if the circular list has been setup, if not, set it up */
+ if (swig_module.next==0) {
+ /* Initialize the swig_module */
+ swig_module.type_initial = swig_type_initial;
+ swig_module.cast_initial = swig_cast_initial;
+ swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
+ }
+
+ /* Try and load any already created modules */
+ module_head = SWIG_GetModule(clientdata);
+ if (!module_head) {
+ /* This is the first module loaded for this interpreter */
+ /* so set the swig module into the interpreter */
+ SWIG_SetModule(clientdata, &swig_module);
+ module_head = &swig_module;
+ } else {
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
+ found=0;
+ iter=module_head;
+ do {
+ if (iter==&swig_module) {
+ found=1;
+ break;
+ }
+ iter=iter->next;
+ } while (iter!= module_head);
+
+ /* if the is found in the list, then all is done and we may leave */
+ if (found) return;
+ /* otherwise we must add out module into the list */
+ swig_module.next = module_head->next;
+ module_head->next = &swig_module;
+ }
+
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
+ /* Now work on filling in swig_module.types */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
+#endif
+ for (i = 0; i < swig_module.size; ++i) {
+ swig_type_info *type = 0;
+ swig_type_info *ret;
+ swig_cast_info *cast;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+#endif
+
+ /* if there is another module already loaded */
+ if (swig_module.next != &swig_module) {
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
+ }
+ if (type) {
+ /* Overwrite clientdata field */
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
+#endif
+ if (swig_module.type_initial[i]->clientdata) {
+ type->clientdata = swig_module.type_initial[i]->clientdata;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
+#endif
+ }
+ } else {
+ type = swig_module.type_initial[i];
+ }
+
+ /* Insert casting types */
+ cast = swig_module.cast_initial[i];
+ while (cast->type) {
+ /* Don't need to add information already in the list */
+ ret = 0;
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
+#endif
+ if (swig_module.next != &swig_module) {
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
+#endif
+ }
+ if (ret) {
+ if (type == swig_module.type_initial[i]) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
+#endif
+ cast->type = ret;
+ ret = 0;
+ } else {
+ /* Check for casting already in the list */
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
+#ifdef SWIGRUNTIME_DEBUG
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
+#endif
+ if (!ocast) ret = 0;
+ }
+ }
+
+ if (!ret) {
+#ifdef SWIGRUNTIME_DEBUG
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
+#endif
+ if (type->cast) {
+ type->cast->prev = cast;
+ cast->next = type->cast;
+ }
+ type->cast = cast;
+ }
+ cast++;
+ }
+ /* Set entry in modules->types array equal to the type */
+ swig_module.types[i] = type;
+ }
+ swig_module.types[i] = 0;
+
+#ifdef SWIGRUNTIME_DEBUG
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+ for (i = 0; i < swig_module.size; ++i) {
+ int j = 0;
+ swig_cast_info *cast = swig_module.cast_initial[i];
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
+ while (cast->type) {
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
+ cast++;
+ ++j;
+ }
+ printf("---- Total casts: %d\n",j);
+ }
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
+#endif
+}
+
+/* This function will propagate the clientdata field of type to
+* any new swig_type_info structures that have been added into the list
+* of equivalent types. It is like calling
+* SWIG_TypeClientData(type, clientdata) a second time.
+*/
+SWIGRUNTIME void
+SWIG_PropagateClientData(void) {
+ size_t i;
+ swig_cast_info *equiv;
+ static int init_run = 0;
+
+ if (init_run) return;
+ init_run = 1;
+
+ for (i = 0; i < swig_module.size; i++) {
+ if (swig_module.types[i]->clientdata) {
+ equiv = swig_module.types[i]->cast;
+ while (equiv) {
+ if (!equiv->converter) {
+ if (equiv->type && !equiv->type->clientdata)
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
+ }
+ equiv = equiv->next;
+ }
+ }
+ }
+}
+
+#ifdef __cplusplus
+#if 0
+{
+ /* c-mode */
+#endif
+}
+#endif
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* Python-specific SWIG API */
+#define SWIG_newvarlink() SWIG_Python_newvarlink()
+#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
+#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
+
+ /* -----------------------------------------------------------------------------
+ * global variable support code.
+ * ----------------------------------------------------------------------------- */
+
+ typedef struct swig_globalvar {
+ char *name; /* Name of global variable */
+ PyObject *(*get_attr)(void); /* Return the current value */
+ int (*set_attr)(PyObject *); /* Set the value */
+ struct swig_globalvar *next;
+ } swig_globalvar;
+
+ typedef struct swig_varlinkobject {
+ PyObject_HEAD
+ swig_globalvar *vars;
+ } swig_varlinkobject;
+
+ SWIGINTERN PyObject *
+ swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+ return PyString_FromString("<Swig global variables>");
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_str(swig_varlinkobject *v) {
+ PyObject *str = PyString_FromString("(");
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ PyString_ConcatAndDel(&str,PyString_FromString(var->name));
+ if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
+ }
+ PyString_ConcatAndDel(&str,PyString_FromString(")"));
+ return str;
+ }
+
+ SWIGINTERN int
+ swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+ PyObject *str = swig_varlink_str(v);
+ fprintf(fp,"Swig global variables ");
+ fprintf(fp,"%s\n", PyString_AsString(str));
+ Py_DECREF(str);
+ return 0;
+ }
+
+ SWIGINTERN void
+ swig_varlink_dealloc(swig_varlinkobject *v) {
+ swig_globalvar *var = v->vars;
+ while (var) {
+ swig_globalvar *n = var->next;
+ free(var->name);
+ free(var);
+ var = n;
+ }
+ }
+
+ SWIGINTERN PyObject *
+ swig_varlink_getattr(swig_varlinkobject *v, char *n) {
+ PyObject *res = NULL;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->get_attr)();
+ break;
+ }
+ var = var->next;
+ }
+ if (res == NULL && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN int
+ swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
+ int res = 1;
+ swig_globalvar *var = v->vars;
+ while (var) {
+ if (strcmp(var->name,n) == 0) {
+ res = (*var->set_attr)(p);
+ break;
+ }
+ var = var->next;
+ }
+ if (res == 1 && !PyErr_Occurred()) {
+ PyErr_SetString(PyExc_NameError,"Unknown C global variable");
+ }
+ return res;
+ }
+
+ SWIGINTERN PyTypeObject*
+ swig_varlink_type(void) {
+ static char varlink__doc__[] = "Swig var link object";
+ static PyTypeObject varlink_type;
+ static int type_init = 0;
+ if (!type_init) {
+ const PyTypeObject tmp
+ = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* Number of items in variable part (ob_size) */
+ (char *)"swigvarlink", /* Type name (tp_name) */
+ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
+ 0, /* Itemsize (tp_itemsize) */
+ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
+ (printfunc) swig_varlink_print, /* Print (tp_print) */
+ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
+ 0, /* tp_compare */
+ (reprfunc) swig_varlink_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ (reprfunc)swig_varlink_str, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ 0, /* tp_flags */
+ varlink__doc__, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
+#endif
+#if PY_VERSION_HEX >= 0x02030000
+ 0, /* tp_del */
+#endif
+#ifdef COUNT_ALLOCS
+ 0,0,0,0 /* tp_alloc -> tp_next */
+#endif
+ };
+ varlink_type = tmp;
+ varlink_type.ob_type = &PyType_Type;
+ type_init = 1;
+ }
+ return &varlink_type;
+ }
+
+ /* Create a variable linking object for use later */
+ SWIGINTERN PyObject *
+ SWIG_Python_newvarlink(void) {
+ swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
+ if (result) {
+ result->vars = 0;
+ }
+ return ((PyObject*) result);
+ }
+
+ SWIGINTERN void
+ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
+ swig_varlinkobject *v = (swig_varlinkobject *) p;
+ swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
+ if (gv) {
+ size_t size = strlen(name)+1;
+ gv->name = (char *)malloc(size);
+ if (gv->name) {
+ strncpy(gv->name,name,size);
+ gv->get_attr = get_attr;
+ gv->set_attr = set_attr;
+ gv->next = v->vars;
+ }
+ }
+ v->vars = gv;
+ }
+
+ SWIGINTERN PyObject *
+ SWIG_globals(void) {
+ static PyObject *_SWIG_globals = 0;
+ if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
+ return _SWIG_globals;
+ }
+
+ /* -----------------------------------------------------------------------------
+ * constants/methods manipulation
+ * ----------------------------------------------------------------------------- */
+
+ /* Install Constants */
+ SWIGINTERN void
+ SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
+ PyObject *obj = 0;
+ size_t i;
+ for (i = 0; constants[i].type; ++i) {
+ switch(constants[i].type) {
+ case SWIG_PY_POINTER:
+ obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+ break;
+ case SWIG_PY_BINARY:
+ obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
+ break;
+ default:
+ obj = 0;
+ break;
+ }
+ if (obj) {
+ PyDict_SetItemString(d, constants[i].name, obj);
+ Py_DECREF(obj);
+ }
+ }
+ }
+
+ /* -----------------------------------------------------------------------------*/
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ /* -----------------------------------------------------------------------------*/
+
+ SWIGINTERN void
+ SWIG_Python_FixMethods(PyMethodDef *methods,
+ swig_const_info *const_table,
+ swig_type_info **types,
+ swig_type_info **types_initial) {
+ size_t i;
+ for (i = 0; methods[i].ml_name; ++i) {
+ const char *c = methods[i].ml_doc;
+ if (c && (c = strstr(c, "swig_ptr: "))) {
+ int j;
+ swig_const_info *ci = 0;
+ const char *name = c + 10;
+ for (j = 0; const_table[j].type; ++j) {
+ if (strncmp(const_table[j].name, name,
+ strlen(const_table[j].name)) == 0) {
+ ci = &(const_table[j]);
+ break;
+ }
+ }
+ if (ci) {
+ size_t shift = (ci->ptype) - types;
+ swig_type_info *ty = types_initial[shift];
+ size_t ldoc = (c - methods[i].ml_doc);
+ size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+ char *ndoc = (char*)malloc(ldoc + lptr + 10);
+ if (ndoc) {
+ char *buff = ndoc;
+ void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+ if (ptr) {
+ strncpy(buff, methods[i].ml_doc, ldoc);
+ buff += ldoc;
+ strncpy(buff, "swig_ptr: ", 10);
+ buff += 10;
+ SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
+ methods[i].ml_doc = ndoc;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#ifdef __cplusplus
+}
+#endif
+
+/* -----------------------------------------------------------------------------*
+ * Partial Init method
+ * -----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIG_init(void) {
+ PyObject *m, *d;
+
+ /* Fix SwigMethods to carry the callback ptrs when needed */
+ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
+
+ m = Py_InitModule((char *) SWIG_name, SwigMethods);
+ d = PyModule_GetDict(m);
+
+ SWIG_InitializeModule(0);
+ SWIG_InstallConstants(d,swig_const_table);
+
+
+ PyDict_SetItemString(d,(char*)"cvar", SWIG_globals());
+ SWIG_addvarlink(SWIG_globals(),(char*)"default_config",Swig_var_default_config_get, Swig_var_default_config_set);
+}
+
diff --git a/source4/param/provision.c b/source4/param/provision.c
new file mode 100644
index 0000000000..0e54acf9e4
--- /dev/null
+++ b/source4/param/provision.c
@@ -0,0 +1,139 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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/>.
+*/
+
+#include "includes.h"
+#include "auth/auth.h"
+#include "lib/ldb_wrap.h"
+#include "libcli/raw/libcliraw.h"
+#include "librpc/ndr/libndr.h"
+
+#include "param/param.h"
+#include "param/provision.h"
+#include <Python.h>
+#include "scripting/python/modules.h"
+
+NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ struct provision_settings *settings,
+ struct provision_result *result)
+{
+ extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);
+ struct ldb_context *ldb_context_from_py_object(PyObject *py_obj);
+ PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters;
+
+ DEBUG(0,("Provision for Become-DC test using python\n"));
+
+ py_load_samba_modules();
+ Py_Initialize();
+ py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+
+ provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
+
+ if (provision_mod == NULL) {
+ PyErr_Print();
+ DEBUG(0, ("Unable to import provision Python module.\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ provision_dict = PyModule_GetDict(provision_mod);
+
+ if (provision_dict == NULL) {
+ DEBUG(0, ("Unable to get dictionary for provision module\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ provision_fn = PyDict_GetItemString(provision_dict, "provision_become_dc");
+ if (provision_fn == NULL) {
+ PyErr_Print();
+ DEBUG(0, ("Unable to get provision_become_dc function\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ DEBUG(0,("New Server in Site[%s]\n",
+ settings->site_name));
+
+ DEBUG(0,("DSA Instance [%s]\n"
+ "\tinvocationId[%s]\n",
+ settings->ntds_dn_str,
+ settings->invocation_id == NULL?"None":GUID_string(mem_ctx, settings->invocation_id)));
+
+ DEBUG(0,("Pathes under targetdir[%s]\n",
+ settings->targetdir));
+ parameters = PyDict_New();
+
+ PyDict_SetItemString(parameters, "smbconf",
+ PyString_FromString(lp_configfile(lp_ctx)));
+
+ PyDict_SetItemString(parameters, "rootdn",
+ PyString_FromString(settings->root_dn_str));
+ if (settings->targetdir != NULL)
+ PyDict_SetItemString(parameters, "targetdir",
+ PyString_FromString(settings->targetdir));
+ PyDict_SetItemString(parameters, "setup_dir",
+ PyString_FromString("setup"));
+ PyDict_SetItemString(parameters, "hostname",
+ PyString_FromString(settings->netbios_name));
+ PyDict_SetItemString(parameters, "domain",
+ PyString_FromString(settings->domain));
+ PyDict_SetItemString(parameters, "realm",
+ PyString_FromString(settings->realm));
+ if (settings->root_dn_str)
+ PyDict_SetItemString(parameters, "rootdn",
+ PyString_FromString(settings->root_dn_str));
+
+ if (settings->domain_dn_str)
+ PyDict_SetItemString(parameters, "domaindn",
+ PyString_FromString(settings->domain_dn_str));
+
+ if (settings->schema_dn_str)
+ PyDict_SetItemString(parameters, "schemadn",
+ PyString_FromString(settings->schema_dn_str));
+
+ if (settings->config_dn_str)
+ PyDict_SetItemString(parameters, "configdn",
+ PyString_FromString(settings->config_dn_str));
+
+ if (settings->server_dn_str)
+ PyDict_SetItemString(parameters, "serverdn",
+ PyString_FromString(settings->server_dn_str));
+
+ if (settings->site_name)
+ PyDict_SetItemString(parameters, "sitename",
+ PyString_FromString(settings->site_name));
+
+ PyDict_SetItemString(parameters, "machinepass",
+ PyString_FromString(settings->machine_password));
+
+ py_result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
+
+ Py_DECREF(parameters);
+
+ if (py_result == NULL) {
+ PyErr_Print();
+ PyErr_Clear();
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ result->domaindn = talloc_strdup(mem_ctx, PyString_AsString(PyObject_GetAttrString(py_result, "domaindn")));
+
+ /* FIXME paths */
+ result->lp_ctx = lp_from_py_object(PyObject_GetAttrString(py_result, "lp"));
+ result->samdb = ldb_context_from_py_object(PyObject_GetAttrString(py_result, "samdb"));
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/param/provision.h b/source4/param/provision.h
new file mode 100644
index 0000000000..af9685d292
--- /dev/null
+++ b/source4/param/provision.h
@@ -0,0 +1,51 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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 _PROVISION_H_
+#define _PROVISION_H_
+
+struct provision_settings {
+ const char *site_name;
+ const char *root_dn_str;
+ const char *domain_dn_str;
+ const char *config_dn_str;
+ const char *schema_dn_str;
+ const char *server_dn_str;
+ const struct GUID *invocation_id;
+ const char *netbios_name;
+ const char *host_ip;
+ const char *realm;
+ const char *domain;
+ const char *ntds_dn_str;
+ const char *machine_password;
+ const char *targetdir;
+};
+
+/* FIXME: Rename this to hostconfig ? */
+struct provision_result {
+ const char *domaindn;
+ struct ldb_context *samdb;
+ struct loadparm_context *lp_ctx;
+};
+
+NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ struct provision_settings *settings,
+ struct provision_result *result);
+
+#endif /* _PROVISION_H_ */
diff --git a/source4/param/samba-hostconfig.pc.in b/source4/param/samba-hostconfig.pc.in
new file mode 100644
index 0000000000..b8ba24096d
--- /dev/null
+++ b/source4/param/samba-hostconfig.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: samba-hostconfig
+Description: Host-wide Samba configuration
+Version: 0.0.1
+Libs: -L${libdir} -lsamba-hostconfig
+Cflags: -I${includedir} -DHAVE_IMMEDIATE_STRUCTURES=1
diff --git a/source4/param/secrets.c b/source4/param/secrets.c
new file mode 100644
index 0000000000..16fbb3b108
--- /dev/null
+++ b/source4/param/secrets.c
@@ -0,0 +1,196 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) Andrew Tridgell 1992-2001
+ Copyright (C) Andrew Bartlett 2002
+ Copyright (C) Rafal Szczesniak 2002
+
+ 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/>.
+*/
+
+/* the Samba secrets database stores any generated, private information
+ such as the local SID and machine trust password */
+
+#include "includes.h"
+#include "secrets.h"
+#include "param/param.h"
+#include "system/filesys.h"
+#include "tdb_wrap.h"
+#include "lib/ldb/include/ldb.h"
+#include "lib/tdb/include/tdb.h"
+#include "lib/util/util_tdb.h"
+#include "lib/util/util_ldb.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+/**
+ * Use a TDB to store an incrementing random seed.
+ *
+ * Initialised to the current pid, the very first time Samba starts,
+ * and incremented by one each time it is needed.
+ *
+ * @note Not called by systems with a working /dev/urandom.
+ */
+static void get_rand_seed(struct tdb_wrap *secretsdb, int *new_seed)
+{
+ *new_seed = getpid();
+ if (secretsdb != NULL) {
+ tdb_change_int32_atomic(secretsdb->tdb, "INFO/random_seed", new_seed, 1);
+ }
+}
+
+/**
+ * open up the secrets database
+ */
+struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+ char *fname;
+ uint8_t dummy;
+ struct tdb_wrap *tdb;
+
+ fname = private_path(mem_ctx, lp_ctx, "secrets.tdb");
+
+ tdb = tdb_wrap_open(mem_ctx, fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+
+ if (!tdb) {
+ DEBUG(0,("Failed to open %s\n", fname));
+ talloc_free(fname);
+ return NULL;
+ }
+ talloc_free(fname);
+
+ /**
+ * Set a reseed function for the crypto random generator
+ *
+ * This avoids a problem where systems without /dev/urandom
+ * could send the same challenge to multiple clients
+ */
+ set_rand_reseed_callback((void (*) (void *, int *))get_rand_seed, tdb);
+
+ /* Ensure that the reseed is done now, while we are root, etc */
+ generate_random_buffer(&dummy, sizeof(dummy));
+
+ return tdb;
+}
+
+/**
+ connect to the secrets ldb
+*/
+struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx)
+{
+ char *path;
+ const char *url;
+ struct ldb_context *ldb;
+
+ url = lp_secrets_url(lp_ctx);
+ if (!url || !url[0]) {
+ return NULL;
+ }
+
+ path = private_path(mem_ctx, lp_ctx, url);
+ if (!path) {
+ return NULL;
+ }
+
+ /* Secrets.ldb *must* always be local. If we call for a
+ * system_session() we will recurse */
+ ldb = ldb_init(mem_ctx, ev_ctx);
+ if (!ldb) {
+ talloc_free(path);
+ return NULL;
+ }
+
+ ldb_set_modules_dir(ldb,
+ talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
+
+ if (ldb_connect(ldb, path, 0, NULL) != 0) {
+ talloc_free(path);
+ return NULL;
+ }
+
+ talloc_free(path);
+
+ return ldb;
+}
+
+/**
+ * Retrieve the domain SID from the secrets database.
+ * @return pointer to a SID object if the SID could be obtained, NULL otherwise
+ */
+struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *domain)
+{
+ struct ldb_context *ldb;
+ struct ldb_message **msgs;
+ int ldb_ret;
+ const char *attrs[] = { "objectSid", NULL };
+ struct dom_sid *result = NULL;
+ const struct ldb_val *v;
+ enum ndr_err_code ndr_err;
+
+ ldb = secrets_db_connect(mem_ctx, ev_ctx, lp_ctx);
+ if (ldb == NULL) {
+ DEBUG(5, ("secrets_db_connect failed\n"));
+ return NULL;
+ }
+
+ ldb_ret = gendb_search(ldb, ldb,
+ ldb_dn_new(mem_ctx, ldb, SECRETS_PRIMARY_DOMAIN_DN),
+ &msgs, attrs,
+ SECRETS_PRIMARY_DOMAIN_FILTER, domain);
+
+ if (ldb_ret == -1) {
+ DEBUG(5, ("Error searching for domain SID for %s: %s",
+ domain, ldb_errstring(ldb)));
+ talloc_free(ldb);
+ return NULL;
+ }
+
+ if (ldb_ret == 0) {
+ DEBUG(5, ("Did not find domain record for %s\n", domain));
+ talloc_free(ldb);
+ return NULL;
+ }
+
+ if (ldb_ret > 1) {
+ DEBUG(5, ("Found more than one (%d) domain records for %s\n",
+ ldb_ret, domain));
+ talloc_free(ldb);
+ return NULL;
+ }
+
+ v = ldb_msg_find_ldb_val(msgs[0], "objectSid");
+ if (v == NULL) {
+ DEBUG(0, ("Domain object for %s does not contain a SID!\n",
+ domain));
+ return NULL;
+ }
+ result = talloc(mem_ctx, struct dom_sid);
+ if (result == NULL) {
+ talloc_free(ldb);
+ return NULL;
+ }
+
+ ndr_err = ndr_pull_struct_blob(v, result, NULL, result,
+ (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(result);
+ talloc_free(ldb);
+ return NULL;
+ }
+
+ return result;
+}
diff --git a/source4/param/secrets.h b/source4/param/secrets.h
new file mode 100644
index 0000000000..83b6dc7fdc
--- /dev/null
+++ b/source4/param/secrets.h
@@ -0,0 +1,53 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * secrets.tdb file format info
+ * Copyright (C) Andrew Tridgell 2000
+ *
+ * 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 _SECRETS_H
+#define _SECRETS_H
+
+/* structure for storing machine account password
+ (ie. when samba server is member of a domain */
+struct machine_acct_pass {
+ uint8_t hash[16];
+ time_t mod_time;
+};
+
+#define SECRETS_PRIMARY_DOMAIN_DN "cn=Primary Domains"
+#define SECRETS_PRINCIPALS_DN "cn=Principals"
+#define SECRETS_PRIMARY_DOMAIN_FILTER "(&(flatname=%s)(objectclass=primaryDomain))"
+#define SECRETS_PRIMARY_REALM_FILTER "(&(realm=%s)(objectclass=primaryDomain))"
+#define SECRETS_KRBTGT_SEARCH "(&((|(realm=%s)(flatname=%s))(samAccountName=krbtgt)))"
+#define SECRETS_PRINCIPAL_SEARCH "(&(|(realm=%s)(flatname=%s))(servicePrincipalName=%s))"
+#define SECRETS_LDAP_FILTER "(objectclass=ldapSecret)"
+
+/**
+ * Use a TDB to store an incrementing random seed.
+ *
+ * Initialised to the current pid, the very first time Samba starts,
+ * and incremented by one each time it is needed.
+ *
+ * @note Not called by systems with a working /dev/urandom.
+ */
+struct loadparm_context;
+struct event_context;
+struct tdb_wrap *secrets_init(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
+struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, struct loadparm_context *lp_ctx);
+struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, struct loadparm_context *lp_ctx, const char *domain);
+
+
+#endif /* _SECRETS_H */
diff --git a/source4/param/share.c b/source4/param/share.c
new file mode 100644
index 0000000000..47aea55751
--- /dev/null
+++ b/source4/param/share.c
@@ -0,0 +1,156 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Modular shares configuration system
+
+ Copyright (C) Simo Sorce 2006
+
+ 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 "param/share.h"
+#include "param/param.h"
+
+const char *share_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
+{
+ return scfg->ctx->ops->string_option(scfg, opt_name, defval);
+}
+
+int share_int_option(struct share_config *scfg, const char *opt_name, int defval)
+{
+ return scfg->ctx->ops->int_option(scfg, opt_name, defval);
+}
+
+bool share_bool_option(struct share_config *scfg, const char *opt_name, bool defval)
+{
+ return scfg->ctx->ops->bool_option(scfg, opt_name, defval);
+}
+
+const char **share_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
+{
+ return scfg->ctx->ops->string_list_option(mem_ctx, scfg, opt_name);
+}
+
+NTSTATUS share_list_all(TALLOC_CTX *mem_ctx, struct share_context *sctx, int *count, const char ***names)
+{
+ return sctx->ops->list_all(mem_ctx, sctx, count, names);
+}
+
+NTSTATUS share_get_config(TALLOC_CTX *mem_ctx, struct share_context *sctx, const char *name, struct share_config **scfg)
+{
+ return sctx->ops->get_config(mem_ctx, sctx, name, scfg);
+}
+
+NTSTATUS share_create(struct share_context *sctx, const char *name, struct share_info *info, int count)
+{
+ if (sctx->ops->create) {
+ return sctx->ops->create(sctx, name, info, count);
+ }
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS share_set(struct share_context *sctx, const char *name, struct share_info *info, int count)
+{
+ if (sctx->ops->set) {
+ return sctx->ops->set(sctx, name, info, count);
+ }
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS share_remove(struct share_context *sctx, const char *name)
+{
+ if (sctx->ops->remove) {
+ return sctx->ops->remove(sctx, name);
+ }
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/* List of currently available share backends */
+static struct share_ops **backends = NULL;
+
+static const struct share_ops *share_backend_by_name(const char *name)
+{
+ int i;
+
+ for (i = 0; backends && backends[i]; i++) {
+ if (strcmp(backends[i]->name, name) == 0) {
+ return backends[i];
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ Register the share backend
+*/
+NTSTATUS share_register(const struct share_ops *ops)
+{
+ int i;
+
+ if (share_backend_by_name(ops->name) != NULL) {
+ DEBUG(0,("SHARE backend [%s] already registered\n", ops->name));
+ return NT_STATUS_OBJECT_NAME_COLLISION;
+ }
+
+ i = 0;
+ while (backends && backends[i]) {
+ i++;
+ }
+
+ backends = realloc_p(backends, struct share_ops *, i + 2);
+ if (!backends) {
+ smb_panic("out of memory in share_register");
+ }
+
+ backends[i] = (struct share_ops *)smb_xmemdup(ops, sizeof(*ops));
+ backends[i]->name = smb_xstrdup(ops->name);
+
+ backends[i + 1] = NULL;
+
+ DEBUG(3, ("SHARE backend [%s] registered.\n", ops->name));
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name,
+ struct event_context *event_ctx,
+ struct loadparm_context *lp_ctx,
+ struct share_context **ctx)
+{
+ const struct share_ops *ops;
+
+ ops = share_backend_by_name(backend_name);
+ if (!ops) {
+ DEBUG(0, ("share_init_connection: share backend [%s] not found!\n", backend_name));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ return ops->init(mem_ctx, ops, event_ctx, lp_ctx, ctx);
+}
+
+/*
+ initialise the SHARE subsystem
+*/
+NTSTATUS share_init(void)
+{
+ extern NTSTATUS share_ldb_init(void);
+ extern NTSTATUS share_classic_init(void);
+ init_module_fn static_init[] = { STATIC_share_MODULES };
+
+ run_init_functions(static_init);
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/param/share.h b/source4/param/share.h
new file mode 100644
index 0000000000..2a85fd4fbb
--- /dev/null
+++ b/source4/param/share.h
@@ -0,0 +1,137 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Modular services configuration
+
+ Copyright (C) Simo Sorce 2006
+
+ 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 _SHARE_H
+#define _SHARE_H
+
+struct share_ops;
+
+struct share_context {
+ const struct share_ops *ops;
+ void *priv_data;
+};
+
+struct share_config {
+ const char *name;
+ struct share_context *ctx;
+ void *opaque;
+};
+
+enum share_info_type {
+ SHARE_INFO_STRING,
+ SHARE_INFO_INT,
+ SHARE_INFO_BLOB
+};
+
+struct share_info {
+ enum share_info_type type;
+ const char *name;
+ void *value;
+};
+
+struct event_context;
+
+struct share_ops {
+ const char *name;
+ NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
+ struct share_context **);
+ const char *(*string_option)(struct share_config *, const char *, const char *);
+ int (*int_option)(struct share_config *, const char *, int);
+ bool (*bool_option)(struct share_config *, const char *, bool);
+ const char **(*string_list_option)(TALLOC_CTX *, struct share_config *, const char *);
+ NTSTATUS (*list_all)(TALLOC_CTX *, struct share_context *, int *, const char ***);
+ NTSTATUS (*get_config)(TALLOC_CTX *, struct share_context *, const char *, struct share_config **);
+ NTSTATUS (*create)(struct share_context *, const char *, struct share_info *, int);
+ NTSTATUS (*set)(struct share_context *, const char *, struct share_info *, int);
+ NTSTATUS (*remove)(struct share_context *, const char *);
+};
+
+struct loadparm_context;
+
+#include "param/share_proto.h"
+
+/* list of shares options */
+
+#define SHARE_NAME "name"
+#define SHARE_PATH "path"
+#define SHARE_COMMENT "comment"
+#define SHARE_PASSWORD "password"
+#define SHARE_HOSTS_ALLOW "hosts-allow"
+#define SHARE_HOSTS_DENY "hosts-deny"
+#define SHARE_NTVFS_HANDLER "ntvfs-handler"
+#define SHARE_TYPE "type"
+#define SHARE_VOLUME "volume"
+#define SHARE_CSC_POLICY "csc-policy"
+#define SHARE_AVAILABLE "available"
+#define SHARE_BROWSEABLE "browseable"
+#define SHARE_MAX_CONNECTIONS "max-connections"
+
+/* I'd like to see the following options go away
+ * and always use EAs and SECDESCs */
+#define SHARE_READONLY "readonly"
+#define SHARE_MAP_SYSTEM "map-system"
+#define SHARE_MAP_HIDDEN "map-hidden"
+#define SHARE_MAP_ARCHIVE "map-archive"
+
+#define SHARE_STRICT_LOCKING "strict-locking"
+#define SHARE_OPLOCKS "oplocks"
+#define SHARE_STRICT_SYNC "strict-sync"
+#define SHARE_MSDFS_ROOT "msdfs-root"
+#define SHARE_CI_FILESYSTEM "ci-filesystem"
+
+#define SHARE_DIR_MASK "directory mask"
+#define SHARE_CREATE_MASK "create mask"
+#define SHARE_FORCE_CREATE_MODE "force create mode"
+#define SHARE_FORCE_DIR_MODE "force directory mode"
+
+/* defaults */
+
+#define SHARE_HOST_ALLOW_DEFAULT NULL
+#define SHARE_HOST_DENY_DEFAULT NULL
+#define SHARE_VOLUME_DEFAULT NULL
+#define SHARE_TYPE_DEFAULT "DISK"
+#define SHARE_CSC_POLICY_DEFAULT 0
+#define SHARE_AVAILABLE_DEFAULT true
+#define SHARE_BROWSEABLE_DEFAULT true
+#define SHARE_MAX_CONNECTIONS_DEFAULT 0
+
+#define SHARE_DIR_MASK_DEFAULT 0755
+#define SHARE_CREATE_MASK_DEFAULT 0744
+#define SHARE_FORCE_CREATE_MODE_DEFAULT 0000
+#define SHARE_FORCE_DIR_MODE_DEFAULT 0000
+
+
+
+/* I'd like to see the following options go away
+ * and always use EAs and SECDESCs */
+#define SHARE_READONLY_DEFAULT true
+#define SHARE_MAP_SYSTEM_DEFAULT false
+#define SHARE_MAP_HIDDEN_DEFAULT false
+#define SHARE_MAP_ARCHIVE_DEFAULT true
+
+#define SHARE_STRICT_LOCKING_DEFAULT true
+#define SHARE_OPLOCKS_DEFAULT true
+#define SHARE_STRICT_SYNC_DEFAULT false
+#define SHARE_MSDFS_ROOT_DEFAULT false
+#define SHARE_CI_FILESYSTEM_DEFAULT false
+
+#endif /* _SHARE_H */
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
new file mode 100644
index 0000000000..bac1aac2d7
--- /dev/null
+++ b/source4/param/share_classic.c
@@ -0,0 +1,362 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Classic file based shares configuration
+
+ Copyright (C) Simo Sorce 2006
+
+ 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 "param/share.h"
+#include "param/param.h"
+
+static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx,
+ const struct share_ops *ops,
+ struct event_context *event_ctx,
+ struct loadparm_context *lp_ctx,
+ struct share_context **ctx)
+{
+ *ctx = talloc(mem_ctx, struct share_context);
+ if (!*ctx) {
+ DEBUG(0, ("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ (*ctx)->ops = ops;
+ (*ctx)->priv_data = lp_ctx;
+
+ return NT_STATUS_OK;
+}
+
+static const char *sclassic_string_option(struct share_config *scfg,
+ const char *opt_name,
+ const char *defval)
+{
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
+ struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+ struct loadparm_context);
+ char *parm, *val;
+ const char *ret;
+
+ if (strchr(opt_name, ':')) {
+ parm = talloc_strdup(scfg, opt_name);
+ if (!parm) {
+ return NULL;
+ }
+ val = strchr(parm, ':');
+ *val = '\0';
+ val++;
+
+ ret = lp_parm_string(lp_ctx, s, parm, val);
+ if (!ret) {
+ ret = defval;
+ }
+ talloc_free(parm);
+ return ret;
+ }
+
+ if (strcmp(opt_name, SHARE_NAME) == 0) {
+ return scfg->name;
+ }
+
+ if (strcmp(opt_name, SHARE_PATH) == 0) {
+ return lp_pathname(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_COMMENT) == 0) {
+ return lp_comment(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_VOLUME) == 0) {
+ return volume_label(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_TYPE) == 0) {
+ if (lp_print_ok(s, lp_default_service(lp_ctx))) {
+ return "PRINTER";
+ }
+ if (strcmp("NTFS", lp_fstype(s, lp_default_service(lp_ctx))) == 0) {
+ return "DISK";
+ }
+ return lp_fstype(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_PASSWORD) == 0) {
+ return defval;
+ }
+
+ DEBUG(0,("request for unknown share string option '%s'\n",
+ opt_name));
+
+ return defval;
+}
+
+static int sclassic_int_option(struct share_config *scfg, const char *opt_name, int defval)
+{
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
+ struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+ struct loadparm_context);
+ char *parm, *val;
+ int ret;
+
+ if (strchr(opt_name, ':')) {
+ parm = talloc_strdup(scfg, opt_name);
+ if (!parm) {
+ return -1;
+ }
+ val = strchr(parm, ':');
+ *val = '\0';
+ val++;
+
+ ret = lp_parm_int(lp_ctx, s, parm, val, defval);
+ if (!ret) {
+ ret = defval;
+ }
+ talloc_free(parm);
+ return ret;
+ }
+
+ if (strcmp(opt_name, SHARE_CSC_POLICY) == 0) {
+ return lp_csc_policy(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_MAX_CONNECTIONS) == 0) {
+ return lp_max_connections(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_CREATE_MASK) == 0) {
+ return lp_create_mask(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_DIR_MASK) == 0) {
+ return lp_dir_mask(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_FORCE_DIR_MODE) == 0) {
+ return lp_force_dir_mode(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_FORCE_CREATE_MODE) == 0) {
+ return lp_force_create_mode(s, lp_default_service(lp_ctx));
+ }
+
+
+ DEBUG(0,("request for unknown share int option '%s'\n",
+ opt_name));
+
+ return defval;
+}
+
+static bool sclassic_bool_option(struct share_config *scfg, const char *opt_name,
+ bool defval)
+{
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
+ struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+ struct loadparm_context);
+ char *parm, *val;
+ bool ret;
+
+ if (strchr(opt_name, ':')) {
+ parm = talloc_strdup(scfg, opt_name);
+ if(!parm) {
+ return false;
+ }
+ val = strchr(parm, ':');
+ *val = '\0';
+ val++;
+
+ ret = lp_parm_bool(lp_ctx, s, parm, val, defval);
+ talloc_free(parm);
+ return ret;
+ }
+
+ if (strcmp(opt_name, SHARE_AVAILABLE) == 0) {
+ return s != NULL;
+ }
+
+ if (strcmp(opt_name, SHARE_BROWSEABLE) == 0) {
+ return lp_browseable(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_READONLY) == 0) {
+ return lp_readonly(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_MAP_SYSTEM) == 0) {
+ return lp_map_system(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_MAP_HIDDEN) == 0) {
+ return lp_map_hidden(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_MAP_ARCHIVE) == 0) {
+ return lp_map_archive(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_STRICT_LOCKING) == 0) {
+ return lp_strict_locking(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_OPLOCKS) == 0) {
+ return lp_oplocks(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_STRICT_SYNC) == 0) {
+ return lp_strict_sync(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_MSDFS_ROOT) == 0) {
+ return lp_msdfs_root(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_CI_FILESYSTEM) == 0) {
+ return lp_ci_filesystem(s, lp_default_service(lp_ctx));
+ }
+
+ DEBUG(0,("request for unknown share bool option '%s'\n",
+ opt_name));
+
+ return defval;
+}
+
+static const char **sclassic_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
+{
+ struct loadparm_service *s = talloc_get_type(scfg->opaque,
+ struct loadparm_service);
+ struct loadparm_context *lp_ctx = talloc_get_type(scfg->ctx->priv_data,
+ struct loadparm_context);
+ char *parm, *val;
+ const char **ret;
+
+ if (strchr(opt_name, ':')) {
+ parm = talloc_strdup(scfg, opt_name);
+ if (!parm) {
+ return NULL;
+ }
+ val = strchr(parm, ':');
+ *val = '\0';
+ val++;
+
+ ret = lp_parm_string_list(mem_ctx, lp_ctx, s, parm, val, ",;");
+ talloc_free(parm);
+ return ret;
+ }
+
+ if (strcmp(opt_name, SHARE_HOSTS_ALLOW) == 0) {
+ return lp_hostsallow(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_HOSTS_DENY) == 0) {
+ return lp_hostsdeny(s, lp_default_service(lp_ctx));
+ }
+
+ if (strcmp(opt_name, SHARE_NTVFS_HANDLER) == 0) {
+ return lp_ntvfs_handler(s, lp_default_service(lp_ctx));
+ }
+
+ DEBUG(0,("request for unknown share list option '%s'\n",
+ opt_name));
+
+ return NULL;
+}
+
+static NTSTATUS sclassic_list_all(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ int *count,
+ const char ***names)
+{
+ int i;
+ int num_services;
+ const char **n;
+
+ num_services = lp_numservices((struct loadparm_context *)ctx->priv_data);
+
+ n = talloc_array(mem_ctx, const char *, num_services);
+ if (!n) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i = 0; i < num_services; i++) {
+ n[i] = talloc_strdup(n, lp_servicename(lp_servicebynum((struct loadparm_context *)ctx->priv_data, i)));
+ if (!n[i]) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ talloc_free(n);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ *names = n;
+ *count = num_services;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS sclassic_get_config(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ const char *name,
+ struct share_config **scfg)
+{
+ struct share_config *s;
+ struct loadparm_service *service;
+
+ service = lp_service((struct loadparm_context *)ctx->priv_data, name);
+
+ if (service == NULL) {
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ s = talloc(mem_ctx, struct share_config);
+ if (!s) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ s->name = talloc_strdup(s, lp_servicename(service));
+ if (!s->name) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ s->opaque = (void *)service;
+ s->ctx = ctx;
+
+ *scfg = s;
+
+ return NT_STATUS_OK;
+}
+
+static const struct share_ops ops = {
+ .name = "classic",
+ .init = sclassic_init,
+ .string_option = sclassic_string_option,
+ .int_option = sclassic_int_option,
+ .bool_option = sclassic_bool_option,
+ .string_list_option = sclassic_string_list_option,
+ .list_all = sclassic_list_all,
+ .get_config = sclassic_get_config
+};
+
+NTSTATUS share_classic_init(void)
+{
+ return share_register(&ops);
+}
+
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
new file mode 100644
index 0000000000..eba1665cc9
--- /dev/null
+++ b/source4/param/share_ldb.c
@@ -0,0 +1,592 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ LDB based shares configuration
+
+ Copyright (C) Simo Sorce 2006
+
+ 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 "ldb/include/ldb.h"
+#include "ldb/include/ldb_errors.h"
+#include "auth/auth.h"
+#include "ldb_wrap.h"
+#include "param/share.h"
+#include "param/param.h"
+
+static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
+ struct share_context **ctx)
+{
+ struct ldb_context *sdb;
+
+ *ctx = talloc(mem_ctx, struct share_context);
+ if (!*ctx) {
+ DEBUG(0, ("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ sdb = ldb_wrap_connect(*ctx, ev_ctx, lp_ctx,
+ private_path(*ctx, lp_ctx, "share.ldb"),
+ system_session(*ctx, lp_ctx),
+ NULL, 0, NULL);
+
+ if (!sdb) {
+ talloc_free(*ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ (*ctx)->ops = ops;
+ (*ctx)->priv_data = (void *)sdb;
+
+ return NT_STATUS_OK;
+}
+
+static const char *sldb_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
+{
+ struct ldb_message *msg;
+ struct ldb_message_element *el;
+
+ if (scfg == NULL) return defval;
+
+ msg = talloc_get_type(scfg->opaque, struct ldb_message);
+
+ if (strchr(opt_name, ':')) {
+ char *name, *p;
+
+ name = talloc_strdup(scfg, opt_name);
+ if (!name) {
+ return NULL;
+ }
+ p = strchr(name, ':');
+ *p = '-';
+
+ el = ldb_msg_find_element(msg, name);
+ } else {
+ el = ldb_msg_find_element(msg, opt_name);
+ }
+
+ if (el == NULL) {
+ return defval;
+ }
+
+ return (const char *)(el->values[0].data);
+}
+
+static int sldb_int_option(struct share_config *scfg, const char *opt_name, int defval)
+{
+ const char *val;
+ int ret;
+
+ val = sldb_string_option(scfg, opt_name, NULL);
+ if (val == NULL) return defval;
+
+ errno = 0;
+ ret = (int)strtol(val, NULL, 10);
+ if (errno) return -1;
+
+ return ret;
+}
+
+static bool sldb_bool_option(struct share_config *scfg, const char *opt_name, bool defval)
+{
+ const char *val;
+
+ val = sldb_string_option(scfg, opt_name, NULL);
+ if (val == NULL) return defval;
+
+ if (strcasecmp(val, "true") == 0) return true;
+
+ return false;
+}
+
+static const char **sldb_string_list_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name)
+{
+ struct ldb_message *msg;
+ struct ldb_message_element *el;
+ const char **list;
+ int i;
+
+ if (scfg == NULL) return NULL;
+
+ msg = talloc_get_type(scfg->opaque, struct ldb_message);
+
+ if (strchr(opt_name, ':')) {
+ char *name, *p;
+
+ name = talloc_strdup(scfg, opt_name);
+ if (!name) {
+ return NULL;
+ }
+ p = strchr(name, ':');
+ *p = '-';
+
+ el = ldb_msg_find_element(msg, name);
+ } else {
+ el = ldb_msg_find_element(msg, opt_name);
+ }
+
+ if (el == NULL) {
+ return NULL;
+ }
+
+ list = talloc_array(mem_ctx, const char *, el->num_values + 1);
+ if (!list) return NULL;
+
+ for (i = 0; i < el->num_values; i++) {
+ list[i] = (const char *)(el->values[i].data);
+ }
+ list[i] = NULL;
+
+ return list;
+}
+
+static NTSTATUS sldb_list_all(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ int *count,
+ const char ***names)
+{
+ int ret, i, j;
+ const char **n;
+ struct ldb_context *ldb;
+ struct ldb_result *res;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(mem_ctx);
+ if (!tmp_ctx) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ldb = talloc_get_type(ctx->priv_data, struct ldb_context);
+
+ ret = ldb_search(ldb, ldb_dn_new(tmp_ctx, ldb, "CN=SHARES"), LDB_SCOPE_SUBTREE, "(name=*)", NULL, &res);
+ talloc_steal(tmp_ctx, res);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ }
+
+ n = talloc_array(mem_ctx, const char *, res->count);
+ if (!n) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i = 0, j = 0; i < res->count; i++) {
+ n[j] = talloc_strdup(n, ldb_msg_find_attr_as_string(res->msgs[i], "name", NULL));
+ if (!n[j]) {
+ DEBUG(0,("WARNING: Malformed share object in share database\n!"));
+ continue;
+ }
+ j++;
+ }
+
+ *names = n;
+ *count = j;
+ talloc_free(tmp_ctx);
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS sldb_get_config(TALLOC_CTX *mem_ctx,
+ struct share_context *ctx,
+ const char *name,
+ struct share_config **scfg)
+{
+ int ret;
+ struct share_config *s;
+ struct ldb_context *ldb;
+ struct ldb_result *res;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(mem_ctx);
+ if (!tmp_ctx) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ldb = talloc_get_type(ctx->priv_data, struct ldb_context);
+
+ ret = ldb_search_exp_fmt(ldb, tmp_ctx, &res,
+ ldb_dn_new(tmp_ctx, ldb, "CN=SHARES"), LDB_SCOPE_SUBTREE, NULL,
+ "(name=%s)", name);
+ if (ret != LDB_SUCCESS || res->count > 1) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_INTERNAL_DB_CORRUPTION;
+ } else if (res->count != 1) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ }
+
+ s = talloc(tmp_ctx, struct share_config);
+ if (!s) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ s->name = talloc_strdup(s, ldb_msg_find_attr_as_string(res->msgs[0], "name", NULL));
+ if (!s->name) {
+ DEBUG(0,("ERROR: Invalid share object!\n"));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ s->opaque = talloc_steal(s, res->msgs[0]);
+ if (!s->opaque) {
+ DEBUG(0,("ERROR: Invalid share object!\n"));
+ talloc_free(tmp_ctx);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ s->ctx = ctx;
+
+ *scfg = talloc_steal(mem_ctx, s);
+
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
+
+#define SHARE_ADD_STRING(name, value) do { \
+ err = ldb_msg_add_string(msg, name, value); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add string share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+#define SHARE_ADD_INT(name, value) do { \
+ err = ldb_msg_add_fmt(msg, name, "%d", value); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add integer share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+#define SHARE_ADD_BLOB(name, value) do { \
+ err = ldb_msg_add_value(msg, name, value, NULL); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add blob share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+NTSTATUS sldb_create(struct share_context *ctx, const char *name, struct share_info *info, int count)
+{
+ struct ldb_context *ldb;
+ struct ldb_message *msg;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS ret;
+ int err, i, j;
+
+ for (i = 0, j = 0; i < count && j != 0x03; i++) {
+ if (strcasecmp(info[i].name, SHARE_TYPE) == 0) j |= 0x02;
+ if (strcasecmp(info[i].name, SHARE_PATH) == 0) j |= 0x01;
+ if (strcasecmp(info[i].name, SHARE_NAME) == 0) {
+ if (strcasecmp(name, (char *)info[i].value) != 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ }
+ }
+ if (!name || j != 0x03) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ldb = talloc_get_type(ctx->priv_data, struct ldb_context);
+
+ msg = ldb_msg_new(tmp_ctx);
+ if (!msg) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ /* TODO: escape info->name */
+ msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s,CN=SHARES", name);
+ if (!msg->dn) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ SHARE_ADD_STRING("objectClass", "top");
+ SHARE_ADD_STRING("objectClass", "share");
+ SHARE_ADD_STRING("cn", name);
+ SHARE_ADD_STRING(SHARE_NAME, name);
+
+ for (i = 0; i < count; i++) {
+ if (strcasecmp(info[i].name, SHARE_NAME) == 0) continue;
+
+ switch (info[i].type) {
+ case SHARE_INFO_STRING:
+ SHARE_ADD_STRING(info[i].name, (char *)info[i].value);
+ break;
+ case SHARE_INFO_INT:
+ SHARE_ADD_INT(info[i].name, *((int *)info[i].value));
+ break;
+ case SHARE_INFO_BLOB:
+ SHARE_ADD_BLOB(info[i].name, (DATA_BLOB *)info[i].value);
+ break;
+ default:
+ DEBUG(2,("ERROR: Invalid share info type for %s\n", info[i].name));
+ ret = NT_STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+ }
+
+ /* TODO: Security Descriptor */
+
+ SHARE_ADD_STRING(SHARE_AVAILABLE, "true");
+ SHARE_ADD_STRING(SHARE_BROWSEABLE, "true");
+ SHARE_ADD_STRING(SHARE_READONLY, "false");
+ SHARE_ADD_STRING(SHARE_NTVFS_HANDLER, "unixuid");
+ SHARE_ADD_STRING(SHARE_NTVFS_HANDLER, "posix");
+
+ err = ldb_add(ldb, msg);
+ if (err != LDB_SUCCESS) {
+ DEBUG(2,("ERROR: unable to add share %s to share.ldb\n"
+ " err=%d [%s]\n", name, err, ldb_errstring(ldb)));
+ if (err == LDB_ERR_NO_SUCH_OBJECT) {
+ ret = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ } else if (err == LDB_ERR_ENTRY_ALREADY_EXISTS) {
+ ret = NT_STATUS_OBJECT_NAME_COLLISION;
+ } else {
+ ret = NT_STATUS_UNSUCCESSFUL;
+ }
+ goto done;
+ }
+
+ ret = NT_STATUS_OK;
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+#define SHARE_MOD_STRING(name, value) do { \
+ err = ldb_msg_add_empty(msg, name, LDB_FLAG_MOD_REPLACE, NULL); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add string share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } \
+ err = ldb_msg_add_string(msg, name, value); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add string share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+#define SHARE_MOD_INT(name, value) do { \
+ err = ldb_msg_add_empty(msg, name, LDB_FLAG_MOD_REPLACE, NULL); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add string share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } \
+ err = ldb_msg_add_fmt(msg, name, "%d", value); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add integer share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+#define SHARE_MOD_BLOB(name, value) do { \
+ err = ldb_msg_add_empty(msg, name, LDB_FLAG_MOD_REPLACE, NULL); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add string share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } \
+ err = ldb_msg_add_value(msg, name, value, NULL); \
+ if (err != LDB_SUCCESS) { \
+ DEBUG(2,("ERROR: unable to add blob share option %s to ldb msg\n", name)); \
+ ret = NT_STATUS_UNSUCCESSFUL; \
+ goto done; \
+ } } while(0)
+
+NTSTATUS sldb_set(struct share_context *ctx, const char *name, struct share_info *info, int count)
+{
+ struct ldb_context *ldb;
+ struct ldb_message *msg;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS ret;
+ bool do_rename = false;
+ char *newname;
+ int err, i;
+
+ if (!name) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ldb = talloc_get_type(ctx->priv_data, struct ldb_context);
+
+ msg = ldb_msg_new(tmp_ctx);
+ if (!msg) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ /* TODO: escape name */
+ msg->dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s,CN=SHARES", name);
+ if (!msg->dn) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (strcasecmp(info[i].name, SHARE_NAME) == 0) {
+ if (strcasecmp(name, (char *)info[i].value) != 0) {
+ do_rename = true;
+ newname = (char *)info[i].value;
+ SHARE_MOD_STRING("cn", (char *)info[i].value);
+ }
+ }
+
+ switch (info[i].type) {
+ case SHARE_INFO_STRING:
+ SHARE_MOD_STRING(info[i].name, (char *)info[i].value);
+ break;
+ case SHARE_INFO_INT:
+ SHARE_MOD_INT(info[i].name, *((int *)info[i].value));
+ break;
+ case SHARE_INFO_BLOB:
+ SHARE_MOD_BLOB(info[i].name, (DATA_BLOB *)info[i].value);
+ break;
+ default:
+ DEBUG(2,("ERROR: Invalid share info type for %s\n", info[i].name));
+ ret = NT_STATUS_INVALID_PARAMETER;
+ goto done;
+ }
+ }
+
+ if (do_rename) {
+ struct ldb_dn *olddn, *newdn;
+
+ olddn = msg->dn;
+
+ /* TODO: escape newname */
+ newdn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s,CN=SHARES", newname);
+ if (!newdn) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ err = ldb_rename(ldb, olddn, newdn);
+ if (err != LDB_SUCCESS) {
+ DEBUG(2,("ERROR: unable to rename share %s (to %s)\n"
+ " err=%d [%s]\n", name, newname, err, ldb_errstring(ldb)));
+ if (err == LDB_ERR_NO_SUCH_OBJECT) {
+ ret = NT_STATUS_OBJECT_NAME_COLLISION;
+ } else {
+ ret = NT_STATUS_UNSUCCESSFUL;
+ }
+ goto done;
+ }
+
+ msg->dn = newdn;
+ }
+
+ err = ldb_modify(ldb, msg);
+ if (err != LDB_SUCCESS) {
+ DEBUG(2,("ERROR: unable to add share %s to share.ldb\n"
+ " err=%d [%s]\n", name, err, ldb_errstring(ldb)));
+ if (err == LDB_ERR_NO_SUCH_OBJECT) {
+ ret = NT_STATUS_OBJECT_NAME_COLLISION;
+ } else {
+ ret = NT_STATUS_UNSUCCESSFUL;
+ }
+ goto done;
+ }
+
+ ret = NT_STATUS_OK;
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+NTSTATUS sldb_remove(struct share_context *ctx, const char *name)
+{
+ struct ldb_context *ldb;
+ struct ldb_dn *dn;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS ret;
+ int err;
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ldb = talloc_get_type(ctx->priv_data, struct ldb_context);
+
+ dn = ldb_dn_new_fmt(tmp_ctx, ldb, "CN=%s,CN=SHARES", name);
+ if (!dn) {
+ DEBUG(0,("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ err = ldb_delete(ldb, dn);
+ if (err != LDB_SUCCESS) {
+ DEBUG(2,("ERROR: unable to remove share %s from share.ldb\n"
+ " err=%d [%s]\n", name, err, ldb_errstring(ldb)));
+ ret = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+
+ ret = NT_STATUS_OK;
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+static const struct share_ops ops = {
+ .name = "ldb",
+ .init = sldb_init,
+ .string_option = sldb_string_option,
+ .int_option = sldb_int_option,
+ .bool_option = sldb_bool_option,
+ .string_list_option = sldb_string_list_option,
+ .list_all = sldb_list_all,
+ .get_config = sldb_get_config,
+ .create = sldb_create,
+ .set = sldb_set,
+ .remove = sldb_remove
+};
+
+NTSTATUS share_ldb_init(void)
+{
+ return share_register(&ops);
+}
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
new file mode 100644
index 0000000000..d1d71e4485
--- /dev/null
+++ b/source4/param/tests/bindings.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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/>.
+#
+
+from samba import param
+import unittest
+
+class LoadParmTestCase(unittest.TestCase):
+ def test_init(self):
+ file = param.LoadParm()
+ self.assertTrue(file is not None)
+
+ def test_length(self):
+ file = param.LoadParm()
+ self.assertEquals(0, len(file))
+
+ def test_set_workgroup(self):
+ file = param.LoadParm()
+ file.set("workgroup", "bla")
+ self.assertEquals("BLA", file.get("workgroup"))
+
+ def test_is_mydomain(self):
+ file = param.LoadParm()
+ file.set("workgroup", "bla")
+ self.assertTrue(file.is_mydomain("BLA"))
+ self.assertFalse(file.is_mydomain("FOOBAR"))
+
+ def test_is_myname(self):
+ file = param.LoadParm()
+ file.set("netbios name", "bla")
+ self.assertTrue(file.is_myname("BLA"))
+ self.assertFalse(file.is_myname("FOOBAR"))
+
+ def test_load_default(self):
+ file = param.LoadParm()
+ file.load_default()
+
+class ParamTestCase(unittest.TestCase):
+ def test_init(self):
+ file = param.ParamFile()
+ self.assertTrue(file is not None)
+
+ def test_add_section(self):
+ file = param.ParamFile()
+ file.add_section("global")
+ self.assertTrue(file["global"] is not None)
+
+ def test_set_param_string(self):
+ file = param.ParamFile()
+ file.add_section("global")
+ file.set_string("data", "bar")
+ self.assertEquals("bar", file.get_string("data"))
+
+ def test_get_section(self):
+ file = param.ParamFile()
+ self.assertEquals(None, file.get_section("unknown"))
+ self.assertRaises(KeyError, lambda: file["unknown"])
diff --git a/source4/param/tests/loadparm.c b/source4/param/tests/loadparm.c
new file mode 100644
index 0000000000..49fcdf7249
--- /dev/null
+++ b/source4/param/tests/loadparm.c
@@ -0,0 +1,167 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 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 "param/share.h"
+#include "param/param.h"
+#include "torture/torture.h"
+
+static bool test_create(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_ctx != NULL, "lp_ctx");
+ return true;
+}
+
+static bool test_set_option(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "workgroup=werkgroep"), "lp_set_option failed");
+ torture_assert_str_equal(tctx, "WERKGROEP", lp_workgroup(lp_ctx), "workgroup");
+ return true;
+}
+
+static bool test_set_cmdline(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_cmdline(lp_ctx, "workgroup", "werkgroep"), "lp_set_cmdline failed");
+ torture_assert(tctx, lp_do_global_parameter(lp_ctx, "workgroup", "barbla"), "lp_set_option failed");
+ torture_assert_str_equal(tctx, "WERKGROEP", lp_workgroup(lp_ctx), "workgroup");
+ return true;
+}
+
+static bool test_do_global_parameter(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_do_global_parameter(lp_ctx, "workgroup", "werkgroep42"),
+ "lp_set_cmdline failed");
+ torture_assert_str_equal(tctx, lp_workgroup(lp_ctx), "WERKGROEP42", "workgroup");
+ return true;
+}
+
+
+static bool test_do_global_parameter_var(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_do_global_parameter_var(lp_ctx, "workgroup", "werk%s%d", "groep", 42),
+ "lp_set_cmdline failed");
+ torture_assert_str_equal(tctx, lp_workgroup(lp_ctx), "WERKGROEP42", "workgroup");
+ return true;
+}
+
+
+static bool test_set_option_invalid(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, !lp_set_option(lp_ctx, "workgroup"), "lp_set_option succeeded");
+ return true;
+}
+
+static bool test_set_option_parametric(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=blaat"), "lp_set_option failed");
+ torture_assert_str_equal(tctx, lp_parm_string(lp_ctx, NULL, "some", "thing"), "blaat",
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_parm_double(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=3.4"), "lp_set_option failed");
+ torture_assert(tctx, lp_parm_double(lp_ctx, NULL, "some", "thing", 2.0) == 3.4,
+ "invalid parametric option");
+ torture_assert(tctx, lp_parm_double(lp_ctx, NULL, "some", "bla", 2.0) == 2.0,
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_parm_bool(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=true"), "lp_set_option failed");
+ torture_assert(tctx, lp_parm_bool(lp_ctx, NULL, "some", "thing", false) == true,
+ "invalid parametric option");
+ torture_assert(tctx, lp_parm_bool(lp_ctx, NULL, "some", "bla", true) == true,
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_parm_int(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=34"), "lp_set_option failed");
+ torture_assert_int_equal(tctx, lp_parm_int(lp_ctx, NULL, "some", "thing", 20), 34,
+ "invalid parametric option");
+ torture_assert_int_equal(tctx, lp_parm_int(lp_ctx, NULL, "some", "bla", 42), 42,
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_parm_bytes(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ torture_assert(tctx, lp_set_option(lp_ctx, "some:thing=16K"), "lp_set_option failed");
+ torture_assert_int_equal(tctx, lp_parm_bytes(lp_ctx, NULL, "some", "thing", 20), 16 * 1024,
+ "invalid parametric option");
+ torture_assert_int_equal(tctx, lp_parm_bytes(lp_ctx, NULL, "some", "bla", 42), 42,
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_do_service_parameter(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ struct loadparm_service *service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), "foo");
+ torture_assert(tctx, lp_do_service_parameter(lp_ctx, service,
+ "some:thing", "foo"), "lp_set_option failed");
+ torture_assert_str_equal(tctx, lp_parm_string(lp_ctx, service, "some", "thing"), "foo",
+ "invalid parametric option");
+ return true;
+}
+
+static bool test_lp_service(struct torture_context *tctx)
+{
+ struct loadparm_context *lp_ctx = loadparm_init(tctx);
+ struct loadparm_service *service = lp_add_service(lp_ctx, lp_default_service(lp_ctx), "foo");
+ torture_assert(tctx, service == lp_service(lp_ctx, "foo"), "invalid service");
+ return true;
+}
+
+struct torture_suite *torture_local_loadparm(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "LOADPARM");
+
+ torture_suite_add_simple_test(suite, "create", test_create);
+ torture_suite_add_simple_test(suite, "set_option", test_set_option);
+ torture_suite_add_simple_test(suite, "set_cmdline", test_set_cmdline);
+ torture_suite_add_simple_test(suite, "set_option_invalid", test_set_option_invalid);
+ torture_suite_add_simple_test(suite, "set_option_parametric", test_set_option_parametric);
+ torture_suite_add_simple_test(suite, "set_lp_parm_double", test_lp_parm_double);
+ torture_suite_add_simple_test(suite, "set_lp_parm_bool", test_lp_parm_bool);
+ torture_suite_add_simple_test(suite, "set_lp_parm_int", test_lp_parm_int);
+ torture_suite_add_simple_test(suite, "set_lp_parm_bytes", test_lp_parm_bytes);
+ torture_suite_add_simple_test(suite, "service_parameter", test_lp_do_service_parameter);
+ torture_suite_add_simple_test(suite, "lp_service", test_lp_service);
+ torture_suite_add_simple_test(suite, "do_global_parameter_var", test_do_global_parameter_var);
+ torture_suite_add_simple_test(suite, "do_global_parameter", test_do_global_parameter);
+
+ return suite;
+}
diff --git a/source4/param/tests/share.c b/source4/param/tests/share.c
new file mode 100644
index 0000000000..c64b5c607a
--- /dev/null
+++ b/source4/param/tests/share.c
@@ -0,0 +1,215 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ local testing of share code
+
+ Copyright (C) Jelmer Vernooij 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 "param/share.h"
+#include "param/param.h"
+#include "torture/torture.h"
+
+static bool test_list_empty(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ int count;
+ const char **names;
+
+ torture_assert_ntstatus_ok(tctx, share_list_all(tctx, ctx, &count, &names),
+ "share_list_all failed");
+
+ return true;
+}
+
+static bool test_create(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ int count;
+ const char **names;
+ int i;
+ bool found = false;
+ struct share_info inf[] = {
+ { SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") },
+ { SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") }
+ };
+ NTSTATUS status;
+
+ status = share_create(ctx, "bloe", inf, 2);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED))
+ torture_skip(tctx, "Not supported by backend");
+
+ torture_assert_ntstatus_ok(tctx, status, "create_share failed");
+
+ torture_assert_ntstatus_ok(tctx, share_list_all(tctx, ctx, &count, &names),
+ "share_list_all failed");
+
+ torture_assert(tctx, count >= 1, "creating share failed");
+
+
+ for (i = 0; i < count; i++) {
+ found |= strcmp(names[i], "bloe") == 0;
+ }
+
+ torture_assert(tctx, found, "created share found");
+
+ return true;
+}
+
+
+static bool test_create_invalid(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ NTSTATUS status;
+
+ status = share_create(ctx, "bla", NULL, 0);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED))
+ torture_skip(tctx, "Not supported by backend");
+
+ torture_assert_ntstatus_equal(tctx, NT_STATUS_INVALID_PARAMETER,
+ status,
+ "create_share failed");
+
+ torture_assert_ntstatus_equal(tctx, NT_STATUS_INVALID_PARAMETER,
+ share_create(ctx, NULL, NULL, 0),
+ "create_share failed");
+
+ return true;
+}
+
+static bool test_share_remove_invalid(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ NTSTATUS status;
+
+ status = share_remove(ctx, "nonexistant");
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED))
+ torture_skip(tctx, "Not supported by backend");
+
+ torture_assert_ntstatus_equal(tctx, status, NT_STATUS_UNSUCCESSFUL, "remove fails");
+
+ return true;
+}
+
+
+
+static bool test_share_remove(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ struct share_info inf[] = {
+ { SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") },
+ { SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") }
+ };
+ NTSTATUS status;
+
+ status = share_create(ctx, "blie", inf, 2);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED))
+ torture_skip(tctx, "Not supported by backend");
+
+ torture_assert_ntstatus_ok(tctx, status, "create_share failed");
+
+ torture_assert_ntstatus_ok(tctx, share_remove(ctx, "blie"), "remove failed");
+
+ return true;
+}
+
+static bool test_double_create(struct torture_context *tctx,
+ const void *tcase_data,
+ const void *test_data)
+{
+ struct share_context *ctx = (struct share_context *)discard_const(tcase_data);
+ struct share_info inf[] = {
+ { SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") },
+ { SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") }
+ };
+ NTSTATUS status;
+
+ status = share_create(ctx, "bla", inf, 2);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED))
+ torture_skip(tctx, "Not supported by backend");
+
+ torture_assert_ntstatus_ok(tctx, status, "create_share failed");
+
+ torture_assert_ntstatus_equal(tctx, NT_STATUS_OBJECT_NAME_COLLISION,
+ share_create(ctx, "bla", inf, 2),
+ "create_share failed");
+
+ return true;
+}
+
+static void tcase_add_share_tests(struct torture_tcase *tcase)
+{
+ torture_tcase_add_test_const(tcase, "list_empty", test_list_empty,NULL);
+ torture_tcase_add_test_const(tcase, "share_create", test_create, NULL);
+ torture_tcase_add_test_const(tcase, "share_remove", test_share_remove,
+ NULL);
+ torture_tcase_add_test_const(tcase, "share_remove_invalid",
+ test_share_remove_invalid, NULL);
+ torture_tcase_add_test_const(tcase, "share_create_invalid",
+ test_create_invalid, NULL);
+ torture_tcase_add_test_const(tcase, "share_double_create",
+ test_double_create, NULL);
+}
+
+static bool setup_ldb(struct torture_context *tctx, void **data)
+{
+ return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
+}
+
+static bool setup_classic(struct torture_context *tctx, void **data)
+{
+ return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
+}
+
+static bool teardown(struct torture_context *tctx, void *data)
+{
+ talloc_free(data);
+ return true;
+}
+
+struct torture_suite *torture_local_share(TALLOC_CTX *mem_ctx)
+{
+ struct torture_suite *suite = torture_suite_create(mem_ctx, "SHARE");
+ struct torture_tcase *tcase;
+
+ share_init();
+
+ tcase = torture_suite_add_tcase(suite, "ldb");
+ torture_tcase_set_fixture(tcase, setup_ldb, teardown);
+ tcase_add_share_tests(tcase);
+
+ tcase = torture_suite_add_tcase(suite, "classic");
+ torture_tcase_set_fixture(tcase, setup_classic, teardown);
+ tcase_add_share_tests(tcase);
+
+ return suite;
+}
diff --git a/source4/param/util.c b/source4/param/util.c
new file mode 100644
index 0000000000..ec192939d0
--- /dev/null
+++ b/source4/param/util.c
@@ -0,0 +1,297 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 2001-2002
+ Copyright (C) Simo Sorce 2001
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
+ Copyright (C) James J Myers 2003
+ Copyright (C) Jelmer Vernooij 2005-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 "dynconfig/dynconfig.h"
+#include "system/network.h"
+#include "system/filesys.h"
+#include "system/dir.h"
+#include "param/param.h"
+
+/**
+ * @file
+ * @brief Misc utility functions
+ */
+
+
+bool lp_is_mydomain(struct loadparm_context *lp_ctx,
+ const char *domain)
+{
+ return strequal(lp_workgroup(lp_ctx), domain);
+}
+
+/**
+ see if a string matches either our primary or one of our secondary
+ netbios aliases. do a case insensitive match
+*/
+bool lp_is_myname(struct loadparm_context *lp_ctx, const char *name)
+{
+ const char **aliases;
+ int i;
+
+ if (strcasecmp(name, lp_netbios_name(lp_ctx)) == 0) {
+ return true;
+ }
+
+ aliases = lp_netbios_aliases(lp_ctx);
+ for (i=0; aliases && aliases[i]; i++) {
+ if (strcasecmp(name, aliases[i]) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+/**
+ A useful function for returning a path in the Samba lock directory.
+**/
+char *lock_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
+{
+ char *fname, *dname;
+ if (name == NULL) {
+ return NULL;
+ }
+ if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) {
+ return talloc_strdup(mem_ctx, name);
+ }
+
+ dname = talloc_strdup(mem_ctx, lp_lockdir(lp_ctx));
+ trim_string(dname,"","/");
+
+ if (!directory_exist(dname)) {
+ mkdir(dname,0755);
+ }
+
+ fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name);
+
+ talloc_free(dname);
+
+ return fname;
+}
+
+/**
+ * @brief Returns an absolute path to a file in the directory containing the current config file
+ *
+ * @param name File to find, relative to the config file directory.
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+
+char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
+{
+ char *fname, *config_dir, *p;
+ config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx));
+ if (config_dir == NULL) {
+ return NULL;
+ }
+ p = strrchr(config_dir, '/');
+ if (p == NULL) {
+ return NULL;
+ }
+ p[0] = '\0';
+ fname = talloc_asprintf(mem_ctx, "%s/%s", config_dir, name);
+ talloc_free(config_dir);
+ return fname;
+}
+
+/**
+ * @brief Returns an absolute path to a file in the Samba private directory.
+ *
+ * @param name File to find, relative to PRIVATEDIR.
+ * if name is not relative, then use it as-is
+ *
+ * @retval Pointer to a talloc'ed string containing the full path.
+ **/
+char *private_path(TALLOC_CTX* mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name)
+{
+ char *fname;
+ if (name == NULL) {
+ return NULL;
+ }
+ if (name[0] == 0 || name[0] == '/' || strstr(name, ":/")) {
+ return talloc_strdup(mem_ctx, name);
+ }
+ fname = talloc_asprintf(mem_ctx, "%s/%s", lp_private_dir(lp_ctx), name);
+ return fname;
+}
+
+/**
+ return a path in the smbd.tmp directory, where all temporary file
+ for smbd go. If NULL is passed for name then return the directory
+ path itself
+*/
+char *smbd_tmp_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name)
+{
+ char *fname, *dname;
+
+ dname = private_path(mem_ctx, lp_ctx, "smbd.tmp");
+ if (!directory_exist(dname)) {
+ mkdir(dname,0755);
+ }
+
+ if (name == NULL) {
+ return dname;
+ }
+
+ fname = talloc_asprintf(mem_ctx, "%s/%s", dname, name);
+ talloc_free(dname);
+
+ return fname;
+}
+
+/**
+ * Obtain the init function from a shared library file
+ */
+init_module_fn load_module(TALLOC_CTX *mem_ctx, const char *path)
+{
+ void *handle;
+ void *init_fn;
+
+ handle = dlopen(path, RTLD_NOW);
+ if (handle == NULL) {
+ DEBUG(0, ("Unable to open %s: %s\n", path, dlerror()));
+ return NULL;
+ }
+
+ init_fn = dlsym(handle, SAMBA_INIT_MODULE);
+
+ if (init_fn == NULL) {
+ DEBUG(0, ("Unable to find init_module() in %s: %s\n", path, dlerror()));
+ DEBUG(1, ("Loading module '%s' failed\n", path));
+ dlclose(handle);
+ return NULL;
+ }
+
+ return (init_module_fn)init_fn;
+}
+
+/**
+ * Obtain list of init functions from the modules in the specified
+ * directory
+ */
+init_module_fn *load_modules(TALLOC_CTX *mem_ctx, const char *path)
+{
+ DIR *dir;
+ struct dirent *entry;
+ char *filename;
+ int success = 0;
+ init_module_fn *ret = talloc_array(mem_ctx, init_module_fn, 2);
+
+ ret[0] = NULL;
+
+ dir = opendir(path);
+ if (dir == NULL) {
+ talloc_free(ret);
+ return NULL;
+ }
+
+ while((entry = readdir(dir))) {
+ if (ISDOT(entry->d_name) || ISDOTDOT(entry->d_name))
+ continue;
+
+ filename = talloc_asprintf(mem_ctx, "%s/%s", path, entry->d_name);
+
+ ret[success] = load_module(mem_ctx, filename);
+ if (ret[success]) {
+ ret = talloc_realloc(mem_ctx, ret, init_module_fn, success+2);
+ success++;
+ ret[success] = NULL;
+ }
+
+ talloc_free(filename);
+ }
+
+ closedir(dir);
+
+ return ret;
+}
+
+/**
+ * Run the specified init functions.
+ *
+ * @return true if all functions ran successfully, false otherwise
+ */
+bool run_init_functions(init_module_fn *fns)
+{
+ int i;
+ bool ret = true;
+
+ if (fns == NULL)
+ return true;
+
+ for (i = 0; fns[i]; i++) { ret &= (bool)NT_STATUS_IS_OK(fns[i]()); }
+
+ return ret;
+}
+
+static char *modules_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name)
+{
+ const char *env_moduledir = getenv("LD_SAMBA_MODULE_PATH");
+ return talloc_asprintf(mem_ctx, "%s/%s",
+ env_moduledir?env_moduledir:lp_modulesdir(lp_ctx),
+ name);
+}
+
+/**
+ * Load the initialization functions from DSO files for a specific subsystem.
+ *
+ * Will return an array of function pointers to initialization functions
+ */
+
+init_module_fn *load_samba_modules(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *subsystem)
+{
+ char *path = modules_path(mem_ctx, lp_ctx, subsystem);
+ init_module_fn *ret;
+
+ ret = load_modules(mem_ctx, path);
+
+ talloc_free(path);
+
+ return ret;
+}
+
+const char *lp_messaging_path(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx)
+{
+ return smbd_tmp_path(mem_ctx, lp_ctx, "messaging");
+}
+
+struct smb_iconv_convenience *smb_iconv_convenience_init_lp(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx)
+{
+ return smb_iconv_convenience_init(mem_ctx, lp_dos_charset(lp_ctx),
+ lp_unix_charset(lp_ctx),
+ lp_parm_bool(lp_ctx, NULL, "iconv", "native", true));
+}
+
+