From 07a65b3f078733b198ede49e3f4828ba6b82b93e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 9 Apr 2002 04:23:52 +0000 Subject: Fixed setform and addform functions. (This used to be commit ecba275cf75be3152c917329ba16d77bf4490259) --- source3/python/py_spoolss_forms.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/source3/python/py_spoolss_forms.c b/source3/python/py_spoolss_forms.c index f7b80d0f33..9f8a49bd52 100644 --- a/source3/python/py_spoolss_forms.c +++ b/source3/python/py_spoolss_forms.c @@ -26,7 +26,8 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; - PyObject *py_form; + PyObject *py_form, *py_form_name; + char *form_name; FORM form; int level = 1; static char *kwlist[] = {"form", "level", NULL}; @@ -39,23 +40,17 @@ PyObject *spoolss_addform(PyObject *self, PyObject *args, PyObject *kw) /* Call rpc function */ - switch (level) { - case 1: { - PyObject *py_form_name; - char *form_name; - - 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); + if (!py_to_FORM(&form, py_form) || + !(py_form_name = PyDict_GetItemString(py_form, "name")) || + !(form_name = PyString_AsString(py_form_name))) { + PyErr_SetString(spoolss_error, "invalid form"); + return NULL; + } + switch (level) { + case 1: init_unistr2(&form.name, form_name, strlen(form_name) + 1); - break; - } default: PyErr_SetString(spoolss_error, "unsupported info level"); return NULL; @@ -126,22 +121,23 @@ PyObject *spoolss_setform(PyObject *self, PyObject *args, PyObject *kw) { spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; WERROR werror; - PyObject *py_form; + PyObject *py_form, *py_form_name; int level = 1; - static char *kwlist[] = {"form_name", "form", "level", NULL}; + static char *kwlist[] = {"form", "level", NULL}; char *form_name; FORM form; /* Parse parameters */ - if (!PyArg_ParseTupleAndKeywords(args, kw, "sO!|i", kwlist, - &form_name, &PyDict_Type, &py_form, - &level)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "O!|i", kwlist, + &PyDict_Type, &py_form, &level)) return NULL; /* Call rpc function */ - if (!py_to_FORM(&form, py_form)) { + if (!py_to_FORM(&form, py_form) || + !(py_form_name = PyDict_GetItemString(py_form, "name")) || + !(form_name = PyString_AsString(py_form_name))) { PyErr_SetString(spoolss_error, "invalid form"); return NULL; } -- cgit