rev |
line source |
slaxemulator@14624
|
1 diff -up hplip-3.12.6/prnt/cupsext/cupsext.c.ipp_accessors hplip-3.12.6/prnt/cupsext/cupsext.c
|
slaxemulator@14624
|
2 --- hplip-3.12.6/prnt/cupsext/cupsext.c.ipp_accessors 2012-06-18 12:41:19.000000000 +0200
|
slaxemulator@14624
|
3 +++ hplip-3.12.6/prnt/cupsext/cupsext.c 2012-07-19 17:11:47.606524137 +0200
|
slaxemulator@14624
|
4 @@ -87,6 +87,46 @@ typedef int Py_ssize_t;
|
slaxemulator@14624
|
5 #define PY_SSIZE_T_MIN INT_MIN
|
slaxemulator@14624
|
6 #endif
|
slaxemulator@14624
|
7
|
slaxemulator@14624
|
8 +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
|
slaxemulator@14624
|
9 +#define HAVE_CUPS_1_6 1
|
slaxemulator@14624
|
10 +#endif
|
slaxemulator@14624
|
11 +
|
slaxemulator@14624
|
12 +#ifndef HAVE_CUPS_1_6
|
slaxemulator@14624
|
13 +#define ippGetCount(attr) attr->num_values
|
slaxemulator@14624
|
14 +#define ippGetGroupTag(attr) attr->group_tag
|
slaxemulator@14624
|
15 +#define ippGetValueTag(attr) attr->value_tag
|
slaxemulator@14624
|
16 +#define ippGetName(attr) attr->name
|
slaxemulator@14624
|
17 +#define ippGetBoolean(attr, element) attr->values[element].boolean
|
slaxemulator@14624
|
18 +#define ippGetInteger(attr, element) attr->values[element].integer
|
slaxemulator@14624
|
19 +#define ippGetStatusCode(ipp) ipp->request.status.status_code
|
slaxemulator@14624
|
20 +#define ippGetString(attr, element, language) attr->values[element].string.text
|
slaxemulator@14624
|
21 +
|
slaxemulator@14624
|
22 +static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp )
|
slaxemulator@14624
|
23 +{
|
slaxemulator@14624
|
24 + if (!ipp)
|
slaxemulator@14624
|
25 + return (NULL);
|
slaxemulator@14624
|
26 + return (ipp->current = ipp->attrs);
|
slaxemulator@14624
|
27 +}
|
slaxemulator@14624
|
28 +
|
slaxemulator@14624
|
29 +static ipp_attribute_t * ippNextAttribute( ipp_t *ipp )
|
slaxemulator@14624
|
30 +{
|
slaxemulator@14624
|
31 + if (!ipp || !ipp->current)
|
slaxemulator@14624
|
32 + return (NULL);
|
slaxemulator@14624
|
33 + return (ipp->current = ipp->current->next);
|
slaxemulator@14624
|
34 +}
|
slaxemulator@14624
|
35 +
|
slaxemulator@14624
|
36 +static int ippSetOperation( ipp_t *ipp, ipp_op_t op )
|
slaxemulator@14624
|
37 +{
|
slaxemulator@14624
|
38 + ipp->request.op.operation_id = op;
|
slaxemulator@14624
|
39 + return (1);
|
slaxemulator@14624
|
40 +}
|
slaxemulator@14624
|
41 +
|
slaxemulator@14624
|
42 +static int ippSetRequestId( ipp_t *ipp, int request_id )
|
slaxemulator@14624
|
43 +{
|
slaxemulator@14624
|
44 + ipp->request.any.request_id = request_id;
|
slaxemulator@14624
|
45 + return (1);
|
slaxemulator@14624
|
46 +}
|
slaxemulator@14624
|
47 +#endif
|
slaxemulator@14624
|
48
|
slaxemulator@14624
|
49 int g_num_options = 0;
|
slaxemulator@14624
|
50 cups_option_t * g_options;
|
slaxemulator@14624
|
51 @@ -333,8 +373,8 @@ PyObject * getPrinters( PyObject * self,
|
slaxemulator@14624
|
52 request = ippNew();
|
slaxemulator@14624
|
53 language = cupsLangDefault();
|
slaxemulator@14624
|
54
|
slaxemulator@14624
|
55 - request->request.op.operation_id = CUPS_GET_PRINTERS;
|
slaxemulator@14624
|
56 - request->request.any.request_id = 1;
|
slaxemulator@14624
|
57 + ippSetOperation( request, CUPS_GET_PRINTERS );
|
slaxemulator@14624
|
58 + ippSetRequestId ( request, 1);
|
slaxemulator@14624
|
59
|
slaxemulator@14624
|
60 ippAddString( request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
|
slaxemulator@14624
|
61 "attributes-charset", NULL, cupsLangEncoding( language ) );
|
slaxemulator@14624
|
62 @@ -378,10 +418,10 @@ PyObject * getPrinters( PyObject * self,
|
slaxemulator@14624
|
63 ipp_pstate_t state;
|
slaxemulator@14624
|
64 int i = 0;
|
slaxemulator@14624
|
65
|
slaxemulator@14624
|
66 - for ( attr = response->attrs; attr != NULL; attr = attr->next )
|
slaxemulator@14624
|
67 + for ( attr = ippFirstAttribute( response ); attr != NULL; attr = ippNextAttribute( response ) )
|
slaxemulator@14624
|
68 {
|
slaxemulator@14624
|
69 - while ( attr != NULL && attr->group_tag != IPP_TAG_PRINTER )
|
slaxemulator@14624
|
70 - attr = attr->next;
|
slaxemulator@14624
|
71 + while ( attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER )
|
slaxemulator@14624
|
72 + attr = ippNextAttribute( response );
|
slaxemulator@14624
|
73
|
slaxemulator@14624
|
74 if ( attr == NULL )
|
slaxemulator@14624
|
75 break;
|
slaxemulator@14624
|
76 @@ -390,41 +430,41 @@ PyObject * getPrinters( PyObject * self,
|
slaxemulator@14624
|
77 state = IPP_PRINTER_IDLE;
|
slaxemulator@14624
|
78 accepting = 0;
|
slaxemulator@14624
|
79
|
slaxemulator@14624
|
80 - while ( attr != NULL && attr->group_tag == IPP_TAG_PRINTER )
|
slaxemulator@14624
|
81 + while ( attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER )
|
slaxemulator@14624
|
82 {
|
slaxemulator@14624
|
83 - if ( strcmp( attr->name, "printer-name" ) == 0 &&
|
slaxemulator@14624
|
84 - attr->value_tag == IPP_TAG_NAME )
|
slaxemulator@14624
|
85 - name = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
86 -
|
slaxemulator@14624
|
87 - else if ( strcmp( attr->name, "device-uri" ) == 0 &&
|
slaxemulator@14624
|
88 - attr->value_tag == IPP_TAG_URI )
|
slaxemulator@14624
|
89 - device_uri = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
90 -
|
slaxemulator@14624
|
91 - else if ( strcmp( attr->name, "printer-uri-supported" ) == 0 &&
|
slaxemulator@14624
|
92 - attr->value_tag == IPP_TAG_URI )
|
slaxemulator@14624
|
93 - printer_uri = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
94 -
|
slaxemulator@14624
|
95 - else if ( strcmp( attr->name, "printer-info" ) == 0 &&
|
slaxemulator@14624
|
96 - attr->value_tag == IPP_TAG_TEXT )
|
slaxemulator@14624
|
97 - info = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
98 -
|
slaxemulator@14624
|
99 - else if ( strcmp( attr->name, "printer-location" ) == 0 &&
|
slaxemulator@14624
|
100 - attr->value_tag == IPP_TAG_TEXT )
|
slaxemulator@14624
|
101 - location = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
102 -
|
slaxemulator@14624
|
103 - else if ( strcmp( attr->name, "printer-make-and-model" ) == 0 &&
|
slaxemulator@14624
|
104 - attr->value_tag == IPP_TAG_TEXT )
|
slaxemulator@14624
|
105 - make_model = attr->values[ 0 ].string.text;
|
slaxemulator@14624
|
106 -
|
slaxemulator@14624
|
107 - else if ( strcmp( attr->name, "printer-state" ) == 0 &&
|
slaxemulator@14624
|
108 - attr->value_tag == IPP_TAG_ENUM )
|
slaxemulator@14624
|
109 - state = ( ipp_pstate_t ) attr->values[ 0 ].integer;
|
slaxemulator@14624
|
110 -
|
slaxemulator@14624
|
111 - else if (!strcmp(attr->name, "printer-is-accepting-jobs") &&
|
slaxemulator@14624
|
112 - attr->value_tag == IPP_TAG_BOOLEAN)
|
slaxemulator@14624
|
113 - accepting = attr->values[ 0 ].boolean;
|
slaxemulator@14624
|
114 + if ( strcmp( ippGetName( attr ), "printer-name" ) == 0 &&
|
slaxemulator@14624
|
115 + ippGetValueTag( attr ) == IPP_TAG_NAME )
|
slaxemulator@14624
|
116 + name = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
117 +
|
slaxemulator@14624
|
118 + else if ( strcmp( ippGetName( attr ), "device-uri" ) == 0 &&
|
slaxemulator@14624
|
119 + ippGetValueTag( attr ) == IPP_TAG_URI )
|
slaxemulator@14624
|
120 + device_uri = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
121 +
|
slaxemulator@14624
|
122 + else if ( strcmp( ippGetName( attr ), "printer-uri-supported" ) == 0 &&
|
slaxemulator@14624
|
123 + ippGetValueTag( attr ) == IPP_TAG_URI )
|
slaxemulator@14624
|
124 + printer_uri = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
125 +
|
slaxemulator@14624
|
126 + else if ( strcmp( ippGetName( attr ), "printer-info" ) == 0 &&
|
slaxemulator@14624
|
127 + ippGetValueTag( attr ) == IPP_TAG_TEXT )
|
slaxemulator@14624
|
128 + info = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
129 +
|
slaxemulator@14624
|
130 + else if ( strcmp( ippGetName( attr ), "printer-location" ) == 0 &&
|
slaxemulator@14624
|
131 + ippGetValueTag( attr ) == IPP_TAG_TEXT )
|
slaxemulator@14624
|
132 + location = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
133 +
|
slaxemulator@14624
|
134 + else if ( strcmp( ippGetName( attr ), "printer-make-and-model" ) == 0 &&
|
slaxemulator@14624
|
135 + ippGetValueTag( attr ) == IPP_TAG_TEXT )
|
slaxemulator@14624
|
136 + make_model = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
137 +
|
slaxemulator@14624
|
138 + else if ( strcmp( ippGetName( attr ), "printer-state" ) == 0 &&
|
slaxemulator@14624
|
139 + ippGetValueTag( attr ) == IPP_TAG_ENUM )
|
slaxemulator@14624
|
140 + state = ( ipp_pstate_t ) ippGetInteger( attr, 0 );
|
slaxemulator@14624
|
141 +
|
slaxemulator@14624
|
142 + else if (!strcmp(ippGetName( attr ), "printer-is-accepting-jobs") &&
|
slaxemulator@14624
|
143 + ippGetValueTag( attr ) == IPP_TAG_BOOLEAN)
|
slaxemulator@14624
|
144 + accepting = ippGetBoolean( attr, 0 );
|
slaxemulator@14624
|
145
|
slaxemulator@14624
|
146 - attr = attr->next;
|
slaxemulator@14624
|
147 + attr = ippNextAttribute( response );
|
slaxemulator@14624
|
148 }
|
slaxemulator@14624
|
149
|
slaxemulator@14624
|
150 if ( device_uri == NULL )
|
slaxemulator@14624
|
151 @@ -522,8 +562,8 @@ PyObject * addPrinter( PyObject * self,
|
slaxemulator@14624
|
152 request = ippNew();
|
slaxemulator@14624
|
153 language = cupsLangDefault();
|
slaxemulator@14624
|
154
|
slaxemulator@14624
|
155 - request->request.op.operation_id = CUPS_ADD_PRINTER;
|
slaxemulator@14624
|
156 - request->request.any.request_id = 1;
|
slaxemulator@14624
|
157 + ippSetOperation( request, CUPS_ADD_PRINTER );
|
slaxemulator@14624
|
158 + ippSetRequestId ( request, 1 );
|
slaxemulator@14624
|
159
|
slaxemulator@14624
|
160 ippAddString( request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
|
slaxemulator@14624
|
161 "attributes-charset", NULL, cupsLangEncoding( language ) );
|
slaxemulator@14624
|
162 @@ -568,7 +608,7 @@ PyObject * addPrinter( PyObject * self,
|
slaxemulator@14624
|
163 }
|
slaxemulator@14624
|
164 else
|
slaxemulator@14624
|
165 {
|
slaxemulator@14624
|
166 - status = response->request.status.status_code;
|
slaxemulator@14624
|
167 + status = ippGetStatusCode( response );
|
slaxemulator@14624
|
168 //ippDelete( response );
|
slaxemulator@14624
|
169 r = 1;
|
slaxemulator@14624
|
170 }
|
slaxemulator@14624
|
171 @@ -631,8 +671,8 @@ PyObject * delPrinter( PyObject * self,
|
slaxemulator@14624
|
172 */
|
slaxemulator@14624
|
173 request = ippNew();
|
slaxemulator@14624
|
174
|
slaxemulator@14624
|
175 - request->request.op.operation_id = CUPS_DELETE_PRINTER;
|
slaxemulator@14624
|
176 - request->request.op.request_id = 1;
|
slaxemulator@14624
|
177 + ippSetOperation( request, CUPS_DELETE_PRINTER );
|
slaxemulator@14624
|
178 + ippSetRequestId ( request, 1 );
|
slaxemulator@14624
|
179
|
slaxemulator@14624
|
180 language = cupsLangDefault();
|
slaxemulator@14624
|
181
|
slaxemulator@14624
|
182 @@ -650,7 +690,7 @@ PyObject * delPrinter( PyObject * self,
|
slaxemulator@14624
|
183 */
|
slaxemulator@14624
|
184 response = cupsDoRequest( http, request, "/admin/" );
|
slaxemulator@14624
|
185
|
slaxemulator@14624
|
186 - if ( ( response != NULL ) && ( response->request.status.status_code <= IPP_OK_CONFLICT ) )
|
slaxemulator@14624
|
187 + if ( ( response != NULL ) && ( ippGetStatusCode( response ) <= IPP_OK_CONFLICT ) )
|
slaxemulator@14624
|
188 {
|
slaxemulator@14624
|
189 r = 1;
|
slaxemulator@14624
|
190 }
|
slaxemulator@14624
|
191 @@ -721,8 +761,8 @@ PyObject * setDefaultPrinter( PyObject *
|
slaxemulator@14624
|
192
|
slaxemulator@14624
|
193 request = ippNew();
|
slaxemulator@14624
|
194
|
slaxemulator@14624
|
195 - request->request.op.operation_id = CUPS_SET_DEFAULT;
|
slaxemulator@14624
|
196 - request->request.op.request_id = 1;
|
slaxemulator@14624
|
197 + ippSetOperation( request, CUPS_SET_DEFAULT );
|
slaxemulator@14624
|
198 + ippSetRequestId ( request, 1 );
|
slaxemulator@14624
|
199
|
slaxemulator@14624
|
200 language = cupsLangDefault();
|
slaxemulator@14624
|
201
|
slaxemulator@14624
|
202 @@ -743,7 +783,7 @@ PyObject * setDefaultPrinter( PyObject *
|
slaxemulator@14624
|
203
|
slaxemulator@14624
|
204 response = cupsDoRequest( http, request, "/admin/" );
|
slaxemulator@14624
|
205
|
slaxemulator@14624
|
206 - if ( ( response != NULL ) && ( response->request.status.status_code <= IPP_OK_CONFLICT ) )
|
slaxemulator@14624
|
207 + if ( ( response != NULL ) && ( ippGetStatusCode( response ) <= IPP_OK_CONFLICT ) )
|
slaxemulator@14624
|
208 {
|
slaxemulator@14624
|
209 r = 1;
|
slaxemulator@14624
|
210 }
|
slaxemulator@14624
|
211 @@ -797,8 +837,8 @@ PyObject * controlPrinter( PyObject * se
|
slaxemulator@14624
|
212
|
slaxemulator@14624
|
213 request = ippNew();
|
slaxemulator@14624
|
214
|
slaxemulator@14624
|
215 - request->request.op.operation_id = op;
|
slaxemulator@14624
|
216 - request->request.op.request_id = 1;
|
slaxemulator@14624
|
217 + ippSetOperation( request, op );
|
slaxemulator@14624
|
218 + ippSetRequestId ( request, 1 );
|
slaxemulator@14624
|
219
|
slaxemulator@14624
|
220 language = cupsLangDefault();
|
slaxemulator@14624
|
221
|
slaxemulator@14624
|
222 @@ -822,7 +862,7 @@ PyObject * controlPrinter( PyObject * se
|
slaxemulator@14624
|
223
|
slaxemulator@14624
|
224 response = cupsDoRequest(http, request, "/admin/");
|
slaxemulator@14624
|
225
|
slaxemulator@14624
|
226 - if (( response != NULL ) && (response->request.status.status_code <= IPP_OK_CONFLICT))
|
slaxemulator@14624
|
227 + if (( response != NULL ) && (ippGetStatusCode( response ) <= IPP_OK_CONFLICT))
|
slaxemulator@14624
|
228 {
|
slaxemulator@14624
|
229 r = 1;
|
slaxemulator@14624
|
230 }
|
slaxemulator@14624
|
231 @@ -837,7 +877,7 @@ abort:
|
slaxemulator@14624
|
232 if ( response != NULL )
|
slaxemulator@14624
|
233 ippDelete( response );
|
slaxemulator@14624
|
234
|
slaxemulator@14624
|
235 - return Py_BuildValue( "i", r );;
|
slaxemulator@14624
|
236 + return Py_BuildValue( "i", r );
|
slaxemulator@14624
|
237 }
|
slaxemulator@14624
|
238
|
slaxemulator@14624
|
239
|
slaxemulator@14624
|
240 @@ -1116,8 +1156,8 @@ PyObject * getPPDList( PyObject * self,
|
slaxemulator@14624
|
241
|
slaxemulator@14624
|
242 request = ippNew();
|
slaxemulator@14624
|
243
|
slaxemulator@14624
|
244 - request->request.op.operation_id = CUPS_GET_PPDS;
|
slaxemulator@14624
|
245 - request->request.op.request_id = 1;
|
slaxemulator@14624
|
246 + ippSetOperation( request, CUPS_GET_PPDS );
|
slaxemulator@14624
|
247 + ippSetRequestId ( request, 1 );
|
slaxemulator@14624
|
248
|
slaxemulator@14624
|
249 language = cupsLangDefault();
|
slaxemulator@14624
|
250
|
slaxemulator@14624
|
251 @@ -1143,43 +1183,43 @@ PyObject * getPPDList( PyObject * self,
|
slaxemulator@14624
|
252 if ((response = cupsDoRequest(http, request, "/")) != NULL)
|
slaxemulator@14624
|
253 {
|
slaxemulator@14624
|
254
|
slaxemulator@14624
|
255 - for (attr = response->attrs; attr; attr = attr->next)
|
slaxemulator@14624
|
256 + for (attr = ippFirstAttribute( response ); attr; attr = ippNextAttribute( response ))
|
slaxemulator@14624
|
257 {
|
slaxemulator@14624
|
258 PyObject *dict;
|
slaxemulator@14624
|
259 char *ppdname = NULL;
|
slaxemulator@14624
|
260
|
slaxemulator@14624
|
261 - while (attr && attr->group_tag != IPP_TAG_PRINTER)
|
slaxemulator@14624
|
262 - attr = attr->next;
|
slaxemulator@14624
|
263 + while (attr && ippGetGroupTag( attr ) != IPP_TAG_PRINTER)
|
slaxemulator@14624
|
264 + attr = ippNextAttribute( response );
|
slaxemulator@14624
|
265
|
slaxemulator@14624
|
266 if (!attr)
|
slaxemulator@14624
|
267 break;
|
slaxemulator@14624
|
268
|
slaxemulator@14624
|
269 dict = PyDict_New ();
|
slaxemulator@14624
|
270
|
slaxemulator@14624
|
271 - for (; attr && attr->group_tag == IPP_TAG_PRINTER; attr = attr->next)
|
slaxemulator@14624
|
272 + for (; attr && ippGetGroupTag( attr ) == IPP_TAG_PRINTER; attr = ippNextAttribute( response ))
|
slaxemulator@14624
|
273 {
|
slaxemulator@14624
|
274 PyObject *val = NULL;
|
slaxemulator@14624
|
275
|
slaxemulator@14624
|
276 - if (!strcmp (attr->name, "ppd-name") && attr->value_tag == IPP_TAG_NAME)
|
slaxemulator@14624
|
277 + if (!strcmp (ippGetName( attr ), "ppd-name") && ippGetValueTag( attr ) == IPP_TAG_NAME)
|
slaxemulator@14624
|
278 {
|
slaxemulator@14624
|
279 - ppdname = attr->values[0].string.text;
|
slaxemulator@14624
|
280 + ppdname = ippGetString( attr, 0, NULL );
|
slaxemulator@14624
|
281
|
slaxemulator@14624
|
282 //sprintf( buf, "print '%s'", ppdname);
|
slaxemulator@14624
|
283 //PyRun_SimpleString( buf );
|
slaxemulator@14624
|
284 }
|
slaxemulator@14624
|
285
|
slaxemulator@14624
|
286 - else if (attr->value_tag == IPP_TAG_TEXT || attr->value_tag == IPP_TAG_NAME || attr->value_tag == IPP_TAG_KEYWORD)
|
slaxemulator@14624
|
287 - //else if ((!strcmp (attr->name, "ppd-natural-language") && attr->value_tag == IPP_TAG_LANGUAGE) ||
|
slaxemulator@14624
|
288 - // (!strcmp (attr->name, "ppd-make-and-model") && attr->value_tag == IPP_TAG_TEXT) ||
|
slaxemulator@14624
|
289 - // (!strcmp (attr->name, "ppd-make") && attr->value_tag == IPP_TAG_TEXT) ||
|
slaxemulator@14624
|
290 - // (!strcmp (attr->name, "ppd-device-id") && attr->value_tag == IPP_TAG_TEXT))
|
slaxemulator@14624
|
291 + else if (ippGetValueTag( attr ) == IPP_TAG_TEXT || ippGetValueTag( attr ) == IPP_TAG_NAME || ippGetValueTag( attr ) == IPP_TAG_KEYWORD)
|
slaxemulator@14624
|
292 + //else if ((!strcmp (ippGetName( attr ), "ppd-natural-language") && ippGetValueTag( attr ) == IPP_TAG_LANGUAGE) ||
|
slaxemulator@14624
|
293 + // (!strcmp (ippGetName( attr ), "ppd-make-and-model") && ippGetValueTag( attr ) == IPP_TAG_TEXT) ||
|
slaxemulator@14624
|
294 + // (!strcmp (ippGetName( attr ), "ppd-make") && ippGetValueTag( attr ) == IPP_TAG_TEXT) ||
|
slaxemulator@14624
|
295 + // (!strcmp (ippGetName( attr ), "ppd-device-id") && ippGetValueTag( attr ) == IPP_TAG_TEXT))
|
slaxemulator@14624
|
296 {
|
slaxemulator@14624
|
297 - val = PyObj_from_UTF8(attr->values[0].string.text);
|
slaxemulator@14624
|
298 + val = PyObj_from_UTF8(ippGetString( attr, 0, NULL ));
|
slaxemulator@14624
|
299 }
|
slaxemulator@14624
|
300
|
slaxemulator@14624
|
301 if (val)
|
slaxemulator@14624
|
302 {
|
slaxemulator@14624
|
303 - PyDict_SetItemString (dict, attr->name, val);
|
slaxemulator@14624
|
304 + PyDict_SetItemString (dict, ippGetName( attr ), val);
|
slaxemulator@14624
|
305 Py_DECREF (val);
|
slaxemulator@14624
|
306 }
|
slaxemulator@14624
|
307 }
|
slaxemulator@14624
|
308 diff -up hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors hplip-3.12.6/scan/sane/hpaio.c
|
slaxemulator@14624
|
309 --- hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors 2012-06-18 12:42:51.000000000 +0200
|
slaxemulator@14624
|
310 +++ hplip-3.12.6/scan/sane/hpaio.c 2012-07-19 17:12:34.557848760 +0200
|
slaxemulator@14624
|
311 @@ -47,6 +47,43 @@
|
slaxemulator@14624
|
312 #define DEBUG_DECLARE_ONLY
|
slaxemulator@14624
|
313 #include "sanei_debug.h"
|
slaxemulator@14624
|
314
|
slaxemulator@14624
|
315 +#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
|
slaxemulator@14624
|
316 +#define HAVE_CUPS_1_6 1
|
slaxemulator@14624
|
317 +#endif
|
slaxemulator@14624
|
318 +
|
slaxemulator@14624
|
319 +#ifndef HAVE_CUPS_1_6
|
slaxemulator@14624
|
320 +#define ippGetGroupTag(attr) attr->group_tag
|
slaxemulator@14624
|
321 +#define ippGetValueTag(attr) attr->value_tag
|
slaxemulator@14624
|
322 +#define ippGetName(attr) attr->name
|
slaxemulator@14624
|
323 +#define ippGetString(attr, element, language) attr->values[element].string.text
|
slaxemulator@14624
|
324 +
|
slaxemulator@14624
|
325 +static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp )
|
slaxemulator@14624
|
326 +{
|
slaxemulator@14624
|
327 + if (!ipp)
|
slaxemulator@14624
|
328 + return (NULL);
|
slaxemulator@14624
|
329 + return (ipp->current = ipp->attrs);
|
slaxemulator@14624
|
330 +}
|
slaxemulator@14624
|
331 +
|
slaxemulator@14624
|
332 +static ipp_attribute_t * ippNextAttribute( ipp_t *ipp )
|
slaxemulator@14624
|
333 +{
|
slaxemulator@14624
|
334 + if (!ipp || !ipp->current)
|
slaxemulator@14624
|
335 + return (NULL);
|
slaxemulator@14624
|
336 + return (ipp->current = ipp->current->next);
|
slaxemulator@14624
|
337 +}
|
slaxemulator@14624
|
338 +
|
slaxemulator@14624
|
339 +static int ippSetOperation( ipp_t *ipp, ipp_op_t op )
|
slaxemulator@14624
|
340 +{
|
slaxemulator@14624
|
341 + ipp->request.op.operation_id = op;
|
slaxemulator@14624
|
342 + return (1);
|
slaxemulator@14624
|
343 +}
|
slaxemulator@14624
|
344 +
|
slaxemulator@14624
|
345 +static int ippSetRequestId( ipp_t *ipp, int request_id )
|
slaxemulator@14624
|
346 +{
|
slaxemulator@14624
|
347 + ipp->request.any.request_id = request_id;
|
slaxemulator@14624
|
348 + return (1);
|
slaxemulator@14624
|
349 +}
|
slaxemulator@14624
|
350 +#endif
|
slaxemulator@14624
|
351 +
|
slaxemulator@14624
|
352 static SANE_Device **DeviceList = NULL;
|
slaxemulator@14624
|
353
|
slaxemulator@14624
|
354 static int AddDeviceList(char *uri, char *model, SANE_Device ***pd)
|
slaxemulator@14624
|
355 @@ -186,8 +223,8 @@ static int GetCupsPrinters(char ***print
|
slaxemulator@14624
|
356 /* Assemble the IPP request */
|
slaxemulator@14624
|
357 request = ippNew();
|
slaxemulator@14624
|
358
|
slaxemulator@14624
|
359 - request->request.op.operation_id = CUPS_GET_PRINTERS;
|
slaxemulator@14624
|
360 - request->request.any.request_id = 1;
|
slaxemulator@14624
|
361 + ippSetOperation( request, CUPS_GET_PRINTERS );
|
slaxemulator@14624
|
362 + ippSetRequestId( request, 1 );
|
slaxemulator@14624
|
363
|
slaxemulator@14624
|
364 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8");
|
slaxemulator@14624
|
365 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en");
|
slaxemulator@14624
|
366 @@ -197,20 +234,20 @@ static int GetCupsPrinters(char ***print
|
slaxemulator@14624
|
367 if ((response = cupsDoRequest(http, request, "/")) == NULL)
|
slaxemulator@14624
|
368 goto bugout;
|
slaxemulator@14624
|
369
|
slaxemulator@14624
|
370 - for (attr = response->attrs; attr != NULL; attr = attr->next)
|
slaxemulator@14624
|
371 + for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response ))
|
slaxemulator@14624
|
372 {
|
slaxemulator@14624
|
373 /* Skip leading attributes until we hit a printer. */
|
slaxemulator@14624
|
374 - while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
|
slaxemulator@14624
|
375 - attr = attr->next;
|
slaxemulator@14624
|
376 + while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER)
|
slaxemulator@14624
|
377 + attr = ippNextAttribute( response );
|
slaxemulator@14624
|
378
|
slaxemulator@14624
|
379 if (attr == NULL)
|
slaxemulator@14624
|
380 break;
|
slaxemulator@14624
|
381
|
slaxemulator@14624
|
382 - while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER)
|
slaxemulator@14624
|
383 + while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER)
|
slaxemulator@14624
|
384 {
|
slaxemulator@14624
|
385 - if (strcmp(attr->name, "device-uri") == 0 && attr->value_tag == IPP_TAG_URI && AddCupsList(attr->values[0].string.text, printer) == 0)
|
slaxemulator@14624
|
386 + if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0)
|
slaxemulator@14624
|
387 cnt++;
|
slaxemulator@14624
|
388 - attr = attr->next;
|
slaxemulator@14624
|
389 + attr = ippNextAttribute( response );
|
slaxemulator@14624
|
390 }
|
slaxemulator@14624
|
391
|
slaxemulator@14624
|
392 if (attr == NULL)
|