wok diff hplip/stuff/cups-1.6-buildfix.diff @ rev 17464
Up mercurial (3.2.3)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Dec 22 15:02:01 2014 +0100 (2014-12-22) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/hplip/stuff/cups-1.6-buildfix.diff Mon Dec 22 15:02:01 2014 +0100 1.3 @@ -0,0 +1,392 @@ 1.4 +diff -up hplip-3.12.6/prnt/cupsext/cupsext.c.ipp_accessors hplip-3.12.6/prnt/cupsext/cupsext.c 1.5 +--- hplip-3.12.6/prnt/cupsext/cupsext.c.ipp_accessors 2012-06-18 12:41:19.000000000 +0200 1.6 ++++ hplip-3.12.6/prnt/cupsext/cupsext.c 2012-07-19 17:11:47.606524137 +0200 1.7 +@@ -87,6 +87,46 @@ typedef int Py_ssize_t; 1.8 + #define PY_SSIZE_T_MIN INT_MIN 1.9 + #endif 1.10 + 1.11 ++#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) 1.12 ++#define HAVE_CUPS_1_6 1 1.13 ++#endif 1.14 ++ 1.15 ++#ifndef HAVE_CUPS_1_6 1.16 ++#define ippGetCount(attr) attr->num_values 1.17 ++#define ippGetGroupTag(attr) attr->group_tag 1.18 ++#define ippGetValueTag(attr) attr->value_tag 1.19 ++#define ippGetName(attr) attr->name 1.20 ++#define ippGetBoolean(attr, element) attr->values[element].boolean 1.21 ++#define ippGetInteger(attr, element) attr->values[element].integer 1.22 ++#define ippGetStatusCode(ipp) ipp->request.status.status_code 1.23 ++#define ippGetString(attr, element, language) attr->values[element].string.text 1.24 ++ 1.25 ++static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp ) 1.26 ++{ 1.27 ++ if (!ipp) 1.28 ++ return (NULL); 1.29 ++ return (ipp->current = ipp->attrs); 1.30 ++} 1.31 ++ 1.32 ++static ipp_attribute_t * ippNextAttribute( ipp_t *ipp ) 1.33 ++{ 1.34 ++ if (!ipp || !ipp->current) 1.35 ++ return (NULL); 1.36 ++ return (ipp->current = ipp->current->next); 1.37 ++} 1.38 ++ 1.39 ++static int ippSetOperation( ipp_t *ipp, ipp_op_t op ) 1.40 ++{ 1.41 ++ ipp->request.op.operation_id = op; 1.42 ++ return (1); 1.43 ++} 1.44 ++ 1.45 ++static int ippSetRequestId( ipp_t *ipp, int request_id ) 1.46 ++{ 1.47 ++ ipp->request.any.request_id = request_id; 1.48 ++ return (1); 1.49 ++} 1.50 ++#endif 1.51 + 1.52 + int g_num_options = 0; 1.53 + cups_option_t * g_options; 1.54 +@@ -333,8 +373,8 @@ PyObject * getPrinters( PyObject * self, 1.55 + request = ippNew(); 1.56 + language = cupsLangDefault(); 1.57 + 1.58 +- request->request.op.operation_id = CUPS_GET_PRINTERS; 1.59 +- request->request.any.request_id = 1; 1.60 ++ ippSetOperation( request, CUPS_GET_PRINTERS ); 1.61 ++ ippSetRequestId ( request, 1); 1.62 + 1.63 + ippAddString( request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, 1.64 + "attributes-charset", NULL, cupsLangEncoding( language ) ); 1.65 +@@ -378,10 +418,10 @@ PyObject * getPrinters( PyObject * self, 1.66 + ipp_pstate_t state; 1.67 + int i = 0; 1.68 + 1.69 +- for ( attr = response->attrs; attr != NULL; attr = attr->next ) 1.70 ++ for ( attr = ippFirstAttribute( response ); attr != NULL; attr = ippNextAttribute( response ) ) 1.71 + { 1.72 +- while ( attr != NULL && attr->group_tag != IPP_TAG_PRINTER ) 1.73 +- attr = attr->next; 1.74 ++ while ( attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER ) 1.75 ++ attr = ippNextAttribute( response ); 1.76 + 1.77 + if ( attr == NULL ) 1.78 + break; 1.79 +@@ -390,41 +430,41 @@ PyObject * getPrinters( PyObject * self, 1.80 + state = IPP_PRINTER_IDLE; 1.81 + accepting = 0; 1.82 + 1.83 +- while ( attr != NULL && attr->group_tag == IPP_TAG_PRINTER ) 1.84 ++ while ( attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER ) 1.85 + { 1.86 +- if ( strcmp( attr->name, "printer-name" ) == 0 && 1.87 +- attr->value_tag == IPP_TAG_NAME ) 1.88 +- name = attr->values[ 0 ].string.text; 1.89 +- 1.90 +- else if ( strcmp( attr->name, "device-uri" ) == 0 && 1.91 +- attr->value_tag == IPP_TAG_URI ) 1.92 +- device_uri = attr->values[ 0 ].string.text; 1.93 +- 1.94 +- else if ( strcmp( attr->name, "printer-uri-supported" ) == 0 && 1.95 +- attr->value_tag == IPP_TAG_URI ) 1.96 +- printer_uri = attr->values[ 0 ].string.text; 1.97 +- 1.98 +- else if ( strcmp( attr->name, "printer-info" ) == 0 && 1.99 +- attr->value_tag == IPP_TAG_TEXT ) 1.100 +- info = attr->values[ 0 ].string.text; 1.101 +- 1.102 +- else if ( strcmp( attr->name, "printer-location" ) == 0 && 1.103 +- attr->value_tag == IPP_TAG_TEXT ) 1.104 +- location = attr->values[ 0 ].string.text; 1.105 +- 1.106 +- else if ( strcmp( attr->name, "printer-make-and-model" ) == 0 && 1.107 +- attr->value_tag == IPP_TAG_TEXT ) 1.108 +- make_model = attr->values[ 0 ].string.text; 1.109 +- 1.110 +- else if ( strcmp( attr->name, "printer-state" ) == 0 && 1.111 +- attr->value_tag == IPP_TAG_ENUM ) 1.112 +- state = ( ipp_pstate_t ) attr->values[ 0 ].integer; 1.113 +- 1.114 +- else if (!strcmp(attr->name, "printer-is-accepting-jobs") && 1.115 +- attr->value_tag == IPP_TAG_BOOLEAN) 1.116 +- accepting = attr->values[ 0 ].boolean; 1.117 ++ if ( strcmp( ippGetName( attr ), "printer-name" ) == 0 && 1.118 ++ ippGetValueTag( attr ) == IPP_TAG_NAME ) 1.119 ++ name = ippGetString( attr, 0, NULL ); 1.120 ++ 1.121 ++ else if ( strcmp( ippGetName( attr ), "device-uri" ) == 0 && 1.122 ++ ippGetValueTag( attr ) == IPP_TAG_URI ) 1.123 ++ device_uri = ippGetString( attr, 0, NULL ); 1.124 ++ 1.125 ++ else if ( strcmp( ippGetName( attr ), "printer-uri-supported" ) == 0 && 1.126 ++ ippGetValueTag( attr ) == IPP_TAG_URI ) 1.127 ++ printer_uri = ippGetString( attr, 0, NULL ); 1.128 ++ 1.129 ++ else if ( strcmp( ippGetName( attr ), "printer-info" ) == 0 && 1.130 ++ ippGetValueTag( attr ) == IPP_TAG_TEXT ) 1.131 ++ info = ippGetString( attr, 0, NULL ); 1.132 ++ 1.133 ++ else if ( strcmp( ippGetName( attr ), "printer-location" ) == 0 && 1.134 ++ ippGetValueTag( attr ) == IPP_TAG_TEXT ) 1.135 ++ location = ippGetString( attr, 0, NULL ); 1.136 ++ 1.137 ++ else if ( strcmp( ippGetName( attr ), "printer-make-and-model" ) == 0 && 1.138 ++ ippGetValueTag( attr ) == IPP_TAG_TEXT ) 1.139 ++ make_model = ippGetString( attr, 0, NULL ); 1.140 ++ 1.141 ++ else if ( strcmp( ippGetName( attr ), "printer-state" ) == 0 && 1.142 ++ ippGetValueTag( attr ) == IPP_TAG_ENUM ) 1.143 ++ state = ( ipp_pstate_t ) ippGetInteger( attr, 0 ); 1.144 ++ 1.145 ++ else if (!strcmp(ippGetName( attr ), "printer-is-accepting-jobs") && 1.146 ++ ippGetValueTag( attr ) == IPP_TAG_BOOLEAN) 1.147 ++ accepting = ippGetBoolean( attr, 0 ); 1.148 + 1.149 +- attr = attr->next; 1.150 ++ attr = ippNextAttribute( response ); 1.151 + } 1.152 + 1.153 + if ( device_uri == NULL ) 1.154 +@@ -522,8 +562,8 @@ PyObject * addPrinter( PyObject * self, 1.155 + request = ippNew(); 1.156 + language = cupsLangDefault(); 1.157 + 1.158 +- request->request.op.operation_id = CUPS_ADD_PRINTER; 1.159 +- request->request.any.request_id = 1; 1.160 ++ ippSetOperation( request, CUPS_ADD_PRINTER ); 1.161 ++ ippSetRequestId ( request, 1 ); 1.162 + 1.163 + ippAddString( request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, 1.164 + "attributes-charset", NULL, cupsLangEncoding( language ) ); 1.165 +@@ -568,7 +608,7 @@ PyObject * addPrinter( PyObject * self, 1.166 + } 1.167 + else 1.168 + { 1.169 +- status = response->request.status.status_code; 1.170 ++ status = ippGetStatusCode( response ); 1.171 + //ippDelete( response ); 1.172 + r = 1; 1.173 + } 1.174 +@@ -631,8 +671,8 @@ PyObject * delPrinter( PyObject * self, 1.175 + */ 1.176 + request = ippNew(); 1.177 + 1.178 +- request->request.op.operation_id = CUPS_DELETE_PRINTER; 1.179 +- request->request.op.request_id = 1; 1.180 ++ ippSetOperation( request, CUPS_DELETE_PRINTER ); 1.181 ++ ippSetRequestId ( request, 1 ); 1.182 + 1.183 + language = cupsLangDefault(); 1.184 + 1.185 +@@ -650,7 +690,7 @@ PyObject * delPrinter( PyObject * self, 1.186 + */ 1.187 + response = cupsDoRequest( http, request, "/admin/" ); 1.188 + 1.189 +- if ( ( response != NULL ) && ( response->request.status.status_code <= IPP_OK_CONFLICT ) ) 1.190 ++ if ( ( response != NULL ) && ( ippGetStatusCode( response ) <= IPP_OK_CONFLICT ) ) 1.191 + { 1.192 + r = 1; 1.193 + } 1.194 +@@ -721,8 +761,8 @@ PyObject * setDefaultPrinter( PyObject * 1.195 + 1.196 + request = ippNew(); 1.197 + 1.198 +- request->request.op.operation_id = CUPS_SET_DEFAULT; 1.199 +- request->request.op.request_id = 1; 1.200 ++ ippSetOperation( request, CUPS_SET_DEFAULT ); 1.201 ++ ippSetRequestId ( request, 1 ); 1.202 + 1.203 + language = cupsLangDefault(); 1.204 + 1.205 +@@ -743,7 +783,7 @@ PyObject * setDefaultPrinter( PyObject * 1.206 + 1.207 + response = cupsDoRequest( http, request, "/admin/" ); 1.208 + 1.209 +- if ( ( response != NULL ) && ( response->request.status.status_code <= IPP_OK_CONFLICT ) ) 1.210 ++ if ( ( response != NULL ) && ( ippGetStatusCode( response ) <= IPP_OK_CONFLICT ) ) 1.211 + { 1.212 + r = 1; 1.213 + } 1.214 +@@ -797,8 +837,8 @@ PyObject * controlPrinter( PyObject * se 1.215 + 1.216 + request = ippNew(); 1.217 + 1.218 +- request->request.op.operation_id = op; 1.219 +- request->request.op.request_id = 1; 1.220 ++ ippSetOperation( request, op ); 1.221 ++ ippSetRequestId ( request, 1 ); 1.222 + 1.223 + language = cupsLangDefault(); 1.224 + 1.225 +@@ -822,7 +862,7 @@ PyObject * controlPrinter( PyObject * se 1.226 + 1.227 + response = cupsDoRequest(http, request, "/admin/"); 1.228 + 1.229 +- if (( response != NULL ) && (response->request.status.status_code <= IPP_OK_CONFLICT)) 1.230 ++ if (( response != NULL ) && (ippGetStatusCode( response ) <= IPP_OK_CONFLICT)) 1.231 + { 1.232 + r = 1; 1.233 + } 1.234 +@@ -837,7 +877,7 @@ abort: 1.235 + if ( response != NULL ) 1.236 + ippDelete( response ); 1.237 + 1.238 +- return Py_BuildValue( "i", r );; 1.239 ++ return Py_BuildValue( "i", r ); 1.240 + } 1.241 + 1.242 + 1.243 +@@ -1116,8 +1156,8 @@ PyObject * getPPDList( PyObject * self, 1.244 + 1.245 + request = ippNew(); 1.246 + 1.247 +- request->request.op.operation_id = CUPS_GET_PPDS; 1.248 +- request->request.op.request_id = 1; 1.249 ++ ippSetOperation( request, CUPS_GET_PPDS ); 1.250 ++ ippSetRequestId ( request, 1 ); 1.251 + 1.252 + language = cupsLangDefault(); 1.253 + 1.254 +@@ -1143,43 +1183,43 @@ PyObject * getPPDList( PyObject * self, 1.255 + if ((response = cupsDoRequest(http, request, "/")) != NULL) 1.256 + { 1.257 + 1.258 +- for (attr = response->attrs; attr; attr = attr->next) 1.259 ++ for (attr = ippFirstAttribute( response ); attr; attr = ippNextAttribute( response )) 1.260 + { 1.261 + PyObject *dict; 1.262 + char *ppdname = NULL; 1.263 + 1.264 +- while (attr && attr->group_tag != IPP_TAG_PRINTER) 1.265 +- attr = attr->next; 1.266 ++ while (attr && ippGetGroupTag( attr ) != IPP_TAG_PRINTER) 1.267 ++ attr = ippNextAttribute( response ); 1.268 + 1.269 + if (!attr) 1.270 + break; 1.271 + 1.272 + dict = PyDict_New (); 1.273 + 1.274 +- for (; attr && attr->group_tag == IPP_TAG_PRINTER; attr = attr->next) 1.275 ++ for (; attr && ippGetGroupTag( attr ) == IPP_TAG_PRINTER; attr = ippNextAttribute( response )) 1.276 + { 1.277 + PyObject *val = NULL; 1.278 + 1.279 +- if (!strcmp (attr->name, "ppd-name") && attr->value_tag == IPP_TAG_NAME) 1.280 ++ if (!strcmp (ippGetName( attr ), "ppd-name") && ippGetValueTag( attr ) == IPP_TAG_NAME) 1.281 + { 1.282 +- ppdname = attr->values[0].string.text; 1.283 ++ ppdname = ippGetString( attr, 0, NULL ); 1.284 + 1.285 + //sprintf( buf, "print '%s'", ppdname); 1.286 + //PyRun_SimpleString( buf ); 1.287 + } 1.288 + 1.289 +- else if (attr->value_tag == IPP_TAG_TEXT || attr->value_tag == IPP_TAG_NAME || attr->value_tag == IPP_TAG_KEYWORD) 1.290 +- //else if ((!strcmp (attr->name, "ppd-natural-language") && attr->value_tag == IPP_TAG_LANGUAGE) || 1.291 +- // (!strcmp (attr->name, "ppd-make-and-model") && attr->value_tag == IPP_TAG_TEXT) || 1.292 +- // (!strcmp (attr->name, "ppd-make") && attr->value_tag == IPP_TAG_TEXT) || 1.293 +- // (!strcmp (attr->name, "ppd-device-id") && attr->value_tag == IPP_TAG_TEXT)) 1.294 ++ else if (ippGetValueTag( attr ) == IPP_TAG_TEXT || ippGetValueTag( attr ) == IPP_TAG_NAME || ippGetValueTag( attr ) == IPP_TAG_KEYWORD) 1.295 ++ //else if ((!strcmp (ippGetName( attr ), "ppd-natural-language") && ippGetValueTag( attr ) == IPP_TAG_LANGUAGE) || 1.296 ++ // (!strcmp (ippGetName( attr ), "ppd-make-and-model") && ippGetValueTag( attr ) == IPP_TAG_TEXT) || 1.297 ++ // (!strcmp (ippGetName( attr ), "ppd-make") && ippGetValueTag( attr ) == IPP_TAG_TEXT) || 1.298 ++ // (!strcmp (ippGetName( attr ), "ppd-device-id") && ippGetValueTag( attr ) == IPP_TAG_TEXT)) 1.299 + { 1.300 +- val = PyObj_from_UTF8(attr->values[0].string.text); 1.301 ++ val = PyObj_from_UTF8(ippGetString( attr, 0, NULL )); 1.302 + } 1.303 + 1.304 + if (val) 1.305 + { 1.306 +- PyDict_SetItemString (dict, attr->name, val); 1.307 ++ PyDict_SetItemString (dict, ippGetName( attr ), val); 1.308 + Py_DECREF (val); 1.309 + } 1.310 + } 1.311 +diff -up hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors hplip-3.12.6/scan/sane/hpaio.c 1.312 +--- hplip-3.12.6/scan/sane/hpaio.c.ipp_accessors 2012-06-18 12:42:51.000000000 +0200 1.313 ++++ hplip-3.12.6/scan/sane/hpaio.c 2012-07-19 17:12:34.557848760 +0200 1.314 +@@ -47,6 +47,43 @@ 1.315 + #define DEBUG_DECLARE_ONLY 1.316 + #include "sanei_debug.h" 1.317 + 1.318 ++#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) 1.319 ++#define HAVE_CUPS_1_6 1 1.320 ++#endif 1.321 ++ 1.322 ++#ifndef HAVE_CUPS_1_6 1.323 ++#define ippGetGroupTag(attr) attr->group_tag 1.324 ++#define ippGetValueTag(attr) attr->value_tag 1.325 ++#define ippGetName(attr) attr->name 1.326 ++#define ippGetString(attr, element, language) attr->values[element].string.text 1.327 ++ 1.328 ++static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp ) 1.329 ++{ 1.330 ++ if (!ipp) 1.331 ++ return (NULL); 1.332 ++ return (ipp->current = ipp->attrs); 1.333 ++} 1.334 ++ 1.335 ++static ipp_attribute_t * ippNextAttribute( ipp_t *ipp ) 1.336 ++{ 1.337 ++ if (!ipp || !ipp->current) 1.338 ++ return (NULL); 1.339 ++ return (ipp->current = ipp->current->next); 1.340 ++} 1.341 ++ 1.342 ++static int ippSetOperation( ipp_t *ipp, ipp_op_t op ) 1.343 ++{ 1.344 ++ ipp->request.op.operation_id = op; 1.345 ++ return (1); 1.346 ++} 1.347 ++ 1.348 ++static int ippSetRequestId( ipp_t *ipp, int request_id ) 1.349 ++{ 1.350 ++ ipp->request.any.request_id = request_id; 1.351 ++ return (1); 1.352 ++} 1.353 ++#endif 1.354 ++ 1.355 + static SANE_Device **DeviceList = NULL; 1.356 + 1.357 + static int AddDeviceList(char *uri, char *model, SANE_Device ***pd) 1.358 +@@ -186,8 +223,8 @@ static int GetCupsPrinters(char ***print 1.359 + /* Assemble the IPP request */ 1.360 + request = ippNew(); 1.361 + 1.362 +- request->request.op.operation_id = CUPS_GET_PRINTERS; 1.363 +- request->request.any.request_id = 1; 1.364 ++ ippSetOperation( request, CUPS_GET_PRINTERS ); 1.365 ++ ippSetRequestId( request, 1 ); 1.366 + 1.367 + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8"); 1.368 + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en"); 1.369 +@@ -197,20 +234,20 @@ static int GetCupsPrinters(char ***print 1.370 + if ((response = cupsDoRequest(http, request, "/")) == NULL) 1.371 + goto bugout; 1.372 + 1.373 +- for (attr = response->attrs; attr != NULL; attr = attr->next) 1.374 ++ for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response )) 1.375 + { 1.376 + /* Skip leading attributes until we hit a printer. */ 1.377 +- while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER) 1.378 +- attr = attr->next; 1.379 ++ while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER) 1.380 ++ attr = ippNextAttribute( response ); 1.381 + 1.382 + if (attr == NULL) 1.383 + break; 1.384 + 1.385 +- while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) 1.386 ++ while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER) 1.387 + { 1.388 +- if (strcmp(attr->name, "device-uri") == 0 && attr->value_tag == IPP_TAG_URI && AddCupsList(attr->values[0].string.text, printer) == 0) 1.389 ++ if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0) 1.390 + cnt++; 1.391 +- attr = attr->next; 1.392 ++ attr = ippNextAttribute( response ); 1.393 + } 1.394 + 1.395 + if (attr == NULL)