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