summarylogtreecommitdiffstats
path: root/cups-fixes.patch
blob: 674254c761fc21e5a97151779f5716cb651a649d (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
diff -Naur a/backend/src/cnij_backend_common.c b/backend/src/cnij_backend_common.c
--- a/backend/src/cnij_backend_common.c	2010-02-23 04:57:49.000000000 +0100
+++ b/backend/src/cnij_backend_common.c	2011-11-17 12:59:27.482025762 +0100
@@ -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"

--- a/cngpijmon/src/bjcupsmon_cups.c	2012-03-17 12:32:43.230805896 +0100
+++ b/cngpijmon/src/bjcupsmon_cups.c	2012-03-17 12:34:23.179018171 +0100
@@ -18,8 +18,10 @@
 */
 
 /*** Includes ***/
+#define _IPP_PRIVATE_STRUCTURES 1
 #include <cups/cups.h>
 #include <cups/language.h>
+#include <cups/ppd.h>
 #include <sys/types.h>
 #include <unistd.h>

--- a/cngpij/cngpij/bjcups.c	2012-07-31 05:22:51.613991808 -0400
+++ b/cngpij/cngpij/bjcups.c	 2012-07-31 05:23:14.780658321 -0400
@@ -21,6 +21,7 @@
 #include	<config.h>
 #endif	// HAVE_CONFIG_H
 
+#define _IPP_PRIVATE_STRUCTURES 1
 #include <cups/cups.h>
 #include <cups/language.h>
 #include <cups/ppd.h>
diff -Naur a/cngpij/cngpij/bjcups.c b/cngpij/cngpij/bjcups.c
--- a/cngpij/cngpij/bjcups.c	2019-10-31 15:00:19.000000000 +0200
+++ b/cngpij/cngpij/bjcups.c	2019-10-31 15:14:44.505666529 +0200
@@ -66,6 +66,48 @@
 extern int GetIPCData(LPIPCU pipc, char *sname);
 
 
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+#define ippGetCount(attr)     attr->num_values
+#define ippGetGroupTag(attr)  attr->group_tag
+#define ippGetValueTag(attr)  attr->value_tag
+#define ippGetName(attr)      attr->name
+#define ippGetBoolean(attr, element) attr->values[element].boolean
+#define ippGetInteger(attr, element) attr->values[element].integer
+#define ippGetStatusCode(ipp) ipp->request.status.status_code
+#define ippGetString(attr, element, language) attr->values[element].string.text
+
+static ipp_attribute_t * ippFirstAttribute( ipp_t *ipp )
+{
+	if (!ipp)
+		return (NULL);
+	return (ipp->current = ipp->attrs);
+}
+
+static ipp_attribute_t * ippNextAttribute( ipp_t *ipp )
+{
+	if (!ipp || !ipp->current)
+		return (NULL);
+	return (ipp->current = ipp->current->next);
+}
+
+static int ippSetOperation( ipp_t *ipp, ipp_op_t op )
+{
+	ipp->request.op.operation_id = op;
+	return (1);
+}
+
+static int ippSetRequestId( ipp_t *ipp, int request_id )
+{
+	ipp->request.any.request_id = request_id;
+	return (1);
+}
+#endif
+
+
 int get_value_and_param_array(short id, short** value, char*** param)
 {
 	int count;
@@ -689,8 +731,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
 		
@@ -699,29 +741,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(pAttribute);
 					}
 					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, "");
 						}
-						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, "");
 						}
-						pAttribute = pAttribute->next;
+						pAttribute = ippNextAttribute(pAttribute);
 					}
 
 					if (strcasecmp(pDestName, pPrinter) == 0) {
@@ -730,7 +772,7 @@
 					}
 					
 					if (pAttribute != NULL)
-						 pAttribute = pAttribute->next;
+						 pAttribute = ippNextAttribute(pAttribute);
 				}
 			}