summaryrefslogtreecommitdiff
path: root/source3/python/py_spoolss_forms.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-04-05 05:48:01 +0000
committerTim Potter <tpot@samba.org>2002-04-05 05:48:01 +0000
commitf9b571811dbd0bfa779a15a9a42cd93d3331530b (patch)
tree05f6a0ec3ffbde7b2cc59b4ef9ca4640898a524f /source3/python/py_spoolss_forms.c
parent77ab3b8850f870c34f9b5f6d33ccf5127bf005b6 (diff)
downloadsamba-f9b571811dbd0bfa779a15a9a42cd93d3331530b.tar.gz
samba-f9b571811dbd0bfa779a15a9a42cd93d3331530b.tar.bz2
samba-f9b571811dbd0bfa779a15a9a42cd93d3331530b.zip
Converted drivers, forms and ports functions to use new conversion routines
and exception throwing. (This used to be commit ed0a6480f75b3eefc52bc3311d8c3816abefcff2)
Diffstat (limited to 'source3/python/py_spoolss_forms.c')
-rw-r--r--source3/python/py_spoolss_forms.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/source3/python/py_spoolss_forms.c b/source3/python/py_spoolss_forms.c
index 75e37f3f0d..f7b80d0f33 100644
--- a/source3/python/py_spoolss_forms.c
+++ b/source3/python/py_spoolss_forms.c
@@ -20,29 +20,6 @@
#include "python/py_spoolss.h"
-struct pyconv py_FORM[] = {
- { "flags", PY_UINT32, offsetof(FORM, flags) },
- { "width", PY_UINT32, offsetof(FORM, size_x) },
- { "length", PY_UINT32, offsetof(FORM, size_y) },
- { "top", PY_UINT32, offsetof(FORM, top) },
- { "left", PY_UINT32, offsetof(FORM, left) },
- { "right", PY_UINT32, offsetof(FORM, right) },
- { "bottom", PY_UINT32, offsetof(FORM, bottom) },
- { NULL }
-};
-
-struct pyconv py_FORM_1[] = {
- { "flags", PY_UINT32, offsetof(FORM_1, flag) },
- { "width", PY_UINT32, offsetof(FORM_1, width) },
- { "length", PY_UINT32, offsetof(FORM_1, length) },
- { "top", PY_UINT32, offsetof(FORM_1, top) },
- { "left", PY_UINT32, offsetof(FORM_1, left) },
- { "right", PY_UINT32, offsetof(FORM_1, right) },
- { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
- { "name", PY_UNISTR, offsetof(FORM_1, name) },
- { NULL }
-};
-
/* Add a form */
PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
@@ -67,7 +44,10 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
PyObject *py_form_name;
char *form_name;
- to_struct(&form, py_form, py_FORM);
+ if (!py_to_FORM(&form, py_form)) {
+ PyErr_SetString(spoolss_error, "invalid form");
+ return NULL;
+ }
py_form_name = PyDict_GetItemString(py_form, "name");
form_name = PyString_AsString(py_form_name);
@@ -86,8 +66,7 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw)
if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror,
- PyInt_FromLong(W_ERROR_V(werror)));
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
return NULL;
}
@@ -125,8 +104,7 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
form_name, 1, &form);
if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror,
- PyInt_FromLong(W_ERROR_V(werror)));
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
return NULL;
}
@@ -134,7 +112,7 @@ PyObject *spoolss_getform(PyObject *self, PyObject *args, PyObject *kw)
switch(level) {
case 1:
- result = from_struct(&form, py_FORM_1);
+ py_from_FORM_1(&result, &form);
break;
}
@@ -163,16 +141,18 @@ PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw)
/* Call rpc function */
- to_struct(&form, py_form, py_FORM);
+ if (!py_to_FORM(&form, py_form)) {
+ PyErr_SetString(spoolss_error, "invalid form");
+ return NULL;
+ }
+
init_unistr2(&form.name, form_name, strlen(form_name) + 1);
werror = cli_spoolss_setform(hnd->cli, hnd->mem_ctx, &hnd->pol,
level, form_name, &form);
if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror,
- PyInt_FromLong(W_ERROR_V(werror)));
-
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
return NULL;
}
@@ -202,8 +182,7 @@ PyObject *spoolss_deleteform(PyObject *self, PyObject *args, PyObject *kw)
hnd->cli, hnd->mem_ctx, &hnd->pol, form_name);
if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror,
- PyInt_FromLong(W_ERROR_V(werror)));
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
return NULL;
}
@@ -240,8 +219,7 @@ PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw)
&num_forms, &forms);
if (!W_ERROR_IS_OK(werror)) {
- PyErr_SetObject(spoolss_werror,
- PyInt_FromLong(W_ERROR_V(werror)));
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
return NULL;
}
@@ -252,7 +230,7 @@ PyObject *spoolss_enumforms(PyObject *self, PyObject *args, PyObject *kw)
switch(level) {
case 1:
- obj = from_struct(&forms[i], py_FORM_1);
+ py_from_FORM_1(&obj, &forms[i]);
break;
}