]>
git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/cupsfilter.c
2 * "$Id: cupsfilter.c 6879 2007-08-29 20:26:50Z mike $"
4 * CUPS filtering program for the Common UNIX Printing System (CUPS).
6 * Copyright 2007 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * main() - Main entry for the test program.
18 * compare_pids() - Compare two filter PIDs...
19 * escape_options() - Convert an options array to a string.
20 * exec_filter() - Execute a single filter.
21 * exec_filters() - Execute filters for the given file and options.
22 * get_job_file() - Get the specified job file.
23 * open_pipe() - Create a pipe which is closed on exec.
24 * read_cupsd_conf() - Read the cupsd.conf file to get the filter settings.
25 * set_string() - Copy and set a string.
26 * usage() - Show program usage...
30 * Include necessary headers...
33 #include <cups/cups.h>
34 #include <cups/i18n.h>
35 #include <cups/string.h>
44 #if defined(__APPLE__)
46 #endif /* __APPLE__ */
53 static char *DataDir
= NULL
;/* CUPS_DATADIR environment variable */
54 static char *FontPath
= NULL
;
55 /* CUPS_FONTPATH environment variable */
56 static mime_filter_t GZIPFilter
= /* gziptoany filter */
58 NULL
, /* Source type */
59 NULL
, /* Destination type */
61 "gziptoany" /* Filter program to run */
63 static char *Path
= NULL
; /* PATH environment variable */
64 static char *ServerBin
= NULL
;
65 /* CUPS_SERVERBIN environment variable */
66 static char *ServerRoot
= NULL
;
67 /* CUPS_SERVERROOT environment variable */
68 static char *RIPCache
= NULL
;
69 /* RIP_CACHE environment variable */
70 static char TempFile
[1024] = "";
78 static int compare_pids(mime_filter_t
*a
, mime_filter_t
*b
);
79 static char *escape_options(int num_options
, cups_option_t
*options
);
80 static int exec_filter(const char *filter
, char **argv
, char **envp
,
82 static int exec_filters(cups_array_t
*filters
, const char *infile
,
83 const char *outfile
, const char *ppdfile
,
84 const char *printer
, const char *user
,
85 const char *title
, int num_options
,
86 cups_option_t
*options
);
87 static void get_job_file(const char *job
);
88 static int open_pipe(int *fds
);
89 static int read_cupsd_conf(const char *filename
);
90 static void set_string(char **s
, const char *val
);
91 static void sighandler(int sig
);
92 static void usage(const char *command
, const char *opt
);
96 * 'main()' - Main entry for the test program.
99 int /* O - Exit status */
100 main(int argc
, /* I - Number of command-line args */
101 char *argv
[]) /* I - Command-line arguments */
103 int i
; /* Looping vars */
104 const char *command
, /* Command name */
105 *opt
; /* Current option */
106 char *srctype
, /* Source type */
107 *dsttype
, /* Destination type */
108 super
[MIME_MAX_SUPER
], /* Super-type name */
109 type
[MIME_MAX_TYPE
]; /* Type name */
110 int compression
; /* Compression of file */
111 int cost
; /* Cost of filters */
112 mime_t
*mime
; /* MIME database */
113 char *infile
, /* File to filter */
114 *outfile
; /* File to create */
115 char cupsdconf
[1024]; /* cupsd.conf file */
116 const char *server_root
; /* CUPS_SERVERROOT environment variable */
117 mime_type_t
*src
, /* Source type */
118 *dst
; /* Destination type */
119 cups_array_t
*filters
; /* Filters for the file */
120 int num_options
; /* Number of options */
121 cups_option_t
*options
; /* Options */
122 const char *ppdfile
; /* PPD file */
123 const char *title
, /* Title string */
124 *user
; /* Username */
125 int removeppd
, /* Remove PPD file */
126 removeinfile
; /* Remove input file */
127 int status
; /* Execution status */
134 if ((command
= strrchr(argv
[0], '/')) != NULL
)
141 dsttype
= "application/pdf";
152 if ((server_root
= getenv("CUPS_SERVERROOT")) == NULL
)
153 server_root
= CUPS_SERVERROOT
;
155 snprintf(cupsdconf
, sizeof(cupsdconf
), "%s/cupsd.conf", server_root
);
158 * Process command-line arguments...
161 _cupsSetLocale(argv
);
163 for (i
= 1; i
< argc
; i
++)
164 if (argv
[i
][0] == '-')
166 for (opt
= argv
[i
] + 1; *opt
; opt
++)
169 case '-' : /* Next argument is a filename... */
171 if (i
< argc
&& !infile
)
177 case 'a' : /* Specify option... */
180 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
185 case 'c' : /* Specify cupsd.conf file location... */
189 if (!strcmp(command
, "convert"))
190 num_options
= cupsAddOption("copies", argv
[i
], num_options
,
193 strlcpy(cupsdconf
, argv
[i
], sizeof(cupsdconf
));
199 case 'D' : /* Delete input file after conversion */
203 case 'f' : /* Specify input file... */
205 if (i
< argc
&& !infile
)
211 case 'i' : /* Specify source MIME type... */
215 if (sscanf(argv
[i
], "%15[^/]/%255s", super
, type
) != 2)
224 case 'j' : /* Get job file or specify destination MIME type... */
225 if (strcmp(command
, "convert"))
230 get_job_file(argv
[i
]);
239 case 'm' : /* Specify destination MIME type... */
243 if (sscanf(argv
[i
], "%15[^/]/%255s", super
, type
) != 2)
252 case 'n' : /* Specify number of copies... */
255 num_options
= cupsAddOption("copies", argv
[i
], num_options
,
261 case 'o' : /* Specify option(s) or output filename */
265 if (!strcmp(command
, "convert"))
268 usage(command
, NULL
);
273 num_options
= cupsParseOptions(argv
[i
], num_options
,
280 case 'p' : /* Specify PPD file... */
281 case 'P' : /* Specify PPD file... */
289 case 't' : /* Specify title... */
290 case 'J' : /* Specify title... */
298 case 'u' : /* Delete PPD file after conversion */
302 case 'U' : /* Specify username... */
310 default : /* Something we don't understand... */
317 if (strcmp(command
, "convert"))
321 _cupsLangPuts(stderr
,
322 _("convert: Use the -f option to specify a file to "
324 usage(command
, NULL
);
329 _cupsLangPuts(stderr
,
330 _("cupsfilter: Only one filename can be specified!\n"));
331 usage(command
, NULL
);
334 if (!infile
&& !srctype
)
335 usage(command
, NULL
);
341 else if ((title
= strrchr(infile
, '/')) != NULL
)
348 * Load the cupsd.conf file and create the MIME database...
351 if (read_cupsd_conf(cupsdconf
))
354 if ((mime
= mimeLoad(ServerRoot
, Path
)) == NULL
)
356 _cupsLangPrintf(stderr
,
357 _("%s: Unable to read MIME database from \"%s\"!\n"),
358 command
, ServerRoot
);
363 * Get the source and destination types...
368 sscanf(srctype
, "%15[^/]/%255s", super
, type
);
369 if ((src
= mimeType(mime
, super
, type
)) == NULL
)
371 _cupsLangPrintf(stderr
,
372 _("%s: Unknown source MIME type %s/%s!\n"),
373 command
, super
, type
);
377 else if ((src
= mimeFileType(mime
, infile
, infile
, &compression
)) == NULL
)
379 _cupsLangPrintf(stderr
,
380 _("%s: Unable to determine MIME type of \"%s\"!\n"),
385 sscanf(dsttype
, "%15[^/]/%255s", super
, type
);
386 if ((dst
= mimeType(mime
, super
, type
)) == NULL
)
388 _cupsLangPrintf(stderr
,
389 _("%s: Unknown destination MIME type %s/%s!\n"),
390 command
, super
, type
);
395 * Figure out how to filter the file...
401 * Special case - no filtering needed...
404 filters
= cupsArrayNew(NULL
, NULL
);
405 cupsArrayAdd(filters
, &GZIPFilter
);
407 else if ((filters
= mimeFilter(mime
, src
, dst
, &cost
)) == NULL
)
409 _cupsLangPrintf(stderr
,
410 _("%s: No filter to convert from %s/%s to %s/%s!\n"),
411 command
, src
->super
, src
->type
, dst
->super
, dst
->type
);
414 else if (compression
)
415 cupsArrayInsert(filters
, &GZIPFilter
);
421 status
= exec_filters(filters
, infile
, outfile
, ppdfile
,
422 !strcmp(command
, "convert") ? "tofile" : "cupsfilter",
423 user
, title
, num_options
, options
);
426 * Remove files as needed, then exit...
432 if (removeppd
&& ppdfile
)
435 if (removeinfile
&& infile
)
443 * 'compare_pids()' - Compare two filter PIDs...
446 static int /* O - Result of comparison */
447 compare_pids(mime_filter_t
*a
, /* I - First filter */
448 mime_filter_t
*b
) /* I - Second filter */
451 * Because we're particularly lazy, we store the process ID in the "cost"
455 return (a
->cost
- b
->cost
);
460 * 'escape_options()' - Convert an options array to a string.
463 static char * /* O - Option string */
465 int num_options
, /* I - Number of options */
466 cups_option_t
*options
) /* I - Options */
468 int i
; /* Looping var */
469 cups_option_t
*option
; /* Current option */
470 int bytes
; /* Number of bytes needed */
471 char *s
, /* Option string */
472 *sptr
, /* Pointer into string */
473 *vptr
; /* Pointer into value */
477 * Figure out the worst-case number of bytes we need for the option string.
480 for (i
= num_options
, option
= options
, bytes
= 1; i
> 0; i
--, option
++)
481 bytes
+= 2 * (strlen(option
->name
) + strlen(option
->value
)) + 2;
486 * Copy the options to the string...
489 for (i
= num_options
, option
= options
, sptr
= s
; i
> 0; i
--, option
++)
491 if (!strcmp(option
->name
, "copies"))
497 strcpy(sptr
, option
->name
);
498 sptr
+= strlen(sptr
);
501 for (vptr
= option
->value
; *vptr
;)
503 if (strchr("\\ \t\n", *vptr
))
517 * 'exec_filter()' - Execute a single filter.
520 static int /* O - Process ID or -1 on error */
521 exec_filter(const char *filter
, /* I - Filter to execute */
522 char **argv
, /* I - Argument list */
523 char **envp
, /* I - Environment list */
524 int infd
, /* I - Stdin file descriptor */
525 int outfd
) /* I - Stdout file descriptor */
527 int pid
; /* Process ID */
528 #if defined(__APPLE__)
529 char processPath
[1024], /* CFProcessPath environment variable */
530 linkpath
[1024]; /* Link path for symlinks... */
531 int linkbytes
; /* Bytes for link path */
535 * Add special voodoo magic for MacOS X - this allows MacOS X
536 * programs to access their bundle resources properly...
539 if ((linkbytes
= readlink(filter
, linkpath
, sizeof(linkpath
) - 1)) > 0)
542 * Yes, this is a symlink to the actual program, nul-terminate and
546 linkpath
[linkbytes
] = '\0';
548 if (linkpath
[0] == '/')
549 snprintf(processPath
, sizeof(processPath
), "CFProcessPath=%s",
552 snprintf(processPath
, sizeof(processPath
), "CFProcessPath=%s/%s",
553 dirname((char *)filter
), linkpath
);
556 snprintf(processPath
, sizeof(processPath
), "CFProcessPath=%s", filter
);
558 envp
[0] = processPath
; /* Replace <CFProcessPath> string */
559 #endif /* __APPLE__ */
561 if ((pid
= fork()) == 0)
564 * Child process goes here...
566 * Update stdin/stdout/stderr as needed...
575 open("/dev/null", O_RDONLY
);
584 open("/dev/null", O_WRONLY
);
588 open("/dev/null", O_RDWR
);
589 fcntl(3, F_SETFL
, O_NDELAY
);
592 open("/dev/null", O_RDWR
);
593 fcntl(4, F_SETFL
, O_NDELAY
);
599 execve(filter
, argv
, envp
);
611 * 'exec_filters()' - Execute filters for the given file and options.
614 static int /* O - 0 on success, 1 on error */
615 exec_filters(cups_array_t
*filters
, /* I - Array of filters to run */
616 const char *infile
, /* I - File to filter */
617 const char *outfile
, /* I - File to create */
618 const char *ppdfile
, /* I - PPD file, if any */
619 const char *printer
, /* I - Printer name */
620 const char *user
, /* I - Username */
621 const char *title
, /* I - Job title */
622 int num_options
, /* I - Number of filter options */
623 cups_option_t
*options
) /* I - Filter options */
625 int i
; /* Looping var */
626 const char *argv
[8], /* Command-line arguments */
627 *envp
[11], /* Environment variables */
628 *temp
; /* Temporary string */
629 char *optstr
, /* Filter options */
630 cups_datadir
[1024], /* CUPS_DATADIR */
631 cups_fontpath
[1024], /* CUPS_FONTPATH */
632 cups_serverbin
[1024], /* CUPS_SERVERBIN */
633 cups_serverroot
[1024], /* CUPS_SERVERROOT */
634 lang
[1024], /* LANG */
635 path
[1024], /* PATH */
637 rip_cache
[1024], /* RIP_CACHE */
638 userenv
[1024], /* USER */
639 program
[1024]; /* Program to run */
640 mime_filter_t
*filter
, /* Current filter */
641 *next
; /* Next filter */
642 int current
, /* Current filter */
643 filterfds
[2][2], /* Pipes for filters */
644 pid
, /* Process ID of filter */
645 status
, /* Exit status */
646 retval
; /* Return value */
647 cups_array_t
*pids
; /* Executed filters array */
648 mime_filter_t key
; /* Search key for filters */
649 cups_lang_t
*language
; /* Current language */
653 * Setup the filter environment and command-line...
656 optstr
= escape_options(num_options
, options
);
658 snprintf(cups_datadir
, sizeof(cups_datadir
), "CUPS_DATADIR=%s", DataDir
);
659 snprintf(cups_fontpath
, sizeof(cups_fontpath
), "CUPS_FONTPATH=%s", FontPath
);
660 snprintf(cups_serverbin
, sizeof(cups_serverbin
), "CUPS_SERVERBIN=%s",
662 snprintf(cups_serverroot
, sizeof(cups_serverroot
), "CUPS_SERVERROOT=%s",
664 language
= cupsLangDefault();
665 snprintf(lang
, sizeof(lang
), "LANG=%s.UTF8", language
->language
);
666 snprintf(path
, sizeof(path
), "PATH=%s", Path
);
668 snprintf(ppd
, sizeof(ppd
), "PPD=%s", ppdfile
);
669 else if ((temp
= getenv("PPD")) != NULL
)
670 snprintf(ppd
, sizeof(ppd
), "PPD=%s", temp
);
673 if (!access("/System/Library/Frameworks/ApplicationServices.framework/"
674 "Versions/A/Frameworks/PrintCore.framework/Versions/A/"
675 "Resources/English.lproj/Generic.ppd", 0))
676 strlcpy(ppd
, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
677 "Versions/A/Frameworks/PrintCore.framework/Versions/A/"
678 "Resources/English.lproj/Generic.ppd", sizeof(ppd
));
680 strlcpy(ppd
, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
681 "Versions/A/Frameworks/PrintCore.framework/Versions/A/"
682 "Resources/Generic.ppd", sizeof(ppd
));
684 snprintf(ppd
, sizeof(ppd
), "PPD=%s/model/laserjet.ppd", DataDir
);
685 #endif /* __APPLE__ */
686 snprintf(rip_cache
, sizeof(rip_cache
), "RIP_CACHE=%s", RIPCache
);
687 snprintf(userenv
, sizeof(userenv
), "USER=%s", user
);
689 argv
[0] = (char *)printer
;
693 argv
[4] = cupsGetOption("copies", num_options
, options
);
701 envp
[0] = "<CFProcessPath>";
702 envp
[1] = cups_datadir
;
703 envp
[2] = cups_fontpath
;
704 envp
[3] = cups_serverbin
;
705 envp
[4] = cups_serverroot
;
713 for (i
= 0; argv
[i
]; i
++)
714 fprintf(stderr
, "DEBUG: argv[%d]=\"%s\"\n", i
, argv
[i
]);
716 for (i
= 0; envp
[i
]; i
++)
717 fprintf(stderr
, "DEBUG: envp[%d]=\"%s\"\n", i
, envp
[i
]);
720 * Execute all of the filters...
723 pids
= cupsArrayNew((cups_array_func_t
)compare_pids
, NULL
);
725 filterfds
[0][0] = -1;
726 filterfds
[0][1] = -1;
727 filterfds
[1][0] = -1;
728 filterfds
[1][1] = -1;
733 for (filter
= (mime_filter_t
*)cupsArrayFirst(filters
);
735 filter
= next
, current
= 1 - current
)
737 next
= (mime_filter_t
*)cupsArrayNext(filters
);
739 if (filter
->filter
[0] == '/')
740 strlcpy(program
, filter
->filter
, sizeof(program
));
742 snprintf(program
, sizeof(program
), "%s/filter/%s", ServerBin
,
745 if (filterfds
[!current
][1] > 1)
747 close(filterfds
[1 - current
][0]);
748 close(filterfds
[1 - current
][1]);
750 filterfds
[1 - current
][0] = -1;
751 filterfds
[1 - current
][0] = -1;
755 open_pipe(filterfds
[1 - current
]);
758 filterfds
[1 - current
][1] = open(outfile
, O_CREAT
| O_TRUNC
| O_WRONLY
,
761 if (filterfds
[1 - current
][1] < 0)
762 fprintf(stderr
, "ERROR: Unable to create \"%s\" - %s\n", outfile
,
766 filterfds
[1 - current
][1] = 1;
768 pid
= exec_filter(program
, (char **)argv
, (char **)envp
,
769 filterfds
[current
][0], filterfds
[1 - current
][1]);
773 fprintf(stderr
, "INFO: %s (PID %d) started.\n", filter
->filter
, pid
);
776 cupsArrayAdd(pids
, filter
);
785 * Close remaining pipes...
788 if (filterfds
[0][1] > 1)
790 close(filterfds
[0][0]);
791 close(filterfds
[0][1]);
794 if (filterfds
[1][1] > 1)
796 close(filterfds
[1][0]);
797 close(filterfds
[1][1]);
801 * Wait for the children to exit...
806 while (cupsArrayCount(pids
) > 0)
808 if ((pid
= wait(&status
)) < 0)
812 if ((filter
= (mime_filter_t
*)cupsArrayFind(pids
, &key
)) != NULL
)
814 cupsArrayRemove(pids
, filter
);
818 if (WIFEXITED(status
))
819 fprintf(stderr
, "ERROR: %s (PID %d) stopped with status %d!\n",
820 filter
->filter
, pid
, WEXITSTATUS(status
));
822 fprintf(stderr
, "ERROR: %s (PID %d) crashed on signal %d!\n",
823 filter
->filter
, pid
, WTERMSIG(status
));
828 fprintf(stderr
, "INFO: %s (PID %d) exited with no errors.\n",
829 filter
->filter
, pid
);
838 * 'get_job_file()' - Get the specified job file.
842 get_job_file(const char *job
) /* I - Job ID */
844 long jobid
, /* Job ID */
845 docnum
; /* Document number */
846 const char *jobptr
; /* Pointer into job ID string */
847 char uri
[1024]; /* job-uri */
848 http_t
*http
; /* Connection to server */
849 ipp_t
*request
; /* Request data */
850 int tempfd
; /* Temporary file */
854 * Get the job ID and document number, if any...
857 if ((jobptr
= strrchr(job
, '-')) != NULL
)
862 jobid
= strtol(jobptr
, (char **)&jobptr
, 10);
865 docnum
= strtol(jobptr
+ 1, NULL
, 10);
869 if (jobid
< 1 || jobid
> INT_MAX
)
871 _cupsLangPrintf(stderr
, _("cupsfilter: Invalid job ID %d!\n"), (int)jobid
);
875 if (docnum
< 1 || docnum
> INT_MAX
)
877 _cupsLangPrintf(stderr
, _("cupsfilter: Invalid document number %d!\n"),
883 * Ask the server for the document file...
886 if ((http
= httpConnectEncrypt(cupsServer(), ippPort(),
887 cupsEncryption())) == NULL
)
889 _cupsLangPrintf(stderr
, _("%s: Unable to connect to server\n"),
894 request
= ippNewRequest(CUPS_GET_DOCUMENT
);
896 snprintf(uri
, sizeof(uri
), "ipp://localhost/jobs/%d", (int)jobid
);
898 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "job-uri", NULL
, uri
);
899 ippAddInteger(request
, IPP_TAG_OPERATION
, IPP_TAG_INTEGER
, "document-number",
902 if ((tempfd
= cupsTempFd(TempFile
, sizeof(TempFile
))) == -1)
904 _cupsLangPrintf(stderr
,
905 _("cupsfilter: Unable to create temporary file: %s\n"),
911 signal(SIGTERM
, sighandler
);
913 ippDelete(cupsDoIORequest(http
, request
, "/", -1, tempfd
));
919 if (cupsLastError() != IPP_OK
)
921 _cupsLangPrintf(stderr
, _("cupsfilter: Unable to get job file - %s\n"),
922 cupsLastErrorString());
930 * 'open_pipe()' - Create a pipe which is closed on exec.
933 static int /* O - 0 on success, -1 on error */
934 open_pipe(int *fds
) /* O - Pipe file descriptors (2) */
949 * Set the "close on exec" flag on each end of the pipe...
952 if (fcntl(fds
[0], F_SETFD
, fcntl(fds
[0], F_GETFD
) | FD_CLOEXEC
))
963 if (fcntl(fds
[1], F_SETFD
, fcntl(fds
[1], F_GETFD
) | FD_CLOEXEC
))
975 * Return 0 indicating success...
983 * 'read_cupsd_conf()' - Read the cupsd.conf file to get the filter settings.
986 static int /* O - 0 on success, 1 on error */
987 read_cupsd_conf(const char *filename
) /* I - File to read */
989 cups_file_t
*fp
; /* cupsd.conf file */
990 const char *temp
; /* Temporary string */
991 char line
[1024], /* Line from file */
992 *ptr
; /* Pointer into line */
993 int linenum
; /* Current line number */
996 if ((temp
= getenv("CUPS_DATADIR")) != NULL
)
997 set_string(&DataDir
, temp
);
999 set_string(&DataDir
, CUPS_DATADIR
);
1001 if ((temp
= getenv("CUPS_FONTPATH")) != NULL
)
1002 set_string(&FontPath
, temp
);
1004 set_string(&FontPath
, CUPS_FONTPATH
);
1006 set_string(&RIPCache
, "8m");
1008 if ((temp
= getenv("CUPS_SERVERBIN")) != NULL
)
1009 set_string(&ServerBin
, temp
);
1011 set_string(&ServerBin
, CUPS_SERVERBIN
);
1013 strlcpy(line
, filename
, sizeof(line
));
1014 if ((ptr
= strrchr(line
, '/')) != NULL
)
1017 getcwd(line
, sizeof(line
));
1019 set_string(&ServerRoot
, line
);
1021 if ((fp
= cupsFileOpen(filename
, "r")) != NULL
)
1025 while (cupsFileGetConf(fp
, line
, sizeof(line
), &ptr
, &linenum
))
1027 if (!strcasecmp(line
, "DataDir"))
1028 set_string(&DataDir
, ptr
);
1029 else if (!strcasecmp(line
, "FontPath"))
1030 set_string(&FontPath
, ptr
);
1031 else if (!strcasecmp(line
, "RIPCache"))
1032 set_string(&RIPCache
, ptr
);
1033 else if (!strcasecmp(line
, "ServerBin"))
1034 set_string(&ServerBin
, ptr
);
1035 else if (!strcasecmp(line
, "ServerRoot"))
1036 set_string(&ServerRoot
, ptr
);
1042 snprintf(line
, sizeof(line
),
1043 "%s/filter:" CUPS_BINDIR
":" CUPS_SBINDIR
":/bin/usr/bin",
1045 set_string(&Path
, line
);
1052 * 'set_string()' - Copy and set a string.
1056 set_string(char **s
, /* O - Copy of string */
1057 const char *val
) /* I - String to copy */
1067 * 'sighandler()' - Signal catcher for when we print from stdin...
1071 sighandler(int s
) /* I - Signal number */
1074 * Remove the temporary file we're using to print a job file...
1089 * 'usage()' - Show program usage...
1093 usage(const char *command
, /* I - Command name */
1094 const char *opt
) /* I - Incorrect option, if any */
1097 _cupsLangPrintf(stderr
, _("%s: Unknown option '%c'!\n"), command
, *opt
);
1099 if (!strcmp(command
, "cupsfilter"))
1100 _cupsLangPuts(stdout
,
1101 _("Usage: cupsfilter -m mime/type [ options ] filename\n"
1105 " -c cupsd.conf Set cupsd.conf file to use\n"
1106 " -j job-id[,N] Filter file N from the specified job (default is file 1)\n"
1107 " -n copies Set number of copies\n"
1108 " -o name=value Set option(s)\n"
1109 " -p filename.ppd Set PPD file\n"
1110 " -t title Set title\n"));
1112 _cupsLangPuts(stdout
,
1113 _("Usage: convert [ options ]\n"
1117 " -f filename Set file to be converted (otherwise stdin)\n"
1118 " -o filename Set file to be generated (otherwise stdout)\n"
1119 " -i mime/type Set input MIME type (otherwise auto-typed)\n"
1120 " -j mime/type Set output MIME type (otherwise application/pdf)\n"
1121 " -P filename.ppd Set PPD file\n"
1122 " -a 'name=value ...' Set option(s)\n"
1123 " -U username Set username for job\n"
1124 " -J title Set title\n"
1125 " -c copies Set number of copies\n"
1126 " -u Remove the PPD file when finished\n"
1127 " -D Remove the input file when finished\n"));
1134 * End of "$Id: cupsfilter.c 6879 2007-08-29 20:26:50Z mike $".