Aborted experiment to avoid namespace pollution and prototype hell and
authorTim Potter <tpot@samba.org>
Thu, 28 Mar 2002 04:14:43 +0000 (04:14 +0000)
committerTim Potter <tpot@samba.org>
Thu, 28 Mar 2002 04:14:43 +0000 (04:14 +0000)
moved to 'make proto' based solution.

source/python/py_conv.h
source/python/py_spoolss.c
source/python/py_spoolss.h
source/python/py_spoolss_drivers.c
source/python/py_spoolss_forms.c
source/python/py_spoolss_ports.c
source/python/py_spoolss_printers.c
source/python/py_spoolss_proto.h [new file with mode: 0644]
source/python/samba-head.patch
source/python/setup.py.in

index 3b1ad8a9b9bfc8285a01c43c126d817cd140ba94..0de2d674de2eaa77525793da46560fc237ea0a1b 100644 (file)
@@ -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 */
index fd05c7e302ac28d7801fc723f60221878900208a..0c8d47848ca0c3d8039ddad72df16b8a192be5f1 100644 (file)
    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 */
index 766e420c6e6692291215122b7b846c60ca5240bf..3040a80e80a3a710b8e0577185230e37261e99c5 100644 (file)
 #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 */
index ba96bf0de60f8ef68d3ba3ba9162cca14d7fc099..014167db27bbde272caa3022e4d8344a10d7a6fc 100644 (file)
@@ -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;
index 4f063638d6013bbeb7cb909127b8893389eb5265..75e37f3f0d817c923f7cc35253ff1fb426eccee3 100644 (file)
@@ -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;
index 1064f3f3d288e61e10103860d2a443e777f62957..a7d55a7897b4b5ef2134e50204e16e4b0f54db91 100644 (file)
    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;
index 192823221a5c81d8d4be2d87c15a76be77950309..69eeb0f66b71af18ec192e5c062dfd4a0a2f8b08 100644 (file)
@@ -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/source/python/py_spoolss_proto.h b/source/python/py_spoolss_proto.h
new file mode 100644 (file)
index 0000000..e1a2789
--- /dev/null
@@ -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  */
index 882d8392d8929fdb6caf459953cf4a6ae20e69e3..6b6a45030a3617ccf89aabc84530c9494141d8c6 100644 (file)
@@ -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)
index 8a7829308820b7a8109beb590c6770e3526f1d1b..dc61586a196ca1d1d5392d1a3572082c27df6831 100755 (executable)
@@ -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),