]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/pcl-common.c
4 * Common PCL functions 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/".
17 * pcl_set_media_size() - Set media size using the page size command.
18 * pjl_write() - Write a PJL command string, performing
19 * substitutions as needed.
23 * Include necessary headers...
27 #include "pcl-common.h"
32 * 'pcl_set_media_size()' - Set media size using the page size command.
36 pcl_set_media_size(ppd_file_t
*ppd
, /* I - PPD file */
37 float width
, /* I - Width of page */
38 float length
) /* I - Length of page */
42 printf("\033&l0O"); /* Set portrait orientation */
44 if (ppd
->model_number
& PCL_PAPER_SIZE
)
45 switch ((int)(length
+ 0.5f
))
47 case 419 : /* Postcard */
48 printf("\033&l71A"); /* Set page size */
51 case 540 : /* Monarch Envelope */
52 printf("\033&l80A"); /* Set page size */
55 case 567 : /* Double Postcard */
56 printf("\033&l72A"); /* Set page size */
60 printf("\033&l25A"); /* Set page size */
63 case 612 : /* Statement */
64 printf("\033&l5A"); /* Set page size */
67 case 624 : /* DL Envelope */
68 printf("\033&l90A"); /* Set page size */
71 case 649 : /* C5 Envelope */
72 printf("\033&l91A"); /* Set page size */
75 case 684 : /* COM-10 Envelope */
76 printf("\033&l81A"); /* Set page size */
79 case 709 : /* B5 Envelope */
80 printf("\033&l100A"); /* Set page size */
84 printf("\033&l45A"); /* Set page size */
87 case 756 : /* Executive */
88 printf("\033&l1A"); /* Set page size */
91 case 792 : /* Letter */
92 printf("\033&l2A"); /* Set page size */
96 printf("\033&l26A"); /* Set page size */
99 case 936 : /* Foolscap */
100 printf("\033&l23A"); /* Set page size */
103 case 1008 : /* Legal */
104 printf("\033&l3A"); /* Set page size */
108 printf("\033&l46A"); /* Set page size */
112 printf("\033&l27A"); /* Set page size */
115 case 1224 : /* Tabloid */
116 printf("\033&l6A"); /* Set page size */
120 printf("\033&l101A"); /* Set page size */
121 printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */
122 printf("\033&l%.2fP", length
/ 12.0);
123 /* Set page length */
124 printf("\033&l%.0fF", length
/ 12.0);
125 /* Set text length to page */
130 printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */
131 printf("\033&l%.2fP", length
/ 12.0);
132 /* Set page length */
133 printf("\033&l%.0fF", length
/ 12.0);
134 /* Set text length to page */
137 printf("\033&l0L"); /* Turn off perforation skip */
138 printf("\033&l0E"); /* Reset top margin to 0 */
143 * 'pjl_write()' - Write a PJL command string, performing substitutions as needed.
147 pjl_write(ppd_file_t
*ppd
, /* I - PPD file */
148 const char *format
, /* I - Format string */
149 const char *value
, /* I - Value for %s */
150 int job_id
, /* I - Job ID */
151 const char *user
, /* I - Username */
152 const char *title
, /* I - Title */
153 int num_options
, /* I - Number of options */
154 cups_option_t
*options
) /* I - Options */
156 const char *optval
; /* Option value */
157 char match
[255], /* Match string */
158 *mptr
; /* Pointer into match string */
169 * Perform substitution...
175 case 'b' : /* job-billing */
176 if ((optval
= cupsGetOption("job-billing", num_options
,
178 fputs(optval
, stdout
);
181 case 'h' : /* job-originating-host-name */
182 if ((optval
= cupsGetOption("job-originating-host-name",
183 num_options
, options
)) != NULL
)
184 fputs(optval
, stdout
);
187 case 'j' : /* job-id */
188 printf("%d", job_id
);
191 case 'n' : /* CR + LF */
196 case 'q' : /* double quote (") */
200 case 's' : /* "value" */
202 fputs(value
, stdout
);
205 case 't' : /* job-name */
206 fputs(title
, stdout
);
209 case 'u' : /* job-originating-user-name */
213 case '?' : /* ?value:string; */
215 * Get the match value...
218 for (format
++, mptr
= match
; *format
&& *format
!= ':'; format
++)
219 if (mptr
< (match
+ sizeof(match
) - 1))
226 * See if we have a match...
232 if (!value
|| strcmp(match
, value
))
235 * Value doesn't match; skip the string that follows...
238 while (*format
&& *format
!= ';')
244 * Value matches; copy the string that follows...
247 while (*format
&& *format
!= ';')
255 default : /* Anything else */
257 case '%' : /* %% = single % */