summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/python/py_spoolss.c53
-rw-r--r--source3/python/py_spoolss_forms.c54
2 files changed, 49 insertions, 58 deletions
diff --git a/source3/python/py_spoolss.c b/source3/python/py_spoolss.c
index 37074baca1..3edc622901 100644
--- a/source3/python/py_spoolss.c
+++ b/source3/python/py_spoolss.c
@@ -22,6 +22,7 @@
#include "Python.h"
#include "python/py_common.h"
#include "python/py_spoolss.h"
+#include "python/py_spoolss_forms.h"
/* Exceptions this module can raise */
@@ -32,6 +33,35 @@ static void py_policy_hnd_dealloc(PyObject* self)
PyObject_Del(self);
}
+
+
+static PyMethodDef spoolss_hnd_methods[] = {
+
+ /* Forms */
+
+ { "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
+ "Enumerate forms" },
+
+ { "setform", spoolss_setform, METH_VARARGS | METH_KEYWORDS,
+ "Modify properties of a form" },
+
+ { "addform", spoolss_addform, METH_VARARGS | METH_KEYWORDS,
+ "Insert a form" },
+
+ { "getform", spoolss_getform, METH_VARARGS | METH_KEYWORDS,
+ "Fetch form properties" },
+
+ { "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS,
+ "Delete a form" },
+
+ { NULL }
+
+};
+static PyObject *py_policy_hnd_getattr(PyObject *self, char *attrname)
+{
+ return Py_FindMethod(spoolss_hnd_methods, self, attrname);
+}
+
static PyObject *new_policy_hnd_object(struct cli_state *cli,
TALLOC_CTX *mem_ctx, POLICY_HND *pol)
{
@@ -54,7 +84,7 @@ PyTypeObject spoolss_policy_hnd_type = {
0,
py_policy_hnd_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- 0, /*tp_getattr*/
+ py_policy_hnd_getattr, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
@@ -1023,26 +1053,6 @@ static PyMethodDef spoolss_methods[] = {
{ "enumprinters", spoolss_enumprinters, METH_VARARGS | METH_KEYWORDS,
"Enumerate printers" },
- /* Forms */
-
- { "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
- "Enumerate forms" },
-
- { "setform", spoolss_setform, METH_VARARGS | METH_KEYWORDS,
- "Modify properties of a form" },
-
- { "addform", spoolss_addform, METH_VARARGS | METH_KEYWORDS,
- "Insert a form" },
-
- { "getform", spoolss_getform, METH_VARARGS | METH_KEYWORDS,
- "Fetch form properties" },
-
- { "deleteform", spoolss_deleteform, METH_VARARGS | METH_KEYWORDS,
- "Delete a form" },
-
- { "enumforms", spoolss_enumforms, METH_VARARGS | METH_KEYWORDS,
- "Delete a form" },
-
{ NULL }
};
@@ -1081,6 +1091,7 @@ static void const_init(PyObject *dict)
for (tmp = spoolss_const_vals; tmp->name; tmp++) {
obj = PyInt_FromLong(tmp->value);
PyDict_SetItemString(dict, tmp->name, obj);
+ Py_DECREF(obj);
}
}
diff --git a/source3/python/py_spoolss_forms.c b/source3/python/py_spoolss_forms.c
index fc7db6ac93..24724dba25 100644
--- a/source3/python/py_spoolss_forms.c
+++ b/source3/python/py_spoolss_forms.c
@@ -49,23 +49,19 @@ struct pyconv py_FORM_1[] = {
PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *po;
- spoolss_policy_hnd_object *hnd;
+ spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
WERROR werror;
PyObject *py_form;
FORM form;
int level = 1;
- static char *kwlist[] = {"hnd", "form", "level", NULL};
+ static char *kwlist[] = {"form", "level", NULL};
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!O!|i", kwlist, &spoolss_policy_hnd_type, &po,
- &PyDict_Type, &py_form, &level))
+ args, kw, "O!|i", kwlist, &PyDict_Type, &py_form, &level))
return NULL;
- hnd = (spoolss_policy_hnd_object *)po;
-
/* Call rpc function */
switch (level) {
@@ -105,25 +101,20 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *po;
- spoolss_policy_hnd_object *hnd;
+ spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
WERROR werror;
PyObject *result;
char *form_name;
int level = 1;
- static char *kwlist[] = {"hnd", "form_name", "level", NULL};
+ static char *kwlist[] = {"form_name", "level", NULL};
uint32 needed;
FORM_1 form;
/* Parse parameters */
- if (!PyArg_ParseTupleAndKeywords(args, kw, "O!s|i", kwlist,
- &spoolss_policy_hnd_type, &po, &form_name,
- &level))
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "s|i", kwlist, &form_name, &level))
return NULL;
- hnd = (spoolss_policy_hnd_object *)po;
-
/* Call rpc function */
werror = cli_spoolss_getform(hnd->cli, hnd->mem_ctx, 0, &needed,
@@ -156,24 +147,20 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *po;
- spoolss_policy_hnd_object *hnd;
+ spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
WERROR werror;
PyObject *py_form;
int level = 1;
- static char *kwlist[] = {"hnd", "form_name", "form", "level", NULL};
+ static char *kwlist[] = {"form_name", "form", "level", NULL};
char *form_name;
FORM form;
/* Parse parameters */
- if (!PyArg_ParseTupleAndKeywords(args, kw, "O!sO!|i", kwlist,
- &spoolss_policy_hnd_type, &po, &form_name,
- &PyDict_Type, &py_form, &level))
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "sO!|i", kwlist,
+ &form_name, &PyDict_Type, &py_form, &level))
return NULL;
- hnd = (spoolss_policy_hnd_object *)po;
-
/* Call rpc function */
to_struct(&form, py_form, py_FORM);
@@ -197,22 +184,18 @@ PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *po;
- spoolss_policy_hnd_object *hnd;
+ spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
WERROR werror;
int level = 1;
- static char *kwlist[] = {"hnd", "form_name", "level", NULL};
+ static char *kwlist[] = {"form_name", "level", NULL};
char *form_name;
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!s|i", kwlist, &spoolss_policy_hnd_type, &po,
- &form_name, &level))
+ args, kw, "s|i", kwlist, &form_name, &level))
return NULL;
- hnd = (spoolss_policy_hnd_object *)po;
-
/* Call rpc function */
werror = cli_spoolss_deleteform(
@@ -232,22 +215,19 @@ PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *po, *result;
- spoolss_policy_hnd_object *hnd;
+ PyObject *result;
+ spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
WERROR werror;
uint32 level = 1, num_forms, needed, i;
- static char *kwlist[] = {"hnd", "level", NULL};
+ static char *kwlist[] = {"level", NULL};
FORM_1 *forms;
/* Parse parameters */
if (!PyArg_ParseTupleAndKeywords(
- args, kw, "O!|i", kwlist, &spoolss_policy_hnd_type,
- &po, &level))
+ args, kw, "|i", kwlist, &level))
return NULL;
- hnd = (spoolss_policy_hnd_object *)po;
-
/* Call rpc function */
werror = cli_spoolss_enumforms(