]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/ppd.h
Load cups into easysw/current.
[thirdparty/cups.git] / cups / ppd.h
CommitLineData
ef416fc2 1/*
bc44d920 2 * "$Id: ppd.h 6649 2007-07-11 21:46:42Z mike $"
ef416fc2 3 *
4 * PostScript Printer Description definitions for the Common UNIX Printing
5 * System (CUPS).
6 *
bc44d920 7 * Copyright 2007 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
fa73b229 96typedef enum ppd_status_e /**** Status Codes @since CUPS 1.1.19@ ****/
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
ecdc0628 121typedef enum ppd_conform_e /**** Conformance Levels @since CUPS 1.1.19@ ****/
ef416fc2 122{
fa73b229 123 PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
124 PPD_CONFORM_STRICT /* Require strict conformance */
ef416fc2 125} ppd_conform_t;
126
fa73b229 127typedef struct ppd_attr_s /**** PPD Attribute Structure @since CUPS 1.1.19@ ****/
ef416fc2 128{
fa73b229 129 char name[PPD_MAX_NAME]; /* Name of attribute (cupsXYZ) */
130 char spec[PPD_MAX_NAME]; /* Specifier string, if any */
131 char text[PPD_MAX_TEXT]; /* Human-readable text, if any */
132 char *value; /* Value string */
ef416fc2 133} ppd_attr_t;
134
fa73b229 135typedef struct ppd_option_s ppd_option_t;
136 /**** Options ****/
ef416fc2 137
fa73b229 138typedef struct ppd_choice_s /**** Option choices ****/
ef416fc2 139{
fa73b229 140 char marked; /* 0 if not selected, 1 otherwise */
141 char choice[PPD_MAX_NAME]; /* Computer-readable option name */
142 char text[PPD_MAX_TEXT]; /* Human-readable option name */
143 char *code; /* Code to send for this option */
144 ppd_option_t *option; /* Pointer to parent option structure */
ef416fc2 145} ppd_choice_t;
146
fa73b229 147struct ppd_option_s /**** Options ****/
ef416fc2 148{
fa73b229 149 char conflicted; /* 0 if no conflicts exist, 1 otherwise */
150 char keyword[PPD_MAX_NAME]; /* Option keyword name ("PageSize", etc.) */
151 char defchoice[PPD_MAX_NAME];/* Default option choice */
152 char text[PPD_MAX_TEXT]; /* Human-readable text */
153 ppd_ui_t ui; /* Type of UI option */
154 ppd_section_t section; /* Section for command */
155 float order; /* Order number */
156 int num_choices; /* Number of option choices */
157 ppd_choice_t *choices; /* Option choices */
ef416fc2 158};
159
fa73b229 160typedef struct ppd_group_s /**** Groups ****/
ef416fc2 161{
162 /**** Group text strings are limited to 39 chars + nul in order to
163 **** preserve binary compatibility and allow applications to get
164 **** the group's keyword name.
165 ****/
166 char text[PPD_MAX_TEXT - PPD_MAX_NAME];
fa73b229 167 /* Human-readable group name */
168 char name[PPD_MAX_NAME]; /* Group name @since CUPS 1.1.18@ */
169 int num_options; /* Number of options */
170 ppd_option_t *options; /* Options */
171 int num_subgroups; /* Number of sub-groups */
172 struct ppd_group_s *subgroups; /* Sub-groups (max depth = 1) */
ef416fc2 173} ppd_group_t;
174
fa73b229 175typedef struct /**** Constraints ****/
ef416fc2 176{
fa73b229 177 char option1[PPD_MAX_NAME]; /* First keyword */
178 char choice1[PPD_MAX_NAME]; /* First option/choice (blank for all) */
179 char option2[PPD_MAX_NAME]; /* Second keyword */
180 char choice2[PPD_MAX_NAME]; /* Second option/choice (blank for all) */
ef416fc2 181} ppd_const_t;
182
fa73b229 183typedef struct ppd_size_s /**** Page Sizes ****/
ef416fc2 184{
fa73b229 185 int marked; /* Page size selected? */
186 char name[PPD_MAX_NAME]; /* Media size option */
187 float width; /* Width of media in points */
188 float length; /* Length of media in points */
189 float left; /* Left printable margin in points */
190 float bottom; /* Bottom printable margin in points */
191 float right; /* Right printable margin in points */
192 float top; /* Top printable margin in points */
ef416fc2 193} ppd_size_t;
194
fa73b229 195typedef struct ppd_emul_s /**** Emulators ****/
ef416fc2 196{
fa73b229 197 char name[PPD_MAX_NAME]; /* Emulator name */
198 char *start; /* Code to switch to this emulation */
199 char *stop; /* Code to stop this emulation */
ef416fc2 200} ppd_emul_t;
201
fa73b229 202typedef struct ppd_profile_s /**** sRGB Color Profiles ****/
ef416fc2 203{
204 char resolution[PPD_MAX_NAME];
fa73b229 205 /* Resolution or "-" */
ef416fc2 206 char media_type[PPD_MAX_NAME];
fa73b229 207 /* Media type or "-" */
208 float density; /* Ink density to use */
209 float gamma; /* Gamma correction to use */
210 float matrix[3][3]; /* Transform matrix */
ef416fc2 211} ppd_profile_t;
212
213/**** New in CUPS 1.2 ****/
fa73b229 214typedef enum ppd_cptype_e /**** Custom Parameter Type @since CUPS 1.2@ ****/
ef416fc2 215{
fa73b229 216 PPD_CUSTOM_CURVE, /* Curve value for f(x) = x^value */
217 PPD_CUSTOM_INT, /* Integer number value */
218 PPD_CUSTOM_INVCURVE, /* Curve value for f(x) = x^(1/value) */
219 PPD_CUSTOM_PASSCODE, /* String of (hidden) numbers */
220 PPD_CUSTOM_PASSWORD, /* String of (hidden) characters */
221 PPD_CUSTOM_POINTS, /* Measurement value in points */
222 PPD_CUSTOM_REAL, /* Real number value */
223 PPD_CUSTOM_STRING /* String of characters */
224} ppd_cptype_t;
225
b423cd4c 226typedef union ppd_cplimit_u /**** Custom Parameter Limit @since CUPS 1.2@ ****/
227{
228 float custom_curve; /* Gamma value */
229 int custom_int; /* Integer value */
230 float custom_invcurve; /* Gamma value */
231 int custom_passcode; /* Passcode length */
232 int custom_password; /* Password length */
233 float custom_points; /* Measurement value */
234 float custom_real; /* Real value */
235 int custom_string; /* String length */
236} ppd_cplimit_t;
237
fa73b229 238typedef union ppd_cpvalue_u /**** Custom Parameter Value @since CUPS 1.2@ ****/
ef416fc2 239{
fa73b229 240 float custom_curve; /* Gamma value */
241 int custom_int; /* Integer value */
242 float custom_invcurve; /* Gamma value */
243 char *custom_passcode; /* Passcode value */
244 char *custom_password; /* Password value */
245 float custom_points; /* Measurement value */
246 float custom_real; /* Real value */
247 char *custom_string; /* String value */
248} ppd_cpvalue_t;
249
250typedef struct ppd_cparam_s /**** Custom Parameter @since CUPS 1.2@ ****/
ef416fc2 251{
fa73b229 252 char name[PPD_MAX_NAME]; /* Parameter name */
253 char text[PPD_MAX_TEXT]; /* Human-readable text */
254 int order; /* Order (0 to N) */
255 ppd_cptype_t type; /* Parameter type */
b423cd4c 256 ppd_cplimit_t minimum, /* Minimum value */
257 maximum; /* Maximum value */
258 ppd_cpvalue_t current; /* Current value */
fa73b229 259} ppd_cparam_t;
260
261typedef struct ppd_coption_s /**** Custom Option @since CUPS 1.2@ ****/
ef416fc2 262{
fa73b229 263 char keyword[PPD_MAX_NAME]; /* Name of option that is being extended... */
264 ppd_option_t *option; /* Option that is being extended... */
265 int marked; /* Extended option is marked */
266 cups_array_t *params; /* Parameters */
267} ppd_coption_t;
268
269typedef struct ppd_file_s /**** PPD File ****/
ef416fc2 270{
fa73b229 271 int language_level; /* Language level of device */
272 int color_device; /* 1 = color device, 0 = grayscale */
273 int variable_sizes; /* 1 = supports variable sizes, 0 = doesn't */
274 int accurate_screens; /* 1 = supports accurate screens, 0 = not */
275 int contone_only; /* 1 = continuous tone only, 0 = not */
276 int landscape; /* -90 or 90 */
277 int model_number; /* Device-specific model number */
278 int manual_copies; /* 1 = Copies done manually, 0 = hardware */
279 int throughput; /* Pages per minute */
280 ppd_cs_t colorspace; /* Default colorspace */
281 char *patches; /* Patch commands to be sent to printer */
282 int num_emulations; /* Number of emulations supported */
283 ppd_emul_t *emulations; /* Emulations and the code to invoke them */
284 char *jcl_begin; /* Start JCL commands */
285 char *jcl_ps; /* Enter PostScript interpreter */
286 char *jcl_end; /* End JCL commands */
287 char *lang_encoding; /* Language encoding */
288 char *lang_version; /* Language version (English, Spanish, etc.) */
289 char *modelname; /* Model name (general) */
290 char *ttrasterizer; /* Truetype rasterizer */
291 char *manufacturer; /* Manufacturer name */
292 char *product; /* Product name (from PS RIP/interpreter) */
293 char *nickname; /* Nickname (specific) */
294 char *shortnickname; /* Short version of nickname */
295 int num_groups; /* Number of UI groups */
296 ppd_group_t *groups; /* UI groups */
297 int num_sizes; /* Number of page sizes */
298 ppd_size_t *sizes; /* Page sizes */
299 float custom_min[2]; /* Minimum variable page size */
300 float custom_max[2]; /* Maximum variable page size */
301 float custom_margins[4]; /* Margins around page */
302 int num_consts; /* Number of UI/Non-UI constraints */
303 ppd_const_t *consts; /* UI/Non-UI constraints */
304 int num_fonts; /* Number of pre-loaded fonts */
305 char **fonts; /* Pre-loaded fonts */
306 int num_profiles; /* Number of sRGB color profiles */
307 ppd_profile_t *profiles; /* sRGB color profiles */
308 int num_filters; /* Number of filters */
309 char **filters; /* Filter strings... */
ef416fc2 310
311 /**** New in CUPS 1.1 ****/
bc44d920 312 int flip_duplex; /* 1 = Flip page for back sides @deprecated@ */
ef416fc2 313
314 /**** New in CUPS 1.1.19 ****/
fa73b229 315 char *protocols; /* Protocols (BCP, TBCP) string @since CUPS 1.1.19@ */
316 char *pcfilename; /* PCFileName string @since CUPS 1.1.19@ */
bd7854cb 317 int num_attrs; /* Number of attributes @since CUPS 1.1.19@ @private@ */
318 int cur_attr; /* Current attribute @since CUPS 1.1.19@ @private@ */
319 ppd_attr_t **attrs; /* Attributes @since CUPS 1.1.19@ @private@ */
ef416fc2 320
321 /**** New in CUPS 1.2 ****/
bd7854cb 322 cups_array_t *sorted_attrs; /* Attribute lookup array @since CUPS 1.2@ @private@ */
323 cups_array_t *options; /* Option lookup array @since CUPS 1.2@ @private@ */
324 cups_array_t *coptions; /* Custom options array @since CUPS 1.2@ @private@ */
b94498cf 325
326 /**** New in CUPS 1.3 ****/
327 cups_array_t *marked; /* Marked choices @since CUPS 1.3@ @private@ */
ef416fc2 328} ppd_file_t;
329
330
331/*
332 * Prototypes...
333 */
334
335extern void ppdClose(ppd_file_t *ppd);
336extern int ppdCollect(ppd_file_t *ppd, ppd_section_t section,
337 ppd_choice_t ***choices);
338extern int ppdConflicts(ppd_file_t *ppd);
339extern int ppdEmit(ppd_file_t *ppd, FILE *fp,
340 ppd_section_t section);
341extern int ppdEmitFd(ppd_file_t *ppd, int fd,
342 ppd_section_t section);
343extern int ppdEmitJCL(ppd_file_t *ppd, FILE *fp, int job_id,
344 const char *user, const char *title);
345extern ppd_choice_t *ppdFindChoice(ppd_option_t *o, const char *option);
346extern ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword);
347extern ppd_option_t *ppdFindOption(ppd_file_t *ppd, const char *keyword);
348extern int ppdIsMarked(ppd_file_t *ppd, const char *keyword,
349 const char *option);
350extern void ppdMarkDefaults(ppd_file_t *ppd);
351extern int ppdMarkOption(ppd_file_t *ppd, const char *keyword,
352 const char *option);
353extern ppd_file_t *ppdOpen(FILE *fp);
354extern ppd_file_t *ppdOpenFd(int fd);
355extern ppd_file_t *ppdOpenFile(const char *filename);
356extern float ppdPageLength(ppd_file_t *ppd, const char *name);
357extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name);
358extern float ppdPageWidth(ppd_file_t *ppd, const char *name);
359
360/**** New in CUPS 1.1.19 ****/
361extern const char *ppdErrorString(ppd_status_t status);
362extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
363 const char *spec);
364extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
365 const char *spec);
366extern ppd_status_t ppdLastError(int *line);
367
368/**** New in CUPS 1.1.20 ****/
369extern void ppdSetConformance(ppd_conform_t c);
370
371/**** New in CUPS 1.2 ****/
fa73b229 372extern int ppdCollect2(ppd_file_t *ppd, ppd_section_t section,
373 float min_order, ppd_choice_t ***choices);
374extern int ppdEmitAfterOrder(ppd_file_t *ppd, FILE *fp,
375 ppd_section_t section, int limit,
376 float min_order);
ef416fc2 377extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp);
757d2cad 378extern char *ppdEmitString(ppd_file_t *ppd, ppd_section_t section,
379 float min_order);
fa73b229 380extern ppd_coption_t *ppdFindCustomOption(ppd_file_t *ppd,
381 const char *keyword);
382extern ppd_cparam_t *ppdFindCustomParam(ppd_coption_t *opt,
383 const char *name);
384extern ppd_cparam_t *ppdFirstCustomParam(ppd_coption_t *opt);
bd7854cb 385extern ppd_option_t *ppdFirstOption(ppd_file_t *ppd);
fa73b229 386extern ppd_cparam_t *ppdNextCustomParam(ppd_coption_t *opt);
bd7854cb 387extern ppd_option_t *ppdNextOption(ppd_file_t *ppd);
fa73b229 388extern int ppdLocalize(ppd_file_t *ppd);
ef416fc2 389extern ppd_file_t *ppdOpen2(cups_file_t *fp);
390
bc44d920 391/**** New in CUPS 1.3 ****/
392extern const char *ppdLocalizeIPPReason(ppd_file_t *ppd,
393 const char *reason,
394 const char *scheme,
395 char *buffer, size_t bufsize);
396
ef416fc2 397
398/*
399 * C++ magic...
400 */
401
402# ifdef __cplusplus
403}
404# endif /* __cplusplus */
405#endif /* !_CUPS_PPD_H_ */
406
407/*
bc44d920 408 * End of "$Id: ppd.h 6649 2007-07-11 21:46:42Z mike $".
ef416fc2 409 */