Simplify the way module initialization functions are handled.
{
static bool initialized = false;
- init_module_fn static_init[] = STATIC_auth_MODULES;
+ init_module_fn static_init[] = { STATIC_auth_MODULES, NULL };
if (initialized) return NT_STATUS_OK;
initialized = true;
#######################
[PYTHON::swig_auth]
-PUBLIC_DEPENDENCIES = auth_system_session LIBPYTHON
+PUBLIC_DEPENDENCIES = auth_system_session
PRIVATE_DEPENDENCIES = SAMDB
SWIG_FILE = auth.i
SECRETS
[PYTHON::swig_credentials]
-PUBLIC_DEPENDENCIES = CREDENTIALS LIBPYTHON
+PUBLIC_DEPENDENCIES = CREDENTIALS
SWIG_FILE = credentials.i
{
static bool initialized = false;
- init_module_fn static_init[] = STATIC_gensec_MODULES;
+ init_module_fn static_init[] = { STATIC_gensec_MODULES, NULL };
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
foreach my $part (values %{$depend}) {
next if (defined($only) and not contains($only,$part->{NAME}));
- foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}},
- @{$part->{PRIVATE_DEPENDENCIES}}) {
- $res .= "\t\"$part->{NAME}\" -> \"$elem\";\n";
+ foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}}) {
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* public */\n";
+ }
+ foreach my $elem (@{$part->{PRIVATE_DEPENDENCIES}}) {
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* private */\n";
}
}
$name =~ s/-/_/g;
$DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
$DEFINE->{KEY} = "STATIC_$name\_MODULES";
- $DEFINE->{VAL} = "{ \\\n";
+ $DEFINE->{VAL} = "\\\n";
foreach (@{$key->{INIT_FUNCTIONS}}) {
$DEFINE->{VAL} .= "\t$_, \\\n";
- my $fn = $key->{INIT_FUNCTION_TYPE};
- unless(defined($fn)) { $fn = "NTSTATUS (*) (void)"; }
- $fn =~ s/\(\*\)/$_/;
- $output .= "$fn;\n";
+ unless (/{/) {
+ my $fn = $key->{INIT_FUNCTION_TYPE};
+ unless(defined($fn)) { $fn = "NTSTATUS (*) (void)"; }
+ $fn =~ s/\(\*\)/$_/;
+ $output .= "$fn;\n";
+ }
}
- $DEFINE->{VAL} .= "\tNULL \\\n }";
+ $DEFINE->{VAL} =~ s/, \\\n$//g; # Remove the last comma
push(@defines,$DEFINE);
}
my $sane_subsystem = lc($mod->{SUBSYSTEM});
$sane_subsystem =~ s/^lib//;
$mod->{INSTALLDIR} = "MODULESDIR/$sane_subsystem";
- push (@{$mod->{PRIVATE_DEPENDENCIES}}, $mod->{SUBSYSTEM});
+ push (@{$mod->{PUBLIC_DEPENDENCIES}}, $mod->{SUBSYSTEM});
}
if (grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}})) {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
add_libreplace($lib);
}
-sub check_python($$)
+sub check_python($$$)
{
- my ($INPUT, $python) = @_;
+ my ($INPUT, $python, $default_ot) = @_;
return if ($INPUT->{LIBPYTHON}{ENABLE} ne "YES");
$python->{INSTALLDIR} = "PYTHONDIR";
- push (@{$python->{PUBLIC_DEPENDENCIES}}, "LIBPYTHON");
+ unless (defined($python->{CFLAGS})) { $python->{CFLAGS} = []; }
if (defined($python->{SWIG_FILE})) {
my $dirname = dirname($python->{SWIG_FILE});
my $basename = basename($python->{SWIG_FILE}, ".i");
$python->{OBJ_FILES} = ["$dirname$basename\_wrap.o"];
$python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
$python->{PYTHON_FILES} = ["$dirname$basename.py"];
- unless (defined($python->{CFLAGS})) { $python->{CFLAGS} = []; }
push (@{$python->{CFLAGS}}, $config::config{CFLAG_NO_UNUSED_MACROS});
push (@{$python->{CFLAGS}}, $config::config{CFLAG_NO_CAST_QUAL});
+ $python->{INIT_FUNCTION} = "{ (char *)\"_$basename\", init_$basename }";
} else {
my $basename = $python->{NAME};
$basename =~ s/^python_//g;
$python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
+ $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
}
+ push (@{$python->{CFLAGS}}, @{$INPUT->{EXT_LIB_PYTHON}->{CFLAGS}});
$python->{SUBSYSTEM} = "LIBPYTHON";
- check_module($INPUT, $python, ["SHARED_LIBRARY"]);
+ check_module($INPUT, $python, $default_ot);
}
sub check_binary($$)
push (@{$lib->{FULL_OBJ_LIST}}, "\$($mod->{TYPE}_$mod->{NAME}_FULL_OBJ_LIST)");
push (@{$lib->{LINK_FLAGS}}, "\$($mod->{TYPE}_$mod->{NAME}_LINK_FLAGS)");
- push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PUBLIC_DEPENDENCIES}}) if defined($mod->{PUBLIC_DEPENDENCIES});
+ push (@{$lib->{CFLAGS}}, @{$mod->{CFLAGS}}) if defined($mod->{CFLAGS});
+ push (@{$lib->{PUBLIC_DEPENDENCIES}}, @{$mod->{PUBLIC_DEPENDENCIES}}) if defined($mod->{PUBLIC_DEPENDENCIES});
push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PRIVATE_DEPENDENCIES}}) if defined($mod->{PRIVATE_DEPENDENCIES});
$mod->{ENABLE} = "NO";
} elsif ($part->{TYPE} eq "BINARY") {
check_binary($INPUT, $part);
} elsif ($part->{TYPE} eq "PYTHON") {
- check_python($INPUT, $part);
+ check_python($INPUT, $part, $module_ot);
} elsif ($part->{TYPE} eq "EXT_LIB") {
} else {
die("Unknown type $part->{TYPE}");
static void event_backend_init(void)
{
#if _SAMBA_BUILD_
- init_module_fn static_init[] = STATIC_LIBEVENTS_MODULES;
+ init_module_fn static_init[] = { STATIC_LIBEVENTS_MODULES, NULL };
init_module_fn *shared_init;
if (event_backends) return;
shared_init = load_samba_modules(NULL, global_loadparm, "events");
int ldb_global_init(void)
{
- int (*static_init_fns[])(void) = STATIC_LIBLDB_MODULES;
+ int (*static_init_fns[])(void) = { STATIC_LIBLDB_MODULES, NULL };
static int initialized = 0;
int ret = 0, i;
#######################
# Start LIBRARY swig_ldb
[PYTHON::swig_ldb]
-PUBLIC_DEPENDENCIES = LIBLDB LIBPYTHON
+PUBLIC_DEPENDENCIES = LIBLDB
SWIG_FILE = ldb.i
# End LIBRARY swig_ldb
#######################
tests/registry.o
[PYTHON::swig_registry]
-PUBLIC_DEPENDENCIES = registry LIBPYTHON
+PUBLIC_DEPENDENCIES = registry
SWIG_FILE = registry.i
NTSTATUS ntptr_init(struct loadparm_context *lp_ctx)
{
- init_module_fn static_init[] = STATIC_ntptr_MODULES;
+ init_module_fn static_init[] = { STATIC_ntptr_MODULES, NULL };
init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "ntptr");
run_init_functions(static_init);
NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
{
static bool initialized = false;
- init_module_fn static_init[] = STATIC_ntvfs_MODULES;
+ init_module_fn static_init[] = { STATIC_ntvfs_MODULES, NULL };
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
{
static bool initialized = false;
- init_module_fn static_init[] = STATIC_sys_notify_MODULES;
+ init_module_fn static_init[] = { STATIC_sys_notify_MODULES, NULL };
init_module_fn *shared_init;
if (initialized) return NT_STATUS_OK;
struct param_opt *opt = param_get_add($self, parameter, section_name);
talloc_free(opt->value);
- opt->value = talloc_strdup(opt, PyObject_Str(ob));
+ opt->value = talloc_strdup(opt, PyString_AsString(PyObject_Str(ob)));
return 0;
}
struct param_opt *opt = param_get_add(self, parameter, section_name);
talloc_free(opt->value);
- opt->value = talloc_strdup(opt, PyObject_Str(ob));
+ opt->value = talloc_strdup(opt, PyString_AsString(PyObject_Str(ob)));
return 0;
}
*/
NTSTATUS share_init(void)
{
- init_module_fn static_init[] = STATIC_share_MODULES;
+ init_module_fn static_init[] = { STATIC_share_MODULES, NULL };
run_init_functions(static_init);
NTSTATUS server_service_rpc_init(void)
{
- init_module_fn static_init[] = STATIC_dcerpc_server_MODULES;
+ init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES, NULL };
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
run_init_functions(static_init);
*/
void smb_setup_ejs_functions(void (*exception_handler)(const char *))
{
- init_module_fn static_init[] = STATIC_smbcalls_MODULES;
+ init_module_fn static_init[] = { STATIC_smbcalls_MODULES, NULL };
init_module_fn *shared_init;
ejs_exception_handler = exception_handler;
PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags`
-SMB_EXT_LIB(LIBPYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS])
+SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS])
AC_MSG_CHECKING(working python module support)
if test x$working_python = xyes
],[
Py_InitModule(NULL, NULL);
],[
- SMB_ENABLE(LIBPYTHON,YES)
+ SMB_ENABLE(EXT_LIB_PYTHON,YES)
SMB_ENABLE(smbpython,YES)
+ SMB_ENABLE(LIBPYTHON,YES)
AC_MSG_RESULT([yes])
],[
+ SMB_ENABLE(EXT_LIB_PYTHON,NO)
SMB_ENABLE(LIBPYTHON,NO)
SMB_ENABLE(smbpython,NO)
AC_MSG_RESULT([no])
LIBS="$ac_save_LIBS"
CFLAGS="$ac_save_CFLAGS"
else
- SMB_ENABLE(LIBPYTHON,NO)
+ SMB_ENABLE(EXT_LIB_PYTHON,NO)
+ SMB_ENABLE(LIBPYTHONyy,NO)
SMB_ENABLE(smbpython,NO)
AC_MSG_RESULT([no])
fi
[BINARY::smbpython]
PRIVATE_DEPENDENCIES = LIBPYTHON
-OBJ_FILES = \
- smbpython.o
+OBJ_FILES = smbpython.o
+
+[SUBSYSTEM::LIBPYTHON]
+PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON
+OBJ_FILES = modules.o
[PYTHON::python_uuid]
PRIVATE_DEPENDENCIES = LIBNDR
--- /dev/null
+/*
+ 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 <Python.h>
+#include "build.h"
+
+extern void init_ldb(void);
+extern void init_security(void);
+extern void init_registry(void);
+extern void init_param(void);
+extern void init_misc(void);
+extern void init_ldb(void);
+extern void init_auth(void);
+extern void init_credentials(void);
+extern void init_tdb(void);
+extern void init_dcerpc(void);
+extern void init_events(void);
+extern void inituuid(void);
+
+static struct _inittab py_modules[] = { STATIC_LIBPYTHON_MODULES };
+
+void py_load_samba_modules(void)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(py_modules); i++) {
+ PyImport_ExtendInittab(&py_modules[i]);
+ }
+}
#include "includes.h"
#include <Python.h>
-int main(int argc, char **argv) {
+void py_load_samba_modules(void);
+
+int main(int argc, char **argv)
+{
+ py_load_samba_modules();
return Py_Main(argc,argv);
}
struct GUID guid;
char *str;
- if (!PyArg_ParseTuple(args, ""))
+ if (!PyArg_ParseTuple(args, (char *)""))
return NULL;
guid = GUID_random();
PyMODINIT_FUNC inituuid(void)
{
- PyObject *mod = Py_InitModule3("uuid", methods, param_doc);
+ PyObject *mod = Py_InitModule3((char *)"uuid", methods, param_doc);
if (mod == NULL)
return;
}
push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\"");
push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\"");
if (defined($ENV{PROVISION_PYTHON})) {
+ push (@provision_options, "$self->{bindir}/smbpython");
push (@provision_options, "$self->{setupdir}/provision.py");
} else {
push (@provision_options, "$self->{bindir}/smbscript");
NTSTATUS process_model_init(struct loadparm_context *lp_ctx)
{
- init_module_fn static_init[] = STATIC_process_model_MODULES;
+ init_module_fn static_init[] = { STATIC_process_model_MODULES, NULL };
init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "process_model");
run_init_functions(static_init);
bool opt_interactive = false;
int opt;
poptContext pc;
- init_module_fn static_init[] = STATIC_service_MODULES;
+ init_module_fn static_init[] = { STATIC_service_MODULES, NULL };
init_module_fn *shared_init;
struct event_context *event_ctx;
NTSTATUS status;
int torture_init(void)
{
- init_module_fn static_init[] = STATIC_torture_MODULES;
+ init_module_fn static_init[] = { STATIC_torture_MODULES, NULL };
init_module_fn *shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "torture");
run_init_functions(static_init);