svn commit: samba r5279 - in trunk/source/python: .
tpot at samba.org
tpot at samba.org
Tue Feb 8 20:19:56 GMT 2005
Author: tpot
Date: 2005-02-08 20:19:55 +0000 (Tue, 08 Feb 2005)
New Revision: 5279
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5279
Log:
Fix for bugzilla #1564 thanks to Daniel Jarboe. Convert printer info
dependent files list to a list of strings instead of just returning
'asdf'.
Modified:
trunk/source/python/py_spoolss.h
trunk/source/python/py_spoolss_drivers.c
trunk/source/python/py_spoolss_drivers_conv.c
Changeset:
Modified: trunk/source/python/py_spoolss.h
===================================================================
--- trunk/source/python/py_spoolss.h 2005-02-08 19:27:18 UTC (rev 5278)
+++ trunk/source/python/py_spoolss.h 2005-02-08 20:19:55 UTC (rev 5279)
@@ -67,7 +67,8 @@
BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info);
BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict);
BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info);
-BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict);
+BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict,
+ TALLOC_CTX *mem_ctx);
BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info);
BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict);
BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info);
Modified: trunk/source/python/py_spoolss_drivers.c
===================================================================
--- trunk/source/python/py_spoolss_drivers.c 2005-02-08 19:27:18 UTC (rev 5278)
+++ trunk/source/python/py_spoolss_drivers.c 2005-02-08 20:19:55 UTC (rev 5279)
@@ -365,7 +365,7 @@
case 3:
ctr.info3 = &dinfo.driver_3;
- if (!py_to_DRIVER_INFO_3(&dinfo.driver_3, info)) {
+ if (!py_to_DRIVER_INFO_3(&dinfo.driver_3, info, mem_ctx)) {
PyErr_SetString(spoolss_error,
"error converting to driver info 3");
goto done;
Modified: trunk/source/python/py_spoolss_drivers_conv.c
===================================================================
--- trunk/source/python/py_spoolss_drivers_conv.c 2005-02-08 19:27:18 UTC (rev 5278)
+++ trunk/source/python/py_spoolss_drivers_conv.c 2005-02-08 20:19:55 UTC (rev 5279)
@@ -78,9 +78,49 @@
{ NULL }
};
-static uint16 *to_dependentfiles(PyObject *dict)
+static uint16 *to_dependentfiles(PyObject *list, TALLOC_CTX *mem_ctx)
{
- return (uint16 *)"abcd\0";
+ uint32 elements, size=0, pos=0, i;
+ char *str;
+ uint16 *ret = NULL;
+ PyObject *borrowedRef;
+
+ if (!PyList_Check(list)) {
+ goto done;
+ }
+
+ /* calculate size for dependentfiles */
+ elements=PyList_Size(list);
+ for (i = 0; i < elements; i++) {
+ borrowedRef=PyList_GetItem(list, i);
+ if (!PyString_Check(borrowedRef))
+ /* non string found, return error */
+ goto done;
+ size+=PyString_Size(borrowedRef)+1;
+ }
+
+ if (!(ret = (uint16*) talloc(mem_ctx,(size+1)*sizeof(uint16))))
+ goto done;
+
+ /* create null terminated sequence of null terminated strings */
+ for (i = 0; i < elements; i++) {
+ borrowedRef=PyList_GetItem(list, i);
+ str=PyString_AsString(borrowedRef);
+ do {
+ if (pos >= size) {
+ /* dependentfiles too small. miscalculated? */
+ ret = NULL;
+ goto done;
+ }
+ SSVAL(&ret[pos], 0, str[0]);
+ pos++;
+ } while (*(str++));
+ }
+ /* final null */
+ ret[pos]='\0';
+
+done:
+ return ret;
}
BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info)
@@ -122,16 +162,17 @@
return True;
}
-BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict)
+BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict,
+ TALLOC_CTX *mem_ctx)
{
PyObject *obj, *dict_copy = PyDict_Copy(dict);
BOOL result = False;
- if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")) ||
- !PyList_Check(obj))
+ if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")))
goto done;
- info->dependentfiles = to_dependentfiles(obj);
+ if (!(info->dependentfiles = to_dependentfiles(obj, mem_ctx)))
+ goto done;
PyDict_DelItemString(dict_copy, "dependent_files");
More information about the samba-cvs
mailing list