Author: jelmer Date: 2007-11-21 12:32:40 +0000 (Wed, 21 Nov 2007) New Revision: 26082
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26082 Log: Convert misc to swig. Added: branches/4.0-python/source/scripting/python/misc.i Removed: branches/4.0-python/source/scripting/python/miscmodule.c Modified: branches/4.0-python/ branches/4.0-python/.bzrignore branches/4.0-python/source/lib/ldb/ldb.i branches/4.0-python/source/scripting/python/config.mk branches/4.0-python/source/scripting/python/samba/__init__.py Changeset: Property changes on: branches/4.0-python ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:file-ids ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/4.0-python/.bzrignore =================================================================== --- branches/4.0-python/.bzrignore 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/.bzrignore 2007-11-21 12:32:40 UTC (rev 26082) @@ -239,3 +239,5 @@ source/librpc/rpc/dcerpc.py source/libcli/swig/libcli_nbt.py source/apidocs +source/scripting/python/misc.py +source/scripting/python/misc_wrap.c Modified: branches/4.0-python/source/lib/ldb/ldb.i =================================================================== --- branches/4.0-python/source/lib/ldb/ldb.i 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/source/lib/ldb/ldb.i 2007-11-21 12:32:40 UTC (rev 26082) @@ -25,7 +25,7 @@ License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -%module ldb +%module(package="ldb") ldb %{ Modified: branches/4.0-python/source/scripting/python/config.mk =================================================================== --- branches/4.0-python/source/scripting/python/config.mk 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/source/scripting/python/config.mk 2007-11-21 12:32:40 UTC (rev 26082) @@ -11,5 +11,5 @@ OBJ_FILES = sidmodule.o [PYTHON::python_misc] -PRIVATE_DEPENDENCIES = LIBNDR -OBJ_FILES = miscmodule.o +PRIVATE_DEPENDENCIES = LIBNDR LIBLDB +SWIG_FILE = misc.i Added: branches/4.0-python/source/scripting/python/misc.i =================================================================== --- branches/4.0-python/source/scripting/python/misc.i 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/source/scripting/python/misc.i 2007-11-21 12:32:40 UTC (rev 26082) @@ -0,0 +1,32 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 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(package="samba.misc") misc + +%{ +#include "includes.h" +#include "ldb.h" +#include "auth/credentials/credentials.h" +%} + +%import "stdint.i" +%import "../../lib/talloc/talloc.i" + +%rename(random_password) generate_random_str; +char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len); + Deleted: branches/4.0-python/source/scripting/python/miscmodule.c =================================================================== --- branches/4.0-python/source/scripting/python/miscmodule.c 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/source/scripting/python/miscmodule.c 2007-11-21 12:32:40 UTC (rev 26082) @@ -1,65 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba utility functions - Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 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 "scripting/python/talloc.h" -#include "Python.h" - -static PyObject *py_random_password(PyObject *self, PyObject *args) -{ - int length; - char *str; - - if (!PyArg_ParseTuple(args, "i", &length)) - return NULL; - - str = generate_random_str(NULL, length); - - if (str == NULL) { - PyErr_SetString(PyExc_TypeError, "can't generate random password"); - return NULL; - } - - return PyString_FromString(str); -} - -static PyObject *py_nttime(PyObject *self, PyObject *args) -{ - struct timeval tv = timeval_current(); - - if (!PyArg_ParseTuple(args, "")) - return NULL; - - return PyInt_FromLong(timeval_to_nttime(&tv)); -} - -static PyMethodDef methods[] = { - { "random_password", (PyCFunction)py_random_password, METH_VARARGS, NULL}, - { "nttime", (PyCFunction)py_nttime, METH_VARARGS, NULL }, - { NULL, NULL } -}; - -PyDoc_STRVAR(param_doc, "Misc helper routines"); - -PyMODINIT_FUNC initmisc(void) -{ - PyObject *mod = Py_InitModule3("misc", methods, param_doc); - if (mod == NULL) - return; -} Modified: branches/4.0-python/source/scripting/python/samba/__init__.py =================================================================== --- branches/4.0-python/source/scripting/python/samba/__init__.py 2007-11-21 12:32:34 UTC (rev 26081) +++ branches/4.0-python/source/scripting/python/samba/__init__.py 2007-11-21 12:32:40 UTC (rev 26082) @@ -19,6 +19,7 @@ # import os +from misc import ldb_set_credentials def Ldb(url, session_info=None, credentials=None, modules_dir=None): """Open a Samba Ldb file. @@ -34,7 +35,7 @@ ret.set_modules_dir(modules_dir) def samba_debug(level,text): print "%d %s" % (level, text) - ret.set_opaque("credentials", credentials) + ldb_set_opaque("credentials", credentials) ret.set_opaque("sessionInfo", session_info) #ret.set_debug(samba_debug) ret.connect(url)
