updated on Wed Jan 18 04:00:29 UTC 2012
[aur-mirror.git] / cups-mc5430dl / rastertokmlf.patch
blob2f7d529f51460bc5444a01ec22e64dc861f58962
1 --- /src/rastertokmlf.c 2006-11-17 09:49:53.297930424 +0100
2 +++ /src/rastertokmlf.c.new 2006-11-17 09:49:53.252954942 +0100
3 @@ -131,353 +131,6 @@
4 int write_bmp_header(cups_page_header_t *header, FILE *file);
5 #endif
7 -int /* 1 = success, 0 = failure */
8 - find_printer_make(const char *deviceuri, /* I - URI to connect on */
9 - char *make,
10 - int msize)
12 - http_t *http; /* HTTP connection to server */
13 - char method[HTTP_MAX_URI], /* URI method */
14 - userpass[HTTP_MAX_URI], /* username:password */
15 - server[HTTP_MAX_URI], /* Server */
16 - resource[HTTP_MAX_URI]; /* Resource path */
17 - int port; /* Port number */
18 - ipp_t *request, /* IPP request */
19 - *response; /* IPP response */
20 - ipp_attribute_t *attrptr; /* Attribute pointer */
21 - int pass=2; /* Did we pass the test? */
22 - char printer_uri[HTTP_MAX_URI];
23 - char *delim; /* Delimiter in file */
25 -#ifdef __linux
26 - char device[IPP_MAX_NAME], /* Device filename */
27 - probefile[IPP_MAX_NAME], /* Probe filename */
28 - basedevice[IPP_MAX_NAME]; /* Base device filename for ports */
30 - FILE *probe; /* /proc/parport/n/autoprobe file */
31 - char line[1024], /* Line from file */
32 - //device_id[1024], /* Device ID string */
33 - mfg[IPP_MAX_NAME],
34 - //make[IPP_MAX_NAME], /* Make from file */
35 - model[IPP_MAX_NAME]; /* Model from file */
36 - int i=0;
37 - //int fd;
38 - //int length;
39 -#endif
41 - if (!strncmp(deviceuri, "usb:",4))
42 - {
43 - if (!strncmp(deviceuri, "usb://",6))
44 - {
45 - strlcpy(make, deviceuri + 6, IPP_MAX_NAME);
47 - if ((delim = strchr(make, '/')) != NULL)
48 - *delim = '\0';
49 - if (make[0])
50 - pass = 1;
51 - //if(!strncmp(deviceuri+6,"KONICA",6))
52 - //pass = 1;
53 - //else
54 - //pass = 0;
55 - }
56 -#ifdef __linux
57 - else
58 - {
59 - if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL)
60 - {
61 - i = 0;
63 - memset(mfg, 0, sizeof(mfg));
64 - memset(model, 0, sizeof(model));
66 - while (fgets(line, sizeof(line), probe) != NULL)
67 - {
68 - /*
69 - * Strip trailing newline.
70 - */
72 - if ((delim = strrchr(line, '\n')) != NULL)
73 - *delim = '\0';
74 - /*
75 - * See if it is a printer device ("P: ...")
76 - */
78 - if (strncmp(line, "S:", 2) == 0)
79 - {
80 - /*
81 - * String attribute...
82 - */
84 - if (strncmp(line, "S: Manufacturer=", 17) == 0)
85 - {
86 - strlcpy(mfg, line + 17, sizeof(mfg));
87 - fprintf(stderr, "DEBUG: mfg is %s usb %d\n", mfg, i);
88 - if (strcmp(mfg, "Hewlett-Packard") == 0)
89 - strcpy(mfg, "HP");
90 - }
91 - else if (strncmp(line, "S: Product=", 12) == 0)
92 - strlcpy(model, line + 12, sizeof(model));
93 - }
94 - else if (strncmp(line, "I:", 2) == 0 &&
95 - (strstr(line, "Driver=printer") != NULL ||
96 - strstr(line, "Driver=usblp") != NULL) &&
97 - mfg[0] && model[0])
98 - {
99 - /*
100 - * We were processing a printer device; send the info out...
101 - */
103 - sprintf(device, "/dev/usb/lp%d", i);
104 - if (access(device, 0))
106 - sprintf(device, "/dev/usb/usblp%d", i);
108 - if (access(device, 0))
109 - sprintf(device, "/dev/usblp%d", i);
112 - fprintf(stderr, "DEBUG: direct usb:%s \"%s %s\" \"USB Printer #%d\"\n",
113 - device, mfg, model, i + 1);
115 - if (!strncmp(deviceuri+4,device,sizeof(device)))
117 - strlcpy(make, mfg, IPP_MAX_NAME);
118 - pass = 1;
119 - break;
122 - i ++;
124 - memset(mfg, 0, sizeof(mfg));
125 - memset(model, 0, sizeof(model));
128 - fclose(probe);
130 - else
132 - /*
133 - * Just check manually for USB devices...
134 - */
135 - for (i = 0; i < 16; i ++)
137 - sprintf(device, "/dev/usb/lp%d", i);
139 - if (access(device, 0))
141 - sprintf(device, "/dev/usb/usblp%d", i);
143 - if (access(device, 0))
145 - sprintf(device, "/dev/usblp%d", i);
147 - if (access(device, 0))
148 - continue;
152 - fprintf(stderr, "DEBUG: direct usb:%s \"Unknown\" \"USB Printer #%d\"\n", device, i + 1);
153 - pass = 0;
157 -#endif
159 - else if (!strncmp(deviceuri, "socket:",7) ||
160 - !strncmp(deviceuri, "lpd:",4))
162 - /*
163 - * Connect to the server...
164 - */
165 - httpSeparate(deviceuri, method, userpass, server, &port, resource);
166 - port = 80;
167 - snprintf(printer_uri, sizeof(printer_uri),
168 - "http://%s:%d/ipp.cgi",server,port);
170 - //httpSeparate(printer_uri, method, userpass, server, &port, resource);
171 - if ((http = httpConnect(server, port)) == NULL)
173 - fprintf(stderr, "DEBUG: Unable to connect to %s on port %d\n", server, port);
174 - return(0);
177 - /*
178 - * Initialize things...
179 - */
181 - pass = 1;
182 - request = ippNew();
184 - /*
185 - * Submit the IPP request...
186 - */
188 - request->request.op.version[1] = 1;
189 - request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
190 - request->request.op.request_id = 1;
192 - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
193 - "attributes-charset", NULL,
194 - "utf-8");
195 - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
196 - "attributes-natural-language", NULL,
197 - "en");
198 - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
199 - "printer-uri", NULL, printer_uri);
201 - response = cupsDoRequest(http, request, "/ipp.cgi"); //resource);
203 - if (response == NULL)
205 - time_t curtime;
206 - curtime = time(NULL);
208 - fprintf(stderr, "DEBUG: \b\b\b\b\bFAIL]\n");
209 - fprintf(stderr, "DEBUG: ERROR %x\n", cupsLastError());
210 - fprintf(stderr, "DEBUG: (%s) @ %s\n",
211 - ippErrorString(cupsLastError()), ctime(&curtime));
212 - pass = 0;
214 - else
216 - attrptr=ippFindAttribute(response, "printer-make-and-model" , IPP_TAG_ZERO);
218 - if (attrptr==NULL)
220 - if (pass)
222 - fprintf(stderr, "DEBUG: \b\b\b\b\bFAIL]\n");
223 - fprintf(stderr, "DEBUG: (%lu bytes in response)\n",
224 - (unsigned long)ippLength(response));
225 - pass = 0;
229 - if (pass)
231 - //fprintf(stderr, "DEBUG: \b\b\b\b\bPASS]\n");
232 - //fprintf(stderr, "DEBUG: (%lu bytes in response)\n",
233 - // (unsigned long)ippLength(response));
234 - fprintf(stderr, "DEBUG: printer maker is %s\n", attrptr->values[0].string.text);
235 - strlcpy(make,attrptr->values[0].string.text,msize);
237 - else
239 - fputs("DEBUG: RECEIVED", stderr);
240 - fprintf(stderr, "DEBUG: status-code = %04x\n",
241 - response->request.status.status_code);
243 - ippDelete(response);
245 - httpClose(http);
247 -#ifdef __linux
248 - else if (!strncmp(deviceuri, "parallel:",9))
250 - strlcpy(basedevice, "/dev/unknown-parallel",sizeof(basedevice));
251 - for (i = 0; i < 4; i ++)
253 - /*
254 - * First compare the device with deviceuri
255 - */
256 - sprintf(device, "/dev/lp%d", i);
257 - if (!strncmp(deviceuri+9,device,8))
259 - strlcpy(basedevice, "/dev/lp",sizeof(basedevice));
260 - break;
263 - sprintf(device, "/dev/parallel/%d", i);
264 - if (!strncmp(deviceuri+9,device,15))
266 - strlcpy(basedevice, "/dev/parallel/", sizeof(basedevice));
267 - break;
270 - sprintf(device, "/dev/par%d", i);
271 - if (!strncmp(deviceuri+9,device,9))
273 - strlcpy(basedevice, "/dev/par",sizeof(basedevice));
274 - break;
277 - sprintf(device, "/dev/printers/%d", i);
278 - if (!strncmp(deviceuri+9,device,14))
280 - strlcpy(basedevice, "/dev/printers/",sizeof(basedevice));
281 - break;
285 - /*
286 - * Then try looking at the probe file...
287 - */
289 - /*
290 - * Linux 2.4 kernel has different path...
291 - */
293 - sprintf(probefile, "/proc/sys/dev/parport/parport%d/autoprobe", i);
294 - probe = fopen(probefile, "r");
296 - if (probe != NULL)
298 - /*
299 - * Found a probe file!
300 - */
302 - memset(make, 0, msize);
303 - memset(model, 0, sizeof(model));
304 - strlcpy(model, "Unknown",sizeof(model));
306 - while (fgets(line, sizeof(line), probe) != NULL)
308 - /*
309 - * Strip trailing ; and/or newline.
310 - */
311 - if ((delim = strrchr(line, ';')) != NULL)
312 - *delim = '\0';
313 - else if ((delim = strrchr(line, '\n')) != NULL)
314 - *delim = '\0';
316 - /*
317 - * Look for MODEL and MANUFACTURER lines...
318 - */
320 - if (strncmp(line, "MODEL:", 6) == 0 &&
321 - strncmp(line, "MODEL:Unknown", 13) != 0)
323 - strlcpy(model, line + 6, sizeof(model));
325 - else if (strncmp(line, "MANUFACTURER:", 13) == 0 &&
326 - strncmp(line, "MANUFACTURER:Unknown", 20) != 0)
328 - strlcpy(make, line + 13, msize);
329 - break;
332 - fclose(probe);
334 - if (make[0])
336 - fprintf(stderr, "DEBUG: direct parallel:%s%d \"%s %s\" \"Parallel Port #%d\"\n",
337 - basedevice, i, make, model, i + 1);
338 - pass = 1;
340 - else
342 - fprintf(stderr, "DEBUG: direct parallel:%s%d \"%s\" \"Parallel Port #%d\"\n",
343 - basedevice, i, model, i + 1);
344 - pass = 0;
348 -#endif
350 - return(pass);
355 * 'Setup()' - Prepare the printer for printing.
357 @@ -488,8 +141,6 @@
358 const char *device_uri; /* The device for the printer... */
359 cups_lang_t *language; /* Language information */
361 - int ret;
363 //reset colormatching flag
364 pImage = (PIMAGEHEADER)malloc(sizeof(IMAGEHEADER));
365 pImage->InitCM_HT = 0;
366 @@ -505,29 +156,7 @@
368 if (device_uri)
370 - char make[IPP_MAX_NAME];
371 fprintf(stderr, "DEBUG: deviceuri is %s\n",device_uri);
373 - //temporarily disable model check for magicolor 5430 DL
374 - //ret = find_printer_make(device_uri, make, sizeof(make));
375 - ret=2;
377 - if (!ret)
379 - //fprintf(stderr, "ERROR: No Printer Information!\n");
380 - fprintf(stderr, "ERROR: Printer Not Found!\n");
381 - return(-1);
383 - else if ( (1==ret) && (strncmp(make ,"KONICA", 6) ))
385 - //fprintf(stderr, "ERROR: Wrong Printer Found!\n");// %s\n",make);
386 - fprintf(stderr, "ERROR: Printer Not Found!\n");
387 - return(-1);
389 - else if (2==ret)
391 - fprintf(stderr, "DEBUG: ipp/mdsn case, let it pass!\n");
394 else