From 762d52feba43fa0ae296d7eed6195fbe3ccc0e71 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 14 May 2002 05:01:04 +0000 Subject: Added enumprinterdata. (This used to be commit 7a15ce7c0c6a6b3a62dd6607fefc32742fa50308) --- source3/python/py_spoolss_printerdata.c | 42 ++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/source3/python/py_spoolss_printerdata.c b/source3/python/py_spoolss_printerdata.c index 622c487b8c..352252f2bd 100644 --- a/source3/python/py_spoolss_printerdata.c +++ b/source3/python/py_spoolss_printerdata.c @@ -156,5 +156,45 @@ PyObject *spoolss_setprinterdata(PyObject *self, PyObject *args, PyObject *kw) PyObject *spoolss_enumprinterdata(PyObject *self, PyObject *args, PyObject *kw) { - return NULL; + spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self; + static char *kwlist[] = { NULL }; + uint32 data_needed, value_needed, ndx = 0, data_size, data_type; + char *value, *data; + WERROR werror; + PyObject *result; + + if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist)) + return NULL; + + /* Get max buffer sizes for value and data */ + + werror = cli_spoolss_enumprinterdata( + hnd->cli, hnd->mem_ctx, &hnd->pol, ndx, 0, 0, + &value_needed, &data_needed, NULL, NULL, NULL, NULL); + + if (!W_ERROR_IS_OK(werror)) { + PyErr_SetObject(spoolss_werror, py_werror_tuple(werror)); + return NULL; + } + + /* Iterate over all printerdata */ + + result = PyDict_New(); + + while (W_ERROR_IS_OK(werror)) { + PyObject *obj; + + werror = cli_spoolss_enumprinterdata( + hnd->cli, hnd->mem_ctx, &hnd->pol, ndx, + value_needed, data_needed, NULL, NULL, + &value, &data_type, &data, &data_size); + + if (py_from_printerdata(&obj, value, data_type, data, + data_size)) + PyDict_SetItemString(result, value, obj); + + ndx++; + } + + return result; } -- cgit