]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/ppd.h
Load cups into easysw/current.
[thirdparty/cups.git] / cups / ppd.h
1 /*
2 * "$Id: ppd.h 6477 2007-04-25 19:55:45Z mike $"
3 *
4 * PostScript Printer Description definitions for the Common UNIX Printing
5 * System (CUPS).
6 *
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Easy Software Products and are protected by Federal
11 * copyright law. Distribution and use rights are outlined in the file
12 * "LICENSE.txt" which should have been included with this file. If this
13 * file is missing or damaged please contact Easy Software Products
14 * at:
15 *
16 * Attn: CUPS Licensing Information
17 * Easy Software Products
18 * 44141 Airport View Drive, Suite 204
19 * Hollywood, Maryland 20636 USA
20 *
21 * Voice: (301) 373-9600
22 * EMail: cups-info@cups.org
23 * WWW: http://www.cups.org
24 *
25 * PostScript is a trademark of Adobe Systems, Inc.
26 *
27 * This code and any derivative of it may be used and distributed
28 * freely under the terms of the GNU General Public License when
29 * used with GNU Ghostscript or its derivatives. Use of the code
30 * (or any derivative of it) with software other than GNU
31 * GhostScript (or its derivatives) is governed by the CUPS license
32 * agreement.
33 *
34 * This file is subject to the Apple OS-Developed Software exception.
35 */
36
37 #ifndef _CUPS_PPD_H_
38 # define _CUPS_PPD_H_
39
40 /*
41 * Include necessary headers...
42 */
43
44 # include <stdio.h>
45 # include "array.h"
46 # include "file.h"
47
48
49 /*
50 * C++ magic...
51 */
52
53 # ifdef __cplusplus
54 extern "C" {
55 # endif /* __cplusplus */
56
57
58 /*
59 * PPD version...
60 */
61
62 # define PPD_VERSION 4.3 /* Kept in sync with Adobe version number */
63
64
65 /*
66 * PPD size limits (defined in Adobe spec)
67 */
68
69 # define PPD_MAX_NAME 41 /* Maximum size of name + 1 for nul */
70 # define PPD_MAX_TEXT 81 /* Maximum size of text + 1 for nul */
71 # define PPD_MAX_LINE 256 /* Maximum size of line + 1 for nul */
72
73
74 /*
75 * Types and structures...
76 */
77
78 typedef enum ppd_ui_e /**** UI Types ****/
79 {
80 PPD_UI_BOOLEAN, /* True or False option */
81 PPD_UI_PICKONE, /* Pick one from a list */
82 PPD_UI_PICKMANY /* Pick zero or more from a list */
83 } ppd_ui_t;
84
85 typedef enum ppd_section_e /**** Order dependency sections ****/
86 {
87 PPD_ORDER_ANY, /* Option code can be anywhere in the file */
88 PPD_ORDER_DOCUMENT, /* ... must be in the DocumentSetup section */
89 PPD_ORDER_EXIT, /* ... must be sent prior to the document */
90 PPD_ORDER_JCL, /* ... must be sent as a JCL command */
91 PPD_ORDER_PAGE, /* ... must be in the PageSetup section */
92 PPD_ORDER_PROLOG /* ... must be in the Prolog section */
93 } ppd_section_t;
94
95 typedef enum ppd_cs_e /**** Colorspaces ****/
96 {
97 PPD_CS_CMYK = -4, /* CMYK colorspace */
98 PPD_CS_CMY, /* CMY colorspace */
99 PPD_CS_GRAY = 1, /* Grayscale colorspace */
100 PPD_CS_RGB = 3, /* RGB colorspace */
101 PPD_CS_RGBK, /* RGBK (K = gray) colorspace */
102 PPD_CS_N /* DeviceN colorspace */
103 } ppd_cs_t;
104
105 typedef enum ppd_status_e /**** Status Codes @since CUPS 1.1.19@ ****/
106 {
107 PPD_OK = 0, /* OK */
108 PPD_FILE_OPEN_ERROR, /* Unable to open PPD file */
109 PPD_NULL_FILE, /* NULL PPD file pointer */
110 PPD_ALLOC_ERROR, /* Memory allocation error */
111 PPD_MISSING_PPDADOBE4, /* Missing PPD-Adobe-4.x header */
112 PPD_MISSING_VALUE, /* Missing value string */
113 PPD_INTERNAL_ERROR, /* Internal error */
114 PPD_BAD_OPEN_GROUP, /* Bad OpenGroup */
115 PPD_NESTED_OPEN_GROUP, /* OpenGroup without a CloseGroup first */
116 PPD_BAD_OPEN_UI, /* Bad OpenUI/JCLOpenUI */
117 PPD_NESTED_OPEN_UI, /* OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first */
118 PPD_BAD_ORDER_DEPENDENCY, /* Bad OrderDependency */
119 PPD_BAD_UI_CONSTRAINTS, /* Bad UIConstraints */
120 PPD_MISSING_ASTERISK, /* Missing asterisk in column 0 */
121 PPD_LINE_TOO_LONG, /* Line longer than 255 chars */
122 PPD_ILLEGAL_CHARACTER, /* Illegal control character */
123 PPD_ILLEGAL_MAIN_KEYWORD, /* Illegal main keyword string */
124 PPD_ILLEGAL_OPTION_KEYWORD, /* Illegal option keyword string */
125 PPD_ILLEGAL_TRANSLATION, /* Illegal translation string */
126 PPD_ILLEGAL_WHITESPACE, /* Illegal whitespace character */
127 PPD_BAD_CUSTOM_PARAM /* Bad custom parameter */
128 } ppd_status_t;
129
130 typedef enum ppd_conform_e /**** Conformance Levels @since CUPS 1.1.19@ ****/
131 {
132 PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
133 PPD_CONFORM_STRICT /* Require strict conformance */
134 } ppd_conform_t;
135
136 typedef struct ppd_attr_s /**** PPD Attribute Structure @since CUPS 1.1.19@ ****/
137 {
138 char name[PPD_MAX_NAME]; /* Name of attribute (cupsXYZ) */
139 char spec[PPD_MAX_NAME]; /* Specifier string, if any */
140 char text[PPD_MAX_TEXT]; /* Human-readable text, if any */
141 char *value; /* Value string */
142 } ppd_attr_t;
143
144 typedef struct ppd_option_s ppd_option_t;
145 /**** Options ****/
146
147 typedef struct ppd_choice_s /**** Option choices ****/
148 {
149 char marked; /* 0 if not selected, 1 otherwise */
150 char choice[PPD_MAX_NAME]; /* Computer-readable option name */
151 char text[PPD_MAX_TEXT]; /* Human-readable option name */
152 char *code; /* Code to send for this option */
153 ppd_option_t *option; /* Pointer to parent option structure */
154 } ppd_choice_t;
155
156 struct ppd_option_s /**** Options ****/
157 {
158 char conflicted; /* 0 if no conflicts exist, 1 otherwise */
159 char keyword[PPD_MAX_NAME]; /* Option keyword name ("PageSize", etc.) */
160 char defchoice[PPD_MAX_NAME];/* Default option choice */
161 char text[PPD_MAX_TEXT]; /* Human-readable text */
162 ppd_ui_t ui; /* Type of UI option */
163 ppd_section_t section; /* Section for command */
164 float order; /* Order number */
165 int num_choices; /* Number of option choices */
166 ppd_choice_t *choices; /* Option choices */
167 };
168
169 typedef struct ppd_group_s /**** Groups ****/
170 {
171 /**** Group text strings are limited to 39 chars + nul in order to
172 **** preserve binary compatibility and allow applications to get
173 **** the group's keyword name.
174 ****/
175 char text[PPD_MAX_TEXT - PPD_MAX_NAME];
176 /* Human-readable group name */
177 char name[PPD_MAX_NAME]; /* Group name @since CUPS 1.1.18@ */
178 int num_options; /* Number of options */
179 ppd_option_t *options; /* Options */
180 int num_subgroups; /* Number of sub-groups */
181 struct ppd_group_s *subgroups; /* Sub-groups (max depth = 1) */
182 } ppd_group_t;
183
184 typedef struct /**** Constraints ****/
185 {
186 char option1[PPD_MAX_NAME]; /* First keyword */
187 char choice1[PPD_MAX_NAME]; /* First option/choice (blank for all) */
188 char option2[PPD_MAX_NAME]; /* Second keyword */
189 char choice2[PPD_MAX_NAME]; /* Second option/choice (blank for all) */
190 } ppd_const_t;
191
192 typedef struct ppd_size_s /**** Page Sizes ****/
193 {
194 int marked; /* Page size selected? */
195 char name[PPD_MAX_NAME]; /* Media size option */
196 float width; /* Width of media in points */
197 float length; /* Length of media in points */
198 float left; /* Left printable margin in points */
199 float bottom; /* Bottom printable margin in points */
200 float right; /* Right printable margin in points */
201 float top; /* Top printable margin in points */
202 } ppd_size_t;
203
204 typedef struct ppd_emul_s /**** Emulators ****/
205 {
206 char name[PPD_MAX_NAME]; /* Emulator name */
207 char *start; /* Code to switch to this emulation */
208 char *stop; /* Code to stop this emulation */
209 } ppd_emul_t;
210
211 typedef struct ppd_profile_s /**** sRGB Color Profiles ****/
212 {
213 char resolution[PPD_MAX_NAME];
214 /* Resolution or "-" */
215 char media_type[PPD_MAX_NAME];
216 /* Media type or "-" */
217 float density; /* Ink density to use */
218 float gamma; /* Gamma correction to use */
219 float matrix[3][3]; /* Transform matrix */
220 } ppd_profile_t;
221
222 /**** New in CUPS 1.2 ****/
223 typedef enum ppd_cptype_e /**** Custom Parameter Type @since CUPS 1.2@ ****/
224 {
225 PPD_CUSTOM_CURVE, /* Curve value for f(x) = x^value */
226 PPD_CUSTOM_INT, /* Integer number value */
227 PPD_CUSTOM_INVCURVE, /* Curve value for f(x) = x^(1/value) */
228 PPD_CUSTOM_PASSCODE, /* String of (hidden) numbers */
229 PPD_CUSTOM_PASSWORD, /* String of (hidden) characters */
230 PPD_CUSTOM_POINTS, /* Measurement value in points */
231 PPD_CUSTOM_REAL, /* Real number value */
232 PPD_CUSTOM_STRING /* String of characters */
233 } ppd_cptype_t;
234
235 typedef union ppd_cplimit_u /**** Custom Parameter Limit @since CUPS 1.2@ ****/
236 {
237 float custom_curve; /* Gamma value */
238 int custom_int; /* Integer value */
239 float custom_invcurve; /* Gamma value */
240 int custom_passcode; /* Passcode length */
241 int custom_password; /* Password length */
242 float custom_points; /* Measurement value */
243 float custom_real; /* Real value */
244 int custom_string; /* String length */
245 } ppd_cplimit_t;
246
247 typedef union ppd_cpvalue_u /**** Custom Parameter Value @since CUPS 1.2@ ****/
248 {
249 float custom_curve; /* Gamma value */
250 int custom_int; /* Integer value */
251 float custom_invcurve; /* Gamma value */
252 char *custom_passcode; /* Passcode value */
253 char *custom_password; /* Password value */
254 float custom_points; /* Measurement value */
255 float custom_real; /* Real value */
256 char *custom_string; /* String value */
257 } ppd_cpvalue_t;
258
259 typedef struct ppd_cparam_s /**** Custom Parameter @since CUPS 1.2@ ****/
260 {
261 char name[PPD_MAX_NAME]; /* Parameter name */
262 char text[PPD_MAX_TEXT]; /* Human-readable text */
263 int order; /* Order (0 to N) */
264 ppd_cptype_t type; /* Parameter type */
265 ppd_cplimit_t minimum, /* Minimum value */
266 maximum; /* Maximum value */
267 ppd_cpvalue_t current; /* Current value */
268 } ppd_cparam_t;
269
270 typedef struct ppd_coption_s /**** Custom Option @since CUPS 1.2@ ****/
271 {
272 char keyword[PPD_MAX_NAME]; /* Name of option that is being extended... */
273 ppd_option_t *option; /* Option that is being extended... */
274 int marked; /* Extended option is marked */
275 cups_array_t *params; /* Parameters */
276 } ppd_coption_t;
277
278 typedef struct ppd_file_s /**** PPD File ****/
279 {
280 int language_level; /* Language level of device */
281 int color_device; /* 1 = color device, 0 = grayscale */
282 int variable_sizes; /* 1 = supports variable sizes, 0 = doesn't */
283 int accurate_screens; /* 1 = supports accurate screens, 0 = not */
284 int contone_only; /* 1 = continuous tone only, 0 = not */
285 int landscape; /* -90 or 90 */
286 int model_number; /* Device-specific model number */
287 int manual_copies; /* 1 = Copies done manually, 0 = hardware */
288 int throughput; /* Pages per minute */
289 ppd_cs_t colorspace; /* Default colorspace */
290 char *patches; /* Patch commands to be sent to printer */
291 int num_emulations; /* Number of emulations supported */
292 ppd_emul_t *emulations; /* Emulations and the code to invoke them */
293 char *jcl_begin; /* Start JCL commands */
294 char *jcl_ps; /* Enter PostScript interpreter */
295 char *jcl_end; /* End JCL commands */
296 char *lang_encoding; /* Language encoding */
297 char *lang_version; /* Language version (English, Spanish, etc.) */
298 char *modelname; /* Model name (general) */
299 char *ttrasterizer; /* Truetype rasterizer */
300 char *manufacturer; /* Manufacturer name */
301 char *product; /* Product name (from PS RIP/interpreter) */
302 char *nickname; /* Nickname (specific) */
303 char *shortnickname; /* Short version of nickname */
304 int num_groups; /* Number of UI groups */
305 ppd_group_t *groups; /* UI groups */
306 int num_sizes; /* Number of page sizes */
307 ppd_size_t *sizes; /* Page sizes */
308 float custom_min[2]; /* Minimum variable page size */
309 float custom_max[2]; /* Maximum variable page size */
310 float custom_margins[4]; /* Margins around page */
311 int num_consts; /* Number of UI/Non-UI constraints */
312 ppd_const_t *consts; /* UI/Non-UI constraints */
313 int num_fonts; /* Number of pre-loaded fonts */
314 char **fonts; /* Pre-loaded fonts */
315 int num_profiles; /* Number of sRGB color profiles */
316 ppd_profile_t *profiles; /* sRGB color profiles */
317 int num_filters; /* Number of filters */
318 char **filters; /* Filter strings... */
319
320 /**** New in CUPS 1.1 ****/
321 int flip_duplex; /* 1 = Flip page for back sides @since CUPS 1.1@ */
322
323 /**** New in CUPS 1.1.19 ****/
324 char *protocols; /* Protocols (BCP, TBCP) string @since CUPS 1.1.19@ */
325 char *pcfilename; /* PCFileName string @since CUPS 1.1.19@ */
326 int num_attrs; /* Number of attributes @since CUPS 1.1.19@ @private@ */
327 int cur_attr; /* Current attribute @since CUPS 1.1.19@ @private@ */
328 ppd_attr_t **attrs; /* Attributes @since CUPS 1.1.19@ @private@ */
329
330 /**** New in CUPS 1.2 ****/
331 cups_array_t *sorted_attrs; /* Attribute lookup array @since CUPS 1.2@ @private@ */
332 cups_array_t *options; /* Option lookup array @since CUPS 1.2@ @private@ */
333 cups_array_t *coptions; /* Custom options array @since CUPS 1.2@ @private@ */
334
335 /**** New in CUPS 1.3 ****/
336 cups_array_t *marked; /* Marked choices @since CUPS 1.3@ @private@ */
337 } ppd_file_t;
338
339
340 /*
341 * Prototypes...
342 */
343
344 extern void ppdClose(ppd_file_t *ppd);
345 extern int ppdCollect(ppd_file_t *ppd, ppd_section_t section,
346 ppd_choice_t ***choices);
347 extern int ppdConflicts(ppd_file_t *ppd);
348 extern int ppdEmit(ppd_file_t *ppd, FILE *fp,
349 ppd_section_t section);
350 extern int ppdEmitFd(ppd_file_t *ppd, int fd,
351 ppd_section_t section);
352 extern int ppdEmitJCL(ppd_file_t *ppd, FILE *fp, int job_id,
353 const char *user, const char *title);
354 extern ppd_choice_t *ppdFindChoice(ppd_option_t *o, const char *option);
355 extern ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword);
356 extern ppd_option_t *ppdFindOption(ppd_file_t *ppd, const char *keyword);
357 extern int ppdIsMarked(ppd_file_t *ppd, const char *keyword,
358 const char *option);
359 extern void ppdMarkDefaults(ppd_file_t *ppd);
360 extern int ppdMarkOption(ppd_file_t *ppd, const char *keyword,
361 const char *option);
362 extern ppd_file_t *ppdOpen(FILE *fp);
363 extern ppd_file_t *ppdOpenFd(int fd);
364 extern ppd_file_t *ppdOpenFile(const char *filename);
365 extern float ppdPageLength(ppd_file_t *ppd, const char *name);
366 extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name);
367 extern float ppdPageWidth(ppd_file_t *ppd, const char *name);
368
369 /**** New in CUPS 1.1.19 ****/
370 extern const char *ppdErrorString(ppd_status_t status);
371 extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
372 const char *spec);
373 extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
374 const char *spec);
375 extern ppd_status_t ppdLastError(int *line);
376
377 /**** New in CUPS 1.1.20 ****/
378 extern void ppdSetConformance(ppd_conform_t c);
379
380 /**** New in CUPS 1.2 ****/
381 extern int ppdCollect2(ppd_file_t *ppd, ppd_section_t section,
382 float min_order, ppd_choice_t ***choices);
383 extern int ppdEmitAfterOrder(ppd_file_t *ppd, FILE *fp,
384 ppd_section_t section, int limit,
385 float min_order);
386 extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp);
387 extern char *ppdEmitString(ppd_file_t *ppd, ppd_section_t section,
388 float min_order);
389 extern ppd_coption_t *ppdFindCustomOption(ppd_file_t *ppd,
390 const char *keyword);
391 extern ppd_cparam_t *ppdFindCustomParam(ppd_coption_t *opt,
392 const char *name);
393 extern ppd_cparam_t *ppdFirstCustomParam(ppd_coption_t *opt);
394 extern ppd_option_t *ppdFirstOption(ppd_file_t *ppd);
395 extern ppd_cparam_t *ppdNextCustomParam(ppd_coption_t *opt);
396 extern ppd_option_t *ppdNextOption(ppd_file_t *ppd);
397 extern int ppdLocalize(ppd_file_t *ppd);
398 extern ppd_file_t *ppdOpen2(cups_file_t *fp);
399
400
401 /*
402 * C++ magic...
403 */
404
405 # ifdef __cplusplus
406 }
407 # endif /* __cplusplus */
408 #endif /* !_CUPS_PPD_H_ */
409
410 /*
411 * End of "$Id: ppd.h 6477 2007-04-25 19:55:45Z mike $".
412 */