]> git.ipfire.org Git - thirdparty/cups.git/blob - backend/ipp.c
Load cups into easysw/current.
[thirdparty/cups.git] / backend / ipp.c
1 /*
2 * "$Id: ipp.c 5180 2006-02-26 01:31:45Z mike $"
3 *
4 * IPP backend for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * This file is subject to the Apple OS-Developed Software exception.
25 *
26 * Contents:
27 *
28 * main() - Send a file to the printer or server.
29 * cancel_job() - Cancel a print job.
30 * check_printer_state() - Check the printer state...
31 * compress_files() - Compress print files...
32 * password_cb() - Disable the password prompt for
33 * cupsDoFileRequest().
34 * report_printer_state() - Report the printer state.
35 * run_pictwps_filter() - Convert PICT files to PostScript when printing
36 * remotely.
37 * sigterm_handler() - Handle 'terminate' signals that stop the backend.
38 */
39
40 /*
41 * Include necessary headers.
42 */
43
44 #include <cups/http-private.h>
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <errno.h>
48 #include <sys/types.h>
49 #include <sys/stat.h>
50 #include <cups/backend.h>
51 #include <cups/cups.h>
52 #include <cups/language.h>
53 #include <cups/string.h>
54 #include <signal.h>
55 #include <sys/wait.h>
56
57
58 /*
59 * Globals...
60 */
61
62 static char *password = NULL; /* Password for device URI */
63 #ifdef __APPLE__
64 static char pstmpname[1024] = ""; /* Temporary PostScript file name */
65 #endif /* __APPLE__ */
66 static char tmpfilename[1024] = ""; /* Temporary spool file name */
67 static int job_cancelled = 0; /* Job cancelled? */
68
69
70 /*
71 * Local functions...
72 */
73
74 static void cancel_job(http_t *http, const char *uri, int id,
75 const char *resource, const char *user, int version);
76 static void check_printer_state(http_t *http, const char *uri,
77 const char *resource, const char *user,
78 int version);
79 #ifdef HAVE_LIBZ
80 static void compress_files(int num_files, char **files);
81 #endif /* HAVE_LIBZ */
82 static const char *password_cb(const char *);
83 static int report_printer_state(ipp_t *ipp);
84
85 #ifdef __APPLE__
86 static int run_pictwps_filter(char **argv, const char *filename);
87 #endif /* __APPLE__ */
88 static void sigterm_handler(int sig);
89
90
91 /*
92 * 'main()' - Send a file to the printer or server.
93 *
94 * Usage:
95 *
96 * printer-uri job-id user title copies options [file]
97 */
98
99 int /* O - Exit status */
100 main(int argc, /* I - Number of command-line args */
101 char *argv[]) /* I - Command-line arguments */
102 {
103 int i; /* Looping var */
104 int num_options; /* Number of printer options */
105 cups_option_t *options; /* Printer options */
106 char method[255], /* Method in URI */
107 hostname[1024], /* Hostname */
108 username[255], /* Username info */
109 resource[1024], /* Resource info (printer name) */
110 *optptr, /* Pointer to URI options */
111 name[255], /* Name of option */
112 value[255], /* Value of option */
113 *ptr; /* Pointer into name or value */
114 int num_files; /* Number of files to print */
115 char **files, /* Files to print */
116 *filename; /* Pointer to single filename */
117 int port; /* Port number (not used) */
118 char uri[HTTP_MAX_URI]; /* Updated URI without user/pass */
119 ipp_status_t ipp_status; /* Status of IPP request */
120 http_t *http; /* HTTP connection */
121 ipp_t *request, /* IPP request */
122 *response, /* IPP response */
123 *supported; /* get-printer-attributes response */
124 int compression, /* Do compression of the job data? */
125 waitjob, /* Wait for job complete? */
126 waitprinter; /* Wait for printer ready? */
127 ipp_attribute_t *job_id_attr; /* job-id attribute */
128 int job_id; /* job-id value */
129 ipp_attribute_t *job_sheets; /* job-media-sheets-completed */
130 ipp_attribute_t *job_state; /* job-state */
131 ipp_attribute_t *copies_sup; /* copies-supported */
132 ipp_attribute_t *format_sup; /* document-format-supported */
133 ipp_attribute_t *printer_state; /* printer-state attribute */
134 ipp_attribute_t *printer_accepting; /* printer-is-accepting-jobs */
135 int copies; /* Number of copies remaining */
136 const char *content_type; /* CONTENT_TYPE environment variable */
137 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
138 struct sigaction action; /* Actions for POSIX signals */
139 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
140 int version; /* IPP version */
141 int reasons; /* Number of printer-state-reasons */
142 static const char * const pattrs[] =
143 { /* Printer attributes we want */
144 "copies-supported",
145 "document-format-supported",
146 "printer-is-accepting-jobs",
147 "printer-state",
148 "printer-state-reasons",
149 };
150 static const char * const jattrs[] =
151 { /* Job attributes we want */
152 "job-media-sheets-completed",
153 "job-state"
154 };
155
156
157 /*
158 * Make sure status messages are not buffered...
159 */
160
161 setbuf(stderr, NULL);
162
163 /*
164 * Ignore SIGPIPE and catch SIGTERM signals...
165 */
166
167 #ifdef HAVE_SIGSET
168 sigset(SIGPIPE, SIG_IGN);
169 sigset(SIGTERM, sigterm_handler);
170 #elif defined(HAVE_SIGACTION)
171 memset(&action, 0, sizeof(action));
172 action.sa_handler = SIG_IGN;
173 sigaction(SIGPIPE, &action, NULL);
174
175 sigemptyset(&action.sa_mask);
176 sigaddset(&action.sa_mask, SIGTERM);
177 action.sa_handler = sigterm_handler;
178 sigaction(SIGTERM, &action, NULL);
179 #else
180 signal(SIGPIPE, SIG_IGN);
181 signal(SIGTERM, sigterm_handler);
182 #endif /* HAVE_SIGSET */
183
184 /*
185 * Check command-line...
186 */
187
188 if (argc == 1)
189 {
190 char *s;
191
192 if ((s = strrchr(argv[0], '/')) != NULL)
193 s ++;
194 else
195 s = argv[0];
196
197 printf("network %s \"Unknown\" \"Internet Printing Protocol (%s)\"\n",
198 s, s);
199 return (CUPS_BACKEND_OK);
200 }
201 else if (argc < 6)
202 {
203 fprintf(stderr,
204 "Usage: %s job-id user title copies options [file ... fileN]\n",
205 argv[0]);
206 return (CUPS_BACKEND_STOP);
207 }
208
209 /*
210 * Get the (final) content type...
211 */
212
213 if ((content_type = getenv("FINAL_CONTENT_TYPE")) == NULL)
214 content_type = "application/octet-stream";
215
216 /*
217 * Extract the hostname and printer name from the URI...
218 */
219
220 if (httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
221 method, sizeof(method), username, sizeof(username),
222 hostname, sizeof(hostname), &port,
223 resource, sizeof(resource)) < HTTP_URI_OK)
224 {
225 fputs("ERROR: Missing device URI on command-line and no DEVICE_URI "
226 "environment variable!\n", stderr);
227 return (CUPS_BACKEND_STOP);
228 }
229
230 if (!strcmp(method, "https"))
231 cupsSetEncryption(HTTP_ENCRYPT_ALWAYS);
232
233 /*
234 * See if there are any options...
235 */
236
237 compression = 0;
238 version = 1;
239 waitjob = 1;
240 waitprinter = 1;
241
242 if ((optptr = strchr(resource, '?')) != NULL)
243 {
244 /*
245 * Yup, terminate the device name string and move to the first
246 * character of the optptr...
247 */
248
249 *optptr++ = '\0';
250
251 /*
252 * Then parse the optptr...
253 */
254
255 while (*optptr)
256 {
257 /*
258 * Get the name...
259 */
260
261 for (ptr = name; *optptr && *optptr != '=';)
262 if (ptr < (name + sizeof(name) - 1))
263 *ptr++ = *optptr++;
264 *ptr = '\0';
265
266 if (*optptr == '=')
267 {
268 /*
269 * Get the value...
270 */
271
272 optptr ++;
273
274 for (ptr = value; *optptr && *optptr != '+' && *optptr != '&';)
275 if (ptr < (value + sizeof(value) - 1))
276 *ptr++ = *optptr++;
277 *ptr = '\0';
278
279 if (*optptr == '+')
280 optptr ++;
281 }
282 else
283 value[0] = '\0';
284
285 /*
286 * Process the option...
287 */
288
289 if (!strcasecmp(name, "waitjob"))
290 {
291 /*
292 * Wait for job completion?
293 */
294
295 waitjob = !strcasecmp(value, "on") ||
296 !strcasecmp(value, "yes") ||
297 !strcasecmp(value, "true");
298 }
299 else if (!strcasecmp(name, "waitprinter"))
300 {
301 /*
302 * Wait for printer idle?
303 */
304
305 waitprinter = !strcasecmp(value, "on") ||
306 !strcasecmp(value, "yes") ||
307 !strcasecmp(value, "true");
308 }
309 else if (!strcasecmp(name, "encryption"))
310 {
311 /*
312 * Enable/disable encryption?
313 */
314
315 if (!strcasecmp(value, "always"))
316 cupsSetEncryption(HTTP_ENCRYPT_ALWAYS);
317 else if (!strcasecmp(value, "required"))
318 cupsSetEncryption(HTTP_ENCRYPT_REQUIRED);
319 else if (!strcasecmp(value, "never"))
320 cupsSetEncryption(HTTP_ENCRYPT_NEVER);
321 else if (!strcasecmp(value, "ifrequested"))
322 cupsSetEncryption(HTTP_ENCRYPT_IF_REQUESTED);
323 else
324 {
325 fprintf(stderr, "ERROR: Unknown encryption option value \"%s\"!\n",
326 value);
327 }
328 }
329 else if (!strcasecmp(name, "version"))
330 {
331 if (!strcmp(value, "1.0"))
332 version = 0;
333 else if (!strcmp(value, "1.1"))
334 version = 1;
335 else
336 {
337 fprintf(stderr, "ERROR: Unknown version option value \"%s\"!\n",
338 value);
339 }
340 }
341 #ifdef HAVE_LIBZ
342 else if (!strcasecmp(name, "compression"))
343 {
344 compression = !strcasecmp(value, "true") ||
345 !strcasecmp(value, "yes") ||
346 !strcasecmp(value, "on") ||
347 !strcasecmp(value, "gzip");
348 }
349 #endif /* HAVE_LIBZ */
350 else
351 {
352 /*
353 * Unknown option...
354 */
355
356 fprintf(stderr, "ERROR: Unknown option \"%s\" with value \"%s\"!\n",
357 name, value);
358 }
359 }
360 }
361
362 /*
363 * If we have 7 arguments, print the file named on the command-line.
364 * Otherwise, copy stdin to a temporary file and print the temporary
365 * file.
366 */
367
368 if (argc == 6)
369 {
370 /*
371 * Copy stdin to a temporary file...
372 */
373
374 int fd; /* File descriptor */
375 cups_file_t *fp; /* Temporary file */
376 char buffer[8192]; /* Buffer for copying */
377 int bytes; /* Number of bytes read */
378
379
380 if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
381 {
382 perror("ERROR: unable to create temporary file");
383 return (CUPS_BACKEND_FAILED);
384 }
385
386 if ((fp = cupsFileOpenFd(fd, compression ? "w9" : "w")) == NULL)
387 {
388 perror("ERROR: unable to open temporary file");
389 close(fd);
390 unlink(tmpfilename);
391 return (CUPS_BACKEND_FAILED);
392 }
393
394 while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
395 if (cupsFileWrite(fp, buffer, bytes) < bytes)
396 {
397 perror("ERROR: unable to write to temporary file");
398 cupsFileClose(fp);
399 unlink(tmpfilename);
400 return (CUPS_BACKEND_FAILED);
401 }
402
403 cupsFileClose(fp);
404
405 /*
406 * Point to the single file from stdin...
407 */
408
409 filename = tmpfilename;
410 files = &filename;
411 num_files = 1;
412 }
413 else
414 {
415 /*
416 * Point to the files on the command-line...
417 */
418
419 num_files = argc - 6;
420 files = argv + 6;
421
422 #ifdef HAVE_LIBZ
423 if (compression)
424 compress_files(num_files, files);
425 #endif /* HAVE_LIBZ */
426 }
427
428 fprintf(stderr, "DEBUG: %d files to send in job...\n", num_files);
429
430 /*
431 * Set the authentication info, if any...
432 */
433
434 cupsSetPasswordCB(password_cb);
435
436 if (username[0])
437 {
438 /*
439 * Use authenticaion information in the device URI...
440 */
441
442 if ((password = strchr(username, ':')) != NULL)
443 *password++ = '\0';
444
445 cupsSetUser(username);
446 }
447 else if (!getuid())
448 {
449 /*
450 * Try loading authentication information from the a##### file.
451 */
452
453 const char *request_root; /* CUPS_REQUESTROOT env var */
454 char afilename[1024], /* a##### filename */
455 aline[1024]; /* Line from file */
456 FILE *fp; /* File pointer */
457
458
459 if ((request_root = getenv("CUPS_REQUESTROOT")) != NULL)
460 {
461 /*
462 * Try opening authentication cache file...
463 */
464
465 snprintf(afilename, sizeof(afilename), "%s/a%05d", request_root,
466 atoi(argv[1]));
467 if ((fp = fopen(afilename, "r")) != NULL)
468 {
469 /*
470 * Read username...
471 */
472
473 if (fgets(aline, sizeof(aline), fp))
474 {
475 /*
476 * Decode username...
477 */
478
479 i = sizeof(username);
480 httpDecode64_2(username, &i, aline);
481
482 /*
483 * Read password...
484 */
485
486 if (fgets(aline, sizeof(aline), fp))
487 {
488 /*
489 * Decode password...
490 */
491
492 i = sizeof(password);
493 httpDecode64_2(password, &i, aline);
494 }
495 }
496
497 /*
498 * Close the file...
499 */
500
501 fclose(fp);
502 }
503 }
504 }
505
506 /*
507 * Try connecting to the remote server...
508 */
509
510 do
511 {
512 fprintf(stderr, "INFO: Connecting to %s on port %d...\n", hostname, port);
513
514 if ((http = httpConnectEncrypt(hostname, port, cupsEncryption())) == NULL)
515 {
516 if (getenv("CLASS") != NULL)
517 {
518 /*
519 * If the CLASS environment variable is set, the job was submitted
520 * to a class and not to a specific queue. In this case, we want
521 * to abort immediately so that the job can be requeued on the next
522 * available printer in the class.
523 */
524
525 fprintf(stderr,
526 "INFO: Unable to connect to %s, queuing on next printer in "
527 "class...\n",
528 hostname);
529
530 if (argc == 6 || strcmp(filename, argv[6]))
531 unlink(filename);
532
533 /*
534 * Sleep 5 seconds to keep the job from requeuing too rapidly...
535 */
536
537 sleep(5);
538
539 return (CUPS_BACKEND_FAILED);
540 }
541
542 if (errno == ECONNREFUSED || errno == EHOSTDOWN ||
543 errno == EHOSTUNREACH)
544 {
545 fprintf(stderr,
546 "INFO: Network host \'%s\' is busy; will retry in 30 "
547 "seconds...\n",
548 hostname);
549 sleep(30);
550 }
551 else if (h_errno)
552 {
553 fprintf(stderr, "INFO: Unable to lookup host \'%s\' - %s\n",
554 hostname, hstrerror(h_errno));
555 sleep(30);
556 }
557 else
558 {
559 perror("ERROR: Unable to connect to IPP host");
560 sleep(30);
561 }
562 }
563 }
564 while (http == NULL);
565
566 fprintf(stderr, "INFO: Connected to %s...\n", hostname);
567
568 /*
569 * Build a URI for the printer and fill the standard IPP attributes for
570 * an IPP_PRINT_FILE request. We can't use the URI in argv[0] because it
571 * might contain username:password information...
572 */
573
574 snprintf(uri, sizeof(uri), "%s://%s:%d%s", method, hostname, port, resource);
575
576 /*
577 * First validate the destination and see if the device supports multiple
578 * copies. We have to do this because some IPP servers (e.g. HP JetDirect)
579 * don't support the copies attribute...
580 */
581
582 copies_sup = NULL;
583 format_sup = NULL;
584 supported = NULL;
585
586 do
587 {
588 /*
589 * Build the IPP request...
590 */
591
592 request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
593 request->request.op.version[1] = version;
594
595 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
596 NULL, uri);
597
598 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
599 "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
600 NULL, pattrs);
601
602 /*
603 * Do the request...
604 */
605
606 fputs("DEBUG: Getting supported attributes...\n", stderr);
607
608 if ((supported = cupsDoRequest(http, request, resource)) == NULL)
609 ipp_status = cupsLastError();
610 else
611 ipp_status = supported->request.status.status_code;
612
613 if (ipp_status > IPP_OK_CONFLICT)
614 {
615 if (ipp_status == IPP_PRINTER_BUSY ||
616 ipp_status == IPP_SERVICE_UNAVAILABLE)
617 {
618 fputs("INFO: Printer busy; will retry in 10 seconds...\n", stderr);
619 report_printer_state(supported);
620 sleep(10);
621 }
622 else if ((ipp_status == IPP_BAD_REQUEST ||
623 ipp_status == IPP_VERSION_NOT_SUPPORTED) && version == 1)
624 {
625 /*
626 * Switch to IPP/1.0...
627 */
628
629 fputs("INFO: Printer does not support IPP/1.1, trying IPP/1.0...\n",
630 stderr);
631 version = 0;
632 httpReconnect(http);
633 }
634 else if (ipp_status == IPP_NOT_FOUND)
635 {
636 fputs("ERROR: Destination printer does not exist!\n", stderr);
637
638 if (supported)
639 ippDelete(supported);
640
641 return (CUPS_BACKEND_STOP);
642 }
643 else
644 {
645 fprintf(stderr, "ERROR: Unable to get printer status (%s)!\n",
646 ippErrorString(ipp_status));
647 sleep(10);
648 }
649
650 if (supported)
651 ippDelete(supported);
652
653 continue;
654 }
655 else if ((copies_sup = ippFindAttribute(supported, "copies-supported",
656 IPP_TAG_RANGE)) != NULL)
657 {
658 /*
659 * Has the "copies-supported" attribute - does it have an upper
660 * bound > 1?
661 */
662
663 if (copies_sup->values[0].range.upper <= 1)
664 copies_sup = NULL; /* No */
665 }
666
667 format_sup = ippFindAttribute(supported, "document-format-supported",
668 IPP_TAG_MIMETYPE);
669
670 if (format_sup)
671 {
672 fprintf(stderr, "DEBUG: document-format-supported (%d values)\n",
673 format_sup->num_values);
674 for (i = 0; i < format_sup->num_values; i ++)
675 fprintf(stderr, "DEBUG: [%d] = \"%s\"\n", i,
676 format_sup->values[i].string.text);
677 }
678
679 report_printer_state(supported);
680 }
681 while (ipp_status > IPP_OK_CONFLICT);
682
683 /*
684 * See if the printer is accepting jobs and is not stopped; if either
685 * condition is true and we are printing to a class, requeue the job...
686 */
687
688 if (getenv("CLASS") != NULL)
689 {
690 printer_state = ippFindAttribute(supported, "printer-state",
691 IPP_TAG_ENUM);
692 printer_accepting = ippFindAttribute(supported, "printer-is-accepting-jobs",
693 IPP_TAG_BOOLEAN);
694
695 if (printer_state == NULL ||
696 (printer_state->values[0].integer > IPP_PRINTER_PROCESSING &&
697 waitprinter) ||
698 printer_accepting == NULL ||
699 !printer_accepting->values[0].boolean)
700 {
701 /*
702 * If the CLASS environment variable is set, the job was submitted
703 * to a class and not to a specific queue. In this case, we want
704 * to abort immediately so that the job can be requeued on the next
705 * available printer in the class.
706 */
707
708 fprintf(stderr,
709 "INFO: Unable to queue job on %s, queuing on next printer in "
710 "class...\n",
711 hostname);
712
713 ippDelete(supported);
714 httpClose(http);
715
716 if (argc == 6 || strcmp(filename, argv[6]))
717 unlink(filename);
718
719 /*
720 * Sleep 5 seconds to keep the job from requeuing too rapidly...
721 */
722
723 sleep(5);
724
725 return (CUPS_BACKEND_FAILED);
726 }
727 }
728
729 /*
730 * See if the printer supports multiple copies...
731 */
732
733 if (copies_sup || argc < 7)
734 copies = 1;
735 else
736 copies = atoi(argv[4]);
737
738 /*
739 * Then issue the print-job request...
740 */
741
742 reasons = 0;
743 job_id = 0;
744
745 while (copies > 0)
746 {
747 /*
748 * Build the IPP request...
749 */
750
751 if (job_cancelled)
752 break;
753
754 if (num_files > 1)
755 request = ippNewRequest(IPP_CREATE_JOB);
756 else
757 request = ippNewRequest(IPP_PRINT_JOB);
758
759 request->request.op.version[1] = version;
760
761 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
762 NULL, uri);
763
764 fprintf(stderr, "DEBUG: printer-uri = \"%s\"\n", uri);
765
766 if (argv[2][0])
767 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
768 "requesting-user-name", NULL, argv[2]);
769
770 fprintf(stderr, "DEBUG: requesting-user-name = \"%s\"\n", argv[2]);
771
772 if (argv[3][0])
773 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL,
774 argv[3]);
775
776 fprintf(stderr, "DEBUG: job-name = \"%s\"\n", argv[3]);
777
778 #ifdef HAVE_LIBZ
779 if (compression)
780 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
781 "compression", NULL, "gzip");
782 #endif /* HAVE_LIBZ */
783
784 /*
785 * Handle options on the command-line...
786 */
787
788 options = NULL;
789 num_options = cupsParseOptions(argv[5], 0, &options);
790
791 #ifdef __APPLE__
792 if (content_type != NULL &&
793 !strcasecmp(content_type, "application/pictwps") && num_files == 1)
794 {
795 if (format_sup != NULL)
796 {
797 for (i = 0; i < format_sup->num_values; i ++)
798 if (!strcasecmp(content_type, format_sup->values[i].string.text))
799 break;
800 }
801
802 if (format_sup == NULL || i >= format_sup->num_values)
803 {
804 /*
805 * Remote doesn't support "application/pictwps" (i.e. it's not MacOS X)
806 * so convert the document to PostScript...
807 */
808
809 if (run_pictwps_filter(argv, filename))
810 return (CUPS_BACKEND_FAILED);
811
812 filename = pstmpname;
813
814 /*
815 * Change the MIME type to application/postscript and change the
816 * number of copies to 1...
817 */
818
819 content_type = "application/postscript";
820 copies = 1;
821 }
822 }
823 #endif /* __APPLE__ */
824
825 if (content_type != NULL && format_sup != NULL)
826 {
827 for (i = 0; i < format_sup->num_values; i ++)
828 if (!strcasecmp(content_type, format_sup->values[i].string.text))
829 break;
830
831 if (i < format_sup->num_values)
832 num_options = cupsAddOption("document-format", content_type,
833 num_options, &options);
834 }
835
836 if (copies_sup)
837 {
838 /*
839 * Only send options if the destination printer supports the copies
840 * attribute. This is a hack for the HP JetDirect implementation of
841 * IPP, which does not accept extension attributes and incorrectly
842 * reports a client-error-bad-request error instead of the
843 * successful-ok-unsupported-attributes status. In short, at least
844 * some HP implementations of IPP are non-compliant.
845 */
846
847 cupsEncodeOptions(request, num_options, options);
848 ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies",
849 atoi(argv[4]));
850 }
851
852 cupsFreeOptions(num_options, options);
853
854 /*
855 * If copies aren't supported, then we are likely dealing with an HP
856 * JetDirect. The HP IPP implementation seems to close the connection
857 * after every request (that is, it does *not* implement HTTP Keep-
858 * Alive, which is REQUIRED by HTTP/1.1...
859 */
860
861 if (!copies_sup)
862 httpReconnect(http);
863
864 /*
865 * Do the request...
866 */
867
868 if (num_files > 1)
869 response = cupsDoRequest(http, request, resource);
870 else
871 response = cupsDoFileRequest(http, request, resource, files[0]);
872
873 ipp_status = cupsLastError();
874
875 if (ipp_status > IPP_OK_CONFLICT)
876 {
877 job_id = 0;
878
879 if (job_cancelled)
880 break;
881
882 if (ipp_status == IPP_SERVICE_UNAVAILABLE ||
883 ipp_status == IPP_PRINTER_BUSY)
884 {
885 fputs("INFO: Printer is busy; retrying print job...\n", stderr);
886 sleep(10);
887 }
888 else
889 fprintf(stderr, "ERROR: Print file was not accepted (%s)!\n",
890 cupsLastErrorString());
891 }
892 else if ((job_id_attr = ippFindAttribute(response, "job-id",
893 IPP_TAG_INTEGER)) == NULL)
894 {
895 fputs("NOTICE: Print file accepted - job ID unknown.\n", stderr);
896 job_id = 0;
897 }
898 else
899 {
900 job_id = job_id_attr->values[0].integer;
901 fprintf(stderr, "NOTICE: Print file accepted - job ID %d.\n", job_id);
902 }
903
904 ippDelete(response);
905
906 if (job_cancelled)
907 break;
908
909 if (job_id && num_files > 1)
910 {
911 for (i = 0; i < num_files; i ++)
912 {
913 request = ippNewRequest(IPP_SEND_DOCUMENT);
914
915 request->request.op.version[1] = version;
916
917 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
918 NULL, uri);
919
920 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
921 job_id);
922
923 if (argv[2][0])
924 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
925 "requesting-user-name", NULL, argv[2]);
926
927 if ((i + 1) == num_files)
928 ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
929
930 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
931 "document-format", NULL, content_type);
932
933 ippDelete(cupsDoFileRequest(http, request, resource, files[i]));
934
935 if (cupsLastError() > IPP_OK_CONFLICT)
936 {
937 ipp_status = cupsLastError();
938
939 fprintf(stderr, "ERROR: Unable to add file %d to job: %s\n",
940 job_id, cupsLastErrorString());
941 break;
942 }
943 }
944 }
945
946 if (ipp_status <= IPP_OK_CONFLICT && argc > 6)
947 {
948 fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1);
949 copies --;
950 }
951 else if (ipp_status == IPP_SERVICE_UNAVAILABLE ||
952 ipp_status == IPP_PRINTER_BUSY)
953 break;
954 else
955 copies --;
956
957 /*
958 * Wait for the job to complete...
959 */
960
961 if (!job_id || !waitjob)
962 continue;
963
964 fputs("INFO: Waiting for job to complete...\n", stderr);
965
966 for (; !job_cancelled;)
967 {
968 /*
969 * Build an IPP_GET_JOB_ATTRIBUTES request...
970 */
971
972 request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES);
973 request->request.op.version[1] = version;
974
975 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
976 NULL, uri);
977
978 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",
979 job_id);
980
981 if (argv[2][0])
982 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
983 "requesting-user-name", NULL, argv[2]);
984
985 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
986 "requested-attributes", sizeof(jattrs) / sizeof(jattrs[0]),
987 NULL, jattrs);
988
989 /*
990 * Do the request...
991 */
992
993 if (!copies_sup)
994 httpReconnect(http);
995
996 response = cupsDoRequest(http, request, resource);
997 ipp_status = cupsLastError();
998
999 if (ipp_status == IPP_NOT_FOUND)
1000 {
1001 /*
1002 * Job has gone away and/or the server has no job history...
1003 */
1004
1005 ippDelete(response);
1006
1007 ipp_status = IPP_OK;
1008 break;
1009 }
1010
1011 if (ipp_status > IPP_OK_CONFLICT)
1012 {
1013 if (ipp_status != IPP_SERVICE_UNAVAILABLE &&
1014 ipp_status != IPP_PRINTER_BUSY)
1015 {
1016 ippDelete(response);
1017
1018 fprintf(stderr, "ERROR: Unable to get job %d attributes (%s)!\n",
1019 job_id, ippErrorString(ipp_status));
1020 break;
1021 }
1022 }
1023
1024 if (response)
1025 {
1026 if ((job_state = ippFindAttribute(response, "job-state",
1027 IPP_TAG_ENUM)) != NULL)
1028 {
1029 /*
1030 * Stop polling if the job is finished or pending-held...
1031 */
1032
1033 if (job_state->values[0].integer > IPP_JOB_PROCESSING ||
1034 job_state->values[0].integer == IPP_JOB_HELD)
1035 {
1036 if ((job_sheets = ippFindAttribute(response,
1037 "job-media-sheets-completed",
1038 IPP_TAG_INTEGER)) != NULL)
1039 fprintf(stderr, "PAGE: total %d\n",
1040 job_sheets->values[0].integer);
1041
1042 ippDelete(response);
1043 break;
1044 }
1045 }
1046 }
1047
1048 ippDelete(response);
1049
1050 /*
1051 * Check the printer state and report it if necessary...
1052 */
1053
1054 check_printer_state(http, uri, resource, argv[2], version);
1055
1056 /*
1057 * Wait 10 seconds before polling again...
1058 */
1059
1060 sleep(10);
1061 }
1062 }
1063
1064 /*
1065 * Cancel the job as needed...
1066 */
1067
1068 if (job_cancelled && job_id)
1069 cancel_job(http, uri, job_id, resource, argv[2], version);
1070
1071 /*
1072 * Check the printer state and report it if necessary...
1073 */
1074
1075 check_printer_state(http, uri, resource, argv[2], version);
1076
1077 /*
1078 * Free memory...
1079 */
1080
1081 httpClose(http);
1082
1083 ippDelete(supported);
1084
1085 /*
1086 * Remove the temporary file(s) if necessary...
1087 */
1088
1089 if (tmpfilename[0])
1090 unlink(tmpfilename);
1091
1092 #ifdef HAVE_LIBZ
1093 if (compression)
1094 {
1095 for (i = 0; i < num_files; i ++)
1096 unlink(files[i]);
1097 }
1098 #endif /* HAVE_LIBZ */
1099
1100 #ifdef __APPLE__
1101 if (pstmpname[0])
1102 unlink(pstmpname);
1103 #endif /* __APPLE__ */
1104
1105 /*
1106 * Return the queue status...
1107 */
1108
1109 return (ipp_status > IPP_OK_CONFLICT ? CUPS_BACKEND_FAILED : CUPS_BACKEND_OK);
1110 }
1111
1112
1113 /*
1114 * 'cancel_job()' - Cancel a print job.
1115 */
1116
1117 static void
1118 cancel_job(http_t *http, /* I - HTTP connection */
1119 const char *uri, /* I - printer-uri */
1120 int id, /* I - job-id */
1121 const char *resource, /* I - Resource path */
1122 const char *user, /* I - requesting-user-name */
1123 int version) /* I - IPP version */
1124 {
1125 ipp_t *request; /* Cancel-Job request */
1126
1127
1128 fputs("INFO: Cancelling print job...\n", stderr);
1129
1130 request = ippNewRequest(IPP_CANCEL_JOB);
1131 request->request.op.version[1] = version;
1132
1133 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
1134 NULL, uri);
1135 ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", id);
1136
1137 if (user && user[0])
1138 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1139 "requesting-user-name", NULL, user);
1140
1141 /*
1142 * Do the request...
1143 */
1144
1145 ippDelete(cupsDoRequest(http, request, resource));
1146
1147 if (cupsLastError() > IPP_OK_CONFLICT)
1148 fprintf(stderr, "ERROR: Unable to cancel job %d: %s\n", id,
1149 cupsLastErrorString());
1150 }
1151
1152
1153 /*
1154 * 'check_printer_state()' - Check the printer state...
1155 */
1156
1157 static void
1158 check_printer_state(
1159 http_t *http, /* I - HTTP connection */
1160 const char *uri, /* I - Printer URI */
1161 const char *resource, /* I - Resource path */
1162 const char *user, /* I - Username, if any */
1163 int version) /* I - IPP version */
1164 {
1165 ipp_t *request, /* IPP request */
1166 *response; /* IPP response */
1167
1168
1169 /*
1170 * Check on the printer state...
1171 */
1172
1173 request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
1174 request->request.op.version[1] = version;
1175
1176 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
1177 NULL, uri);
1178
1179 if (user && user[0])
1180 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1181 "requesting-user-name", NULL, user);
1182
1183 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
1184 "requested-attributes", NULL, "printer-state-reasons");
1185
1186 /*
1187 * Do the request...
1188 */
1189
1190 if ((response = cupsDoRequest(http, request, resource)) != NULL)
1191 {
1192 report_printer_state(response);
1193 ippDelete(response);
1194 }
1195 }
1196
1197
1198 #ifdef HAVE_LIBZ
1199 /*
1200 * 'compress_files()' - Compress print files...
1201 */
1202
1203 static void
1204 compress_files(int num_files, /* I - Number of files */
1205 char **files) /* I - Files */
1206 {
1207 int i, /* Looping var */
1208 fd; /* Temporary file descriptor */
1209 ssize_t bytes; /* Bytes read/written */
1210 size_t total; /* Total bytes read */
1211 cups_file_t *in, /* Input file */
1212 *out; /* Output file */
1213 struct stat outinfo; /* Output file information */
1214 char filename[1024], /* Temporary filename */
1215 buffer[65536]; /* Copy buffer */
1216
1217
1218 fprintf(stderr, "DEBUG: Compressing %d job files...\n", num_files);
1219 for (i = 0; i < num_files; i ++)
1220 {
1221 if ((fd = cupsTempFd(filename, sizeof(filename))) < 0)
1222 {
1223 perror("ERROR: Unable to create temporary compressed print file");
1224 exit(CUPS_BACKEND_FAILED);
1225 }
1226
1227 if ((out = cupsFileOpenFd(fd, "w9")) == NULL)
1228 {
1229 perror("ERROR: Unable to open temporary compressed print file");
1230 exit(CUPS_BACKEND_FAILED);
1231 }
1232
1233 if ((in = cupsFileOpen(files[i], "r")) == NULL)
1234 {
1235 fprintf(stderr, "ERROR: Unable to open print file \"%s\": %s\n",
1236 files[i], strerror(errno));
1237 cupsFileClose(out);
1238 exit(CUPS_BACKEND_FAILED);
1239 }
1240
1241 total = 0;
1242 while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
1243 if (cupsFileWrite(out, buffer, bytes) < bytes)
1244 {
1245 fprintf(stderr, "ERROR: Unable to write %d bytes to \"%s\": %s\n",
1246 bytes, filename, strerror(errno));
1247 cupsFileClose(in);
1248 cupsFileClose(out);
1249 exit(CUPS_BACKEND_FAILED);
1250 }
1251 else
1252 total += bytes;
1253
1254 cupsFileClose(out);
1255 cupsFileClose(in);
1256
1257 files[i] = strdup(filename);
1258
1259 if (!stat(filename, &outinfo))
1260 fprintf(stderr,
1261 "DEBUG: File %d compressed to %.1f%% of original size, "
1262 CUPS_LLFMT " bytes...\n",
1263 i + 1, 100.0 * outinfo.st_size / total, outinfo.st_size);
1264 }
1265 }
1266 #endif /* HAVE_LIBZ */
1267
1268
1269 /*
1270 * 'password_cb()' - Disable the password prompt for cupsDoFileRequest().
1271 */
1272
1273 static const char * /* O - Password */
1274 password_cb(const char *prompt) /* I - Prompt (not used) */
1275 {
1276 (void)prompt;
1277
1278 if (password)
1279 return (password);
1280 else
1281 {
1282 /*
1283 * If there is no password set in the device URI, return the
1284 * "authentication required" exit code...
1285 */
1286
1287 if (tmpfilename[0])
1288 unlink(tmpfilename);
1289
1290 #ifdef __APPLE__
1291 if (pstmpname[0])
1292 unlink(pstmpname);
1293 #endif /* __APPLE__ */
1294
1295 exit(CUPS_BACKEND_AUTH_REQUIRED);
1296 }
1297 }
1298
1299
1300 /*
1301 * 'report_printer_state()' - Report the printer state.
1302 */
1303
1304 static int /* O - Number of reasons shown */
1305 report_printer_state(ipp_t *ipp) /* I - IPP response */
1306 {
1307 int i; /* Looping var */
1308 int count; /* Count of reasons shown... */
1309 ipp_attribute_t *reasons; /* printer-state-reasons */
1310 const char *reason; /* Current reason */
1311 const char *message; /* Message to show */
1312 char unknown[1024]; /* Unknown message string */
1313 const char *prefix; /* Prefix for STATE: line */
1314 char state[1024]; /* State string */
1315
1316
1317 if ((reasons = ippFindAttribute(ipp, "printer-state-reasons",
1318 IPP_TAG_KEYWORD)) == NULL)
1319 return (0);
1320
1321 state[0] = '\0';
1322 prefix = "STATE: ";
1323
1324 for (i = 0, count = 0; i < reasons->num_values; i ++)
1325 {
1326 reason = reasons->values[i].string.text;
1327
1328 strlcat(state, prefix, sizeof(state));
1329 strlcat(state, reason, sizeof(state));
1330
1331 prefix = ",";
1332 message = NULL;
1333
1334 if (!strncmp(reason, "media-needed", 12))
1335 message = "Media tray needs to be filled.";
1336 else if (!strncmp(reason, "media-jam", 9))
1337 message = "Media jam!";
1338 else if (!strncmp(reason, "moving-to-paused", 16) ||
1339 !strncmp(reason, "paused", 6) ||
1340 !strncmp(reason, "shutdown", 8))
1341 message = "Printer off-line.";
1342 else if (!strncmp(reason, "toner-low", 9))
1343 message = "Toner low.";
1344 else if (!strncmp(reason, "toner-empty", 11))
1345 message = "Out of toner!";
1346 else if (!strncmp(reason, "cover-open", 10))
1347 message = "Cover open.";
1348 else if (!strncmp(reason, "interlock-open", 14))
1349 message = "Interlock open.";
1350 else if (!strncmp(reason, "door-open", 9))
1351 message = "Door open.";
1352 else if (!strncmp(reason, "input-tray-missing", 18))
1353 message = "Media tray missing!";
1354 else if (!strncmp(reason, "media-low", 9))
1355 message = "Media tray almost empty.";
1356 else if (!strncmp(reason, "media-empty", 11))
1357 message = "Media tray empty!";
1358 else if (!strncmp(reason, "output-tray-missing", 19))
1359 message = "Output tray missing!";
1360 else if (!strncmp(reason, "output-area-almost-full", 23))
1361 message = "Output bin almost full.";
1362 else if (!strncmp(reason, "output-area-full", 16))
1363 message = "Output bin full!";
1364 else if (!strncmp(reason, "marker-supply-low", 17))
1365 message = "Ink/toner almost empty.";
1366 else if (!strncmp(reason, "marker-supply-empty", 19))
1367 message = "Ink/toner empty!";
1368 else if (!strncmp(reason, "marker-waste-almost-full", 24))
1369 message = "Ink/toner waste bin almost full.";
1370 else if (!strncmp(reason, "marker-waste-full", 17))
1371 message = "Ink/toner waste bin full!";
1372 else if (!strncmp(reason, "fuser-over-temp", 15))
1373 message = "Fuser temperature high!";
1374 else if (!strncmp(reason, "fuser-under-temp", 16))
1375 message = "Fuser temperature low!";
1376 else if (!strncmp(reason, "opc-near-eol", 12))
1377 message = "OPC almost at end-of-life.";
1378 else if (!strncmp(reason, "opc-life-over", 13))
1379 message = "OPC at end-of-life!";
1380 else if (!strncmp(reason, "developer-low", 13))
1381 message = "Developer almost empty.";
1382 else if (!strncmp(reason, "developer-empty", 15))
1383 message = "Developer empty!";
1384 else if (strstr(reason, "error") != NULL)
1385 {
1386 message = unknown;
1387
1388 snprintf(unknown, sizeof(unknown), "Unknown printer error (%s)!",
1389 reason);
1390 }
1391
1392 if (message)
1393 {
1394 count ++;
1395 if (strstr(reasons->values[i].string.text, "error"))
1396 fprintf(stderr, "ERROR: %s\n", message);
1397 else if (strstr(reasons->values[i].string.text, "warning"))
1398 fprintf(stderr, "WARNING: %s\n", message);
1399 else
1400 fprintf(stderr, "INFO: %s\n", message);
1401 }
1402 }
1403
1404 fprintf(stderr, "%s\n", state);
1405
1406 return (count);
1407 }
1408
1409
1410 #ifdef __APPLE__
1411 /*
1412 * 'run_pictwps_filter()' - Convert PICT files to PostScript when printing
1413 * remotely.
1414 *
1415 * This step is required because the PICT format is not documented and
1416 * subject to change, so developing a filter for other OS's is infeasible.
1417 * Also, fonts required by the PICT file need to be embedded on the
1418 * client side (which has the fonts), so we run the filter to get a
1419 * PostScript file for printing...
1420 */
1421
1422 static int /* O - Exit status of filter */
1423 run_pictwps_filter(char **argv, /* I - Command-line arguments */
1424 const char *filename)/* I - Filename */
1425 {
1426 struct stat fileinfo; /* Print file information */
1427 const char *ppdfile; /* PPD file for destination printer */
1428 int pid; /* Child process ID */
1429 int fd; /* Temporary file descriptor */
1430 int status; /* Exit status of filter */
1431 const char *printer; /* PRINTER env var */
1432 static char ppdenv[1024]; /* PPD environment variable */
1433
1434
1435 /*
1436 * First get the PPD file for the printer...
1437 */
1438
1439 printer = getenv("PRINTER");
1440 if (!printer)
1441 {
1442 fputs("ERROR: PRINTER environment variable not defined!\n", stderr);
1443 return (-1);
1444 }
1445
1446 if ((ppdfile = cupsGetPPD(printer)) == NULL)
1447 {
1448 fprintf(stderr, "ERROR: Unable to get PPD file for printer \"%s\" - %s.\n",
1449 printer, ippErrorString(cupsLastError()));
1450 /*return (-1);*/
1451 }
1452 else
1453 {
1454 snprintf(ppdenv, sizeof(ppdenv), "PPD=%s", ppdfile);
1455 putenv(ppdenv);
1456 }
1457
1458 /*
1459 * Then create a temporary file for printing...
1460 */
1461
1462 if ((fd = cupsTempFd(pstmpname, sizeof(pstmpname))) < 0)
1463 {
1464 fprintf(stderr, "ERROR: Unable to create temporary file - %s.\n",
1465 strerror(errno));
1466 if (ppdfile)
1467 unlink(ppdfile);
1468 return (-1);
1469 }
1470
1471 /*
1472 * Get the owner of the spool file - it is owned by the user we want to run
1473 * as...
1474 */
1475
1476 if (argv[6])
1477 stat(argv[6], &fileinfo);
1478 else
1479 {
1480 /*
1481 * Use the OSX defaults, as an up-stream filter created the PICT
1482 * file...
1483 */
1484
1485 fileinfo.st_uid = 1;
1486 fileinfo.st_gid = 80;
1487 }
1488
1489 if (ppdfile)
1490 chown(ppdfile, fileinfo.st_uid, fileinfo.st_gid);
1491
1492 fchown(fd, fileinfo.st_uid, fileinfo.st_gid);
1493
1494 /*
1495 * Finally, run the filter to convert the file...
1496 */
1497
1498 if ((pid = fork()) == 0)
1499 {
1500 /*
1501 * Child process for pictwpstops... Redirect output of pictwpstops to a
1502 * file...
1503 */
1504
1505 close(1);
1506 dup(fd);
1507 close(fd);
1508
1509 if (!getuid())
1510 {
1511 /*
1512 * Change to an unpriviledged user...
1513 */
1514
1515 setgid(fileinfo.st_gid);
1516 setuid(fileinfo.st_uid);
1517 }
1518
1519 execlp("pictwpstops", printer, argv[1], argv[2], argv[3], argv[4], argv[5],
1520 filename, NULL);
1521 perror("ERROR: Unable to exec pictwpstops");
1522 return (errno);
1523 }
1524
1525 close(fd);
1526
1527 if (pid < 0)
1528 {
1529 /*
1530 * Error!
1531 */
1532
1533 perror("ERROR: Unable to fork pictwpstops");
1534 unlink(filename);
1535 if (ppdfile)
1536 unlink(ppdfile);
1537 return (-1);
1538 }
1539
1540 /*
1541 * Now wait for the filter to complete...
1542 */
1543
1544 if (wait(&status) < 0)
1545 {
1546 perror("ERROR: Unable to wait for pictwpstops");
1547 close(fd);
1548 unlink(filename);
1549 if (ppdfile)
1550 unlink(ppdfile);
1551 return (-1);
1552 }
1553
1554 if (ppdfile)
1555 unlink(ppdfile);
1556
1557 close(fd);
1558
1559 if (status)
1560 {
1561 if (status >= 256)
1562 fprintf(stderr, "ERROR: pictwpstops exited with status %d!\n",
1563 status / 256);
1564 else
1565 fprintf(stderr, "ERROR: pictwpstops exited on signal %d!\n",
1566 status);
1567
1568 unlink(filename);
1569 return (status);
1570 }
1571
1572 /*
1573 * Return with no errors..
1574 */
1575
1576 return (0);
1577 }
1578 #endif /* __APPLE__ */
1579
1580
1581 /*
1582 * 'sigterm_handler()' - Handle 'terminate' signals that stop the backend.
1583 */
1584
1585 static void
1586 sigterm_handler(int sig) /* I - Signal */
1587 {
1588 (void)sig; /* remove compiler warnings... */
1589
1590 if (!job_cancelled)
1591 {
1592 /*
1593 * Flag that the job should be cancelled...
1594 */
1595
1596 job_cancelled = 1;
1597 return;
1598 }
1599
1600 /*
1601 * The scheduler already tried to cancel us once, now just terminate
1602 * after removing our temp files!
1603 */
1604
1605 if (tmpfilename[0])
1606 unlink(tmpfilename);
1607
1608 #ifdef __APPLE__
1609 if (pstmpname[0])
1610 unlink(pstmpname);
1611 #endif /* __APPLE__ */
1612
1613 exit(1);
1614 }
1615
1616
1617 /*
1618 * End of "$Id: ipp.c 5180 2006-02-26 01:31:45Z mike $".
1619 */