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