diff options
author | Tim Potter <tpot@samba.org> | 2002-07-29 03:50:35 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-07-29 03:50:35 +0000 |
commit | 0872bc448686cad6e9e95d24fbf72fdad48ed5d3 (patch) | |
tree | a8fc2d9ce1529abae83bb0e2392ec28b729dc07a /source3 | |
parent | c74a8d72f9875ea34886cca6baa8a1cb3c7ad301 (diff) | |
download | samba-0872bc448686cad6e9e95d24fbf72fdad48ed5d3.tar.gz samba-0872bc448686cad6e9e95d24fbf72fdad48ed5d3.tar.bz2 samba-0872bc448686cad6e9e95d24fbf72fdad48ed5d3.zip |
Skeleton for a libsmb python wrapper.
(This used to be commit 36cc488c4d99198d346103b0e44776a7de145428)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/python/py_smb.c | 107 | ||||
-rw-r--r-- | source3/python/py_smb.h | 42 | ||||
-rw-r--r-- | source3/python/samba-head.patch | 6 | ||||
-rwxr-xr-x | source3/python/setup.py.in | 9 |
4 files changed, 161 insertions, 3 deletions
diff --git a/source3/python/py_smb.c b/source3/python/py_smb.c new file mode 100644 index 0000000000..c206e6ba9b --- /dev/null +++ b/source3/python/py_smb.c @@ -0,0 +1,107 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "python/py_smb.h" + +/* + * Exceptions raised by this module + */ + +PyObject *smb_ntstatus; /* This exception is raised when a RPC call + returns a status code other than + NT_STATUS_OK */ + + +/* + * Method dispatch tables + */ + +static PyMethodDef smb_methods[] = { + { NULL } +}; + +/* Create a new cli_state python object */ + +PyObject *new_cli_state_object(struct cli_state *cli) +{ + cli_state_object *o; + + o = PyObject_New(cli_state_object, &cli_state_type); + + o->cli = cli; + + return (PyObject*)o; +} + +static void py_cli_state_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +static PyObject *py_cli_state_getattr(PyObject *self, char *attrname) +{ + return Py_FindMethod(smb_methods, self, attrname); +} + +PyTypeObject cli_state_type = { + PyObject_HEAD_INIT(NULL) + 0, + "SMB client connection", + sizeof(cli_state_object), + 0, + py_cli_state_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + py_cli_state_getattr, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +/* + * Module initialisation + */ + +void initsmb(void) +{ + PyObject *module, *dict; + + /* Initialise module */ + + module = Py_InitModule("smb", smb_methods); + dict = PyModule_GetDict(module); + + smb_ntstatus = PyErr_NewException("smb.ntstatus", NULL, NULL); + PyDict_SetItemString(dict, "ntstatus", smb_ntstatus); + + /* Initialise policy handle object */ + + cli_state_type.ob_type = &PyType_Type; + + /* Do samba initialisation */ + + py_samba_init(); + + setup_logging("smb", True); + DEBUGLEVEL = 10; +} diff --git a/source3/python/py_smb.h b/source3/python/py_smb.h new file mode 100644 index 0000000000..18677b4905 --- /dev/null +++ b/source3/python/py_smb.h @@ -0,0 +1,42 @@ +/* + Python wrappers for DCERPC/SMB client routines. + + Copyright (C) Tim Potter, 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _PY_SMB_H +#define _PY_SMB_H + +#include "includes.h" +#include "Python.h" + +#include "python/py_common_proto.h" + +/* cli_state handle object */ + +typedef struct { + PyObject_HEAD + struct cli_state *cli; +} cli_state_object; + +/* Exceptions raised by this module */ + +extern PyTypeObject cli_state_type; + +extern PyObject *smb_ntstatus; + +#endif /* _PY_SMB_H */ diff --git a/source3/python/samba-head.patch b/source3/python/samba-head.patch index 0f4ab146a8..a739346a5b 100644 --- a/source3/python/samba-head.patch +++ b/source3/python/samba-head.patch @@ -4,7 +4,7 @@ RCS file: /data/cvs/samba/source/Makefile.in,v retrieving revision 1.500 diff -u -r1.500 Makefile.in --- Makefile.in 2002/07/28 06:04:32 1.500 -+++ Makefile.in 2002/07/29 01:58:05 ++++ Makefile.in 2002/07/29 03:48:03 @@ -838,6 +838,45 @@ -$(INSTALLCMD) -d ${prefix}/include -$(INSTALLCMD) include/libsmbclient.h ${prefix}/include @@ -12,7 +12,7 @@ diff -u -r1.500 Makefile.in +# Python extensions + +PYTHON_OBJS = $(LIB_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) $(UBIQX_OBJ) \ -+ $(PARAM_OBJ) $(LIBMSRPC_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) ++ $(PARAM_OBJ) $(LIBMSRPC_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) $(SECRETS_OBJ) + +PY_SPOOLSS_PROTO_OBJ = python/py_spoolss.o \ + python/py_spoolss_printers.o python/py_spoolss_printers_conv.o\ @@ -57,7 +57,7 @@ RCS file: /data/cvs/samba/source/configure.in,v retrieving revision 1.324 diff -u -r1.324 configure.in --- configure.in 2002/07/27 01:37:32 1.324 -+++ configure.in 2002/07/29 01:58:06 ++++ configure.in 2002/07/29 03:48:04 @@ -2797,7 +2797,7 @@ builddir=`pwd` AC_SUBST(builddir) diff --git a/source3/python/setup.py.in b/source3/python/setup.py.in index 0895e25c08..c61ec2c214 100755 --- a/source3/python/setup.py.in +++ b/source3/python/setup.py.in @@ -150,5 +150,14 @@ setup( library_dirs = ["/usr/kerberos/lib"], extra_objects = obj_list), + # libsmb module + + Extension(name = "smb", + sources = [samba_srcdir + "python/py_smb.c", + samba_srcdir + "python/py_common.c"], + libraries = lib_list, + library_dirs = ["/usr/kerberos/lib"], + extra_objects = obj_list), + ], ) |