]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/commandtopclx.c
4 * Advanced PCL command filter for CUPS.
6 * Copyright 2007 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.h>
27 #include <cups/string.h>
32 * 'main()' - Main entry and processing of driver.
35 int /* O - Exit status */
36 main(int argc
, /* I - Number of command-line arguments */
37 char *argv
[]) /* I - Command-line arguments */
39 FILE *fp
; /* Command file */
40 char line
[1024], /* Line from file */
41 *lineptr
; /* Pointer into line */
42 int feedpage
; /* Feed the page */
43 ppd_file_t
*ppd
; /* PPD file */
47 * Check for valid arguments...
50 if (argc
< 6 || argc
> 7)
53 * We don't have the correct number of arguments; write an error message
57 fputs("ERROR: commandtopclx job-id user title copies options [file]\n", stderr
);
62 * Open the PPD file...
65 if ((ppd
= ppdOpenFile(getenv("PPD"))) == NULL
)
67 fputs("ERROR: Unable to open PPD file!\n", stderr
);
72 * Open the command file as needed...
77 if ((fp
= fopen(argv
[6], "r")) == NULL
)
79 perror("ERROR: Unable to open command file - ");
87 * Reset the printer...
90 cupsWritePrintData("\033E", 2);
93 * Read the commands from the file and send the appropriate commands...
98 while (fgets(line
, sizeof(line
), fp
) != NULL
)
101 * Drop trailing newline...
104 lineptr
= line
+ strlen(line
) - 1;
105 if (*lineptr
== '\n')
109 * Skip leading whitespace...
112 for (lineptr
= line
; isspace(*lineptr
); lineptr
++);
115 * Skip comments and blank lines...
118 if (*lineptr
== '#' || !*lineptr
)
122 * Parse the command...
125 if (strncasecmp(lineptr
, "Clean", 5) == 0 &&
126 (ppd
->model_number
& PCL_INKJET
))
132 cupsWritePrintData("\033&b16WPML \004\000\006\001\004\001\005\001"
133 "\001\004\001\144", 22);
136 fprintf(stderr
, "ERROR: Invalid printer command \"%s\"!\n", lineptr
);
140 * Eject the page as needed...
145 fputs("PAGE: 1 1\n", stderr
);
151 * Reset the printer...
154 cupsWritePrintData("\033E", 2);
157 * Close the command file and return...