#!/bin/sh /usr/share/dpatch/dpatch-run ## rss.dpatch by Torsten Landschoff ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Blank-ink-only patch by Richard Spencer-Smith @DPATCH@ Index: hplip-3.13.9.orig/scan/sane/hpaio.c =================================================================== --- hplip-3.13.9.orig/scan/sane/hpaio.c +++ hplip-3.13.9/scan/sane/hpaio.c @@ -177,8 +177,54 @@ static int AddCupsList(char *uri, char * int i, stat=1; /* Look for hp network URIs only. */ - if (strncasecmp(uri, "hp:/net/", 8) !=0) - goto bugout; + if (!strncasecmp(uri, "hp:/net/", 8)); + else if (!strncasecmp(uri, "socket://", 9)) + { + char *ip; + char pathmax[255]; + int size; + char *pt; + + pathmax[0] = 0; + pt = strchr(uri + 9, ':'); + + if (!pt) + goto bugout; + + ip = calloc(20, sizeof(*ip)); + strncpy(ip, uri + 9, pt - (uri + 9)); + hpmud_make_net_uri(ip, 1, pathmax, 255, &size); + DBG6("ip %s\n", ip); + free(ip); + + if (!size || pathmax[0] == 0) + goto bugout; + uri = pathmax; + } + else if (!strncasecmp(uri, "ipp://", 6)) + { + char *ip; + char pathmax[255]; + int size; + char *pt; + + pathmax[0] = 0; + pt = strchr(uri + 6, ':'); + + if (!pt) + goto bugout; + + ip = calloc(20, sizeof(*ip)); + strncpy(ip, uri + 6, pt - (uri + 6)); + hpmud_make_net_uri(ip, 1, pathmax, 255, &size); + DBG6("ip %s\n", ip); + free(ip); + if (!size || pathmax[0] == 0) + goto bugout; + uri = pathmax; + } + else + goto bugout; if (*printer == NULL) { @@ -211,6 +257,24 @@ bugout: return stat; } +static int _cnt=0; + +static void _add_find_printers(const char *device_class, + const char *device_id, + const char *device_info, + const char *device_make_and_model, + const char *device_uri, + const char *device_location, + void *user_data) +{ + char ***printer = user_data; + + if (device_uri) + { + if (!AddCupsList(strdup(device_uri), printer)) + _cnt++; + } +} static int GetCupsPrinters(char ***printer) { @@ -218,40 +282,45 @@ static int GetCupsPrinters(char ***print ipp_t *request=NULL; /* IPP request object */ ipp_t *response=NULL; /* IPP response object */ ipp_attribute_t *attr; /* Current IPP attribute */ - int cnt=0; + + _cnt = 0; + cupsGetDevices(CUPS_HTTP_DEFAULT, CUPS_TIMEOUT_DEFAULT, + CUPS_INCLUDE_ALL, "lxnet,lxhcp,cnijnet", + _add_find_printers, + printer); /* Connect to the HTTP server */ - if ((http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption())) == NULL) + /*if ((http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption())) == NULL) goto bugout; - + */ /* Assemble the IPP request */ - request = ippNew(); + /*request = ippNew(); - ippSetOperation( request, CUPS_GET_PRINTERS ); - ippSetRequestId( request, 1 ); + request->request.op.operation_id = CUPS_GET_PRINTERS; + request->request.any.request_id = 1; ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, "utf-8"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, "en"); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "device-uri"); - + */ /* Send the request and get a response. */ - if ((response = cupsDoRequest(http, request, "/")) == NULL) + /*if ((response = cupsDoRequest(http, request, "/")) == NULL) goto bugout; - for (attr = ippFirstAttribute ( response ); attr != NULL; attr = ippNextAttribute( response )) - { + for (attr = response->attrs; attr != NULL; attr = attr->next) + {*/ /* Skip leading attributes until we hit a printer. */ - while (attr != NULL && ippGetGroupTag( attr ) != IPP_TAG_PRINTER) - attr = ippNextAttribute( response ); + /*while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER) + attr = attr->next; if (attr == NULL) break; - while (attr != NULL && ippGetGroupTag( attr ) == IPP_TAG_PRINTER) + while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) { - if (strcmp(ippGetName( attr ), "device-uri") == 0 && ippGetValueTag( attr ) == IPP_TAG_URI && AddCupsList(ippGetString( attr, 0, NULL ), printer) == 0) + if (strcmp(attr->name, "device-uri") == 0 && attr->value_tag == IPP_TAG_URI && AddCupsList(attr->values[0].string.text, printer) == 0) cnt++; - attr = ippNextAttribute( response ); + attr = attr->next; } if (attr == NULL) @@ -259,9 +328,9 @@ static int GetCupsPrinters(char ***print } ippDelete(response); - bugout: - return cnt; + */ + return _cnt; } static int DevDiscovery(int localOnly)