Remove dead code for packing buffers which has now been reimplemented.
[samba.git] / source3 / python / py_spoolss_drivers_conv.c
1 /* 
2    Python wrappers for DCERPC/SMB client routines.
3
4    Copyright (C) Tim Potter, 2002
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "python/py_spoolss.h"
22 #include "python/py_conv.h"
23
24 /* Structure/hash conversions */
25
26 struct pyconv py_DRIVER_INFO_1[] = {
27         { "name", PY_UNISTR, offsetof(DRIVER_INFO_1, name) },
28         { NULL }
29 };
30
31 struct pyconv py_DRIVER_INFO_2[] = {
32         { "version", PY_UINT32, offsetof(DRIVER_INFO_2, version) },
33         { "name", PY_UNISTR, offsetof(DRIVER_INFO_2, name) },
34         { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_2, architecture) },
35         { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_2, driverpath) },
36         { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_2, datafile) },
37         { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_2, configfile) },
38         { NULL }
39 };
40
41 struct pyconv py_DRIVER_INFO_3[] = {
42         { "version", PY_UINT32, offsetof(DRIVER_INFO_3, version) },
43         { "name", PY_UNISTR, offsetof(DRIVER_INFO_3, name) },
44         { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_3, architecture) },
45         { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_3, driverpath) },
46         { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_3, datafile) },
47         { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_3, configfile) },
48         { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_3, helpfile) },
49         { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_3, monitorname) },
50         { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_3, defaultdatatype) },
51         { NULL }
52 };
53
54 struct pyconv py_DRIVER_INFO_6[] = {
55         { "version", PY_UINT32, offsetof(DRIVER_INFO_6, version) },
56         { "name", PY_UNISTR, offsetof(DRIVER_INFO_6, name) },
57         { "architecture", PY_UNISTR, offsetof(DRIVER_INFO_6, architecture) },
58         { "driver_path", PY_UNISTR, offsetof(DRIVER_INFO_6, driverpath) },
59         { "data_file", PY_UNISTR, offsetof(DRIVER_INFO_6, datafile) },
60         { "config_file", PY_UNISTR, offsetof(DRIVER_INFO_6, configfile) },
61         { "help_file", PY_UNISTR, offsetof(DRIVER_INFO_6, helpfile) },
62         { "monitor_name", PY_UNISTR, offsetof(DRIVER_INFO_6, monitorname) },
63         { "default_datatype", PY_UNISTR, offsetof(DRIVER_INFO_6, defaultdatatype) },
64         /* driver_date */
65         { "padding", PY_UINT32, offsetof(DRIVER_INFO_6, padding) },
66         { "driver_version_low", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_low) },
67         { "driver_version_high", PY_UINT32, offsetof(DRIVER_INFO_6, driver_version_high) },
68         { "mfg_name", PY_UNISTR, offsetof(DRIVER_INFO_6, mfgname) },
69         { "oem_url", PY_UNISTR, offsetof(DRIVER_INFO_6, oem_url) },
70         { "hardware_id", PY_UNISTR, offsetof(DRIVER_INFO_6, hardware_id) },
71         { "provider", PY_UNISTR, offsetof(DRIVER_INFO_6, provider) },
72         
73         { NULL }
74 };
75
76 struct pyconv py_DRIVER_DIRECTORY_1[] = {
77         { "name", PY_UNISTR, offsetof(DRIVER_DIRECTORY_1, name) },
78         { NULL }
79 };
80
81 static uint16 *to_dependentfiles(PyObject *dict)
82 {
83         return (uint16 *)"abcd\0";
84 }
85
86 BOOL py_from_DRIVER_INFO_1(PyObject **dict, DRIVER_INFO_1 *info)
87 {
88         *dict = from_struct(info, py_DRIVER_INFO_1);
89         PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
90
91         return True;
92 }
93
94 BOOL py_to_DRIVER_INFO_1(DRIVER_INFO_1 *info, PyObject *dict)
95 {
96         return False;
97 }
98
99 BOOL py_from_DRIVER_INFO_2(PyObject **dict, DRIVER_INFO_2 *info)
100 {
101         *dict = from_struct(info, py_DRIVER_INFO_2);
102         PyDict_SetItemString(*dict, "level", PyInt_FromLong(2));
103
104         return True;
105 }
106
107 BOOL py_to_DRIVER_INFO_2(DRIVER_INFO_2 *info, PyObject *dict)
108 {
109         return False;
110 }
111
112 BOOL py_from_DRIVER_INFO_3(PyObject **dict, DRIVER_INFO_3 *info)
113 {
114         *dict = from_struct(info, py_DRIVER_INFO_3);
115
116         PyDict_SetItemString(*dict, "level", PyInt_FromLong(3));
117
118         PyDict_SetItemString(
119                 *dict, "dependent_files", 
120                 from_unistr_list(info->dependentfiles));
121
122         return True;
123 }
124
125 BOOL py_to_DRIVER_INFO_3(DRIVER_INFO_3 *info, PyObject *dict)
126 {
127         PyObject *obj, *dict_copy = PyDict_Copy(dict);
128         BOOL result = False;
129
130         if (!(obj = PyDict_GetItemString(dict_copy, "dependent_files")) ||
131             !PyList_Check(obj))
132                 goto done;
133
134         info->dependentfiles = to_dependentfiles(obj);
135
136         PyDict_DelItemString(dict_copy, "dependent_files");
137
138         if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
139             !PyInt_Check(obj))
140                 goto done;
141
142         PyDict_DelItemString(dict_copy, "level");
143
144         if (!to_struct(info, dict_copy, py_DRIVER_INFO_3))
145             goto done;
146
147         result = True;
148
149 done:
150         Py_DECREF(dict_copy);
151         return result;
152 }
153
154 BOOL py_from_DRIVER_INFO_6(PyObject **dict, DRIVER_INFO_6 *info)
155 {
156         *dict = from_struct(info, py_DRIVER_INFO_6);
157         PyDict_SetItemString(*dict, "level", PyInt_FromLong(6));
158         PyDict_SetItemString(
159                 *dict, "dependent_files", 
160                 from_unistr_list(info->dependentfiles));
161         return True;
162 }
163
164 BOOL py_to_DRIVER_INFO_6(DRIVER_INFO_6 *info, PyObject *dict)
165 {
166         return False;
167 }
168
169 BOOL py_from_DRIVER_DIRECTORY_1(PyObject **dict, DRIVER_DIRECTORY_1 *info)
170 {
171         *dict = from_struct(info, py_DRIVER_DIRECTORY_1);
172         PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
173         return True;
174 }
175
176 BOOL py_to_DRIVER_DIRECTORY_1(DRIVER_DIRECTORY_1 *info, PyObject *dict)
177 {
178         return False;
179 }