wok-6.x view hplip/stuff/cups-1.6-buildfix.diff @ rev 22601

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