From e411dc9687d84dae9e01c57a37ce1bc4b8c71a10 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 6 Sep 2002 07:01:40 +0000 Subject: Decode list of dependent files in printer driver info3 and info6. It's a null terminated list of null terminated unicode strings. What a mess! (This used to be commit aae48211ff4f22e0c2e2fe57c370f465df4332bc) --- source3/python/py_spoolss_drivers_conv.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'source3/python/py_spoolss_drivers_conv.c') diff --git a/source3/python/py_spoolss_drivers_conv.c b/source3/python/py_spoolss_drivers_conv.c index dbf33905ae..5d181f9cd9 100644 --- a/source3/python/py_spoolss_drivers_conv.c +++ b/source3/python/py_spoolss_drivers_conv.c @@ -46,7 +46,6 @@ struct pyconv py_DRIVER_INFO_3[] = { { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) }, { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) }, { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) }, - /* dependentfiles */ { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) }, { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) }, { NULL } @@ -80,6 +79,30 @@ struct pyconv py_DRIVER_DIRECTORY_1[] = { { NULL } }; +/* Convert a NULL terminated list of NULL terminated unicode strings + to a list of (char *) strings */ + +static PyObject *from_dependentfiles(uint16 *dependentfiles) +{ + PyObject *list; + int offset = 0; + + list = PyList_New(0); + + while (*(dependentfiles + offset) != 0) { + fstring name; + int len; + + len = rpcstr_pull(name, dependentfiles + offset, + sizeof(fstring), -1, STR_TERMINATE); + + offset += len / 2; + PyList_Append(list, PyString_FromString(name)); + } + + return list; +} + BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info) { *dict = from_struct(info, py_DRIVER_INFO_1); @@ -108,6 +131,10 @@ BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info) { *dict = from_struct(info, py_DRIVER_INFO_3); PyDict_SetItemString(*dict, "level", PyInt_FromLong(3)); + PyDict_SetItemString( + *dict, "dependent_files", + from_dependentfiles(info->dependentfiles)); + return True; } @@ -127,6 +154,9 @@ BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info) { *dict = from_struct(info, py_DRIVER_INFO_6); PyDict_SetItemString(*dict, "level", PyInt_FromLong(6)); + PyDict_SetItemString( + *dict, "dependent_files", + from_dependentfiles (info->dependentfiles)); return True; } -- cgit