Decode list of dependent files in printer driver info3 and info6.
authorTim Potter <tpot@samba.org>
Fri, 6 Sep 2002 07:01:40 +0000 (07:01 +0000)
committerTim Potter <tpot@samba.org>
Fri, 6 Sep 2002 07:01:40 +0000 (07:01 +0000)
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

index dbf33905ae5b48aca5df3ec8712ff0d91e03f5e4..5d181f9cd90251d534f4a0c56fc8ff6b31c5212c 100644 (file)
@@ -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;
 }