]>
Commit | Line | Data |
---|---|---|
1e5f976e KK |
1 | diff -durN release-1.2.1/backend/backend-private.h cups-1.2.x/backend/backend-private.h |
2 | --- release-1.2.1/backend/backend-private.h 1970-01-01 01:00:00.000000000 +0100 | |
3 | +++ cups-1.2.x/backend/backend-private.h 2006-06-26 12:42:40.000000000 +0100 | |
4 | @@ -0,0 +1,73 @@ | |
5 | +/* | |
6 | + * "$Id$" | |
7 | + * | |
8 | + * Backend support definitions for the Common UNIX Printing System (CUPS). | |
9 | + * | |
10 | + * Copyright 1997-2006 by Easy Software Products, all rights reserved. | |
11 | + * | |
12 | + * These coded instructions, statements, and computer programs are the | |
13 | + * property of Easy Software Products and are protected by Federal | |
14 | + * copyright law. Distribution and use rights are outlined in the file | |
15 | + * "LICENSE" which should have been included with this file. If this | |
16 | + * file is missing or damaged please contact Easy Software Products | |
17 | + * at: | |
18 | + * | |
19 | + * Attn: CUPS Licensing Information | |
20 | + * Easy Software Products | |
21 | + * 44141 Airport View Drive, Suite 204 | |
22 | + * Hollywood, Maryland 20636 USA | |
23 | + * | |
24 | + * Voice: (301) 373-9600 | |
25 | + * EMail: cups-info@cups.org | |
26 | + * WWW: http://www.cups.org | |
27 | + * | |
28 | + * This file is subject to the Apple OS-Developed Software exception. | |
29 | + */ | |
30 | + | |
31 | +#ifndef _CUPS_BACKEND_PRIVATE_H_ | |
32 | +# define _CUPS_BACKEND_PRIVATE_H_ | |
33 | + | |
34 | + | |
35 | +/* | |
36 | + * Include necessary headers. | |
37 | + */ | |
38 | + | |
39 | +# include <cups/backend.h> | |
40 | +# include <cups/cups.h> | |
41 | +# include <cups/debug.h> | |
42 | +# include <stdlib.h> | |
43 | +# include <errno.h> | |
44 | +# include <cups/string.h> | |
45 | +# include <signal.h> | |
46 | + | |
47 | + | |
48 | +/* | |
49 | + * C++ magic... | |
50 | + */ | |
51 | + | |
52 | +# ifdef _cplusplus | |
53 | +extern "C" { | |
54 | +# endif /* _cplusplus */ | |
55 | + | |
56 | + | |
57 | +/* | |
58 | + * Prototypes... | |
59 | + */ | |
60 | + | |
61 | +extern int backendGetDeviceID(int fd, char *device_id, int device_id_size, | |
62 | + char *make_model, int make_model_size, | |
63 | + const char *scheme, char *uri, int uri_size); | |
64 | +extern int backendGetMakeModel(const char *device_id, char *make_model, | |
65 | + int make_model_size); | |
66 | +extern ssize_t backendRunLoop(int print_fd, int device_fd, int use_bc); | |
67 | + | |
68 | + | |
69 | +# ifdef _cplusplus | |
70 | +} | |
71 | +# endif /* _cplusplus */ | |
72 | +#endif /* !_CUPS_BACKEND_PRIVATE_H_ */ | |
73 | + | |
74 | + | |
75 | +/* | |
76 | + * End of "$Id$". | |
77 | + */ | |
78 | diff -durN release-1.2.1/backend/Dependencies cups-1.2.x/backend/Dependencies | |
79 | --- release-1.2.1/backend/Dependencies 2006-07-04 17:32:11.000000000 +0100 | |
80 | +++ cups-1.2.x/backend/Dependencies 2006-06-26 12:42:40.000000000 +0100 | |
81 | @@ -9,26 +9,31 @@ | |
82 | lpd.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h | |
83 | lpd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h | |
84 | lpd.o: ../cups/string.h | |
85 | -parallel.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h | |
86 | -parallel.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h | |
87 | -parallel.o: ../cups/language.h ../cups/string.h ../config.h ieee1284.c | |
88 | -parallel.o: ../cups/debug.h | |
89 | +pap.o: ../cups/http.h ../cups/md5.h | |
90 | +parallel.o: backend-private.h ../cups/backend.h ../cups/cups.h ../cups/ipp.h | |
91 | +parallel.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h ../cups/array.h | |
92 | +parallel.o: ../cups/file.h ../cups/language.h ../cups/debug.h | |
93 | +parallel.o: ../cups/string.h ../config.h | |
94 | scsi.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h | |
95 | scsi.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h | |
96 | scsi.o: ../cups/language.h ../cups/string.h ../config.h | |
97 | -serial.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h | |
98 | -serial.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h | |
99 | -serial.o: ../cups/language.h ../cups/string.h ../config.h | |
100 | -snmp.o: ../cups/backend.h ../cups/http-private.h ../config.h ../cups/http.h | |
101 | -snmp.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h | |
102 | -snmp.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h | |
103 | -snmp.o: ../cups/string.h ../cups/array.h ../cups/file.h ieee1284.c | |
104 | -snmp.o: ../cups/debug.h | |
105 | -socket.o: ../cups/backend.h ../cups/http-private.h ../config.h ../cups/http.h | |
106 | -socket.o: ../cups/md5.h ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h | |
107 | -socket.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h | |
108 | -socket.o: ../cups/string.h | |
109 | -test1284.o: ../cups/string.h ../config.h ieee1284.c ../cups/debug.h | |
110 | +serial.o: backend-private.h ../cups/backend.h ../cups/cups.h ../cups/ipp.h | |
111 | +serial.o: ../cups/http.h ../cups/md5.h ../cups/ppd.h ../cups/array.h | |
112 | +serial.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/string.h | |
113 | +serial.o: ../config.h | |
114 | +snmp.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h | |
115 | +snmp.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h | |
116 | +snmp.o: ../cups/backend.h ../cups/cups.h ../cups/ppd.h ../cups/array.h | |
117 | +snmp.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/string.h | |
118 | +snmp.o: ../cups/array.h ../cups/file.h | |
119 | +socket.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h | |
120 | +socket.o: ../cups/ipp-private.h ../cups/ipp.h backend-private.h | |
121 | +socket.o: ../cups/backend.h ../cups/cups.h ../cups/ppd.h ../cups/array.h | |
122 | +socket.o: ../cups/file.h ../cups/language.h ../cups/debug.h ../cups/string.h | |
123 | +test1284.o: ../cups/string.h ../config.h ieee1284.c backend-private.h | |
124 | +test1284.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h | |
125 | +test1284.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h | |
126 | +test1284.o: ../cups/language.h ../cups/debug.h | |
127 | usb.o: ../cups/backend.h ../cups/cups.h ../cups/ipp.h ../cups/http.h | |
128 | usb.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h | |
129 | usb.o: ../cups/language.h ../cups/string.h ../config.h | |
130 | diff -durN release-1.2.1/backend/easysw-firewire-design.txt cups-1.2.x/backend/easysw-firewire-design.txt | |
131 | --- release-1.2.1/backend/easysw-firewire-design.txt 2006-07-04 17:32:11.000000000 +0100 | |
132 | +++ cups-1.2.x/backend/easysw-firewire-design.txt 1970-01-01 01:00:00.000000000 +0100 | |
133 | @@ -1,71 +0,0 @@ | |
134 | -Preliminary Design for CUPS Firewire Printer Backend - 03/19/2002 | |
135 | ------------------------------------------------------------------ | |
136 | - | |
137 | -OVERVIEW | |
138 | - | |
139 | - Easy Software Products will develop an IEEE-1394, a.k.a. | |
140 | - Firewire, printing interface for its Common UNIX Printing | |
141 | - System ("CUPS") for initial use under the Linux operating | |
142 | - system. A follow-on implementation for MacOS X is | |
143 | - anticipated as well. | |
144 | - | |
145 | - The operating system interfaces for IEEE-1394 ports vary | |
146 | - widely; the CUPS printing interface will abstract the OS | |
147 | - layer to a simpler interface geared towards discovering, | |
148 | - opening, reading from, writing to, and closing IEEE-1394 | |
149 | - printers. | |
150 | - | |
151 | - The initial development of the CUPS backend will be targeted | |
152 | - at the EPSON Stylus Pro 10000 large format printer, which | |
153 | - requires the bandwidth provided by Firewire in order to | |
154 | - print at full speed. This printer supports printing via | |
155 | - Serial Bus Protocol 2 (SBP-2) using the SCSI and PWG command | |
156 | - sets. The CUPS backend will implement the PWG command set on | |
157 | - LUN 0 only. | |
158 | - | |
159 | - | |
160 | -OS ABSTRACTION LAYER | |
161 | - | |
162 | - The OS abstraction layer will be a thin client library that | |
163 | - implements the following functions: | |
164 | - | |
165 | - ieee1394_list | |
166 | - ieee1394_open | |
167 | - ieee1394_close | |
168 | - ieee1394_read | |
169 | - ieee1394_write | |
170 | - ieee1394_error | |
171 | - | |
172 | - The "ieee1394_list" function will list all of the available | |
173 | - printer devices on the bus. The device information will | |
174 | - consist of the device URI (ieee1394:/something) used to | |
175 | - access the device and the make and model information, if | |
176 | - available, for the device ("EPSON Stylus Printer"). | |
177 | - | |
178 | - The "ieee1394_open" and "ieee1394_close" functions will open | |
179 | - and close a connection to the printer, respectively. | |
180 | - | |
181 | - The "ieee1394_read" and "ieee1394_write" functions will read | |
182 | - and write data to and from the printer, respectively. The | |
183 | - read function will be non-blocking, returning data only if | |
184 | - there is data coming back from the printer. | |
185 | - | |
186 | - The "ieee1394_error" function will return a string | |
187 | - describing the last error or NULL if no error occurred. | |
188 | - | |
189 | - The library will be responsible for creating any background | |
190 | - threads that are needed to monitor the connection to the | |
191 | - printer. | |
192 | - | |
193 | - | |
194 | -CUPS BACKEND | |
195 | - | |
196 | - The CUPS backend will use the OS abstraction layer to list | |
197 | - and access the Firewire printers. The "main" function will | |
198 | - read and write printer data, while the "list_devices" | |
199 | - function will be called as necessary to identify the | |
200 | - available devices. | |
201 | - | |
202 | - The CUPS 1.1 backend will record any status information in | |
203 | - the error log file, while the 1.2 backend will supply it to | |
204 | - the printer driver process. | |
205 | diff -durN release-1.2.1/backend/easysw-firewire-linux.txt cups-1.2.x/backend/easysw-firewire-linux.txt | |
206 | --- release-1.2.1/backend/easysw-firewire-linux.txt 2006-07-04 17:32:11.000000000 +0100 | |
207 | +++ cups-1.2.x/backend/easysw-firewire-linux.txt 1970-01-01 01:00:00.000000000 +0100 | |
208 | @@ -1,35 +0,0 @@ | |
209 | -Easy Software Products | |
210 | -44141 Airport View Drive | |
211 | -Suite 204 | |
212 | -Hollywood, Maryland 20636 | |
213 | -+1.301.373.9600 | |
214 | -March 8, 2002 | |
215 | - | |
216 | - | |
217 | -Subject: EPSON Firewire Printer Driver for Linux | |
218 | - | |
219 | -Currently, no Firewire printer support exists for Linux. Since | |
220 | -the latest EPSON printer products depend on the Firewire | |
221 | -interface to print at full speed, a solution is needed to | |
222 | -support customers using Linux as their server platform. | |
223 | - | |
224 | -The Linux Firewire subsystem provides a user-mode driver | |
225 | -interface that allows driver programs to access Firewire | |
226 | -devices. Easy Software Products will utilize this interface to | |
227 | -develop a "backend" program for the Common UNIX Printing System | |
228 | -that will allow users to print to EPSON printers using the | |
229 | -Firewire interface. | |
230 | - | |
231 | -After examining the Linux interface, we estimate that it will | |
232 | -require approximately 30 hours of development time to write, | |
233 | -test, and document the Firewire backend, for a total cost of | |
234 | -$3,000. The new backend will become a standard part of the CUPS | |
235 | -software distribution and will be included with at least the | |
236 | -following Linux distributions: | |
237 | - | |
238 | - - Caldera Linux | |
239 | - - Mandrake Linux | |
240 | - - Red Hat Linux | |
241 | - - SuSE Linux | |
242 | - | |
243 | -ESP will provide EPSON with binaries for Red Hat Linux 7.2. | |
244 | diff -durN release-1.2.1/backend/ieee1284.c cups-1.2.x/backend/ieee1284.c | |
245 | --- release-1.2.1/backend/ieee1284.c 2006-07-04 17:32:11.000000000 +0100 | |
246 | +++ cups-1.2.x/backend/ieee1284.c 2006-06-26 12:42:40.000000000 +0100 | |
247 | @@ -1,5 +1,5 @@ | |
248 | /* | |
249 | - * "$Id$" | |
250 | + * "$Id$" | |
251 | * | |
252 | * IEEE-1284 support functions for the Common UNIX Printing System (CUPS). | |
253 | * | |
254 | @@ -25,51 +25,41 @@ | |
255 | * | |
256 | * Contents: | |
257 | * | |
258 | - * get_device_id() - Get the IEEE-1284 device ID string and corresponding | |
259 | - * URI. | |
260 | - * get_make_model() - Get the make and model string from the device ID. | |
261 | + * backendGetDeviceID() - Get the IEEE-1284 device ID string and | |
262 | + * corresponding URI. | |
263 | + * backendGetMakeModel() - Get the make and model string from the device ID. | |
264 | */ | |
265 | ||
266 | /* | |
267 | * Include necessary headers. | |
268 | */ | |
269 | ||
270 | -#include <cups/debug.h> | |
271 | - | |
272 | +#include "backend-private.h" | |
273 | ||
274 | -/* | |
275 | - * Prototypes... | |
276 | - */ | |
277 | +#ifdef __linux | |
278 | +# include <sys/ioctl.h> | |
279 | +# include <linux/lp.h> | |
280 | +# define IOCNR_GET_DEVICE_ID 1 | |
281 | +# define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len) | |
282 | +#endif /* __linux */ | |
283 | ||
284 | -static int get_make_model(const char *device_id, char *make_model, | |
285 | - int make_model_size); | |
286 | +#ifdef __sun | |
287 | +# ifdef __sparc | |
288 | +# include <sys/ecppio.h> | |
289 | +# else | |
290 | +# include <sys/ioccom.h> | |
291 | +# include <sys/ecppsys.h> | |
292 | +# endif /* __sparc */ | |
293 | +#endif /* __sun */ | |
294 | ||
295 | ||
296 | /* | |
297 | - * 'get_device_id()' - Get the IEEE-1284 device ID string and | |
298 | - * corresponding URI. | |
299 | + * 'backendGetDeviceID()' - Get the IEEE-1284 device ID string and | |
300 | + * corresponding URI. | |
301 | */ | |
302 | ||
303 | -#ifndef SNMP_BACKEND | |
304 | -# ifdef __linux | |
305 | -# include <sys/ioctl.h> | |
306 | -# include <linux/lp.h> | |
307 | -# define IOCNR_GET_DEVICE_ID 1 | |
308 | -# define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len) | |
309 | -# endif /* __linux */ | |
310 | - | |
311 | -# ifdef __sun | |
312 | -# ifdef __sparc | |
313 | -# include <sys/ecppio.h> | |
314 | -# else | |
315 | -# include <sys/ioccom.h> | |
316 | -# include <sys/ecppsys.h> | |
317 | -# endif /* __sparc */ | |
318 | -# endif /* __sun */ | |
319 | - | |
320 | - | |
321 | int /* O - 0 on success, -1 on failure */ | |
322 | -get_device_id( | |
323 | +backendGetDeviceID( | |
324 | int fd, /* I - File descriptor */ | |
325 | char *device_id, /* O - 1284 device ID */ | |
326 | int device_id_size, /* I - Size of buffer */ | |
327 | @@ -93,7 +83,7 @@ | |
328 | #endif /* __sun && ECPPIOC_GETDEVID */ | |
329 | ||
330 | ||
331 | - DEBUG_printf(("get_device_id(fd=%d, device_id=%p, device_id_size=%d, " | |
332 | + DEBUG_printf(("backendGetDeviceID(fd=%d, device_id=%p, device_id_size=%d, " | |
333 | "make_model=%p, make_model_size=%d, scheme=\"%s\", " | |
334 | "uri=%p, uri_size=%d)\n", fd, device_id, device_id_size, | |
335 | make_model, make_model_size, scheme ? scheme : "(null)", | |
336 | @@ -107,7 +97,7 @@ | |
337 | !device_id || device_id_size < 32 || | |
338 | !make_model || make_model_size < 32) | |
339 | { | |
340 | - DEBUG_puts("get_device_id: Bad args!"); | |
341 | + DEBUG_puts("backendGetDeviceID: Bad args!"); | |
342 | return (-1); | |
343 | } | |
344 | ||
345 | @@ -155,7 +145,7 @@ | |
346 | } | |
347 | # ifdef DEBUG | |
348 | else | |
349 | - printf("get_device_id: ioctl failed - %s\n", strerror(errno)); | |
350 | + printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno)); | |
351 | # endif /* DEBUG */ | |
352 | #endif /* __linux */ | |
353 | ||
354 | @@ -178,11 +168,11 @@ | |
355 | } | |
356 | # ifdef DEBUG | |
357 | else | |
358 | - printf("get_device_id: ioctl failed - %s\n", strerror(errno)); | |
359 | + printf("backendGetDeviceID: ioctl failed - %s\n", strerror(errno)); | |
360 | # endif /* DEBUG */ | |
361 | #endif /* __sun && ECPPIOC_GETDEVID */ | |
362 | ||
363 | - DEBUG_printf(("get_device_id: device_id=\"%s\"\n", device_id)); | |
364 | + DEBUG_printf(("backendGetDeviceID: device_id=\"%s\"\n", device_id)); | |
365 | ||
366 | if (!*device_id) | |
367 | return (-1); | |
368 | @@ -191,7 +181,7 @@ | |
369 | * Get the make and model... | |
370 | */ | |
371 | ||
372 | - get_make_model(device_id, make_model, make_model_size); | |
373 | + backendGetMakeModel(device_id, make_model, make_model_size); | |
374 | ||
375 | /* | |
376 | * Then generate a device URI... | |
377 | @@ -303,15 +293,14 @@ | |
378 | ||
379 | return (0); | |
380 | } | |
381 | -#endif /* !SNMP_BACKEND */ | |
382 | ||
383 | ||
384 | /* | |
385 | - * 'get_make_model()' - Get the make and model string from the device ID. | |
386 | + * 'backendGetMakeModel()' - Get the make and model string from the device ID. | |
387 | */ | |
388 | ||
389 | int /* O - 0 on success, -1 on failure */ | |
390 | -get_make_model( | |
391 | +backendGetMakeModel( | |
392 | const char *device_id, /* O - 1284 device ID */ | |
393 | char *make_model, /* O - Make/model */ | |
394 | int make_model_size) /* I - Size of buffer */ | |
395 | @@ -322,7 +311,7 @@ | |
396 | *mdl; /* Model string */ | |
397 | ||
398 | ||
399 | - DEBUG_printf(("get_make_model(device_id=\"%s\", " | |
400 | + DEBUG_printf(("backendGetMakeModel(device_id=\"%s\", " | |
401 | "make_model=%p, make_model_size=%d)\n", device_id, | |
402 | make_model, make_model_size)); | |
403 | ||
404 | @@ -332,7 +321,7 @@ | |
405 | ||
406 | if (!device_id || !*device_id || !make_model || make_model_size < 32) | |
407 | { | |
408 | - DEBUG_puts("get_make_model: Bad args!"); | |
409 | + DEBUG_puts("backendGetMakeModel: Bad args!"); | |
410 | return (-1); | |
411 | } | |
412 | ||
413 | @@ -506,5 +495,5 @@ | |
414 | ||
415 | ||
416 | /* | |
417 | - * End of "$Id$". | |
418 | + * End of "$Id$". | |
419 | */ | |
420 | diff -durN release-1.2.1/backend/ieee1394.c cups-1.2.x/backend/ieee1394.c | |
421 | --- release-1.2.1/backend/ieee1394.c 2006-07-04 17:32:11.000000000 +0100 | |
422 | +++ cups-1.2.x/backend/ieee1394.c 1970-01-01 01:00:00.000000000 +0100 | |
423 | @@ -1,267 +0,0 @@ | |
424 | -/* | |
425 | - * "$Id$" | |
426 | - * | |
427 | - * IEEE-1394 backend for the Common UNIX Printing System (CUPS). | |
428 | - * | |
429 | - * Copyright 2002 by Easy Software Products, all rights reserved. | |
430 | - * | |
431 | - * Redistribution and use in source and binary forms, with or | |
432 | - * without modification, are permitted provided that the | |
433 | - * following conditions are met: | |
434 | - * | |
435 | - * 1. Redistributions of source code must retain the above | |
436 | - * copyright notice, this list of conditions and the | |
437 | - * following disclaimer. | |
438 | - * | |
439 | - * 2. Redistributions in binary form must reproduce the | |
440 | - * above copyright notice, this list of conditions and | |
441 | - * the following disclaimer in the documentation and/or | |
442 | - * other materials provided with the distribution. | |
443 | - * | |
444 | - * 3. All advertising materials mentioning features or use | |
445 | - * of this software must display the following | |
446 | - * acknowledgement: | |
447 | - * | |
448 | - * This product includes software developed by Easy | |
449 | - * Software Products. | |
450 | - * | |
451 | - * 4. The name of Easy Software Products may not be used to | |
452 | - * endorse or promote products derived from this software | |
453 | - * without specific prior written permission. | |
454 | - * | |
455 | - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS | |
456 | - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
457 | - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
458 | - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
459 | - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS | |
460 | - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
461 | - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
462 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
463 | - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
464 | - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
465 | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
466 | - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
467 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
468 | - * DAMAGE. | |
469 | - * | |
470 | - * Contents: | |
471 | - * | |
472 | - * main() - Send a file to the printer. | |
473 | - * list_devices() - List all known printer devices... | |
474 | - */ | |
475 | - | |
476 | -/* | |
477 | - * Include necessary headers. | |
478 | - */ | |
479 | - | |
480 | -#include "ieee1394.h" | |
481 | - | |
482 | - | |
483 | -/* | |
484 | - * Local functions... | |
485 | - */ | |
486 | - | |
487 | -void list_devices(void); | |
488 | - | |
489 | - | |
490 | -/* | |
491 | - * 'main()' - Send a file to the printer. | |
492 | - * | |
493 | - * Usage: | |
494 | - * | |
495 | - * printer-uri job-id user title copies options [file] | |
496 | - */ | |
497 | - | |
498 | -int /* O - Exit status */ | |
499 | -main(int argc, /* I - Number of command-line arguments (6 or 7) */ | |
500 | - char *argv[]) /* I - Command-line arguments */ | |
501 | -{ | |
502 | - ieee1394_dev_t dev; /* Printer device */ | |
503 | - int fp; /* Print file */ | |
504 | - int copies; /* Number of copies to print */ | |
505 | - int rbytes; /* Number of bytes read from device */ | |
506 | - size_t nbytes, /* Number of bytes read from file */ | |
507 | - tbytes; /* Total number of bytes written */ | |
508 | - char buffer[8192]; /* Input/output buffer */ | |
509 | -#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) | |
510 | - struct sigaction action; /* Actions for POSIX signals */ | |
511 | -#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ | |
512 | - | |
513 | - | |
514 | - /* | |
515 | - * Make sure status messages are not buffered... | |
516 | - */ | |
517 | - | |
518 | - setbuf(stderr, NULL); | |
519 | - | |
520 | - /* | |
521 | - * Check command-line... | |
522 | - */ | |
523 | - | |
524 | - if (argc == 1) | |
525 | - { | |
526 | - list_devices(); | |
527 | - | |
528 | - return (0); | |
529 | - } | |
530 | - else if (argc < 6 || argc > 7) | |
531 | - { | |
532 | - fprintf(stderr, "Usage: %s job-id user title copies options [file]\n", | |
533 | - argv[0]); | |
534 | - return (1); | |
535 | - } | |
536 | - | |
537 | - /* | |
538 | - * If we have 7 arguments, print the file named on the command-line. | |
539 | - * Otherwise, send stdin instead... | |
540 | - */ | |
541 | - | |
542 | - if (argc == 6) | |
543 | - { | |
544 | - fp = 0; | |
545 | - copies = 1; | |
546 | - } | |
547 | - else | |
548 | - { | |
549 | - /* | |
550 | - * Try to open the print file... | |
551 | - */ | |
552 | - | |
553 | - if ((fp = open(argv[6], O_RDONLY)) < 0) | |
554 | - { | |
555 | - perror("ERROR: unable to open print file"); | |
556 | - return (1); | |
557 | - } | |
558 | - | |
559 | - copies = atoi(argv[4]); | |
560 | - } | |
561 | - | |
562 | - /* | |
563 | - * Try to open the printer device... | |
564 | - */ | |
565 | - | |
566 | - fputs("STATE: +connecting-to-device\n", stderr); | |
567 | - | |
568 | - do | |
569 | - { | |
570 | - if ((dev = ieee1394_open(argv[0])) == NULL) | |
571 | - { | |
572 | - fputs("INFO: Firewire printer busy; will retry in 30 seconds...\n", stderr); | |
573 | - sleep(30); | |
574 | - } | |
575 | - } | |
576 | - while (dev == NULL); | |
577 | - | |
578 | - fputs("STATE: -connecting-to-device\n", stderr); | |
579 | - | |
580 | - /* | |
581 | - * Now that we are "connected" to the port, ignore SIGTERM so that we | |
582 | - * can finish out any page data the driver sends (e.g. to eject the | |
583 | - * current page... Only ignore SIGTERM if we are printing data from | |
584 | - * stdin (otherwise you can't cancel raw jobs...) | |
585 | - */ | |
586 | - | |
587 | - if (argc < 7) | |
588 | - { | |
589 | -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ | |
590 | - sigset(SIGTERM, SIG_IGN); | |
591 | -#elif defined(HAVE_SIGACTION) | |
592 | - memset(&action, 0, sizeof(action)); | |
593 | - | |
594 | - sigemptyset(&action.sa_mask); | |
595 | - action.sa_handler = SIG_IGN; | |
596 | - sigaction(SIGTERM, &action, NULL); | |
597 | -#else | |
598 | - signal(SIGTERM, SIG_IGN); | |
599 | -#endif /* HAVE_SIGSET */ | |
600 | - } | |
601 | - | |
602 | - /* | |
603 | - * Finally, send the print file... | |
604 | - */ | |
605 | - | |
606 | - while (copies > 0) | |
607 | - { | |
608 | - copies --; | |
609 | - | |
610 | - if (fp != 0) | |
611 | - { | |
612 | - fputs("PAGE: 1 1\n", stderr); | |
613 | - lseek(fp, 0, SEEK_SET); | |
614 | - } | |
615 | - | |
616 | - tbytes = 0; | |
617 | - while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0) | |
618 | - { | |
619 | - /* | |
620 | - * Write the print data to the printer... | |
621 | - */ | |
622 | - | |
623 | - tbytes += nbytes; | |
624 | - | |
625 | - if (ieee1394_write(dev, buffer, nbytes) < 0) | |
626 | - { | |
627 | - perror("ERROR: Unable to send print file to printer"); | |
628 | - break; | |
629 | - } | |
630 | - | |
631 | - if ((rbytes = ieee1394_read(dev, buffer, sizeof(buffer))) > 0) | |
632 | - fprintf(stderr, "INFO: Read %d bytes from printer...\n", rbytes); | |
633 | - | |
634 | - if (argc > 6) | |
635 | - fprintf(stderr, "INFO: Sending print file, %lu bytes...\n", | |
636 | - (unsigned long)tbytes); | |
637 | - } | |
638 | - } | |
639 | - | |
640 | - /* | |
641 | - * Close the printer device and input file and return... | |
642 | - */ | |
643 | - | |
644 | - ieee1394_close(dev); | |
645 | - | |
646 | - if (fp != 0) | |
647 | - close(fp); | |
648 | - | |
649 | - fputs("INFO: Ready to print.\n", stderr); | |
650 | - | |
651 | - return (0); | |
652 | -} | |
653 | - | |
654 | - | |
655 | -/* | |
656 | - * 'list_devices()' - List all known devices... | |
657 | - */ | |
658 | - | |
659 | -void | |
660 | -list_devices(void) | |
661 | -{ | |
662 | - int i, /* Looping var */ | |
663 | - num_info; /* Number of devices */ | |
664 | - ieee1394_info_t *info; /* Devices... */ | |
665 | - | |
666 | - | |
667 | - /* | |
668 | - * Get the available devices... | |
669 | - */ | |
670 | - | |
671 | - info = ieee1394_list(&num_info); | |
672 | - | |
673 | - /* | |
674 | - * List them as needed... | |
675 | - */ | |
676 | - | |
677 | - if (num_info > 0) | |
678 | - { | |
679 | - for (i = 0; i < num_info; i ++) | |
680 | - printf("direct %s \"%s\" \"%s\"\n", info[i].uri, | |
681 | - info[i].make_model, info[i].description); | |
682 | - | |
683 | - free(info); | |
684 | - } | |
685 | -} | |
686 | - | |
687 | - | |
688 | -/* | |
689 | - * End of "$Id$". | |
690 | - */ | |
691 | diff -durN release-1.2.1/backend/ieee1394.h cups-1.2.x/backend/ieee1394.h | |
692 | --- release-1.2.1/backend/ieee1394.h 2006-07-04 17:32:11.000000000 +0100 | |
693 | +++ cups-1.2.x/backend/ieee1394.h 1970-01-01 01:00:00.000000000 +0100 | |
694 | @@ -1,103 +0,0 @@ | |
695 | -/* | |
696 | - * "$Id$" | |
697 | - * | |
698 | - * IEEE-1394 header for the Common UNIX Printing System (CUPS). | |
699 | - * | |
700 | - * Copyright 2002 by Easy Software Products, all rights reserved. | |
701 | - * | |
702 | - * Redistribution and use in source and binary forms, with or | |
703 | - * without modification, are permitted provided that the | |
704 | - * following conditions are met: | |
705 | - * | |
706 | - * 1. Redistributions of source code must retain the above | |
707 | - * copyright notice, this list of conditions and the | |
708 | - * following disclaimer. | |
709 | - * | |
710 | - * 2. Redistributions in binary form must reproduce the | |
711 | - * above copyright notice, this list of conditions and | |
712 | - * the following disclaimer in the documentation and/or | |
713 | - * other materials provided with the distribution. | |
714 | - * | |
715 | - * 3. All advertising materials mentioning features or use | |
716 | - * of this software must display the following | |
717 | - * acknowledgement: | |
718 | - * | |
719 | - * This product includes software developed by Easy | |
720 | - * Software Products. | |
721 | - * | |
722 | - * 4. The name of Easy Software Products may not be used to | |
723 | - * endorse or promote products derived from this software | |
724 | - * without specific prior written permission. | |
725 | - * | |
726 | - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS | |
727 | - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
728 | - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
729 | - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
730 | - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS | |
731 | - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
732 | - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
733 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
734 | - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
735 | - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
736 | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
737 | - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
738 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
739 | - * DAMAGE. | |
740 | - */ | |
741 | - | |
742 | -/* | |
743 | - * Include necessary headers. | |
744 | - */ | |
745 | - | |
746 | -#include <cups/cups.h> | |
747 | -#include <stdio.h> | |
748 | -#include <stdlib.h> | |
749 | -#include <stdarg.h> | |
750 | -#include <cups/string.h> | |
751 | -#include <errno.h> | |
752 | -#include <sys/types.h> | |
753 | -#include <sys/stat.h> | |
754 | -#include <signal.h> | |
755 | - | |
756 | -#ifdef WIN32 | |
757 | -# include <io.h> | |
758 | -#else | |
759 | -# include <unistd.h> | |
760 | -# include <fcntl.h> | |
761 | -#endif /* WIN32 */ | |
762 | - | |
763 | - | |
764 | -/* | |
765 | - * Device information structure... | |
766 | - */ | |
767 | - | |
768 | -typedef struct | |
769 | -{ | |
770 | - char uri[HTTP_MAX_URI], /* Device URI */ | |
771 | - description[128], /* Description of port */ | |
772 | - make_model[128]; /* Make and model */ | |
773 | -} ieee1394_info_t; | |
774 | - | |
775 | - | |
776 | -/* | |
777 | - * Private device connection information... | |
778 | - */ | |
779 | - | |
780 | -typedef void *ieee1394_dev_t; | |
781 | - | |
782 | - | |
783 | -/* | |
784 | - * Prototypes for standard IEEE-1394 interface... | |
785 | - */ | |
786 | - | |
787 | -extern ieee1394_info_t *ieee1394_list(int *num_devices); | |
788 | -extern ieee1394_dev_t ieee1394_open(const char *uri); | |
789 | -extern int ieee1394_close(ieee1394_dev_t dev); | |
790 | -extern int ieee1394_read(ieee1394_dev_t dev, char *buffer, int len); | |
791 | -extern int ieee1394_write(ieee1394_dev_t dev, char *buffer, int len); | |
792 | -extern const char *ieee1394_error(void); | |
793 | - | |
794 | - | |
795 | -/* | |
796 | - * End of "$Id$". | |
797 | - */ | |
798 | diff -durN release-1.2.1/backend/ieee1394-linux.c cups-1.2.x/backend/ieee1394-linux.c | |
799 | --- release-1.2.1/backend/ieee1394-linux.c 2006-07-04 17:32:11.000000000 +0100 | |
800 | +++ cups-1.2.x/backend/ieee1394-linux.c 1970-01-01 01:00:00.000000000 +0100 | |
801 | @@ -1,877 +0,0 @@ | |
802 | -/* | |
803 | - * "$Id$" | |
804 | - * | |
805 | - * Linux IEEE-1394 glue for the Common UNIX Printing System (CUPS). | |
806 | - * | |
807 | - * Copyright 2002 by Easy Software Products, all rights reserved. | |
808 | - * | |
809 | - * Redistribution and use in source and binary forms, with or | |
810 | - * without modification, are permitted provided that the | |
811 | - * following conditions are met: | |
812 | - * | |
813 | - * 1. Redistributions of source code must retain the above | |
814 | - * copyright notice, this list of conditions and the | |
815 | - * following disclaimer. | |
816 | - * | |
817 | - * 2. Redistributions in binary form must reproduce the | |
818 | - * above copyright notice, this list of conditions and | |
819 | - * the following disclaimer in the documentation and/or | |
820 | - * other materials provided with the distribution. | |
821 | - * | |
822 | - * 3. All advertising materials mentioning features or use | |
823 | - * of this software must display the following | |
824 | - * acknowledgement: | |
825 | - * | |
826 | - * This product includes software developed by Easy | |
827 | - * Software Products. | |
828 | - * | |
829 | - * 4. The name of Easy Software Products may not be used to | |
830 | - * endorse or promote products derived from this software | |
831 | - * without specific prior written permission. | |
832 | - * | |
833 | - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS | |
834 | - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, | |
835 | - * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
836 | - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
837 | - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS | |
838 | - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
839 | - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
840 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
841 | - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
842 | - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
843 | - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
844 | - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
845 | - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
846 | - * DAMAGE. | |
847 | - * | |
848 | - * Contents: | |
849 | - * | |
850 | - * get_device_id() - Get the IEEE-1284 device ID for a node... | |
851 | - * get_unit_type() - Get the unit type for a node... | |
852 | - * show_data() - Show a data node... | |
853 | - * show_dir() - Show a directory list... | |
854 | - * ieee1394_list() - List the available printer devices. | |
855 | - * ieee1394_open() - Open a printer device. | |
856 | - * ieee1394_close() - Close a printer device. | |
857 | - * ieee1394_read() - Read from a printer device. | |
858 | - * ieee1394_write() - Write data to a printer device. | |
859 | - * ieee1394_error() - Return the last error. | |
860 | - */ | |
861 | - | |
862 | -/* | |
863 | - * Include necessary headers. | |
864 | - */ | |
865 | - | |
866 | -#include "ieee1394.h" | |
867 | -#include <cups/debug.h> | |
868 | -#include <libraw1394/raw1394.h> | |
869 | -#include <libraw1394/csr.h> | |
870 | - | |
871 | - | |
872 | -/* | |
873 | - * Limits... | |
874 | - */ | |
875 | - | |
876 | -#define MAX_NODES 100 | |
877 | - | |
878 | - | |
879 | -/* | |
880 | - * Structures... | |
881 | - */ | |
882 | - | |
883 | -typedef struct | |
884 | -{ | |
885 | - char uri[HTTP_MAX_URI],/* URI for this node... */ | |
886 | - description[128],/* Description of port */ | |
887 | - make_model[128];/* Make and model */ | |
888 | - int port, /* Port where this node is found */ | |
889 | - node; /* Node number */ | |
890 | - unsigned long long addr; /* Management address */ | |
891 | -} linux1394_node_t; | |
892 | - | |
893 | -typedef struct | |
894 | -{ | |
895 | - raw1394handle_t handle; /* Handle for printer device */ | |
896 | - int node; /* Node number for printer device */ | |
897 | - unsigned long long addr; /* Management address */ | |
898 | -} linux1394_dev_t; | |
899 | - | |
900 | - | |
901 | -/* | |
902 | - * ORB messages for communication with the device... | |
903 | - */ | |
904 | - | |
905 | -typedef struct /**** Login ORB Message */ | |
906 | -{ | |
907 | - unsigned char passwd_addr[8]; /* Password address */ | |
908 | - unsigned char resp_addr[8]; /* Login response address */ | |
909 | - unsigned char notify_excl; /* Notify and exclusive bits */ | |
910 | - unsigned char recon_func; /* Reconnect time and function */ | |
911 | - unsigned char lun[2]; /* Logical unit number */ | |
912 | - unsigned char passwd_len[2]; /* Length of password */ | |
913 | - unsigned char resp_len[2]; /* Length of login response */ | |
914 | - unsigned char fifo_addr[8]; /* Local status FIFO address */ | |
915 | -} login_orb_t; | |
916 | - | |
917 | -typedef struct /**** Login Response Message ****/ | |
918 | -{ | |
919 | - unsigned char length[2]; /* Length of response */ | |
920 | - unsigned char login_id[2]; /* Login ID */ | |
921 | - unsigned char cmd_addr[8]; /* Command block agent address */ | |
922 | - unsigned char reserved[2]; /* Reserved (0) */ | |
923 | - unsigned char recon_hold[2]; /* Number of seconds to hold login */ | |
924 | -} login_resp_t; | |
925 | - | |
926 | - | |
927 | -/* | |
928 | - * Local globals... | |
929 | - */ | |
930 | - | |
931 | -static char error_string[1024] = ""; | |
932 | -static int num_nodes; | |
933 | -static linux1394_node_t nodes[MAX_NODES]; | |
934 | - | |
935 | - | |
936 | -/* | |
937 | - * 'get_device_id()' - Get the IEEE-1284 device ID for a node... | |
938 | - */ | |
939 | - | |
940 | -static char * /* O - Device ID */ | |
941 | -get_device_id(raw1394handle_t handle,/* I - Handle for device */ | |
942 | - int node, /* I - Node number */ | |
943 | - unsigned long long offset,/* I - Offset to directory */ | |
944 | - char *id, /* O - ID string */ | |
945 | - int idlen) /* I - Size of ID string */ | |
946 | -{ | |
947 | - unsigned char data[1024], /* Data from ROM */ | |
948 | - *dataptr; /* Pointer into data */ | |
949 | - int length; /* Length of directory */ | |
950 | - int datalen; /* Length of data */ | |
951 | - unsigned long long dataoff; /* Offset of data */ | |
952 | - | |
953 | - | |
954 | - DEBUG_printf(("get_device_id(handle = %p, node = %d, offset = %llx, id = %p, idlen = %d)\n", | |
955 | - handle, node, offset, id, idlen)); | |
956 | - | |
957 | - *id = '\0'; | |
958 | - | |
959 | - /* | |
960 | - * Read the directory length from the first quadlet... | |
961 | - */ | |
962 | - | |
963 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
964 | - return (NULL); | |
965 | - | |
966 | - offset += 4; | |
967 | - | |
968 | - /* | |
969 | - * The length is in the upper 16 bits... | |
970 | - */ | |
971 | - | |
972 | - length = (data[0] << 8) | data[1]; | |
973 | - | |
974 | - DEBUG_printf((" length = %d\n", length)); | |
975 | - | |
976 | - /* | |
977 | - * Then read the directory, looking for unit directory or device tags... | |
978 | - */ | |
979 | - | |
980 | - while (length > 0) | |
981 | - { | |
982 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
983 | - return (NULL); | |
984 | - | |
985 | - DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1], | |
986 | - data[2], data[3])); | |
987 | - | |
988 | - if (data[0] == 0xd1) | |
989 | - { | |
990 | - /* | |
991 | - * Found the unit directory... | |
992 | - */ | |
993 | - | |
994 | - offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2; | |
995 | - | |
996 | - return (get_device_id(handle, node, offset, id, idlen)); | |
997 | - } | |
998 | - else if (data[0] == 0x81) | |
999 | - { | |
1000 | - /* | |
1001 | - * Found potential IEEE-1284 device ID... | |
1002 | - */ | |
1003 | - | |
1004 | - dataoff = offset + (((((data[1] << 8) | data[2]) << 8) | data[3]) << 2); | |
1005 | - | |
1006 | - if (raw1394_read(handle, 0xffc0 | node, dataoff, 4, (quadlet_t *)data) < 0) | |
1007 | - return (NULL); | |
1008 | - | |
1009 | - dataoff += 4; | |
1010 | - | |
1011 | - /* | |
1012 | - * Read the leaf value... | |
1013 | - */ | |
1014 | - | |
1015 | - datalen = (data[0] << 8) | data[1]; | |
1016 | - | |
1017 | - if (datalen > (sizeof(data) / 4)) | |
1018 | - datalen = sizeof(data) / 4; | |
1019 | - | |
1020 | - for (dataptr = data; datalen > 0; datalen --, dataptr += 4, dataoff += 4) | |
1021 | - if (raw1394_read(handle, 0xffc0 | node, dataoff, 4, | |
1022 | - (quadlet_t *)dataptr) < 0) | |
1023 | - return (NULL); | |
1024 | - | |
1025 | - if (data[0] == 0 && memcmp(data + 8, "MFG:", 4) == 0) | |
1026 | - { | |
1027 | - /* | |
1028 | - * Found the device ID... | |
1029 | - */ | |
1030 | - | |
1031 | - datalen = dataptr - data - 8; | |
1032 | - if (datalen >= idlen) | |
1033 | - datalen --; | |
1034 | - | |
1035 | - memcpy(id, data + 8, datalen); | |
1036 | - id[datalen] = '\0'; | |
1037 | - | |
1038 | - return (id); | |
1039 | - } | |
1040 | - } | |
1041 | - | |
1042 | - offset += 4; | |
1043 | - length --; | |
1044 | - } | |
1045 | - | |
1046 | - return (NULL); | |
1047 | -} | |
1048 | - | |
1049 | - | |
1050 | -/* | |
1051 | - * 'get_man_addr()' - Get the management address for a node... | |
1052 | - */ | |
1053 | - | |
1054 | -static int /* O - Unit type */ | |
1055 | -get_man_addr(raw1394handle_t handle, /* I - Handle for device */ | |
1056 | - int node, /* I - Node number */ | |
1057 | - unsigned long long offset) /* I - Offset to directory */ | |
1058 | -{ | |
1059 | - unsigned char data[4]; /* Data from ROM */ | |
1060 | - int length; /* Length of directory */ | |
1061 | - | |
1062 | - | |
1063 | - DEBUG_printf(("get_man_addr(handle = %p, node = %d, offset = %llx)\n", | |
1064 | - handle, node, offset)); | |
1065 | - | |
1066 | - /* | |
1067 | - * Read the directory length from the first quadlet... | |
1068 | - */ | |
1069 | - | |
1070 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1071 | - return (-1); | |
1072 | - | |
1073 | - offset += 4; | |
1074 | - | |
1075 | - /* | |
1076 | - * The length is in the upper 16 bits... | |
1077 | - */ | |
1078 | - | |
1079 | - length = (data[0] << 8) | data[1]; | |
1080 | - | |
1081 | - DEBUG_printf((" length = %d\n", length)); | |
1082 | - | |
1083 | - /* | |
1084 | - * Then read the directory, looking for unit directory or type tags... | |
1085 | - */ | |
1086 | - | |
1087 | - while (length > 0) | |
1088 | - { | |
1089 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1090 | - return (-1); | |
1091 | - | |
1092 | - DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1], | |
1093 | - data[2], data[3])); | |
1094 | - | |
1095 | - if (data[0] == 0xd1) | |
1096 | - { | |
1097 | - /* | |
1098 | - * Found the unit directory... | |
1099 | - */ | |
1100 | - | |
1101 | - offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2; | |
1102 | - | |
1103 | - return (get_man_addr(handle, node, offset)); | |
1104 | - } | |
1105 | - else if (data[0] == 0x54) | |
1106 | - { | |
1107 | - /* | |
1108 | - * Found the management address... | |
1109 | - */ | |
1110 | - | |
1111 | - return (((((data[1] << 8) | data[2]) << 8) | data[3]) << 2); | |
1112 | - } | |
1113 | - | |
1114 | - offset += 4; | |
1115 | - length --; | |
1116 | - } | |
1117 | - | |
1118 | - return (-1); | |
1119 | -} | |
1120 | - | |
1121 | - | |
1122 | -/* | |
1123 | - * 'get_unit_type()' - Get the unit type for a node... | |
1124 | - */ | |
1125 | - | |
1126 | -static int /* O - Unit type */ | |
1127 | -get_unit_type(raw1394handle_t handle,/* I - Handle for device */ | |
1128 | - int node, /* I - Node number */ | |
1129 | - unsigned long long offset)/* I - Offset to directory */ | |
1130 | -{ | |
1131 | - unsigned char data[4]; /* Data from ROM */ | |
1132 | - int length; /* Length of directory */ | |
1133 | - | |
1134 | - | |
1135 | - DEBUG_printf(("get_unit_type(handle = %p, node = %d, offset = %llx)\n", | |
1136 | - handle, node, offset)); | |
1137 | - | |
1138 | - /* | |
1139 | - * Read the directory length from the first quadlet... | |
1140 | - */ | |
1141 | - | |
1142 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1143 | - return (-1); | |
1144 | - | |
1145 | - offset += 4; | |
1146 | - | |
1147 | - /* | |
1148 | - * The length is in the upper 16 bits... | |
1149 | - */ | |
1150 | - | |
1151 | - length = (data[0] << 8) | data[1]; | |
1152 | - | |
1153 | - DEBUG_printf((" length = %d\n", length)); | |
1154 | - | |
1155 | - /* | |
1156 | - * Then read the directory, looking for unit directory or type tags... | |
1157 | - */ | |
1158 | - | |
1159 | - while (length > 0) | |
1160 | - { | |
1161 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1162 | - return (-1); | |
1163 | - | |
1164 | - DEBUG_printf((" data = %02X %02X %02X %02X\n", data[0], data[1], | |
1165 | - data[2], data[3])); | |
1166 | - | |
1167 | - if (data[0] == 0xd1) | |
1168 | - { | |
1169 | - /* | |
1170 | - * Found the unit directory... | |
1171 | - */ | |
1172 | - | |
1173 | - offset += ((((data[1] << 8) | data[2]) << 8) | data[3]) << 2; | |
1174 | - | |
1175 | - return (get_unit_type(handle, node, offset)); | |
1176 | - } | |
1177 | - else if (data[0] == 0x14) | |
1178 | - { | |
1179 | - /* | |
1180 | - * Found the unit type... | |
1181 | - */ | |
1182 | - | |
1183 | - return (data[1] & 0x1f); | |
1184 | - } | |
1185 | - | |
1186 | - offset += 4; | |
1187 | - length --; | |
1188 | - } | |
1189 | - | |
1190 | - return (-1); | |
1191 | -} | |
1192 | - | |
1193 | - | |
1194 | -#ifdef DEBUG | |
1195 | -/* | |
1196 | - * 'show_data()' - Show a data node... | |
1197 | - */ | |
1198 | - | |
1199 | -static void | |
1200 | -show_data(raw1394handle_t handle, /* I - Handle for device */ | |
1201 | - int node, /* I - Node number */ | |
1202 | - unsigned long long offset, /* I - Offset to directory */ | |
1203 | - int indent) /* Amount to indent */ | |
1204 | -{ | |
1205 | - int i; /* Looping var */ | |
1206 | - unsigned char data[4]; /* Data from ROM */ | |
1207 | - int length; /* Length of data */ | |
1208 | - | |
1209 | - | |
1210 | - /* | |
1211 | - * Read the data length from the first quadlet... | |
1212 | - */ | |
1213 | - | |
1214 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1215 | - return; | |
1216 | - | |
1217 | - offset += 4; | |
1218 | - | |
1219 | - /* | |
1220 | - * The length is in the upper 16 bits... | |
1221 | - */ | |
1222 | - | |
1223 | - length = (data[0] << 8) | data[1]; | |
1224 | - | |
1225 | - /* | |
1226 | - * Then read the data... | |
1227 | - */ | |
1228 | - | |
1229 | - for (i = 0; i < indent; i ++) | |
1230 | - putchar(' '); | |
1231 | - | |
1232 | - printf("LEAF (%d quadlets)\n", length); | |
1233 | - | |
1234 | - while (length > 0) | |
1235 | - { | |
1236 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1237 | - return; | |
1238 | - | |
1239 | - for (i = 0; i < indent; i ++) | |
1240 | - putchar(' '); | |
1241 | - | |
1242 | - printf("%02X %02X %02X %02X '%c%c%c%c'\n", | |
1243 | - data[0], data[1], data[2], data[3], | |
1244 | - (data[0] < ' ' || data[0] >= 0x7f) ? '.' : data[0], | |
1245 | - (data[1] < ' ' || data[1] >= 0x7f) ? '.' : data[1], | |
1246 | - (data[2] < ' ' || data[2] >= 0x7f) ? '.' : data[2], | |
1247 | - (data[3] < ' ' || data[3] >= 0x7f) ? '.' : data[3]); | |
1248 | - | |
1249 | - offset += 4; | |
1250 | - length --; | |
1251 | - } | |
1252 | -} | |
1253 | - | |
1254 | - | |
1255 | -/* | |
1256 | - * 'show_dir()' - Show a directory list... | |
1257 | - */ | |
1258 | - | |
1259 | -static void | |
1260 | -show_dir(raw1394handle_t handle, /* I - Handle for device */ | |
1261 | - int node, /* I - Node number */ | |
1262 | - unsigned long long offset, /* I - Offset to directory */ | |
1263 | - int indent) /* Amount to indent */ | |
1264 | -{ | |
1265 | - int i; /* Looping var */ | |
1266 | - unsigned char data[4]; /* Data from ROM */ | |
1267 | - int length; /* Length of directory */ | |
1268 | - int value; /* Value in directory */ | |
1269 | - | |
1270 | - | |
1271 | - /* | |
1272 | - * Read the directory length from the first quadlet... | |
1273 | - */ | |
1274 | - | |
1275 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1276 | - return; | |
1277 | - | |
1278 | - offset += 4; | |
1279 | - | |
1280 | - /* | |
1281 | - * The length is in the upper 16 bits... | |
1282 | - */ | |
1283 | - | |
1284 | - length = (data[0] << 8) | data[1]; | |
1285 | - | |
1286 | - /* | |
1287 | - * Then read the directory... | |
1288 | - */ | |
1289 | - | |
1290 | - while (length > 0) | |
1291 | - { | |
1292 | - if (raw1394_read(handle, 0xffc0 | node, offset, 4, (quadlet_t *)data) < 0) | |
1293 | - return; | |
1294 | - | |
1295 | - for (i = 0; i < indent; i ++) | |
1296 | - putchar(' '); | |
1297 | - | |
1298 | - printf("%02X %02X %02X %02X\n", data[0], data[1], data[2], data[3]); | |
1299 | - | |
1300 | - value = (((data[1] << 8) | data[2]) << 8) | data[3]; | |
1301 | - | |
1302 | - switch (data[0] & 0xc0) | |
1303 | - { | |
1304 | - case 0x00 : | |
1305 | - for (i = -4; i < indent; i ++) | |
1306 | - putchar(' '); | |
1307 | - | |
1308 | - printf("IMMEDIATE %d\n", value); | |
1309 | - break; | |
1310 | - | |
1311 | - case 0x40 : | |
1312 | - for (i = -4; i < indent; i ++) | |
1313 | - putchar(' '); | |
1314 | - | |
1315 | - printf("CSR OFFSET +%06X\n", value); | |
1316 | - break; | |
1317 | - | |
1318 | - case 0x80 : | |
1319 | - show_data(handle, node, offset + value * 4, indent + 4); | |
1320 | - break; | |
1321 | - | |
1322 | - case 0xc0 : | |
1323 | - show_dir(handle, node, offset + value * 4, indent + 4); | |
1324 | - break; | |
1325 | - } | |
1326 | - | |
1327 | - offset += 4; | |
1328 | - length --; | |
1329 | - } | |
1330 | -} | |
1331 | -#endif /* DEBUG */ | |
1332 | - | |
1333 | - | |
1334 | -/* | |
1335 | - * 'ieee1394_list()' - List the available printer devices. | |
1336 | - */ | |
1337 | - | |
1338 | -ieee1394_info_t * /* O - Printer information */ | |
1339 | -ieee1394_list(int *num_devices) /* O - Number of printers */ | |
1340 | -{ | |
1341 | - int i, j; /* Looping vars */ | |
1342 | - raw1394handle_t handle; /* 1394 handle */ | |
1343 | - int num_ports; /* Number of ports */ | |
1344 | - struct raw1394_portinfo ports[100]; /* Port data... */ | |
1345 | - unsigned char guid[8]; /* Global unique ID */ | |
1346 | - int vendor; /* Vendor portion of GUID */ | |
1347 | - int unit_type; /* Unit type */ | |
1348 | - int addr; /* Management address offset */ | |
1349 | - char id[1024], /* Device ID string */ | |
1350 | - *idptr, /* Pointer into ID string */ | |
1351 | - *idsep; /* Pointer to separator */ | |
1352 | - ieee1394_info_t *devices; /* Device list */ | |
1353 | - | |
1354 | - | |
1355 | - /* | |
1356 | - * Connect to the user-mode driver interface... | |
1357 | - */ | |
1358 | - | |
1359 | - handle = raw1394_new_handle(); | |
1360 | - num_ports = raw1394_get_port_info(handle, ports, | |
1361 | - sizeof(ports) / sizeof(ports[0])); | |
1362 | - | |
1363 | - DEBUG_printf(("num_ports = %d\n", num_ports)); | |
1364 | - | |
1365 | - /* | |
1366 | - * Loop through the ports to discover what nodes are available. | |
1367 | - */ | |
1368 | - | |
1369 | - num_nodes = 0; | |
1370 | - | |
1371 | - for (i = 0; i < num_ports; i ++) | |
1372 | - { | |
1373 | - DEBUG_printf(("ports[%d] = { nodes = %d, name = \"%s\" }\n", i, | |
1374 | - ports[i].nodes, ports[i].name)); | |
1375 | - | |
1376 | - raw1394_set_port(handle, i); | |
1377 | - | |
1378 | - for (j = 0; j < ports[i].nodes; j ++) | |
1379 | - { | |
1380 | - if (raw1394_read(handle, 0xffc0 | j, | |
1381 | - CSR_REGISTER_BASE + CSR_CONFIG_ROM + 12, 4, | |
1382 | - (quadlet_t *)guid) < 0) | |
1383 | - { | |
1384 | - DEBUG_printf((" Node #%d: Unable to contact (%s)!\n", j, | |
1385 | - strerror(errno))); | |
1386 | - continue; | |
1387 | - } | |
1388 | - else | |
1389 | - { | |
1390 | - raw1394_read(handle, 0xffc0 | j, | |
1391 | - CSR_REGISTER_BASE + CSR_CONFIG_ROM + 16, 4, | |
1392 | - (quadlet_t *)(guid + 4)); | |
1393 | - | |
1394 | - DEBUG_printf((" Node #%d: GUID = %02X%02X%02X%02X%02X%02X%02X%02X\n", | |
1395 | - j, guid[0], guid[1], guid[2], guid[3], guid[4], | |
1396 | - guid[5], guid[6], guid[7])); | |
1397 | - | |
1398 | - vendor = (((guid[0] << 8) | guid[1]) << 8) | guid[2]; | |
1399 | - unit_type = get_unit_type(handle, j, | |
1400 | - CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20); | |
1401 | - | |
1402 | - DEBUG_printf(("vendor = %x, unit_type = %d\n", vendor, unit_type)); | |
1403 | - | |
1404 | - if (unit_type == 2 && num_nodes < MAX_NODES) | |
1405 | - { | |
1406 | - /* | |
1407 | - * Found a printer device; add it to the nodes list... | |
1408 | - */ | |
1409 | - | |
1410 | -#ifdef DEBUG | |
1411 | - show_dir(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20, 0); | |
1412 | -#endif /* DEBUG */ | |
1413 | - | |
1414 | - memset(nodes + num_nodes, 0, sizeof(linux1394_node_t)); | |
1415 | - | |
1416 | - sprintf(nodes[num_nodes].uri, "ieee1394://%02X%02X%02X%02X%02X%02X%02X%02X", | |
1417 | - guid[0], guid[1], guid[2], guid[3], guid[4], | |
1418 | - guid[5], guid[6], guid[7]); | |
1419 | - | |
1420 | - nodes[num_nodes].port = i; | |
1421 | - nodes[num_nodes].node = j; | |
1422 | - | |
1423 | - addr = get_man_addr(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20); | |
1424 | - | |
1425 | - if (addr < 0) | |
1426 | - continue; | |
1427 | - | |
1428 | - nodes[num_nodes].addr = CSR_REGISTER_BASE + addr; | |
1429 | - | |
1430 | - DEBUG_printf(("Node address = %llx\n", nodes[num_nodes].addr)); | |
1431 | - | |
1432 | - get_device_id(handle, j, CSR_REGISTER_BASE + CSR_CONFIG_ROM + 20, | |
1433 | - id, sizeof(id)); | |
1434 | - | |
1435 | - if (id[0]) | |
1436 | - { | |
1437 | - /* | |
1438 | - * Grab the manufacturer and model name from the device ID | |
1439 | - * string... | |
1440 | - */ | |
1441 | - | |
1442 | - idptr = id + 4; | |
1443 | - idsep = strchr(id, ';'); | |
1444 | - if (idsep) | |
1445 | - *idsep++ = '\0'; | |
1446 | - else | |
1447 | - idsep = idptr; | |
1448 | - | |
1449 | - snprintf(nodes[num_nodes].description, | |
1450 | - sizeof(nodes[num_nodes].description), | |
1451 | - "%s Firewire Printer", idptr); | |
1452 | - | |
1453 | - if ((idptr = strstr(idsep, "DES:")) == NULL) | |
1454 | - idptr = strstr(idsep, "MDL:"); | |
1455 | - | |
1456 | - if (idptr == NULL) | |
1457 | - strcpy(nodes[num_nodes].make_model, "Unknown"); | |
1458 | - else | |
1459 | - { | |
1460 | - /* | |
1461 | - * Grab the DES or MDL code... | |
1462 | - */ | |
1463 | - | |
1464 | - idptr += 4; | |
1465 | - idsep = strchr(idptr, ';'); | |
1466 | - if (idsep) | |
1467 | - *idsep = '\0'; | |
1468 | - | |
1469 | - if (strncmp(id + 4, idptr, strlen(id + 4)) == 0) | |
1470 | - { | |
1471 | - /* | |
1472 | - * Use the description directly... | |
1473 | - */ | |
1474 | - | |
1475 | - strlcpy(nodes[num_nodes].make_model, idptr, | |
1476 | - sizeof(nodes[num_nodes].make_model)); | |
1477 | - } | |
1478 | - else | |
1479 | - { | |
1480 | - /* | |
1481 | - * Add the manufacturer to the front of the name... | |
1482 | - */ | |
1483 | - | |
1484 | - snprintf(nodes[num_nodes].make_model, | |
1485 | - sizeof(nodes[num_nodes].make_model), | |
1486 | - "%s %s", id + 4, idptr); | |
1487 | - } | |
1488 | - } | |
1489 | - } | |
1490 | - else | |
1491 | - { | |
1492 | - /* | |
1493 | - * Flag it as an unknown printer... | |
1494 | - */ | |
1495 | - | |
1496 | - sprintf(nodes[num_nodes].description, | |
1497 | - "Unknown%06X Firewire Printer", vendor); | |
1498 | - strcpy(nodes[num_nodes].make_model, "Unknown"); | |
1499 | - } | |
1500 | - | |
1501 | - num_nodes ++; | |
1502 | - } | |
1503 | - } | |
1504 | - } | |
1505 | - } | |
1506 | - | |
1507 | - /* | |
1508 | - * Done querying the Firewire bus... | |
1509 | - */ | |
1510 | - | |
1511 | - raw1394_destroy_handle(handle); | |
1512 | - | |
1513 | - /* | |
1514 | - * Build an array of device info structures as needed... | |
1515 | - */ | |
1516 | - | |
1517 | - if (num_devices == NULL) | |
1518 | - return (NULL); | |
1519 | - | |
1520 | - *num_devices = num_nodes; | |
1521 | - | |
1522 | - if (num_nodes) | |
1523 | - { | |
1524 | - if ((devices = calloc(sizeof(ieee1394_info_t), num_nodes)) != NULL) | |
1525 | - { | |
1526 | - for (i = 0; i < num_nodes; i ++) | |
1527 | - { | |
1528 | - strcpy(devices[i].uri, nodes[i].uri); | |
1529 | - strcpy(devices[i].description, nodes[i].description); | |
1530 | - strcpy(devices[i].make_model, nodes[i].make_model); | |
1531 | - } | |
1532 | - } | |
1533 | - | |
1534 | - return (devices); | |
1535 | - } | |
1536 | - else | |
1537 | - return (NULL); | |
1538 | -} | |
1539 | - | |
1540 | - | |
1541 | -/* | |
1542 | - * 'ieee1394_open()' - Open a printer device. | |
1543 | - */ | |
1544 | - | |
1545 | -ieee1394_dev_t /* O - Printer device or NULL */ | |
1546 | -ieee1394_open(const char *uri) /* I - Device URI */ | |
1547 | -{ | |
1548 | - int i; /* Looping var */ | |
1549 | - linux1394_dev_t *ldev; /* Linux device */ | |
1550 | - | |
1551 | - | |
1552 | - /* | |
1553 | - * Return early if we can't see any printers... | |
1554 | - */ | |
1555 | - | |
1556 | - if (num_nodes == 0) | |
1557 | - ieee1394_list(NULL); | |
1558 | - | |
1559 | - if (num_nodes == 0) | |
1560 | - { | |
1561 | - strcpy(error_string, "No IEEE-1394 printers found!"); | |
1562 | - return (NULL); | |
1563 | - } | |
1564 | - | |
1565 | - /* | |
1566 | - * Look for the URI... | |
1567 | - */ | |
1568 | - | |
1569 | - for (i = 0; i < num_nodes; i ++) | |
1570 | - if (strcmp(nodes[i].uri, uri) == 0) | |
1571 | - break; | |
1572 | - | |
1573 | - if (i >= num_nodes) | |
1574 | - { | |
1575 | - snprintf(error_string, sizeof(error_string), "Device %s not found!", uri); | |
1576 | - return (NULL); | |
1577 | - } | |
1578 | - | |
1579 | - /* | |
1580 | - * Now create a new device structure... | |
1581 | - */ | |
1582 | - | |
1583 | - if ((ldev = calloc(sizeof(linux1394_dev_t), 1)) == NULL) | |
1584 | - { | |
1585 | - strcpy(error_string, "Out of memory!"); | |
1586 | - return (NULL); | |
1587 | - } | |
1588 | - | |
1589 | - ldev->handle = raw1394_new_handle(); | |
1590 | - ldev->node = nodes[i].node; | |
1591 | - ldev->addr = nodes[i].addr; | |
1592 | - | |
1593 | - raw1394_set_port(ldev->handle, nodes[i].port); | |
1594 | - | |
1595 | - error_string[0] = '\0'; | |
1596 | - | |
1597 | - return ((ieee1394_dev_t)ldev); | |
1598 | -} | |
1599 | - | |
1600 | - | |
1601 | -/* | |
1602 | - * 'ieee1394_close()' - Close a printer device. | |
1603 | - */ | |
1604 | - | |
1605 | -int /* O - 0 on success, -1 on failure */ | |
1606 | -ieee1394_close(ieee1394_dev_t dev) /* I - Printer device */ | |
1607 | -{ | |
1608 | - linux1394_dev_t *ldev; /* Linux device */ | |
1609 | - | |
1610 | - | |
1611 | - ldev = (linux1394_dev_t *)dev; | |
1612 | - | |
1613 | - raw1394_destroy_handle(ldev->handle); | |
1614 | - | |
1615 | - free(ldev); | |
1616 | - | |
1617 | - return (0); | |
1618 | -} | |
1619 | - | |
1620 | - | |
1621 | -/* | |
1622 | - * 'ieee1394_read()' - Read from a printer device. | |
1623 | - */ | |
1624 | - | |
1625 | -int /* O - Number of bytes read or -1 */ | |
1626 | -ieee1394_read(ieee1394_dev_t dev, /* I - Printer device */ | |
1627 | - char *buffer, /* I - Read buffer */ | |
1628 | - int len) /* I - Max bytes to read */ | |
1629 | -{ | |
1630 | - linux1394_dev_t *ldev; /* Linux device */ | |
1631 | - | |
1632 | - | |
1633 | - ldev = (linux1394_dev_t *)dev; | |
1634 | - | |
1635 | - | |
1636 | - return (0); | |
1637 | -} | |
1638 | - | |
1639 | - | |
1640 | -/* | |
1641 | - * 'ieee1394_write()' - Write data to a printer device. | |
1642 | - */ | |
1643 | - | |
1644 | -int /* O - Number of bytes written or -1 */ | |
1645 | -ieee1394_write(ieee1394_dev_t dev, /* I - Printer device */ | |
1646 | - char *buffer, /* I - Buffer to write */ | |
1647 | - int len) /* I - Number of bytes to write */ | |
1648 | -{ | |
1649 | - linux1394_dev_t *ldev; /* Linux device */ | |
1650 | - | |
1651 | - | |
1652 | - ldev = (linux1394_dev_t *)dev; | |
1653 | - | |
1654 | - | |
1655 | -/* if (raw1394_write(handle, 0xffc0 | j, 0, , | |
1656 | - (quadlet_t *)guid) < 0)*/ | |
1657 | - | |
1658 | - return (len); | |
1659 | -} | |
1660 | - | |
1661 | - | |
1662 | -/* | |
1663 | - * 'ieee1394_error()' - Return the last error. | |
1664 | - */ | |
1665 | - | |
1666 | -const char * /* O - Error string or NULL */ | |
1667 | -ieee1394_error(void) | |
1668 | -{ | |
1669 | - if (error_string[0]) | |
1670 | - return (error_string); | |
1671 | - else | |
1672 | - return (NULL); | |
1673 | -} | |
1674 | - | |
1675 | - | |
1676 | -/* | |
1677 | - * End of "$Id$". | |
1678 | - */ | |
1679 | diff -durN release-1.2.1/backend/ipp.c cups-1.2.x/backend/ipp.c | |
1680 | --- release-1.2.1/backend/ipp.c 2006-07-04 17:32:11.000000000 +0100 | |
1681 | +++ cups-1.2.x/backend/ipp.c 2006-06-26 12:42:40.000000000 +0100 | |
1682 | @@ -1,5 +1,5 @@ | |
1683 | /* | |
1684 | - * "$Id$" | |
1685 | + * "$Id$" | |
1686 | * | |
1687 | * IPP backend for the Common UNIX Printing System (CUPS). | |
1688 | * | |
1689 | @@ -211,7 +211,8 @@ | |
1690 | */ | |
1691 | ||
1692 | if ((content_type = getenv("FINAL_CONTENT_TYPE")) == NULL) | |
1693 | - content_type = "application/octet-stream"; | |
1694 | + if ((content_type = getenv("CONTENT_TYPE")) == NULL) | |
1695 | + content_type = "application/octet-stream"; | |
1696 | ||
1697 | /* | |
1698 | * Extract the hostname and printer name from the URI... | |
1699 | @@ -1619,5 +1620,5 @@ | |
1700 | ||
1701 | ||
1702 | /* | |
1703 | - * End of "$Id$". | |
1704 | + * End of "$Id$". | |
1705 | */ | |
1706 | diff -durN release-1.2.1/backend/Makefile cups-1.2.x/backend/Makefile | |
1707 | --- release-1.2.1/backend/Makefile 2006-07-04 17:32:11.000000000 +0100 | |
1708 | +++ cups-1.2.x/backend/Makefile 2006-06-26 12:42:40.000000000 +0100 | |
1709 | @@ -1,5 +1,5 @@ | |
1710 | # | |
1711 | -# "$Id$" | |
1712 | +# "$Id$" | |
1713 | # | |
1714 | # Backend makefile for the Common UNIX Printing System (CUPS). | |
1715 | # | |
1716 | @@ -28,7 +28,8 @@ | |
1717 | ||
1718 | RBACKENDS = ipp lpd | |
1719 | UBACKENDS = $(PAP) parallel scsi serial snmp socket usb | |
1720 | -TARGETS = betest test1284 $(RBACKENDS) $(UBACKENDS) | |
1721 | +TARGETS = betest test1284 libbackend.a $(RBACKENDS) $(UBACKENDS) | |
1722 | +LIBOBJS = ieee1284.o runloop.o | |
1723 | OBJS = betest.o ipp.o lpd.o pap.o parallel.o scsi.o \ | |
1724 | serial.o snmp.o socket.o test1284.o usb.o | |
1725 | ||
1726 | @@ -105,6 +106,17 @@ | |
1727 | ||
1728 | ||
1729 | # | |
1730 | +# libbackend.a | |
1731 | +# | |
1732 | + | |
1733 | +libbackend.a: $(LIBOBJS) | |
1734 | + echo Archiving $@... | |
1735 | + $(RM) $@ | |
1736 | + $(AR) $(ARFLAGS) $@ $(LIBOBJS) | |
1737 | + $(RANLIB) $@ | |
1738 | + | |
1739 | + | |
1740 | +# | |
1741 | # ieee1394 | |
1742 | # | |
1743 | ||
1744 | @@ -149,9 +161,9 @@ | |
1745 | # parallel | |
1746 | # | |
1747 | ||
1748 | -parallel: parallel.o ../cups/$(LIBCUPS) | |
1749 | +parallel: parallel.o ../cups/$(LIBCUPS) libbackend.a | |
1750 | echo Linking $@... | |
1751 | - $(CC) $(LDFLAGS) -o parallel parallel.o $(LIBS) | |
1752 | + $(CC) $(LDFLAGS) -o parallel parallel.o libbackend.a $(LIBS) | |
1753 | ||
1754 | ||
1755 | # | |
1756 | @@ -169,37 +181,37 @@ | |
1757 | # serial | |
1758 | # | |
1759 | ||
1760 | -serial: serial.o ../cups/$(LIBCUPS) | |
1761 | +serial: serial.o ../cups/$(LIBCUPS) libbackend.a | |
1762 | echo Linking $@... | |
1763 | - $(CC) $(LDFLAGS) -o serial serial.o $(BACKLIBS) $(LIBS) | |
1764 | + $(CC) $(LDFLAGS) -o serial serial.o libbackend.a $(BACKLIBS) $(LIBS) | |
1765 | ||
1766 | ||
1767 | # | |
1768 | # snmp | |
1769 | # | |
1770 | ||
1771 | -snmp: snmp.o ../cups/$(LIBCUPS) | |
1772 | +snmp: snmp.o ../cups/$(LIBCUPS) libbackend.a | |
1773 | echo Linking $@... | |
1774 | - $(CC) $(LDFLAGS) -o snmp snmp.o $(LIBS) | |
1775 | + $(CC) $(LDFLAGS) -o snmp snmp.o libbackend.a $(LIBS) | |
1776 | ||
1777 | ||
1778 | # | |
1779 | # socket | |
1780 | # | |
1781 | ||
1782 | -socket: socket.o ../cups/$(LIBCUPS) | |
1783 | +socket: socket.o ../cups/$(LIBCUPS) libbackend.a | |
1784 | echo Linking $@... | |
1785 | - $(CC) $(LDFLAGS) -o socket socket.o $(LIBS) | |
1786 | + $(CC) $(LDFLAGS) -o socket socket.o libbackend.a $(LIBS) | |
1787 | ||
1788 | ||
1789 | # | |
1790 | # usb | |
1791 | # | |
1792 | ||
1793 | -usb: usb.o ../cups/$(LIBCUPS) | |
1794 | +usb: usb.o ../cups/$(LIBCUPS) libbackend.a | |
1795 | echo Linking $@... | |
1796 | - $(CC) $(LDFLAGS) -o usb usb.o $(BACKLIBS) $(LIBS) | |
1797 | -usb.o: usb.c usb-darwin.c usb-unix.c ieee1284.c | |
1798 | + $(CC) $(LDFLAGS) -o usb usb.o libbackend.a $(BACKLIBS) $(LIBS) | |
1799 | +usb.o: usb.c usb-darwin.c usb-unix.c | |
1800 | ||
1801 | ||
1802 | # | |
1803 | @@ -210,5 +222,5 @@ | |
1804 | ||
1805 | ||
1806 | # | |
1807 | -# End of "$Id$". | |
1808 | +# End of "$Id$". | |
1809 | # | |
1810 | diff -durN release-1.2.1/backend/parallel.c cups-1.2.x/backend/parallel.c | |
1811 | --- release-1.2.1/backend/parallel.c 2006-07-04 17:32:11.000000000 +0100 | |
1812 | +++ cups-1.2.x/backend/parallel.c 2006-06-26 12:42:40.000000000 +0100 | |
1813 | @@ -1,5 +1,5 @@ | |
1814 | /* | |
1815 | - * "$Id$" | |
1816 | + * "$Id$" | |
1817 | * | |
1818 | * Parallel port backend for the Common UNIX Printing System (CUPS). | |
1819 | * | |
1820 | @@ -33,14 +33,7 @@ | |
1821 | * Include necessary headers. | |
1822 | */ | |
1823 | ||
1824 | -#include <cups/backend.h> | |
1825 | -#include <cups/cups.h> | |
1826 | -#include <stdio.h> | |
1827 | -#include <stdlib.h> | |
1828 | -#include <errno.h> | |
1829 | -#include <cups/string.h> | |
1830 | -#include <signal.h> | |
1831 | -#include "ieee1284.c" | |
1832 | +#include "backend-private.h" | |
1833 | ||
1834 | #ifdef __hpux | |
1835 | # include <sys/time.h> | |
1836 | @@ -94,25 +87,18 @@ | |
1837 | resource[1024], /* Resource info (device and options) */ | |
1838 | *options; /* Pointer to options */ | |
1839 | int port; /* Port number (not used) */ | |
1840 | - int fp; /* Print file */ | |
1841 | + int print_fd, /* Print file */ | |
1842 | + device_fd; /* Parallel device */ | |
1843 | int copies; /* Number of copies to print */ | |
1844 | - int fd; /* Parallel device */ | |
1845 | - int rbytes; /* Number of bytes read */ | |
1846 | - int wbytes; /* Number of bytes written */ | |
1847 | - size_t nbytes, /* Number of bytes read */ | |
1848 | - tbytes; /* Total number of bytes written */ | |
1849 | - char buffer[8192], /* Output buffer */ | |
1850 | - *bufptr; /* Pointer into buffer */ | |
1851 | + size_t tbytes; /* Total number of bytes written */ | |
1852 | struct termios opts; /* Parallel port options */ | |
1853 | - fd_set input, /* Input set for select() */ | |
1854 | - output; /* Output set for select() */ | |
1855 | +#if defined(__linux) && defined(LP_POUTPA) | |
1856 | + unsigned int status; /* Port status (off-line, out-of-paper, etc.) */ | |
1857 | int paperout; /* Paper out? */ | |
1858 | +#endif /* __linux && LP_POUTPA */ | |
1859 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) | |
1860 | struct sigaction action; /* Actions for POSIX signals */ | |
1861 | #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ | |
1862 | -#ifdef __linux | |
1863 | - unsigned int status; /* Port status (off-line, out-of-paper, etc.) */ | |
1864 | -#endif /* __linux */ | |
1865 | ||
1866 | ||
1867 | /* | |
1868 | @@ -157,8 +143,8 @@ | |
1869 | ||
1870 | if (argc == 6) | |
1871 | { | |
1872 | - fp = 0; | |
1873 | - copies = 1; | |
1874 | + print_fd = 0; | |
1875 | + copies = 1; | |
1876 | } | |
1877 | else | |
1878 | { | |
1879 | @@ -166,7 +152,7 @@ | |
1880 | * Try to open the print file... | |
1881 | */ | |
1882 | ||
1883 | - if ((fp = open(argv[6], O_RDONLY)) < 0) | |
1884 | + if ((print_fd = open(argv[6], O_RDONLY)) < 0) | |
1885 | { | |
1886 | perror("ERROR: unable to open print file"); | |
1887 | return (CUPS_BACKEND_FAILED); | |
1888 | @@ -206,7 +192,7 @@ | |
1889 | ||
1890 | do | |
1891 | { | |
1892 | - if ((fd = open(resource, O_WRONLY | O_EXCL)) == -1) | |
1893 | + if ((device_fd = open(resource, O_WRONLY | O_EXCL)) == -1) | |
1894 | { | |
1895 | if (getenv("CLASS") != NULL) | |
1896 | { | |
1897 | @@ -217,8 +203,8 @@ | |
1898 | * available printer in the class. | |
1899 | */ | |
1900 | ||
1901 | - fputs("INFO: Unable to open parallel port, queuing on next printer in class...\n", | |
1902 | - stderr); | |
1903 | + fputs("INFO: Unable to open parallel port, queuing on next printer " | |
1904 | + "in class...\n", stderr); | |
1905 | ||
1906 | /* | |
1907 | * Sleep 5 seconds to keep the job from requeuing too rapidly... | |
1908 | @@ -231,23 +217,26 @@ | |
1909 | ||
1910 | if (errno == EBUSY) | |
1911 | { | |
1912 | - fputs("INFO: Parallel port busy; will retry in 30 seconds...\n", stderr); | |
1913 | + fputs("INFO: Parallel port busy; will retry in 30 seconds...\n", | |
1914 | + stderr); | |
1915 | sleep(30); | |
1916 | } | |
1917 | else if (errno == ENXIO || errno == EIO || errno == ENOENT) | |
1918 | { | |
1919 | - fputs("INFO: Printer not connected; will retry in 30 seconds...\n", stderr); | |
1920 | + fputs("INFO: Printer not connected; will retry in 30 seconds...\n", | |
1921 | + stderr); | |
1922 | sleep(30); | |
1923 | } | |
1924 | else | |
1925 | { | |
1926 | - fprintf(stderr, "ERROR: Unable to open parallel port device file \"%s\": %s\n", | |
1927 | + fprintf(stderr, | |
1928 | + "ERROR: Unable to open parallel port device file \"%s\": %s\n", | |
1929 | resource, strerror(errno)); | |
1930 | return (CUPS_BACKEND_FAILED); | |
1931 | } | |
1932 | } | |
1933 | } | |
1934 | - while (fd < 0); | |
1935 | + while (device_fd < 0); | |
1936 | ||
1937 | fputs("STATE: -connecting-to-device\n", stderr); | |
1938 | ||
1939 | @@ -255,25 +244,21 @@ | |
1940 | * Set any options provided... | |
1941 | */ | |
1942 | ||
1943 | - tcgetattr(fd, &opts); | |
1944 | + tcgetattr(device_fd, &opts); | |
1945 | ||
1946 | opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */ | |
1947 | ||
1948 | /**** No options supported yet ****/ | |
1949 | ||
1950 | - tcsetattr(fd, TCSANOW, &opts); | |
1951 | - | |
1952 | - /* | |
1953 | - * Check printer status... | |
1954 | - */ | |
1955 | - | |
1956 | - paperout = 0; | |
1957 | + tcsetattr(device_fd, TCSANOW, &opts); | |
1958 | ||
1959 | #if defined(__linux) && defined(LP_POUTPA) | |
1960 | /* | |
1961 | * Show the printer status before we send the file... | |
1962 | */ | |
1963 | ||
1964 | + paperout = 0; | |
1965 | + | |
1966 | while (!ioctl(fd, LPGETSTATUS, &status)) | |
1967 | { | |
1968 | fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status); | |
1969 | @@ -298,146 +283,38 @@ | |
1970 | #endif /* __linux && LP_POUTPA */ | |
1971 | ||
1972 | /* | |
1973 | - * Now that we are "connected" to the port, ignore SIGTERM so that we | |
1974 | - * can finish out any page data the driver sends (e.g. to eject the | |
1975 | - * current page... Only ignore SIGTERM if we are printing data from | |
1976 | - * stdin (otherwise you can't cancel raw jobs...) | |
1977 | - */ | |
1978 | - | |
1979 | - if (argc < 7) | |
1980 | - { | |
1981 | -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ | |
1982 | - sigset(SIGTERM, SIG_IGN); | |
1983 | -#elif defined(HAVE_SIGACTION) | |
1984 | - memset(&action, 0, sizeof(action)); | |
1985 | - | |
1986 | - sigemptyset(&action.sa_mask); | |
1987 | - action.sa_handler = SIG_IGN; | |
1988 | - sigaction(SIGTERM, &action, NULL); | |
1989 | -#else | |
1990 | - signal(SIGTERM, SIG_IGN); | |
1991 | -#endif /* HAVE_SIGSET */ | |
1992 | - } | |
1993 | - | |
1994 | - /* | |
1995 | * Finally, send the print file... | |
1996 | */ | |
1997 | ||
1998 | - wbytes = 0; | |
1999 | + tbytes = 0; | |
2000 | ||
2001 | - while (copies > 0) | |
2002 | + while (copies > 0 && tbytes >= 0) | |
2003 | { | |
2004 | copies --; | |
2005 | ||
2006 | - if (fp != 0) | |
2007 | + if (print_fd != 0) | |
2008 | { | |
2009 | fputs("PAGE: 1 1\n", stderr); | |
2010 | - lseek(fp, 0, SEEK_SET); | |
2011 | + lseek(print_fd, 0, SEEK_SET); | |
2012 | } | |
2013 | ||
2014 | - tbytes = 0; | |
2015 | - while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0) | |
2016 | - { | |
2017 | - /* | |
2018 | - * Write the print data to the printer... | |
2019 | - */ | |
2020 | - | |
2021 | - tbytes += nbytes; | |
2022 | - bufptr = buffer; | |
2023 | - | |
2024 | - while (nbytes > 0) | |
2025 | - { | |
2026 | - /* | |
2027 | - * See if we are ready to read or write... | |
2028 | - */ | |
2029 | - | |
2030 | - do | |
2031 | - { | |
2032 | - FD_ZERO(&input); | |
2033 | - FD_SET(fd, &input); | |
2034 | - FD_ZERO(&output); | |
2035 | - FD_SET(fd, &output); | |
2036 | - } | |
2037 | - while (select(fd + 1, &input, &output, NULL, NULL) < 0); | |
2038 | - | |
2039 | - if (FD_ISSET(fd, &input)) | |
2040 | - { | |
2041 | - /* | |
2042 | - * Read backchannel data... | |
2043 | - */ | |
2044 | - | |
2045 | - if ((rbytes = read(fd, resource, sizeof(resource))) > 0) | |
2046 | - { | |
2047 | - fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n", | |
2048 | - rbytes); | |
2049 | - cupsBackChannelWrite(resource, rbytes, 1.0); | |
2050 | - } | |
2051 | - } | |
2052 | - | |
2053 | - if (FD_ISSET(fd, &output)) | |
2054 | - { | |
2055 | - /* | |
2056 | - * Write print data... | |
2057 | - */ | |
2058 | - | |
2059 | - if ((wbytes = write(fd, bufptr, nbytes)) < 0) | |
2060 | - if (errno == ENOTTY) | |
2061 | - wbytes = write(fd, bufptr, nbytes); | |
2062 | - | |
2063 | - if (wbytes < 0) | |
2064 | - { | |
2065 | - /* | |
2066 | - * Check for retryable errors... | |
2067 | - */ | |
2068 | - | |
2069 | - if (errno == ENOSPC) | |
2070 | - { | |
2071 | - paperout = 1; | |
2072 | - fputs("ERROR: Out of paper!\n", stderr); | |
2073 | - fputs("STATUS: +media-tray-empty-error\n", stderr); | |
2074 | - } | |
2075 | - else if (errno != EAGAIN && errno != EINTR) | |
2076 | - { | |
2077 | - perror("ERROR: Unable to send print file to printer"); | |
2078 | - break; | |
2079 | - } | |
2080 | - } | |
2081 | - else | |
2082 | - { | |
2083 | - /* | |
2084 | - * Update count and pointer... | |
2085 | - */ | |
2086 | - | |
2087 | - if (paperout) | |
2088 | - { | |
2089 | - fputs("STATUS: -media-tray-empty-error\n", stderr); | |
2090 | - paperout = 0; | |
2091 | - } | |
2092 | - | |
2093 | - nbytes -= wbytes; | |
2094 | - bufptr += wbytes; | |
2095 | - } | |
2096 | - } | |
2097 | - } | |
2098 | - | |
2099 | - if (wbytes < 0) | |
2100 | - break; | |
2101 | + tbytes = backendRunLoop(print_fd, device_fd, 1); | |
2102 | ||
2103 | - if (argc > 6) | |
2104 | - fprintf(stderr, "INFO: Sending print file, %lu bytes...\n", | |
2105 | - (unsigned long)tbytes); | |
2106 | - } | |
2107 | + if (print_fd != 0 && tbytes >= 0) | |
2108 | + fprintf(stderr, "INFO: Sent print file, " CUPS_LLFMT " bytes...\n", | |
2109 | + CUPS_LLCAST tbytes); | |
2110 | } | |
2111 | ||
2112 | /* | |
2113 | * Close the socket connection and input file and return... | |
2114 | */ | |
2115 | ||
2116 | - close(fd); | |
2117 | - if (fp != 0) | |
2118 | - close(fp); | |
2119 | + close(device_fd); | |
2120 | ||
2121 | - return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
2122 | + if (print_fd != 0) | |
2123 | + close(print_fd); | |
2124 | + | |
2125 | + return (tbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
2126 | } | |
2127 | ||
2128 | ||
2129 | @@ -485,9 +362,9 @@ | |
2130 | * Now grab the IEEE 1284 device ID string... | |
2131 | */ | |
2132 | ||
2133 | - if (!get_device_id(fd, device_id, sizeof(device_id), | |
2134 | - make_model, sizeof(make_model), | |
2135 | - NULL, NULL, 0)) | |
2136 | + if (!backendGetDeviceID(fd, device_id, sizeof(device_id), | |
2137 | + make_model, sizeof(make_model), | |
2138 | + NULL, NULL, 0)) | |
2139 | printf("direct parallel:%s \"%s\" \"%s LPT #%d\" \"%s\"\n", device, | |
2140 | make_model, make_model, i + 1, device_id); | |
2141 | else | |
2142 | @@ -735,5 +612,5 @@ | |
2143 | ||
2144 | ||
2145 | /* | |
2146 | - * End of "$Id$". | |
2147 | + * End of "$Id$". | |
2148 | */ | |
2149 | diff -durN release-1.2.1/backend/runloop.c cups-1.2.x/backend/runloop.c | |
2150 | --- release-1.2.1/backend/runloop.c 1970-01-01 01:00:00.000000000 +0100 | |
2151 | +++ cups-1.2.x/backend/runloop.c 2006-06-26 12:42:40.000000000 +0100 | |
2152 | @@ -0,0 +1,218 @@ | |
2153 | +/* | |
2154 | + * "$Id$" | |
2155 | + * | |
2156 | + * Common run loop API for the Common UNIX Printing System (CUPS). | |
2157 | + * | |
2158 | + * Copyright 2006 by Easy Software Products, all rights reserved. | |
2159 | + * | |
2160 | + * These coded instructions, statements, and computer programs are the | |
2161 | + * property of Easy Software Products and are protected by Federal | |
2162 | + * copyright law. Distribution and use rights are outlined in the file | |
2163 | + * "LICENSE" which should have been included with this file. If this | |
2164 | + * file is missing or damaged please contact Easy Software Products | |
2165 | + * at: | |
2166 | + * | |
2167 | + * Attn: CUPS Licensing Information | |
2168 | + * Easy Software Products | |
2169 | + * 44141 Airport View Drive, Suite 204 | |
2170 | + * Hollywood, Maryland 20636 USA | |
2171 | + * | |
2172 | + * Voice: (301) 373-9600 | |
2173 | + * EMail: cups-info@cups.org | |
2174 | + * WWW: http://www.cups.org | |
2175 | + * | |
2176 | + * This file is subject to the Apple OS-Developed Software exception. | |
2177 | + * | |
2178 | + * Contents: | |
2179 | + * | |
2180 | + * backendRunLoop() - Read and write print and back-channel data. | |
2181 | + */ | |
2182 | + | |
2183 | +/* | |
2184 | + * Include necessary headers. | |
2185 | + */ | |
2186 | + | |
2187 | +#include "backend-private.h" | |
2188 | +#include <sys/select.h> | |
2189 | + | |
2190 | + | |
2191 | +/* | |
2192 | + * 'backendRunLoop()' - Read and write print and back-channel data. | |
2193 | + */ | |
2194 | + | |
2195 | +ssize_t /* O - Total bytes on success, -1 on error */ | |
2196 | +backendRunLoop(int print_fd, /* I - Print file descriptor */ | |
2197 | + int device_fd, /* I - Device file descriptor */ | |
2198 | + int use_bc) /* I - Use back-channel? */ | |
2199 | +{ | |
2200 | + int nfds; /* Maximum file descriptor value + 1 */ | |
2201 | + fd_set input, /* Input set for reading */ | |
2202 | + output; /* Output set for writing */ | |
2203 | + ssize_t print_bytes, /* Print bytes read */ | |
2204 | + bc_bytes, /* Backchannel bytes read */ | |
2205 | + total_bytes, /* Total bytes written */ | |
2206 | + bytes; /* Bytes written */ | |
2207 | + int paperout; /* "Paper out" status */ | |
2208 | + char print_buffer[8192], /* Print data buffer */ | |
2209 | + *print_ptr, /* Pointer into print data buffer */ | |
2210 | + bc_buffer[1024]; /* Back-channel data buffer */ | |
2211 | +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) | |
2212 | + struct sigaction action; /* Actions for POSIX signals */ | |
2213 | +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ | |
2214 | + | |
2215 | + | |
2216 | + /* | |
2217 | + * If we are printing data from a print driver on stdin, ignore SIGTERM | |
2218 | + * so that the driver can finish out any page data, e.g. to eject the | |
2219 | + * current page. We only do this for stdin printing as otherwise there | |
2220 | + * is no way to cancel a raw print job... | |
2221 | + */ | |
2222 | + | |
2223 | + if (!print_fd) | |
2224 | + { | |
2225 | +#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ | |
2226 | + sigset(SIGTERM, SIG_IGN); | |
2227 | +#elif defined(HAVE_SIGACTION) | |
2228 | + memset(&action, 0, sizeof(action)); | |
2229 | + | |
2230 | + sigemptyset(&action.sa_mask); | |
2231 | + action.sa_handler = SIG_IGN; | |
2232 | + sigaction(SIGTERM, &action, NULL); | |
2233 | +#else | |
2234 | + signal(SIGTERM, SIG_IGN); | |
2235 | +#endif /* HAVE_SIGSET */ | |
2236 | + } | |
2237 | + | |
2238 | + /* | |
2239 | + * Figure out the maximum file descriptor value to use with select()... | |
2240 | + */ | |
2241 | + | |
2242 | + nfds = (print_fd > device_fd ? print_fd : device_fd) + 1; | |
2243 | + | |
2244 | + /* | |
2245 | + * Now loop until we are out of data from print_fd... | |
2246 | + */ | |
2247 | + | |
2248 | + for (print_bytes = 0, print_ptr = print_buffer, paperout = 0, total_bytes = 0;;) | |
2249 | + { | |
2250 | + /* | |
2251 | + * Use select() to determine whether we have data to copy around... | |
2252 | + */ | |
2253 | + | |
2254 | + FD_ZERO(&input); | |
2255 | + if (!print_bytes) | |
2256 | + FD_SET(print_fd, &input); | |
2257 | + if (use_bc) | |
2258 | + FD_SET(device_fd, &input); | |
2259 | + | |
2260 | + FD_ZERO(&output); | |
2261 | + if (print_bytes) | |
2262 | + FD_SET(device_fd, &output); | |
2263 | + | |
2264 | + if (select(nfds, &input, &output, NULL, NULL) < 0) | |
2265 | + continue; /* Ignore errors here */ | |
2266 | + | |
2267 | + /* | |
2268 | + * Check if we have back-channel data ready... | |
2269 | + */ | |
2270 | + | |
2271 | + if (FD_ISSET(device_fd, &input)) | |
2272 | + { | |
2273 | + if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0) | |
2274 | + { | |
2275 | + fprintf(stderr, | |
2276 | + "DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n", | |
2277 | + CUPS_LLCAST bc_bytes); | |
2278 | + cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0); | |
2279 | + } | |
2280 | + } | |
2281 | + | |
2282 | + /* | |
2283 | + * Check if we have print data ready... | |
2284 | + */ | |
2285 | + | |
2286 | + if (FD_ISSET(print_fd, &input)) | |
2287 | + { | |
2288 | + if ((print_bytes = read(print_fd, print_buffer, | |
2289 | + sizeof(print_buffer))) < 0) | |
2290 | + { | |
2291 | + /* | |
2292 | + * Read error - bail if we don't see EAGAIN or EINTR... | |
2293 | + */ | |
2294 | + | |
2295 | + if (errno != EAGAIN || errno != EINTR) | |
2296 | + { | |
2297 | + perror("ERROR: Unable to read print data"); | |
2298 | + return (-1); | |
2299 | + } | |
2300 | + | |
2301 | + print_bytes = 0; | |
2302 | + } | |
2303 | + else if (print_bytes == 0) | |
2304 | + { | |
2305 | + /* | |
2306 | + * End of file, break out of the loop... | |
2307 | + */ | |
2308 | + | |
2309 | + break; | |
2310 | + } | |
2311 | + | |
2312 | + print_ptr = print_buffer; | |
2313 | + } | |
2314 | + | |
2315 | + /* | |
2316 | + * Check if the device is ready to receive data and we have data to | |
2317 | + * send... | |
2318 | + */ | |
2319 | + | |
2320 | + if (print_bytes && FD_ISSET(device_fd, &output)) | |
2321 | + { | |
2322 | + if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0) | |
2323 | + { | |
2324 | + /* | |
2325 | + * Write error - bail if we don't see an error we can retry... | |
2326 | + */ | |
2327 | + | |
2328 | + if (errno == ENOSPC) | |
2329 | + { | |
2330 | + if (!paperout) | |
2331 | + { | |
2332 | + fputs("ERROR: Out of paper!\n", stderr); | |
2333 | + fputs("STATUS: +media-tray-empty-error\n", stderr); | |
2334 | + paperout = 1; | |
2335 | + } | |
2336 | + } | |
2337 | + else if (errno != EAGAIN && errno != EINTR && errno != ENOTTY) | |
2338 | + { | |
2339 | + perror("ERROR: Unable to write print data"); | |
2340 | + return (-1); | |
2341 | + } | |
2342 | + } | |
2343 | + else | |
2344 | + { | |
2345 | + if (paperout) | |
2346 | + { | |
2347 | + fputs("STATUS: -media-tray-empty-error\n", stderr); | |
2348 | + paperout = 0; | |
2349 | + } | |
2350 | + | |
2351 | + fprintf(stderr, "DEBUG: Wrote %d bytes...\n", (int)bytes); | |
2352 | + | |
2353 | + print_bytes -= bytes; | |
2354 | + print_ptr += bytes; | |
2355 | + total_bytes += bytes; | |
2356 | + } | |
2357 | + } | |
2358 | + } | |
2359 | + | |
2360 | + /* | |
2361 | + * Return with success... | |
2362 | + */ | |
2363 | + | |
2364 | + return (total_bytes); | |
2365 | +} | |
2366 | + | |
2367 | + | |
2368 | +/* | |
2369 | + * End of "$Id$". | |
2370 | + */ | |
2371 | diff -durN release-1.2.1/backend/serial.c cups-1.2.x/backend/serial.c | |
2372 | --- release-1.2.1/backend/serial.c 2006-07-04 17:32:11.000000000 +0100 | |
2373 | +++ cups-1.2.x/backend/serial.c 2006-06-26 12:42:40.000000000 +0100 | |
2374 | @@ -1,5 +1,5 @@ | |
2375 | /* | |
2376 | - * "$Id$" | |
2377 | + * "$Id$" | |
2378 | * | |
2379 | * Serial port backend for the Common UNIX Printing System (CUPS). | |
2380 | * | |
2381 | @@ -33,13 +33,7 @@ | |
2382 | * Include necessary headers. | |
2383 | */ | |
2384 | ||
2385 | -#include <cups/backend.h> | |
2386 | -#include <cups/cups.h> | |
2387 | -#include <stdio.h> | |
2388 | -#include <stdlib.h> | |
2389 | -#include <errno.h> | |
2390 | -#include <cups/string.h> | |
2391 | -#include <signal.h> | |
2392 | +#include "backend-private.h" | |
2393 | ||
2394 | #ifdef __hpux | |
2395 | # include <sys/modem.h> | |
2396 | @@ -121,21 +115,23 @@ | |
2397 | value[255], /* Value of option */ | |
2398 | *ptr; /* Pointer into name or value */ | |
2399 | int port; /* Port number (not used) */ | |
2400 | - int fp; /* Print file */ | |
2401 | int copies; /* Number of copies to print */ | |
2402 | - int fd; /* Parallel device */ | |
2403 | - int rbytes; /* Number of bytes read */ | |
2404 | - int wbytes; /* Number of bytes written */ | |
2405 | - size_t nbytes, /* Number of bytes read */ | |
2406 | - tbytes; /* Total number of bytes written */ | |
2407 | + int print_fd, /* Print file */ | |
2408 | + device_fd; /* Serial device */ | |
2409 | + int nfds; /* Maximum file descriptor value + 1 */ | |
2410 | + fd_set input, /* Input set for reading */ | |
2411 | + output; /* Output set for writing */ | |
2412 | + ssize_t print_bytes, /* Print bytes read */ | |
2413 | + bc_bytes, /* Backchannel bytes read */ | |
2414 | + total_bytes, /* Total bytes written */ | |
2415 | + bytes; /* Bytes written */ | |
2416 | int dtrdsr; /* Do dtr/dsr flow control? */ | |
2417 | - int bufsize; /* Size of output buffer for writes */ | |
2418 | - char buffer[8192], /* Output buffer */ | |
2419 | - *bufptr; /* Pointer into buffer */ | |
2420 | + int print_size; /* Size of output buffer for writes */ | |
2421 | + char print_buffer[8192], /* Print data buffer */ | |
2422 | + *print_ptr, /* Pointer into print data buffer */ | |
2423 | + bc_buffer[1024]; /* Back-channel data buffer */ | |
2424 | struct termios opts; /* Serial port options */ | |
2425 | struct termios origopts; /* Original port options */ | |
2426 | - fd_set input, /* Input set for select() */ | |
2427 | - output; /* Output set for select() */ | |
2428 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) | |
2429 | struct sigaction action; /* Actions for POSIX signals */ | |
2430 | #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ | |
2431 | @@ -183,8 +179,8 @@ | |
2432 | ||
2433 | if (argc == 6) | |
2434 | { | |
2435 | - fp = 0; | |
2436 | - copies = 1; | |
2437 | + print_fd = 0; | |
2438 | + copies = 1; | |
2439 | } | |
2440 | else | |
2441 | { | |
2442 | @@ -192,7 +188,7 @@ | |
2443 | * Try to open the print file... | |
2444 | */ | |
2445 | ||
2446 | - if ((fp = open(argv[6], O_RDONLY)) < 0) | |
2447 | + if ((print_fd = open(argv[6], O_RDONLY)) < 0) | |
2448 | { | |
2449 | perror("ERROR: unable to open print file"); | |
2450 | return (CUPS_BACKEND_FAILED); | |
2451 | @@ -232,7 +228,8 @@ | |
2452 | ||
2453 | do | |
2454 | { | |
2455 | - if ((fd = open(resource, O_WRONLY | O_NOCTTY | O_EXCL | O_NDELAY)) == -1) | |
2456 | + if ((device_fd = open(resource, O_RDWR | O_NOCTTY | O_EXCL | | |
2457 | + O_NDELAY)) == -1) | |
2458 | { | |
2459 | if (getenv("CLASS") != NULL) | |
2460 | { | |
2461 | @@ -268,7 +265,7 @@ | |
2462 | } | |
2463 | } | |
2464 | } | |
2465 | - while (fd < 0); | |
2466 | + while (device_fd < 0); | |
2467 | ||
2468 | fputs("STATE: -connecting-to-device\n", stderr); | |
2469 | ||
2470 | @@ -276,16 +273,18 @@ | |
2471 | * Set any options provided... | |
2472 | */ | |
2473 | ||
2474 | - tcgetattr(fd, &origopts); | |
2475 | - tcgetattr(fd, &opts); | |
2476 | + tcgetattr(device_fd, &origopts); | |
2477 | + tcgetattr(device_fd, &opts); | |
2478 | ||
2479 | - opts.c_lflag &= ~(ICANON | ECHO | ISIG); /* Raw mode */ | |
2480 | - opts.c_oflag &= ~OPOST; /* Don't post-process */ | |
2481 | + opts.c_lflag &= ~(ICANON | ECHO | ISIG); | |
2482 | + /* Raw mode */ | |
2483 | + opts.c_oflag &= ~OPOST; /* Don't post-process */ | |
2484 | ||
2485 | - bufsize = 96; /* 9600 baud / 10 bits/char / 10Hz */ | |
2486 | - dtrdsr = 0; /* No dtr/dsr flow control */ | |
2487 | + print_size = 96; /* 9600 baud / 10 bits/char / 10Hz */ | |
2488 | + dtrdsr = 0; /* No dtr/dsr flow control */ | |
2489 | ||
2490 | - if (options != NULL) | |
2491 | + if (options) | |
2492 | + { | |
2493 | while (*options) | |
2494 | { | |
2495 | /* | |
2496 | @@ -326,7 +325,7 @@ | |
2497 | * Set the baud rate... | |
2498 | */ | |
2499 | ||
2500 | - bufsize = atoi(value) / 100; | |
2501 | + print_size = atoi(value) / 100; | |
2502 | ||
2503 | #if B19200 == 19200 | |
2504 | cfsetispeed(&opts, atoi(value)); | |
2505 | @@ -488,9 +487,10 @@ | |
2506 | } | |
2507 | } | |
2508 | } | |
2509 | + } | |
2510 | ||
2511 | - tcsetattr(fd, TCSANOW, &opts); | |
2512 | - fcntl(fd, F_SETFL, 0); | |
2513 | + tcsetattr(device_fd, TCSANOW, &opts); | |
2514 | + fcntl(device_fd, F_SETFL, 0); | |
2515 | ||
2516 | /* | |
2517 | * Now that we are "connected" to the port, ignore SIGTERM so that we | |
2518 | @@ -499,7 +499,7 @@ | |
2519 | * stdin (otherwise you can't cancel raw jobs...) | |
2520 | */ | |
2521 | ||
2522 | - if (argc < 7) | |
2523 | + if (print_fd != 0) | |
2524 | { | |
2525 | #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ | |
2526 | sigset(SIGTERM, SIG_IGN); | |
2527 | @@ -515,133 +515,181 @@ | |
2528 | } | |
2529 | ||
2530 | /* | |
2531 | - * Finally, send the print file... | |
2532 | + * Figure out the maximum file descriptor value to use with select()... | |
2533 | */ | |
2534 | ||
2535 | - if (bufsize > sizeof(buffer)) | |
2536 | - bufsize = sizeof(buffer); | |
2537 | + nfds = (print_fd > device_fd ? print_fd : device_fd) + 1; | |
2538 | ||
2539 | - wbytes = 0; | |
2540 | + /* | |
2541 | + * Finally, send the print file. Ordinarily we would just use the | |
2542 | + * backendRunLoop() function, however since we need to use smaller | |
2543 | + * writes and may need to do DSR/DTR flow control, we duplicate much | |
2544 | + * of the code here instead... | |
2545 | + */ | |
2546 | + | |
2547 | + if (print_size > sizeof(print_buffer)) | |
2548 | + print_size = sizeof(print_buffer); | |
2549 | + | |
2550 | + total_bytes = 0; | |
2551 | ||
2552 | while (copies > 0) | |
2553 | { | |
2554 | copies --; | |
2555 | ||
2556 | - if (fp != 0) | |
2557 | + if (print_fd != 0) | |
2558 | { | |
2559 | fputs("PAGE: 1 1\n", stderr); | |
2560 | - lseek(fp, 0, SEEK_SET); | |
2561 | + lseek(print_fd, 0, SEEK_SET); | |
2562 | } | |
2563 | ||
2564 | - if (dtrdsr) | |
2565 | + /* | |
2566 | + * Now loop until we are out of data from print_fd... | |
2567 | + */ | |
2568 | + | |
2569 | + for (print_bytes = 0, print_ptr = print_buffer;;) | |
2570 | { | |
2571 | /* | |
2572 | - * Check the port and sleep until DSR is set... | |
2573 | + * Use select() to determine whether we have data to copy around... | |
2574 | */ | |
2575 | ||
2576 | - int status; | |
2577 | + FD_ZERO(&input); | |
2578 | + if (!print_bytes) | |
2579 | + FD_SET(print_fd, &input); | |
2580 | + FD_SET(device_fd, &input); | |
2581 | ||
2582 | + FD_ZERO(&output); | |
2583 | + if (print_bytes) | |
2584 | + FD_SET(device_fd, &output); | |
2585 | ||
2586 | - if (!ioctl(fd, TIOCMGET, &status)) | |
2587 | - if (!(status & TIOCM_DSR)) | |
2588 | + if (select(nfds, &input, &output, NULL, NULL) < 0) | |
2589 | + continue; /* Ignore errors here */ | |
2590 | + | |
2591 | + /* | |
2592 | + * Check if we have back-channel data ready... | |
2593 | + */ | |
2594 | + | |
2595 | + if (FD_ISSET(device_fd, &input)) | |
2596 | + { | |
2597 | + if ((bc_bytes = read(device_fd, bc_buffer, sizeof(bc_buffer))) > 0) | |
2598 | + { | |
2599 | + fprintf(stderr, | |
2600 | + "DEBUG: Received " CUPS_LLFMT " bytes of back-channel data!\n", | |
2601 | + CUPS_LLCAST bc_bytes); | |
2602 | + cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0); | |
2603 | + } | |
2604 | + } | |
2605 | + | |
2606 | + /* | |
2607 | + * Check if we have print data ready... | |
2608 | + */ | |
2609 | + | |
2610 | + if (FD_ISSET(print_fd, &input)) | |
2611 | + { | |
2612 | + if ((print_bytes = read(print_fd, print_buffer, print_size)) < 0) | |
2613 | { | |
2614 | /* | |
2615 | - * Wait for DSR to go high... | |
2616 | + * Read error - bail if we don't see EAGAIN or EINTR... | |
2617 | */ | |
2618 | ||
2619 | - fputs("DEBUG: DSR is low; waiting for device...\n", stderr); | |
2620 | - | |
2621 | - do | |
2622 | + if (errno != EAGAIN || errno != EINTR) | |
2623 | { | |
2624 | - sleep(1); | |
2625 | - if (ioctl(fd, TIOCMGET, &status)) | |
2626 | - break; | |
2627 | - } | |
2628 | - while (!(status & TIOCM_DSR)); | |
2629 | - | |
2630 | - fputs("DEBUG: DSR is high; writing to device...\n", stderr); | |
2631 | - } | |
2632 | - } | |
2633 | + perror("ERROR: Unable to read print data"); | |
2634 | ||
2635 | - tbytes = 0; | |
2636 | - while ((nbytes = read(fp, buffer, bufsize)) > 0) | |
2637 | - { | |
2638 | - /* | |
2639 | - * Write the print data to the printer... | |
2640 | - */ | |
2641 | + tcsetattr(device_fd, TCSADRAIN, &origopts); | |
2642 | ||
2643 | - tbytes += nbytes; | |
2644 | - bufptr = buffer; | |
2645 | + close(device_fd); | |
2646 | ||
2647 | - while (nbytes > 0) | |
2648 | - { | |
2649 | - /* | |
2650 | - * See if we are ready to read or write... | |
2651 | - */ | |
2652 | + if (print_fd != 0) | |
2653 | + close(print_fd); | |
2654 | ||
2655 | - do | |
2656 | - { | |
2657 | - FD_ZERO(&input); | |
2658 | - FD_SET(fd, &input); | |
2659 | - FD_ZERO(&output); | |
2660 | - FD_SET(fd, &output); | |
2661 | - } | |
2662 | - while (select(fd + 1, &input, &output, NULL, NULL) < 0); | |
2663 | + return (CUPS_BACKEND_FAILED); | |
2664 | + } | |
2665 | ||
2666 | - if (FD_ISSET(fd, &input)) | |
2667 | + print_bytes = 0; | |
2668 | + } | |
2669 | + else if (print_bytes == 0) | |
2670 | { | |
2671 | /* | |
2672 | - * Read backchannel data... | |
2673 | + * End of file, break out of the loop... | |
2674 | */ | |
2675 | ||
2676 | - if ((rbytes = read(fd, resource, sizeof(resource))) > 0) | |
2677 | - { | |
2678 | - fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n", | |
2679 | - rbytes); | |
2680 | - cupsBackChannelWrite(resource, rbytes, 1.0); | |
2681 | - } | |
2682 | + break; | |
2683 | } | |
2684 | ||
2685 | - if (FD_ISSET(fd, &output)) | |
2686 | + print_ptr = print_buffer; | |
2687 | + } | |
2688 | + | |
2689 | + /* | |
2690 | + * Check if the device is ready to receive data and we have data to | |
2691 | + * send... | |
2692 | + */ | |
2693 | + | |
2694 | + if (print_bytes && FD_ISSET(device_fd, &output)) | |
2695 | + { | |
2696 | + if (dtrdsr) | |
2697 | { | |
2698 | /* | |
2699 | - * Write print data... | |
2700 | + * Check the port and sleep until DSR is set... | |
2701 | */ | |
2702 | ||
2703 | - if ((wbytes = write(fd, bufptr, nbytes)) < 0) | |
2704 | - if (errno == ENOTTY) | |
2705 | - wbytes = write(fd, bufptr, nbytes); | |
2706 | + int status; | |
2707 | ||
2708 | - if (wbytes < 0) | |
2709 | - { | |
2710 | - /* | |
2711 | - * Check for retryable errors... | |
2712 | - */ | |
2713 | ||
2714 | - if (errno != EAGAIN && errno != EINTR) | |
2715 | + if (!ioctl(device_fd, TIOCMGET, &status)) | |
2716 | + if (!(status & TIOCM_DSR)) | |
2717 | { | |
2718 | - perror("ERROR: Unable to send print file to printer"); | |
2719 | - break; | |
2720 | - } | |
2721 | - } | |
2722 | - else | |
2723 | + /* | |
2724 | + * Wait for DSR to go high... | |
2725 | + */ | |
2726 | + | |
2727 | + fputs("DEBUG: DSR is low; waiting for device...\n", stderr); | |
2728 | + | |
2729 | + do | |
2730 | + { | |
2731 | + /* | |
2732 | + * Poll every 100ms... | |
2733 | + */ | |
2734 | + | |
2735 | + usleep(100000); | |
2736 | + | |
2737 | + if (ioctl(device_fd, TIOCMGET, &status)) | |
2738 | + break; | |
2739 | + } | |
2740 | + while (!(status & TIOCM_DSR)); | |
2741 | + | |
2742 | + fputs("DEBUG: DSR is high; writing to device...\n", stderr); | |
2743 | + } | |
2744 | + } | |
2745 | + | |
2746 | + if ((bytes = write(device_fd, print_ptr, print_bytes)) < 0) | |
2747 | + { | |
2748 | + /* | |
2749 | + * Write error - bail if we don't see an error we can retry... | |
2750 | + */ | |
2751 | + | |
2752 | + if (errno != EAGAIN && errno != EINTR && errno != ENOTTY) | |
2753 | { | |
2754 | - /* | |
2755 | - * Update count and pointer... | |
2756 | - */ | |
2757 | + perror("ERROR: Unable to write print data"); | |
2758 | ||
2759 | - nbytes -= wbytes; | |
2760 | - bufptr += wbytes; | |
2761 | + tcsetattr(device_fd, TCSADRAIN, &origopts); | |
2762 | + | |
2763 | + close(device_fd); | |
2764 | + | |
2765 | + if (print_fd != 0) | |
2766 | + close(print_fd); | |
2767 | + | |
2768 | + return (CUPS_BACKEND_FAILED); | |
2769 | } | |
2770 | } | |
2771 | - } | |
2772 | - | |
2773 | - if (wbytes < 0) | |
2774 | - break; | |
2775 | + else | |
2776 | + { | |
2777 | + fprintf(stderr, "DEBUG: Wrote %d bytes...\n", (int)bytes); | |
2778 | ||
2779 | - if (argc > 6) | |
2780 | - fprintf(stderr, "INFO: Sending print file, %lu bytes...\n", | |
2781 | - (unsigned long)tbytes); | |
2782 | + print_bytes -= bytes; | |
2783 | + print_ptr += bytes; | |
2784 | + total_bytes += bytes; | |
2785 | + } | |
2786 | + } | |
2787 | } | |
2788 | } | |
2789 | ||
2790 | @@ -649,13 +697,14 @@ | |
2791 | * Close the serial port and input file and return... | |
2792 | */ | |
2793 | ||
2794 | - tcsetattr(fd, TCSADRAIN, &origopts); | |
2795 | + tcsetattr(device_fd, TCSADRAIN, &origopts); | |
2796 | ||
2797 | - close(fd); | |
2798 | - if (fp != 0) | |
2799 | - close(fp); | |
2800 | + close(device_fd); | |
2801 | ||
2802 | - return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
2803 | + if (print_fd != 0) | |
2804 | + close(print_fd); | |
2805 | + | |
2806 | + return (total_bytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
2807 | } | |
2808 | ||
2809 | ||
2810 | @@ -1169,5 +1218,5 @@ | |
2811 | ||
2812 | ||
2813 | /* | |
2814 | - * End of "$Id$". | |
2815 | + * End of "$Id$". | |
2816 | */ | |
2817 | diff -durN release-1.2.1/backend/snmp.c cups-1.2.x/backend/snmp.c | |
2818 | --- release-1.2.1/backend/snmp.c 2006-07-04 17:32:11.000000000 +0100 | |
2819 | +++ cups-1.2.x/backend/snmp.c 2006-06-28 09:59:03.000000000 +0100 | |
2820 | @@ -1,5 +1,5 @@ | |
2821 | /* | |
2822 | - * "$Id$" | |
2823 | + * "$Id$" | |
2824 | * | |
2825 | * SNMP discovery backend for the Common UNIX Printing System (CUPS). | |
2826 | * | |
2827 | @@ -77,17 +77,10 @@ | |
2828 | * Include necessary headers. | |
2829 | */ | |
2830 | ||
2831 | -#include <cups/backend.h> | |
2832 | #include <cups/http-private.h> | |
2833 | -#include <cups/cups.h> | |
2834 | -#include <cups/string.h> | |
2835 | +#include "backend-private.h" | |
2836 | #include <cups/array.h> | |
2837 | #include <cups/file.h> | |
2838 | -#include <errno.h> | |
2839 | -#include <signal.h> | |
2840 | - | |
2841 | -#define SNMP_BACKEND | |
2842 | -#include "ieee1284.c" | |
2843 | ||
2844 | ||
2845 | /* | |
2846 | @@ -391,7 +384,7 @@ | |
2847 | ||
2848 | debug_printf("DEBUG: add_cache(addr=%p, addrname=\"%s\", uri=\"%s\", " | |
2849 | "id=\"%s\", make_and_model=\"%s\")\n", | |
2850 | - addr, addrname, uri, id ? id : "(null)", | |
2851 | + addr, addrname, uri ? uri : "(null)", id ? id : "(null)", | |
2852 | make_and_model ? make_and_model : "(null)"); | |
2853 | ||
2854 | temp = calloc(1, sizeof(snmp_cache_t)); | |
2855 | @@ -1648,6 +1641,14 @@ | |
2856 | info = NULL; | |
2857 | ||
2858 | /* | |
2859 | + * Don't use the printer-make-and-model if it contains a generic | |
2860 | + * string like "Ricoh IPP Printer"... | |
2861 | + */ | |
2862 | + | |
2863 | + if (model && strstr(model->values[0].string.text, "IPP Printer")) | |
2864 | + model = NULL; | |
2865 | + | |
2866 | + /* | |
2867 | * If we don't have a printer-make-and-model string from the printer | |
2868 | * but do have the 1284 device ID string, generate a make-and-model | |
2869 | * string from the device ID info... | |
2870 | @@ -1656,7 +1657,9 @@ | |
2871 | if (model) | |
2872 | strlcpy(temp, model->values[0].string.text, sizeof(temp)); | |
2873 | else if (info) | |
2874 | - get_make_model(info->values[0].string.text, temp, sizeof(temp)); | |
2875 | + backendGetMakeModel(info->values[0].string.text, temp, sizeof(temp)); | |
2876 | + else | |
2877 | + temp[0] = '\0'; | |
2878 | ||
2879 | fix_make_model(make_model, temp, sizeof(make_model)); | |
2880 | ||
2881 | @@ -1928,8 +1931,8 @@ | |
2882 | * Description is the IEEE-1284 device ID... | |
2883 | */ | |
2884 | ||
2885 | - get_make_model(packet.object_value.string, make_model, | |
2886 | - sizeof(make_model)); | |
2887 | + backendGetMakeModel(packet.object_value.string, make_model, | |
2888 | + sizeof(make_model)); | |
2889 | } | |
2890 | else | |
2891 | { | |
2892 | @@ -2212,5 +2215,5 @@ | |
2893 | ||
2894 | ||
2895 | /* | |
2896 | - * End of "$Id$". | |
2897 | + * End of "$Id$". | |
2898 | */ | |
2899 | diff -durN release-1.2.1/backend/socket.c cups-1.2.x/backend/socket.c | |
2900 | --- release-1.2.1/backend/socket.c 2006-07-04 17:32:11.000000000 +0100 | |
2901 | +++ cups-1.2.x/backend/socket.c 2006-06-26 12:42:40.000000000 +0100 | |
2902 | @@ -1,5 +1,5 @@ | |
2903 | /* | |
2904 | - * "$Id$" | |
2905 | + * "$Id$" | |
2906 | * | |
2907 | * AppSocket backend for the Common UNIX Printing System (CUPS). | |
2908 | * | |
2909 | @@ -32,17 +32,11 @@ | |
2910 | * Include necessary headers. | |
2911 | */ | |
2912 | ||
2913 | -#include <cups/backend.h> | |
2914 | #include <cups/http-private.h> | |
2915 | -#include <cups/cups.h> | |
2916 | -#include <stdio.h> | |
2917 | -#include <stdlib.h> | |
2918 | +#include "backend-private.h" | |
2919 | #include <stdarg.h> | |
2920 | -#include <cups/string.h> | |
2921 | -#include <errno.h> | |
2922 | #include <sys/types.h> | |
2923 | #include <sys/stat.h> | |
2924 | -#include <signal.h> | |
2925 | ||
2926 | #ifdef WIN32 | |
2927 | # include <winsock.h> | |
2928 | @@ -76,24 +70,19 @@ | |
2929 | name[255], /* Name of option */ | |
2930 | value[255], /* Value of option */ | |
2931 | *ptr; /* Pointer into name or value */ | |
2932 | - int fp; /* Print file */ | |
2933 | + int print_fd; /* Print file */ | |
2934 | int copies; /* Number of copies to print */ | |
2935 | int waiteof; /* Wait for end-of-file? */ | |
2936 | int port; /* Port number */ | |
2937 | char portname[255]; /* Port name */ | |
2938 | int delay; /* Delay for retries... */ | |
2939 | - int fd; /* AppSocket */ | |
2940 | + int device_fd; /* AppSocket */ | |
2941 | int error; /* Error code (if any) */ | |
2942 | http_addrlist_t *addrlist; /* Address list */ | |
2943 | - int rbytes; /* Number of bytes read */ | |
2944 | - int wbytes; /* Number of bytes written */ | |
2945 | - int nbytes; /* Number of bytes read */ | |
2946 | - size_t tbytes; /* Total number of bytes written */ | |
2947 | - char buffer[8192], /* Output buffer */ | |
2948 | - *bufptr; /* Pointer into buffer */ | |
2949 | + ssize_t tbytes; /* Total number of bytes written */ | |
2950 | struct timeval timeout; /* Timeout for select() */ | |
2951 | - fd_set input, /* Input set for select() */ | |
2952 | - output; /* Output set for select() */ | |
2953 | + fd_set input; /* Input set for select() */ | |
2954 | + ssize_t bc_bytes; /* Number of back-channel bytes read */ | |
2955 | #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) | |
2956 | struct sigaction action; /* Actions for POSIX signals */ | |
2957 | #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ | |
2958 | @@ -142,8 +131,8 @@ | |
2959 | ||
2960 | if (argc == 6) | |
2961 | { | |
2962 | - fp = 0; | |
2963 | - copies = 1; | |
2964 | + print_fd = 0; | |
2965 | + copies = 1; | |
2966 | } | |
2967 | else | |
2968 | { | |
2969 | @@ -151,7 +140,7 @@ | |
2970 | * Try to open the print file... | |
2971 | */ | |
2972 | ||
2973 | - if ((fp = open(argv[6], O_RDONLY)) < 0) | |
2974 | + if ((print_fd = open(argv[6], O_RDONLY)) < 0) | |
2975 | { | |
2976 | perror("ERROR: unable to open print file"); | |
2977 | return (CUPS_BACKEND_FAILED); | |
2978 | @@ -252,228 +241,134 @@ | |
2979 | fprintf(stderr, "INFO: Attempting to connect to host %s on port %d\n", | |
2980 | hostname, port); | |
2981 | ||
2982 | - wbytes = 0; | |
2983 | + fputs("STATE: +connecting-to-device\n", stderr); | |
2984 | ||
2985 | - while (copies > 0) | |
2986 | + for (delay = 5;;) | |
2987 | { | |
2988 | - fputs("STATE: +connecting-to-device\n", stderr); | |
2989 | - | |
2990 | - for (delay = 5;;) | |
2991 | + if (!httpAddrConnect(addrlist, &device_fd)) | |
2992 | { | |
2993 | - if (!httpAddrConnect(addrlist, &fd)) | |
2994 | - { | |
2995 | - error = errno; | |
2996 | - fd = -1; | |
2997 | + error = errno; | |
2998 | + device_fd = -1; | |
2999 | ||
3000 | - if (getenv("CLASS") != NULL) | |
3001 | - { | |
3002 | - /* | |
3003 | - * If the CLASS environment variable is set, the job was submitted | |
3004 | - * to a class and not to a specific queue. In this case, we want | |
3005 | - * to abort immediately so that the job can be requeued on the next | |
3006 | - * available printer in the class. | |
3007 | - */ | |
3008 | + if (getenv("CLASS") != NULL) | |
3009 | + { | |
3010 | + /* | |
3011 | + * If the CLASS environment variable is set, the job was submitted | |
3012 | + * to a class and not to a specific queue. In this case, we want | |
3013 | + * to abort immediately so that the job can be requeued on the next | |
3014 | + * available printer in the class. | |
3015 | + */ | |
3016 | ||
3017 | - fprintf(stderr, "INFO: Unable to connect to \"%s\", queuing on next printer in class...\n", | |
3018 | - hostname); | |
3019 | + fprintf(stderr, "INFO: Unable to connect to \"%s\", queuing on next printer in class...\n", | |
3020 | + hostname); | |
3021 | ||
3022 | - /* | |
3023 | - * Sleep 5 seconds to keep the job from requeuing too rapidly... | |
3024 | - */ | |
3025 | + /* | |
3026 | + * Sleep 5 seconds to keep the job from requeuing too rapidly... | |
3027 | + */ | |
3028 | ||
3029 | - sleep(5); | |
3030 | + sleep(5); | |
3031 | ||
3032 | - return (CUPS_BACKEND_FAILED); | |
3033 | - } | |
3034 | + return (CUPS_BACKEND_FAILED); | |
3035 | + } | |
3036 | ||
3037 | - if (error == ECONNREFUSED || error == EHOSTDOWN || | |
3038 | - error == EHOSTUNREACH) | |
3039 | - { | |
3040 | - fprintf(stderr, "INFO: Network host \'%s\' is busy; will retry in %d seconds...\n", | |
3041 | - hostname, delay); | |
3042 | - sleep(delay); | |
3043 | + if (error == ECONNREFUSED || error == EHOSTDOWN || | |
3044 | + error == EHOSTUNREACH) | |
3045 | + { | |
3046 | + fprintf(stderr, | |
3047 | + "INFO: Network host \'%s\' is busy; will retry in %d seconds...\n", | |
3048 | + hostname, delay); | |
3049 | + sleep(delay); | |
3050 | ||
3051 | - if (delay < 30) | |
3052 | - delay += 5; | |
3053 | - } | |
3054 | - else | |
3055 | - { | |
3056 | - perror("ERROR: Unable to connect to printer (retrying in 30 seconds)"); | |
3057 | - sleep(30); | |
3058 | - } | |
3059 | + if (delay < 30) | |
3060 | + delay += 5; | |
3061 | } | |
3062 | else | |
3063 | - break; | |
3064 | + { | |
3065 | + perror("ERROR: Unable to connect to printer (retrying in 30 seconds)"); | |
3066 | + sleep(30); | |
3067 | + } | |
3068 | } | |
3069 | + else | |
3070 | + break; | |
3071 | + } | |
3072 | ||
3073 | - fputs("STATE: -connecting-to-device\n", stderr); | |
3074 | - | |
3075 | - /* | |
3076 | - * Now that we are "connected" to the port, ignore SIGTERM so that we | |
3077 | - * can finish out any page data the driver sends (e.g. to eject the | |
3078 | - * current page... Only ignore SIGTERM if we are printing data from | |
3079 | - * stdin (otherwise you can't cancel raw jobs...) | |
3080 | - */ | |
3081 | - | |
3082 | - if (argc < 7) | |
3083 | - { | |
3084 | -#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ | |
3085 | - sigset(SIGTERM, SIG_IGN); | |
3086 | -#elif defined(HAVE_SIGACTION) | |
3087 | - memset(&action, 0, sizeof(action)); | |
3088 | + fputs("STATE: -connecting-to-device\n", stderr); | |
3089 | ||
3090 | - sigemptyset(&action.sa_mask); | |
3091 | - action.sa_handler = SIG_IGN; | |
3092 | - sigaction(SIGTERM, &action, NULL); | |
3093 | -#else | |
3094 | - signal(SIGTERM, SIG_IGN); | |
3095 | -#endif /* HAVE_SIGSET */ | |
3096 | - } | |
3097 | + /* | |
3098 | + * Print everything... | |
3099 | + */ | |
3100 | ||
3101 | - /* | |
3102 | - * Finally, send the print file... | |
3103 | - */ | |
3104 | + tbytes = 0; | |
3105 | ||
3106 | + while (copies > 0 && tbytes >= 0) | |
3107 | + { | |
3108 | copies --; | |
3109 | ||
3110 | - if (fp != 0) | |
3111 | + if (print_fd != 0) | |
3112 | { | |
3113 | fputs("PAGE: 1 1\n", stderr); | |
3114 | - lseek(fp, 0, SEEK_SET); | |
3115 | + lseek(print_fd, 0, SEEK_SET); | |
3116 | } | |
3117 | ||
3118 | - fputs("INFO: Connected to host, sending print job...\n", stderr); | |
3119 | - | |
3120 | - tbytes = 0; | |
3121 | - while ((nbytes = read(fp, buffer, sizeof(buffer))) > 0) | |
3122 | - { | |
3123 | - /* | |
3124 | - * Write the print data to the printer... | |
3125 | - */ | |
3126 | - | |
3127 | - tbytes += nbytes; | |
3128 | - bufptr = buffer; | |
3129 | - | |
3130 | - while (nbytes > 0) | |
3131 | - { | |
3132 | - /* | |
3133 | - * See if we are ready to read or write... | |
3134 | - */ | |
3135 | - | |
3136 | - do | |
3137 | - { | |
3138 | - FD_ZERO(&input); | |
3139 | - FD_SET(fd, &input); | |
3140 | - FD_ZERO(&output); | |
3141 | - FD_SET(fd, &output); | |
3142 | - } | |
3143 | - while (select(fd + 1, &input, &output, NULL, NULL) < 0); | |
3144 | - | |
3145 | - if (FD_ISSET(fd, &input)) | |
3146 | - { | |
3147 | - /* | |
3148 | - * Read backchannel data... | |
3149 | - */ | |
3150 | - | |
3151 | - if ((rbytes = recv(fd, resource, sizeof(resource), 0)) > 0) | |
3152 | - { | |
3153 | - fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n", | |
3154 | - rbytes); | |
3155 | - cupsBackChannelWrite(resource, rbytes, 1.0); | |
3156 | - } | |
3157 | - } | |
3158 | - | |
3159 | - if (FD_ISSET(fd, &output)) | |
3160 | - { | |
3161 | - /* | |
3162 | - * Write print data... | |
3163 | - */ | |
3164 | - | |
3165 | - if ((wbytes = send(fd, bufptr, nbytes, 0)) < 0) | |
3166 | - { | |
3167 | - /* | |
3168 | - * Check for retryable errors... | |
3169 | - */ | |
3170 | + tbytes = backendRunLoop(print_fd, device_fd, 1); | |
3171 | ||
3172 | - if (errno != EAGAIN && errno != EINTR) | |
3173 | - { | |
3174 | - perror("ERROR: Unable to send print file to printer"); | |
3175 | - break; | |
3176 | - } | |
3177 | - } | |
3178 | - else | |
3179 | - { | |
3180 | - /* | |
3181 | - * Update count and pointer... | |
3182 | - */ | |
3183 | + if (print_fd != 0 && tbytes >= 0) | |
3184 | + fprintf(stderr, "INFO: Sent print file, " CUPS_LLFMT " bytes...\n", | |
3185 | + CUPS_LLCAST tbytes); | |
3186 | + } | |
3187 | ||
3188 | - nbytes -= wbytes; | |
3189 | - bufptr += wbytes; | |
3190 | - } | |
3191 | - } | |
3192 | - } | |
3193 | + if (waiteof) | |
3194 | + { | |
3195 | + /* | |
3196 | + * Shutdown the socket and wait for the other end to finish... | |
3197 | + */ | |
3198 | ||
3199 | - if (wbytes < 0) | |
3200 | - break; | |
3201 | + fputs("INFO: Print file sent, waiting for printer to finish...\n", stderr); | |
3202 | ||
3203 | - if (argc > 6) | |
3204 | - fprintf(stderr, "INFO: Sending print file, %lu bytes...\n", | |
3205 | - (unsigned long)tbytes); | |
3206 | - } | |
3207 | + shutdown(device_fd, 1); | |
3208 | ||
3209 | - if (waiteof) | |
3210 | + for (;;) | |
3211 | { | |
3212 | /* | |
3213 | - * Shutdown the socket and wait for the other end to finish... | |
3214 | + * Wait a maximum of 90 seconds for backchannel data or a closed | |
3215 | + * connection... | |
3216 | */ | |
3217 | ||
3218 | - fputs("INFO: Print file sent, waiting for printer to finish...\n", stderr); | |
3219 | + timeout.tv_sec = 90; | |
3220 | + timeout.tv_usec = 0; | |
3221 | ||
3222 | - shutdown(fd, 1); | |
3223 | + FD_ZERO(&input); | |
3224 | + FD_SET(device_fd, &input); | |
3225 | ||
3226 | - for (;;) | |
3227 | +#ifdef __hpux | |
3228 | + if (select(device_fd + 1, (int *)&input, NULL, NULL, &timeout) > 0) | |
3229 | +#else | |
3230 | + if (select(device_fd + 1, &input, NULL, NULL, &timeout) > 0) | |
3231 | +#endif /* __hpux */ | |
3232 | { | |
3233 | /* | |
3234 | - * Wait a maximum of 90 seconds for backchannel data or a closed | |
3235 | - * connection... | |
3236 | + * Grab the data coming back and spit it out to stderr... | |
3237 | */ | |
3238 | ||
3239 | - timeout.tv_sec = 90; | |
3240 | - timeout.tv_usec = 0; | |
3241 | - | |
3242 | - FD_ZERO(&input); | |
3243 | - FD_SET(fd, &input); | |
3244 | - | |
3245 | - #ifdef __hpux | |
3246 | - if (select(fd + 1, (int *)&input, NULL, NULL, &timeout) > 0) | |
3247 | - #else | |
3248 | - if (select(fd + 1, &input, NULL, NULL, &timeout) > 0) | |
3249 | - #endif /* __hpux */ | |
3250 | + if ((bc_bytes = read(device_fd, resource, sizeof(resource))) > 0) | |
3251 | { | |
3252 | - /* | |
3253 | - * Grab the data coming back and spit it out to stderr... | |
3254 | - */ | |
3255 | - | |
3256 | - if ((rbytes = recv(fd, resource, sizeof(resource), 0)) > 0) | |
3257 | - { | |
3258 | - fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n", | |
3259 | - rbytes); | |
3260 | - cupsBackChannelWrite(resource, rbytes, 1.0); | |
3261 | - } | |
3262 | - else | |
3263 | - break; | |
3264 | + fprintf(stderr, "DEBUG: Received %d bytes of back-channel data!\n", | |
3265 | + (int)bc_bytes); | |
3266 | + cupsBackChannelWrite(resource, bc_bytes, 1.0); | |
3267 | } | |
3268 | else | |
3269 | break; | |
3270 | } | |
3271 | + else | |
3272 | + break; | |
3273 | } | |
3274 | + } | |
3275 | ||
3276 | - /* | |
3277 | - * Close the socket connection... | |
3278 | - */ | |
3279 | + /* | |
3280 | + * Close the socket connection... | |
3281 | + */ | |
3282 | ||
3283 | - close(fd); | |
3284 | - } | |
3285 | + close(device_fd); | |
3286 | ||
3287 | httpAddrFreeList(addrlist); | |
3288 | ||
3289 | @@ -481,16 +376,16 @@ | |
3290 | * Close the input file and return... | |
3291 | */ | |
3292 | ||
3293 | - if (fp != 0) | |
3294 | - close(fp); | |
3295 | + if (print_fd != 0) | |
3296 | + close(print_fd); | |
3297 | ||
3298 | - if (wbytes >= 0) | |
3299 | + if (tbytes >= 0) | |
3300 | fputs("INFO: Ready to print.\n", stderr); | |
3301 | ||
3302 | - return (wbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
3303 | + return (tbytes < 0 ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK); | |
3304 | } | |
3305 | ||
3306 | ||
3307 | /* | |
3308 | - * End of "$Id$". | |
3309 | + * End of "$Id$". | |
3310 | */ | |
3311 | diff -durN release-1.2.1/backend/test1284.c cups-1.2.x/backend/test1284.c | |
3312 | --- release-1.2.1/backend/test1284.c 2006-07-04 17:32:11.000000000 +0100 | |
3313 | +++ cups-1.2.x/backend/test1284.c 2006-06-26 12:42:40.000000000 +0100 | |
3314 | @@ -1,5 +1,5 @@ | |
3315 | /* | |
3316 | - * "$Id$" | |
3317 | + * "$Id$" | |
3318 | * | |
3319 | * IEEE-1284 support functions test program for the Common UNIX Printing | |
3320 | * System (CUPS). | |
3321 | @@ -41,6 +41,7 @@ | |
3322 | # include <unistd.h> | |
3323 | # include <fcntl.h> | |
3324 | #endif /* WIN32 */ | |
3325 | + | |
3326 | #define DEBUG | |
3327 | #include "ieee1284.c" | |
3328 | ||
3329 | @@ -76,8 +77,8 @@ | |
3330 | ||
3331 | printf("%s:\n", argv[i]); | |
3332 | ||
3333 | - get_device_id(fd, device_id, sizeof(device_id), make_model, | |
3334 | - sizeof(make_model), "test", uri, sizeof(uri)); | |
3335 | + backendGetDeviceID(fd, device_id, sizeof(device_id), make_model, | |
3336 | + sizeof(make_model), "test", uri, sizeof(uri)); | |
3337 | ||
3338 | printf(" device_id=\"%s\"\n", device_id); | |
3339 | printf(" make_model=\"%s\"\n", make_model); | |
3340 | @@ -91,5 +92,5 @@ | |
3341 | ||
3342 | ||
3343 | /* | |
3344 | - * End of "$Id$". | |
3345 | + * End of "$Id$". | |
3346 | */ | |
3347 | diff -durN release-1.2.1/backend/usb.c cups-1.2.x/backend/usb.c | |
3348 | --- release-1.2.1/backend/usb.c 2006-07-04 17:32:11.000000000 +0100 | |
3349 | +++ cups-1.2.x/backend/usb.c 2006-06-26 12:42:40.000000000 +0100 | |
3350 | @@ -1,5 +1,5 @@ | |
3351 | /* | |
3352 | - * "$Id$" | |
3353 | + * "$Id$" | |
3354 | * | |
3355 | * USB port backend for the Common UNIX Printing System (CUPS). | |
3356 | * | |
3357 | @@ -63,7 +63,7 @@ | |
3358 | void list_devices(void); | |
3359 | int print_device(const char *uri, const char *hostname, | |
3360 | const char *resource, const char *options, | |
3361 | - int fp, int copies, int argc, char *argv[]); | |
3362 | + int print_fd, int copies, int argc, char *argv[]); | |
3363 | ||
3364 | ||
3365 | /* | |
3366 | @@ -108,7 +108,7 @@ | |
3367 | const char *hostname, /* I - Hostname/manufacturer */ | |
3368 | const char *resource, /* I - Resource/modelname */ | |
3369 | const char *options, /* I - Device options/serial number */ | |
3370 | - int fp, /* I - File descriptor to print */ | |
3371 | + int print_fd, /* I - File descriptor to print */ | |
3372 | int copies, /* I - Copies to print */ | |
3373 | int argc, /* I - Number of command-line arguments (6 or 7) */ | |
3374 | char *argv[]) /* I - Command-line arguments */ | |
3375 | @@ -124,7 +124,7 @@ | |
3376 | (void)hostname; | |
3377 | (void)resource; | |
3378 | (void)options; | |
3379 | - (void)fp; | |
3380 | + (void)print_fd; | |
3381 | (void)copies; | |
3382 | (void)argc; | |
3383 | (void)argv; | |
3384 | @@ -146,7 +146,7 @@ | |
3385 | main(int argc, /* I - Number of command-line arguments (6 or 7) */ | |
3386 | char *argv[]) /* I - Command-line arguments */ | |
3387 | { | |
3388 | - int fp; /* Print file */ | |
3389 | + int print_fd; /* Print file */ | |
3390 | int copies; /* Number of copies to print */ | |
3391 | int status; /* Exit status */ | |
3392 | int port; /* Port number (not used) */ | |
3393 | @@ -232,8 +232,8 @@ | |
3394 | ||
3395 | if (argc == 6) | |
3396 | { | |
3397 | - fp = 0; | |
3398 | - copies = 1; | |
3399 | + print_fd = 0; | |
3400 | + copies = 1; | |
3401 | } | |
3402 | else | |
3403 | { | |
3404 | @@ -241,7 +241,7 @@ | |
3405 | * Try to open the print file... | |
3406 | */ | |
3407 | ||
3408 | - if ((fp = open(argv[6], O_RDONLY)) < 0) | |
3409 | + if ((print_fd = open(argv[6], O_RDONLY)) < 0) | |
3410 | { | |
3411 | fprintf(stderr, "ERROR: unable to open print file %s - %s\n", | |
3412 | argv[6], strerror(errno)); | |
3413 | @@ -255,19 +255,20 @@ | |
3414 | * Finally, send the print file... | |
3415 | */ | |
3416 | ||
3417 | - status = print_device(uri, hostname, resource, options, fp, copies, argc, argv); | |
3418 | + status = print_device(uri, hostname, resource, options, print_fd, copies, | |
3419 | + argc, argv); | |
3420 | ||
3421 | /* | |
3422 | * Close the input file and return... | |
3423 | */ | |
3424 | ||
3425 | - if (fp != 0) | |
3426 | - close(fp); | |
3427 | + if (print_fd != 0) | |
3428 | + close(print_fd); | |
3429 | ||
3430 | return (status); | |
3431 | } | |
3432 | ||
3433 | ||
3434 | /* | |
3435 | - * End of "$Id$". | |
3436 | + * End of "$Id$". | |
3437 | */ | |
3438 | diff -durN release-1.2.1/backend/usb-darwin.c cups-1.2.x/backend/usb-darwin.c | |
3439 | --- release-1.2.1/backend/usb-darwin.c 2006-07-04 17:32:11.000000000 +0100 | |
3440 | +++ cups-1.2.x/backend/usb-darwin.c 2006-06-26 12:42:40.000000000 +0100 | |
3441 | @@ -1,5 +1,5 @@ | |
3442 | /* | |
3443 | - * "$Id$" | |
3444 | + * "$Id$" | |
3445 | * | |
3446 |