00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "python/py_spoolss.h"
00022 #include "python/py_conv.h"
00023
00024
00025
00026 struct pyconv py_DRIVER_INFO_1[] = {
00027 { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) },
00028 { NULL }
00029 };
00030
00031 struct pyconv py_DRIVER_INFO_2[] = {
00032 { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) },
00033 { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) },
00034 { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) },
00035 { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) },
00036 { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) },
00037 { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) },
00038 { NULL }
00039 };
00040
00041 struct pyconv py_DRIVER_INFO_3[] = {
00042 { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) },
00043 { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) },
00044 { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) },
00045 { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) },
00046 { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) },
00047 { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) },
00048 { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) },
00049 { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) },
00050 { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) },
00051 { NULL }
00052 };
00053
00054 struct pyconv py_DRIVER_INFO_6[] = {
00055 { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) },
00056 { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) },
00057 { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) },
00058 { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) },
00059 { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) },
00060 { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) },
00061 { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) },
00062 { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) },
00063 { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) },
00064
00065 { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) },
00066 { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) },
00067 { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) },
00068 { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) },
00069 { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) },
00070 { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) },
00071 { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) },
00072
00073 { NULL }
00074 };
00075
00076 struct pyconv py_DRIVER_DIRECTORY_1[] = {
00077 { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) },
00078 { NULL }
00079 };
00080
00081 static uint16 *to_dependentfiles(PyObject *list, TALLOC_CTX *mem_ctx)
00082 {
00083 uint32 elements, size=0, pos=0, i;
00084 char *str;
00085 uint16 *ret = NULL;
00086 PyObject *borrowedRef;
00087
00088 if (!PyList_Check(list)) {
00089 goto done;
00090 }
00091
00092
00093 elements=PyList_Size(list);
00094 for (i = 0; i < elements; i++) {
00095 borrowedRef=PyList_GetItem(list, i);
00096 if (!PyString_Check(borrowedRef))
00097
00098 goto done;
00099 size+=PyString_Size(borrowedRef)+1;
00100 }
00101
00102 if (!(ret = (uint16*)_talloc(mem_ctx,((size+1)*sizeof(uint16)))))
00103 goto done;
00104
00105
00106 for (i = 0; i < elements; i++) {
00107 borrowedRef=PyList_GetItem(list, i);
00108 str=PyString_AsString(borrowedRef);
00109 do {
00110 if (pos >= size) {
00111
00112 ret = NULL;
00113 goto done;
00114 }
00115 SSVAL(&ret[pos], 0, str[0]);
00116 pos++;
00117 } while (*(str++));
00118 }
00119
00120 ret[pos]='\0';
00121
00122 done:
00123 return ret;
00124 }
00125
00126 BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info)
00127 {
00128 *dict = from_struct(info, py_DRIVER_INFO_1);
00129 PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
00130
00131 return True;
00132 }
00133
00134 BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict)
00135 {
00136 return False;
00137 }
00138
00139 BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info)
00140 {
00141 *dict = from_struct(info, py_DRIVER_INFO_2);
00142 PyDict_SetItemString(*dict, "level", PyInt_FromLong(2));
00143
00144 return True;
00145 }
00146
00147 BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict)
00148 {
00149 return False;
00150 }
00151
00152 BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info)
00153 {
00154 *dict = from_struct(info, py_DRIVER_INFO_3);
00155
00156 PyDict_SetItemString(*dict, "level", PyInt_FromLong(3));
00157
00158 PyDict_SetItemString(
00159 *dict, "dependent_files",
00160 from_unistr_list(info->dependentfiles));
00161
00162 return True;
00163 }
00164
00165 BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict,
00166 TALLOC_CTX *mem_ctx)
00167 {
00168 PyObject *obj, *dict_copy = PyDict_Copy(dict);
00169 BOOL result = False;
00170
00171 if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")))
00172 goto done;
00173
00174 if (!(info->dependentfiles = to_dependentfiles(obj, mem_ctx)))
00175 goto done;
00176
00177 PyDict_DelItemString(dict_copy, "dependent_files");
00178
00179 if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00180 !PyInt_Check(obj))
00181 goto done;
00182
00183 PyDict_DelItemString(dict_copy, "level");
00184
00185 if (!to_struct(info, dict_copy, py_DRIVER_INFO_3))
00186 goto done;
00187
00188 result = True;
00189
00190 done:
00191 Py_DECREF(dict_copy);
00192 return result;
00193 }
00194
00195 BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info)
00196 {
00197 *dict = from_struct(info, py_DRIVER_INFO_6);
00198 PyDict_SetItemString(*dict, "level", PyInt_FromLong(6));
00199 PyDict_SetItemString(
00200 *dict, "dependent_files",
00201 from_unistr_list(info->dependentfiles));
00202 return True;
00203 }
00204
00205 BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict)
00206 {
00207 return False;
00208 }
00209
00210 BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info)
00211 {
00212 *dict = from_struct(info, py_DRIVER_DIRECTORY_1);
00213 PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
00214 return True;
00215 }
00216
00217 BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict)
00218 {
00219 return False;
00220 }