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