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