summarylogtreecommitdiffstats
path: root/fix_cups.patch
blob: 929bec913bbacdbf1d1f36d71b29d095f562240d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
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/cngpij/cngpij/bjcups.c b/cngpij/cngpij/bjcups.c
--- a/cngpij/cngpij/bjcups.c	2012-04-16 22:39:20.000000000 -0500
+++ b/cngpij/cngpij/bjcups.c	2020-02-27 19:19:43.439595944 -0600
@@ -698,8 +698,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
 		
@@ -708,29 +708,29 @@
 		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) {
 				fputs("ERROR: IPP ERROR\n", stderr);
 				goto onErr;
 			}
 			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) {
@@ -739,7 +739,7 @@
 					}
 					
 					if (pAttribute != NULL)
-						 pAttribute = pAttribute->next;
+						 pAttribute = ippNextAttribute(pResponse);
 				}
 			}
 			
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-27 19:13:14.074174222 -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(pResponse) > 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(pResponse) > 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(pResponse) > 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(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_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);
 				}
 			}