]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/commandtopclx.c
1ef53aab42b12674d2a7ce5cc7a9e777805c45da
4 * Advanced PCL command filter for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1993-2005 by Easy Software Products.
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/".
18 * main() - Main entry and command processing.
22 * Include necessary headers...
25 #include <cups/cups-private.h>
31 * 'main()' - Main entry and processing of driver.
34 int /* O - Exit status */
35 main(int argc
, /* I - Number of command-line arguments */
36 char *argv
[]) /* I - Command-line arguments */
38 FILE *fp
; /* Command file */
39 char line
[1024], /* Line from file */
40 *lineptr
; /* Pointer into line */
41 int feedpage
; /* Feed the page */
42 ppd_file_t
*ppd
; /* PPD file */
46 * Check for valid arguments...
49 if (argc
< 6 || argc
> 7)
52 * We don't have the correct number of arguments; write an error message
56 _cupsLangPrintf(stderr
,
57 _("Usage: %s job-id user title copies options [file]"),
63 * Open the PPD file...
66 if ((ppd
= ppdOpenFile(getenv("PPD"))) == NULL
)
68 fputs("ERROR: Unable to open PPD file!\n", stderr
);
73 * Open the command file as needed...
78 if ((fp
= fopen(argv
[6], "r")) == NULL
)
80 perror("ERROR: Unable to open command file - ");
88 * Reset the printer...
91 cupsWritePrintData("\033E", 2);
94 * Read the commands from the file and send the appropriate commands...
99 while (fgets(line
, sizeof(line
), fp
) != NULL
)
102 * Drop trailing newline...
105 lineptr
= line
+ strlen(line
) - 1;
106 if (*lineptr
== '\n')
110 * Skip leading whitespace...
113 for (lineptr
= line
; isspace(*lineptr
); lineptr
++);
116 * Skip comments and blank lines...
119 if (*lineptr
== '#' || !*lineptr
)
123 * Parse the command...
126 if (_cups_strncasecmp(lineptr
, "Clean", 5) == 0 &&
127 (ppd
->model_number
& PCL_INKJET
))
133 cupsWritePrintData("\033&b16WPML \004\000\006\001\004\001\005\001"
134 "\001\004\001\144", 22);
137 fprintf(stderr
, "ERROR: Invalid printer command \"%s\"!\n", lineptr
);
141 * Eject the page as needed...
146 fputs("PAGE: 1 1\n", stderr
);
152 * Reset the printer...
155 cupsWritePrintData("\033E", 2);
158 * Close the command file and return...