From 230e36ccded13f5bf0e95ff93e6aa65ad7e368ec Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 28 Mar 2002 04:14:43 +0000 Subject: Aborted experiment to avoid namespace pollution and prototype hell and moved to 'make proto' based solution. (This used to be commit 1e48f872a494228e82fd32c789b3dcea6b014211) --- source3/python/py_conv.h | 11 ++++++--- source3/python/py_spoolss.c | 21 ++---------------- source3/python/py_spoolss.h | 21 +++++++++++++----- source3/python/py_spoolss_drivers.c | 14 +++++++----- source3/python/py_spoolss_forms.c | 14 ++++++------ source3/python/py_spoolss_ports.c | 7 +----- source3/python/py_spoolss_printers.c | 16 ++++++-------- source3/python/py_spoolss_proto.h | 43 ++++++++++++++++++++++++++++++++++++ source3/python/samba-head.patch | 19 +++++++++++----- source3/python/setup.py.in | 7 +++++- 10 files changed, 111 insertions(+), 62 deletions(-) create mode 100644 source3/python/py_spoolss_proto.h (limited to 'source3') diff --git a/source3/python/py_conv.h b/source3/python/py_conv.h index 3b1ad8a9b9..0de2d674de 100644 --- a/source3/python/py_conv.h +++ b/source3/python/py_conv.h @@ -18,8 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef _PY_SPOOLSS_CONV_H -#define _PY_SPOOLSS_CONV_H +#ifndef _PY_CONV_H +#define _PY_CONV_H enum pyconv_types { PY_UNISTR, PY_UINT32, PY_UINT16 }; @@ -32,4 +32,9 @@ struct pyconv { PyObject *from_struct(void *s, struct pyconv *conv); void to_struct(void *s, PyObject *dict, struct pyconv *conv); -#endif /* _PY_SPOOLSS_CONV_H */ +/* Another version of offsetof (-: */ + +#undef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _PY_CONV_H */ diff --git a/source3/python/py_spoolss.c b/source3/python/py_spoolss.c index fd05c7e302..0c8d47848c 100644 --- a/source3/python/py_spoolss.c +++ b/source3/python/py_spoolss.c @@ -18,11 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#include "Python.h" - -#include "python/py_common.h" -#include "python/py_conv.h" #include "python/py_spoolss.h" /* Exceptions this module can raise */ @@ -33,13 +28,6 @@ PyObject *spoolss_error, *spoolss_werror; * Routines to convert from python hashes to Samba structures */ -/* Return a cli_state struct opened on the SPOOLSS pipe. If credentials - are passed use them. */ - -typedef struct cli_state *(cli_pipe_fn)( - struct cli_state *cli, char *system_name, - struct ntuser_creds *creds); - struct cli_state *open_pipe_creds(char *system_name, PyObject *creds, cli_pipe_fn *connect_fn, struct cli_state *cli) @@ -110,8 +98,8 @@ struct cli_state *open_pipe_creds(char *system_name, PyObject *creds, return cli; } -static PyObject *new_policy_hnd_object(struct cli_state *cli, - TALLOC_CTX *mem_ctx, POLICY_HND *pol) +PyObject *new_policy_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol) { spoolss_policy_hnd_object *o; @@ -128,11 +116,6 @@ static PyObject *new_policy_hnd_object(struct cli_state *cli, * Method dispatch table */ -#include "py_spoolss_printers.c" -#include "py_spoolss_drivers.c" -#include "py_spoolss_ports.c" -#include "py_spoolss_forms.c" - static PyMethodDef spoolss_methods[] = { /* Open/close printer handles */ diff --git a/source3/python/py_spoolss.h b/source3/python/py_spoolss.h index 766e420c6e..3040a80e80 100644 --- a/source3/python/py_spoolss.h +++ b/source3/python/py_spoolss.h @@ -21,10 +21,13 @@ #ifndef _PY_SPOOLSS_H #define _PY_SPOOLSS_H -/* Another version of offsetof (-: */ +#include "includes.h" +#include "Python.h" -#undef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#include "python/py_common.h" +#include "python/py_conv.h" + +/* Spoolss policy handle object */ typedef struct { PyObject_HEAD @@ -33,11 +36,19 @@ typedef struct { POLICY_HND pol; } spoolss_policy_hnd_object; +/* Exceptions raised by this module */ + extern PyTypeObject spoolss_policy_hnd_type; extern PyObject *spoolss_error, *spoolss_werror; -void to_struct(void *s, PyObject *dict, struct pyconv *conv); -PyObject *from_struct(void *s, struct pyconv *conv); +/* Return a cli_state struct opened on the SPOOLSS pipe. If credentials + are passed use them. */ + +typedef struct cli_state *(cli_pipe_fn)( + struct cli_state *cli, char *system_name, + struct ntuser_creds *creds); + +#include "python/py_spoolss_proto.h" #endif /* _PY_SPOOLSS_H */ diff --git a/source3/python/py_spoolss_drivers.c b/source3/python/py_spoolss_drivers.c index ba96bf0de6..014167db27 100644 --- a/source3/python/py_spoolss_drivers.c +++ b/source3/python/py_spoolss_drivers.c @@ -18,6 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "python/py_spoolss.h" + /* Structure/hash conversions */ struct pyconv py_DRIVER_INFO_1[] = { @@ -80,8 +82,8 @@ struct pyconv py_DRIVER_DIRECTORY_1[] = { /* Enumerate printer drivers */ -static PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, + PyObject *kw) { WERROR werror; PyObject *result = Py_None, *creds = NULL; @@ -179,8 +181,8 @@ static PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, /* Fetch printer driver */ -static PyObject *spoolss_getprinterdriver(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_getprinterdriver(PyObject *self, PyObject *args, + PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -232,8 +234,8 @@ static PyObject *spoolss_getprinterdriver(PyObject *self, PyObject *args, /* Fetch printer driver directory */ -static PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args, + PyObject *kw) { WERROR werror; PyObject *result = Py_None, *creds = NULL; diff --git a/source3/python/py_spoolss_forms.c b/source3/python/py_spoolss_forms.c index 4f063638d6..75e37f3f0d 100644 --- a/source3/python/py_spoolss_forms.c +++ b/source3/python/py_spoolss_forms.c @@ -18,6 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "python/py_spoolss.h" + struct pyconv py_FORM[] = { { "flags", PY_UINT32, offsetof(FORM, flags) }, { "width", PY_UINT32, offsetof(FORM, size_x) }, @@ -43,7 +45,7 @@ struct pyconv py_FORM_1[] = { /* Add a form */ -static PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) +PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -95,7 +97,7 @@ static PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) /* Get form properties */ -static PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw) +PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -142,7 +144,7 @@ static PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw) /* Set form properties */ -static PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw) +PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -180,8 +182,7 @@ static PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw) /* Delete a form */ -static PyObject *spoolss_deleteform(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -212,8 +213,7 @@ static PyObject *spoolss_deleteform(PyObject *self, PyObject *args, /* Enumerate forms */ -static PyObject *spoolss_enumforms(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw) { PyObject *result; spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; diff --git a/source3/python/py_spoolss_ports.c b/source3/python/py_spoolss_ports.c index 1064f3f3d2..a7d55a7897 100644 --- a/source3/python/py_spoolss_ports.c +++ b/source3/python/py_spoolss_ports.c @@ -18,10 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#include "Python.h" - -#include "python/py_conv.h" #include "python/py_spoolss.h" struct pyconv py_PORT_INFO_1[] = { @@ -40,8 +36,7 @@ struct pyconv py_PORT_INFO_2[] = { /* Enumerate ports */ -static PyObject *spoolss_enumports(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw) { WERROR werror; PyObject *result, *creds = NULL; diff --git a/source3/python/py_spoolss_printers.c b/source3/python/py_spoolss_printers.c index 192823221a..69eeb0f66b 100644 --- a/source3/python/py_spoolss_printers.c +++ b/source3/python/py_spoolss_printers.c @@ -18,6 +18,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "python/py_spoolss.h" + struct pyconv py_PRINTER_INFO_0[] = { { "printer_name", PY_UNISTR, offsetof(PRINTER_INFO_0, printername) }, { "server_name", PY_UNISTR, offsetof(PRINTER_INFO_0, servername) }, @@ -234,8 +236,7 @@ static PyObject *PyDEVICEMODE_FromDEVICEMODE(DEVICEMODE *devmode) /* Open a printer */ -static PyObject *spoolss_openprinter(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw) { char *full_name, *computer_name = NULL; TALLOC_CTX *mem_ctx; @@ -296,7 +297,7 @@ static PyObject *spoolss_openprinter(PyObject *self, PyObject *args, /* Close a printer */ -static PyObject *spoolss_closeprinter(PyObject *self, PyObject *args) +PyObject *spoolss_closeprinter(PyObject *self, PyObject *args) { PyObject *po; spoolss_policy_hnd_object *hnd; @@ -326,8 +327,7 @@ static PyObject *spoolss_closeprinter(PyObject *self, PyObject *args) /* Fetch printer information */ -static PyObject *spoolss_getprinter(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_getprinter(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -403,8 +403,7 @@ static PyObject *spoolss_getprinter(PyObject *self, PyObject *args, /* Set printer information */ -static PyObject *spoolss_setprinter(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_setprinter(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; @@ -458,8 +457,7 @@ static PyObject *spoolss_setprinter(PyObject *self, PyObject *args, /* Enumerate printers */ -static PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, - PyObject *kw) +PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw) { WERROR werror; PyObject *result, *creds = NULL; diff --git a/source3/python/py_spoolss_proto.h b/source3/python/py_spoolss_proto.h new file mode 100644 index 0000000000..e1a27896f7 --- /dev/null +++ b/source3/python/py_spoolss_proto.h @@ -0,0 +1,43 @@ +#ifndef _PY_SPOOLSS_PROTO_H +#define _PY_SPOOLSS_PROTO_H + +/* This file is automatically generated with "make proto". DO NOT EDIT */ + + +/* The following definitions come from python/py_spoolss.c */ + +struct cli_state *open_pipe_creds(char *system_name, PyObject *creds, + cli_pipe_fn *connect_fn, + struct cli_state *cli); +void initspoolss(void); + +/* The following definitions come from python/py_spoolss_drivers.c */ + +PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args, + PyObject *kw); +PyObject *spoolss_getprinterdriver(PyObject *self, PyObject *args, + PyObject *kw); +PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args, + PyObject *kw); + +/* The following definitions come from python/py_spoolss_forms.c */ + +PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw); + +/* The following definitions come from python/py_spoolss_ports.c */ + +PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw); + +/* The following definitions come from python/py_spoolss_printers.c */ + +PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_closeprinter(PyObject *self, PyObject *args); +PyObject *spoolss_getprinter(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_setprinter(PyObject *self, PyObject *args, PyObject *kw); +PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw); + +#endif /* _PY_SPOOLSS_PROTO_H */ diff --git a/source3/python/samba-head.patch b/source3/python/samba-head.patch index 882d8392d8..6b6a45030a 100644 --- a/source3/python/samba-head.patch +++ b/source3/python/samba-head.patch @@ -4,8 +4,8 @@ RCS file: /data/cvs/samba/source/Makefile.in,v retrieving revision 1.460 diff -u -r1.460 Makefile.in --- Makefile.in 2002/03/22 02:39:35 1.460 -+++ Makefile.in 2002/03/28 00:02:54 -@@ -781,6 +781,20 @@ ++++ Makefile.in 2002/03/28 04:12:51 +@@ -781,6 +781,27 @@ -$(INSTALLCMD) -d ${prefix}/include -$(INSTALLCMD) include/libsmbclient.h ${prefix}/include @@ -14,14 +14,21 @@ diff -u -r1.460 Makefile.in +PYTHON_OBJS = $(LIB_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) $(UBIQX_OBJ) \ + $(PARAM_OBJ) $(LIBMSRPC_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) + -+python/setup.py: $(srcdir)/setup.py.in -+ @echo "WARNING: you need to run ./config.status" ++PY_SPOOLSS_PROTO_OBJ = python/py_spoolss.o python/py_spoolss_printers.o \ ++ python/py_spoolss_forms.o python/py_spoolss_ports.o \ ++ python/py_spoolss_drivers.o ++ ++python_proto: python_spoolss_proto ++ ++python_spoolss_proto: ++ @cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \ ++ -h _PY_SPOOLSS_PROTO_H python/py_spoolss_proto.h \ ++ $(PY_SPOOLSS_PROTO_OBJ) + +python_ext: $(PYTHON_OBJS) + @echo python python/setup.py build + @PYTHON_OBJS="$(PYTHON_OBJS)" PYTHON_CFLAGS="$(CFLAGS) $(CPPFLAGS)" \ + python python/setup.py build -+ + # revert to the previously installed version revert: @@ -32,7 +39,7 @@ RCS file: /data/cvs/samba/source/configure.in,v retrieving revision 1.292 diff -u -r1.292 configure.in --- configure.in 2002/03/19 02:32:31 1.292 -+++ configure.in 2002/03/28 00:02:55 ++++ configure.in 2002/03/28 04:12:52 @@ -2690,7 +2690,7 @@ builddir=`pwd` AC_SUBST(builddir) diff --git a/source3/python/setup.py.in b/source3/python/setup.py.in index 8a78293088..dc61586a19 100755 --- a/source3/python/setup.py.in +++ b/source3/python/setup.py.in @@ -86,7 +86,12 @@ setup( Extension(name = "spoolss", sources = [samba_srcdir + "python/py_spoolss.c", samba_srcdir + "python/py_common.c", - samba_srcdir + "python/py_conv.c"], + samba_srcdir + "python/py_conv.c", + samba_srcdir + "python/py_spoolss_forms.c", + samba_srcdir + "python/py_spoolss_drivers.c", + samba_srcdir + "python/py_spoolss_printers.c", + samba_srcdir + "python/py_spoolss_ports.c", + ], libraries = lib_list, library_dirs = ["/usr/kerberos/lib"], extra_objects = obj_list), -- cgit