summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-09-06 07:01:40 +0000
committerTim Potter <tpot@samba.org>2002-09-06 07:01:40 +0000
commite411dc9687d84dae9e01c57a37ce1bc4b8c71a10 (patch)
tree447bf6aa3c64c6dc3c58ee874ab709dc0afbc8d5 /source3/python
parent22b75d5c81b7e7ca99e11a304053dac618f7a14e (diff)
downloadsamba-e411dc9687d84dae9e01c57a37ce1bc4b8c71a10.tar.gz
samba-e411dc9687d84dae9e01c57a37ce1bc4b8c71a10.tar.bz2
samba-e411dc9687d84dae9e01c57a37ce1bc4b8c71a10.zip
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)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_spoolss_drivers_conv.c32
1 files changed, 31 insertions, 1 deletions
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;
}