Created
February 14, 2020 02:11
Star
You must be signed in to star a gist
WIP Cnijfilter-MG4200 CUPS patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff '--color=auto' -Naur a/backend/src/cnij_backend_common.c b/backend/src/cnij_backend_common.c | |
--- a/backend/src/cnij_backend_common.c 2012-03-28 23:50:27.000000000 -0500 | |
+++ b/backend/src/cnij_backend_common.c 2020-02-13 20:07:23.272487206 -0600 | |
@@ -38,6 +38,7 @@ | |
// CUPS Header | |
#include <cups/cups.h> | |
#include <cups/ipp.h> | |
+#include <cups/ppd.h> | |
// Header file for CANON | |
#include "cnij_backend_common.h" | |
diff '--color=auto' -Naur a/cngpijmon/src/bjcupsmon_cups.c b/cngpijmon/src/bjcupsmon_cups.c | |
--- a/cngpijmon/src/bjcupsmon_cups.c 2012-05-22 04:49:27.000000000 -0500 | |
+++ b/cngpijmon/src/bjcupsmon_cups.c 2020-02-13 20:08:12.741975245 -0600 | |
@@ -215,8 +215,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, IPP_GET_PRINTER_ATTRIBUTES); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -225,12 +225,12 @@ | |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, pURI); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pRequest) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
else { | |
if ((pAttribute = ippFindAttribute(pResponse, "printer-state", IPP_TAG_ENUM)) != NULL) { | |
- printerState = (ipp_state_t)pAttribute->values[0].integer; | |
+ printerState = (ipp_state_t)ippGetInteger(pAttribute, 0); | |
} | |
} | |
@@ -288,8 +288,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, IPP_GET_PRINTER_ATTRIBUTES); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -298,7 +298,7 @@ | |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printerURI); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pRequest) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
else { | |
@@ -310,7 +310,7 @@ | |
//} | |
pAttribute = ippFindAttribute(pResponse, "printer-state-message", IPP_TAG_TEXT); | |
if (pAttribute != NULL) { | |
- strncpy(pStatus, pAttribute->values[0].string.text, bufSize); | |
+ strncpy(pStatus, ippGetString(pAttribute, 0, NULL), bufSize); | |
} | |
} | |
ippDelete(pResponse); | |
@@ -369,8 +369,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = IPP_CANCEL_JOB; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, IPP_CANCEL_JOB); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -381,7 +381,7 @@ | |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/jobs/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pRequest) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
ippDelete(pResponse); | |
@@ -444,8 +444,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = IPP_GET_JOBS; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, IPP_GET_JOBS); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -456,31 +456,31 @@ | |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",(int)(sizeof(jobattrs) / sizeof(jobattrs[0])), NULL, jobattrs); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pRequest) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
else { | |
- pAttribute = pResponse->attrs; | |
+ pAttribute = ippFirstAttribute(pResponse); | |
while (pAttribute != NULL) { | |
- while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_JOB) { | |
- pAttribute = pAttribute->next; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_JOB) { | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
if (pAttribute == NULL) { | |
break; | |
} | |
- while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_JOB) { | |
- if (strcmp(pAttribute->name, "job-id") == 0 && pAttribute->value_tag == IPP_TAG_INTEGER) { | |
- jobID = pAttribute->values[0].integer; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_JOB) { | |
+ if (strcmp(ippGetName(pAttribute), "job-id") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_INTEGER) { | |
+ jobID = ippGetInteger(pAttribute, 0); | |
} | |
- if (strcmp(pAttribute->name, "job-state") == 0 && pAttribute->value_tag == IPP_TAG_ENUM) { | |
- jobState = (ipp_jstate_t)pAttribute->values[0].integer; | |
+ if (strcmp(ippGetName(pAttribute), "job-state") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_ENUM) { | |
+ jobState = (ipp_jstate_t)ippGetInteger(pAttribute, 0); | |
} | |
- if (strcmp(pAttribute->name, "job-originating-user-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { | |
- pJobUserName = pAttribute->values[0].string.text; | |
+ if (strcmp(ippGetName(pAttribute), "job-originating-user-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { | |
+ pJobUserName = ippGetString(pAttribute, 0, NULL); | |
} | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
if (jobState == IPP_JOB_PROCESSING) { | |
if (pJobUserName != NULL) { | |
@@ -497,7 +497,7 @@ | |
} | |
if (pAttribute != NULL) | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
} | |
@@ -555,8 +555,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = CUPS_GET_PRINTERS; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, CUPS_GET_PRINTERS); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -565,28 +565,28 @@ | |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", sizeof(attributes) / sizeof(attributes[0]), NULL, attributes); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
else { | |
- pAttribute = pResponse->attrs; | |
+ pAttribute = ippFirstAttribute(pResponse); | |
while (pAttribute != NULL) { | |
- while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) { | |
- pAttribute = pAttribute->next; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) { | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
if (pAttribute == NULL) { | |
break; | |
} | |
- while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) { | |
- if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { | |
- pPrinter = pAttribute->values[0].string.text; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) { | |
+ if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { | |
+ pPrinter = ippGetString(pAttribute, 0, NULL); | |
} | |
- if (strcmp(pAttribute->name, "printer-uri-supported") == 0 && pAttribute->value_tag == IPP_TAG_URI) { | |
- pUri = pAttribute->values[0].string.text; | |
+ if (strcmp(ippGetName(pAttribute), "printer-uri-supported") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) { | |
+ pUri = ippGetString(pAttribute, 0, NULL); | |
} | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
// Tora 020418: Compare two printer names ignoring the character case. | |
@@ -603,7 +603,7 @@ | |
} | |
if (pAttribute != NULL) | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
} | |
@@ -658,8 +658,8 @@ | |
else { | |
pRequest = ippNew(); | |
- pRequest->request.op.operation_id = CUPS_GET_PRINTERS; | |
- pRequest->request.op.request_id = 1; | |
+ ippSetOperation(pRequest, CUPS_GET_PRINTERS); | |
+ ippSetRequestId(pRequest, 1); | |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 | |
@@ -668,28 +668,28 @@ | |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, NULL); | |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { | |
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { | |
+ if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { | |
retVal = ID_ERR_CUPS_API_FAILED; | |
} | |
else { | |
- pAttribute = pResponse->attrs; | |
+ pAttribute = ippFirstAttribute(pResponse); | |
while (pAttribute != NULL) { | |
- while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) { | |
- pAttribute = pAttribute->next; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) { | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
if (pAttribute == NULL) { | |
break; | |
} | |
- while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) { | |
- if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { | |
- pPrinter = pAttribute->values[0].string.text; | |
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) { | |
+ if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { | |
+ pPrinter = ippGetString(pAttribute, 0, NULL); | |
} | |
- if (strcmp(pAttribute->name, "device-uri") == 0 && pAttribute->value_tag == IPP_TAG_URI) { | |
- pDUri = pAttribute->values[0].string.text; | |
+ if (strcmp(ippGetName(pAttribute), "device-uri") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) { | |
+ pDUri = ippGetString(pAttribute, 0, NULL); | |
} | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
if (strcasecmp(pDestName, pPrinter) == 0) { | |
@@ -698,7 +698,7 @@ | |
} | |
if (pAttribute != NULL) | |
- pAttribute = pAttribute->next; | |
+ pAttribute = ippNextAttribute(pResponse); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment