]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/ppd.h
Load cups into easysw/current.
[thirdparty/cups.git] / cups / ppd.h
1 /*
2 * "$Id: ppd.h 4785 2005-10-13 19:39:05Z mike $"
3 *
4 * PostScript Printer Description definitions for the Common UNIX Printing
5 * System (CUPS).
6 *
7 * Copyright 1997-2005 by Easy Software Products, all rights reserved.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Easy Software Products and are protected by Federal
11 * copyright law. Distribution and use rights are outlined in the file
12 * "LICENSE.txt" which should have been included with this file. If this
13 * file is missing or damaged please contact Easy Software Products
14 * at:
15 *
16 * Attn: CUPS Licensing Information
17 * Easy Software Products
18 * 44141 Airport View Drive, Suite 204
19 * Hollywood, Maryland 20636 USA
20 *
21 * Voice: (301) 373-9600
22 * EMail: cups-info@cups.org
23 * WWW: http://www.cups.org
24 *
25 * PostScript is a trademark of Adobe Systems, Inc.
26 *
27 * This code and any derivative of it may be used and distributed
28 * freely under the terms of the GNU General Public License when
29 * used with GNU Ghostscript or its derivatives. Use of the code
30 * (or any derivative of it) with software other than GNU
31 * GhostScript (or its derivatives) is governed by the CUPS license
32 * agreement.
33 *
34 * This file is subject to the Apple OS-Developed Software exception.
35 */
36
37 #ifndef _CUPS_PPD_H_
38 # define _CUPS_PPD_H_
39
40 /*
41 * Include necessary headers...
42 */
43
44 # include <stdio.h>
45 # include "file.h"
46
47
48 /*
49 * C++ magic...
50 */
51
52 # ifdef __cplusplus
53 extern "C" {
54 # endif /* __cplusplus */
55
56
57 /*
58 * PPD version...
59 */
60
61 # define PPD_VERSION 4.3 /* Kept in sync with Adobe version number */
62
63
64 /*
65 * PPD size limits (defined in Adobe spec)
66 */
67
68 # define PPD_MAX_NAME 41 /* Maximum size of name + 1 for nul */
69 # define PPD_MAX_TEXT 81 /* Maximum size of text + 1 for nul */
70 # define PPD_MAX_LINE 256 /* Maximum size of line + 1 for nul */
71
72
73 /*
74 * Types and structures...
75 */
76
77 typedef enum ppd_ui_e /**** UI Types ****/
78 {
79 PPD_UI_BOOLEAN, /* True or False option */
80 PPD_UI_PICKONE, /* Pick one from a list */
81 PPD_UI_PICKMANY /* Pick zero or more from a list */
82 } ppd_ui_t;
83
84 typedef enum ppd_section_e /**** Order dependency sections ****/
85 {
86 PPD_ORDER_ANY, /* Option code can be anywhere in the file */
87 PPD_ORDER_DOCUMENT, /* ... must be in the DocumentSetup section */
88 PPD_ORDER_EXIT, /* ... must be sent prior to the document */
89 PPD_ORDER_JCL, /* ... must be sent as a JCL command */
90 PPD_ORDER_PAGE, /* ... must be in the PageSetup section */
91 PPD_ORDER_PROLOG /* ... must be in the Prolog section */
92 } ppd_section_t;
93
94 typedef enum ppd_cs_e /**** Colorspaces ****/
95 {
96 PPD_CS_CMYK = -4, /* CMYK colorspace */
97 PPD_CS_CMY, /* CMY colorspace */
98 PPD_CS_GRAY = 1, /* Grayscale colorspace */
99 PPD_CS_RGB = 3, /* RGB colorspace */
100 PPD_CS_RGBK, /* RGBK (K = gray) colorspace */
101 PPD_CS_N /* DeviceN colorspace */
102 } ppd_cs_t;
103
104 typedef enum ppd_status_e /**** Status Codes @since CUPS 1.1.19@ ****/
105 {
106 PPD_OK = 0, /* OK */
107 PPD_FILE_OPEN_ERROR, /* Unable to open PPD file */
108 PPD_NULL_FILE, /* NULL PPD file pointer */
109 PPD_ALLOC_ERROR, /* Memory allocation error */
110 PPD_MISSING_PPDADOBE4, /* Missing PPD-Adobe-4.x header */
111 PPD_MISSING_VALUE, /* Missing value string */
112 PPD_INTERNAL_ERROR, /* Internal error */
113 PPD_BAD_OPEN_GROUP, /* Bad OpenGroup */
114 PPD_NESTED_OPEN_GROUP, /* OpenGroup without a CloseGroup first */
115 PPD_BAD_OPEN_UI, /* Bad OpenUI/JCLOpenUI */
116 PPD_NESTED_OPEN_UI, /* OpenUI/JCLOpenUI without a CloseUI/JCLCloseUI first */
117 PPD_BAD_ORDER_DEPENDENCY, /* Bad OrderDependency */
118 PPD_BAD_UI_CONSTRAINTS, /* Bad UIConstraints */
119 PPD_MISSING_ASTERISK, /* Missing asterisk in column 0 */
120 PPD_LINE_TOO_LONG, /* Line longer than 255 chars */
121 PPD_ILLEGAL_CHARACTER, /* Illegal control character */
122 PPD_ILLEGAL_MAIN_KEYWORD, /* Illegal main keyword string */
123 PPD_ILLEGAL_OPTION_KEYWORD, /* Illegal option keyword string */
124 PPD_ILLEGAL_TRANSLATION, /* Illegal translation string */
125 PPD_ILLEGAL_WHITESPACE /* Illegal whitespace character */
126 } ppd_status_t;
127
128 typedef enum ppd_conform_e /**** Conformance Levels ****/
129 {
130 PPD_CONFORM_RELAXED, /* Relax whitespace and control char */
131 PPD_CONFORM_STRICT /* Require strict conformance */
132 } ppd_conform_t;
133
134 typedef struct ppd_attr_str /**** PPD Attribute Structure @since CUPS 1.1.19@ ****/
135 {
136 char name[PPD_MAX_NAME];
137 /* Name of attribute (cupsXYZ) */
138 char spec[PPD_MAX_NAME];
139 /* Specifier string, if any */
140 char text[PPD_MAX_TEXT];
141 /* Human-readable text, if any */
142 char *value; /* Value string */
143 } ppd_attr_t;
144
145 typedef struct ppd_option_str ppd_option_t;
146 /**** Options ****/
147
148 typedef struct ppd_choice_str /**** Option choices ****/
149 {
150 char marked; /* 0 if not selected, 1 otherwise */
151 char choice[PPD_MAX_NAME];
152 /* Computer-readable option name */
153 char text[PPD_MAX_TEXT];
154 /* Human-readable option name */
155 char *code; /* Code to send for this option */
156 ppd_option_t *option; /* Pointer to parent option structure */
157 } ppd_choice_t;
158
159 struct ppd_option_str /**** Options ****/
160 {
161 char conflicted; /* 0 if no conflicts exist, 1 otherwise */
162 char keyword[PPD_MAX_NAME];
163 /* Option keyword name ("PageSize", etc.) */
164 char defchoice[PPD_MAX_NAME];
165 /* Default option choice */
166 char text[PPD_MAX_TEXT];
167 /* Human-readable text */
168 ppd_ui_t ui; /* Type of UI option */
169 ppd_section_t section; /* Section for command */
170 float order; /* Order number */
171 int num_choices; /* Number of option choices */
172 ppd_choice_t *choices; /* Option choices */
173 };
174
175 typedef struct ppd_group_str /**** Groups ****/
176 {
177 /**** Group text strings are limited to 39 chars + nul in order to
178 **** preserve binary compatibility and allow applications to get
179 **** the group's keyword name.
180 ****/
181 char text[PPD_MAX_TEXT - PPD_MAX_NAME];
182 /* Human-readable group name */
183 char name[PPD_MAX_NAME];
184 /* Group name @since CUPS 1.1.18@ */
185 int num_options; /* Number of options */
186 ppd_option_t *options; /* Options */
187 int num_subgroups; /* Number of sub-groups */
188 struct ppd_group_str *subgroups;
189 /* Sub-groups (max depth = 1) */
190 } ppd_group_t;
191
192 typedef struct /**** Constraints ****/
193 {
194 char option1[PPD_MAX_NAME];
195 /* First keyword */
196 char choice1[PPD_MAX_NAME];
197 /* First option/choice (blank for all) */
198 char option2[PPD_MAX_NAME];
199 /* Second keyword */
200 char choice2[PPD_MAX_NAME];
201 /* Second option/choice (blank for all) */
202 } ppd_const_t;
203
204 typedef struct ppd_size_str /**** Page Sizes ****/
205 {
206 int marked; /* Page size selected? */
207 char name[PPD_MAX_NAME];
208 /* 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
217 typedef struct ppd_emul_str /**** Emulators ****/
218 {
219 char name[PPD_MAX_NAME];
220 /* Emulator name */
221 char *start; /* Code to switch to this emulation */
222 char *stop; /* Code to stop this emulation */
223 } ppd_emul_t;
224
225 typedef struct ppd_profile_str /**** sRGB Color Profiles ****/
226 {
227 char resolution[PPD_MAX_NAME];
228 /* Resolution or "-" */
229 char media_type[PPD_MAX_NAME];
230 /* Media type or "-" */
231 float density; /* Ink density to use */
232 float gamma; /* Gamma correction to use */
233 float matrix[3][3]; /* Transform matrix */
234 } ppd_profile_t;
235
236 /**** New in CUPS 1.2 ****/
237 # if 0
238 typedef enum ppd_ext_ui_e /**** Extended UI Types @since CUPS 1.2@ ****/
239 {
240 PPD_UI_CUPS_TEXT, /* Specify a string */
241 PPD_UI_CUPS_INTEGER, /* Specify an integer number */
242 PPD_UI_CUPS_REAL, /* Specify a real number */
243 PPD_UI_CUPS_GAMMA, /* Specify a gamma number */
244 PPD_UI_CUPS_CURVE, /* Specify start, end, and gamma numbers */
245 PPD_UI_CUPS_INTEGER_ARRAY, /* Specify an array of integer numbers */
246 PPD_UI_CUPS_REAL_ARRAY, /* Specify an array of real numbers */
247 PPD_UI_CUPS_XY_ARRAY /* Specify an array of X/Y real numbers */
248 } ppd_ext_ui_t;
249
250 typedef union ppd_ext_value_u /**** Extended Values @since CUPS 1.2@ ****/
251 {
252 char *text; /* Text value */
253 int integer; /* Integer value */
254 float real; /* Real value */
255 float gamma; /* Gamma value */
256 struct
257 {
258 float start; /* Linear (density) start value for curve */
259 float end; /* Linear (density) end value for curve */
260 float gamma; /* Gamma correction */
261 } curve; /* Curve values */
262 struct
263 {
264 int num_elements; /* Number of array elements */
265 int *elements; /* Array of integer values */
266 } integer_array; /* Integer array value */
267 struct
268 {
269 int num_elements; /* Number of array elements */
270 float *elements; /* Array of real values */
271 } real_array; /* Real array value */
272 struct
273 {
274 int num_elements; /* Number of array elements */
275 float *elements; /* Array of XY values */
276 } xy_array; /* XY array value */
277 } ppd_ext_value_t;
278
279 typedef struct ppd_ext_param_str/**** Extended Parameter @since CUPS 1.2@ ****/
280 {
281 char keyword[PPD_MAX_NAME];
282 /* Parameter name */
283 char text[PPD_MAX_TEXT];
284 /* Human-readable text */
285 ppd_ext_value_t *value; /* Current values */
286 ppd_ext_value_t *defval; /* Default values */
287 ppd_ext_value_t *minval; /* Minimum numeric values */
288 ppd_ext_value_t *maxval; /* Maximum numeric values */
289 } ppd_ext_param_t;
290
291 typedef struct ppd_ext_option_str
292 /**** Extended Options @since CUPS 1.2@ ****/
293 {
294 char keyword[PPD_MAX_NAME];
295 /* Name of option that is being extended... */
296 ppd_option_t *option; /* Option that is being extended... */
297 int marked; /* Extended option is marked */
298 char *code; /* Generic PS code for extended options */
299 int num_params; /* Number of parameters */
300 ppd_ext_param_t **params; /* Parameters */
301 } ppd_ext_option_t;
302 # endif /* 0 */
303
304 typedef struct ppd_file_str /**** Files ****/
305 {
306 int language_level; /* Language level of device */
307 int color_device; /* 1 = color device, 0 = grayscale */
308 int variable_sizes; /* 1 = supports variable sizes, 0 = doesn't */
309 int accurate_screens;
310 /* 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 */
343 ppd_profile_t *profiles; /* sRGB color profiles */
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 @since CUPS 1.1@ */
349
350 /**** New in CUPS 1.1.19 ****/
351 char *protocols; /* Protocols (BCP, TBCP) string @since CUPS 1.1.19@ */
352 char *pcfilename; /* PCFileName string @since CUPS 1.1.19@ */
353 int num_attrs; /* Number of attributes @since CUPS 1.1.19@ */
354 int cur_attr; /* Current attribute @since CUPS 1.1.19@ */
355 ppd_attr_t **attrs; /* Attributes @since CUPS 1.1.19@ */
356
357 /**** New in CUPS 1.2 ****/
358 # if 0
359 int num_extended; /* Number of extended options @since CUPS 1.2@ */
360 ppd_ext_option_t **extended; /* Extended options @since CUPS 1.2@ */
361 # endif /* 0 */
362 } ppd_file_t;
363
364
365 /*
366 * Prototypes...
367 */
368
369 extern void ppdClose(ppd_file_t *ppd);
370 extern int ppdCollect(ppd_file_t *ppd, ppd_section_t section,
371 ppd_choice_t ***choices);
372 extern int ppdConflicts(ppd_file_t *ppd);
373 extern int ppdEmit(ppd_file_t *ppd, FILE *fp,
374 ppd_section_t section);
375 extern int ppdEmitFd(ppd_file_t *ppd, int fd,
376 ppd_section_t section);
377 extern int ppdEmitJCL(ppd_file_t *ppd, FILE *fp, int job_id,
378 const char *user, const char *title);
379 extern ppd_choice_t *ppdFindChoice(ppd_option_t *o, const char *option);
380 extern ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword);
381 extern ppd_option_t *ppdFindOption(ppd_file_t *ppd, const char *keyword);
382 extern int ppdIsMarked(ppd_file_t *ppd, const char *keyword,
383 const char *option);
384 extern void ppdMarkDefaults(ppd_file_t *ppd);
385 extern int ppdMarkOption(ppd_file_t *ppd, const char *keyword,
386 const char *option);
387 extern ppd_file_t *ppdOpen(FILE *fp);
388 extern ppd_file_t *ppdOpenFd(int fd);
389 extern ppd_file_t *ppdOpenFile(const char *filename);
390 extern float ppdPageLength(ppd_file_t *ppd, const char *name);
391 extern ppd_size_t *ppdPageSize(ppd_file_t *ppd, const char *name);
392 extern float ppdPageWidth(ppd_file_t *ppd, const char *name);
393
394 /**** New in CUPS 1.1.19 ****/
395 extern const char *ppdErrorString(ppd_status_t status);
396 extern ppd_attr_t *ppdFindAttr(ppd_file_t *ppd, const char *name,
397 const char *spec);
398 extern ppd_attr_t *ppdFindNextAttr(ppd_file_t *ppd, const char *name,
399 const char *spec);
400 extern ppd_status_t ppdLastError(int *line);
401
402 /**** New in CUPS 1.1.20 ****/
403 extern void ppdSetConformance(ppd_conform_t c);
404
405 /**** New in CUPS 1.2 ****/
406 extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp);
407 extern ppd_file_t *ppdOpen2(cups_file_t *fp);
408
409
410 /*
411 * C++ magic...
412 */
413
414 # ifdef __cplusplus
415 }
416 # endif /* __cplusplus */
417 #endif /* !_CUPS_PPD_H_ */
418
419 /*
420 * End of "$Id: ppd.h 4785 2005-10-13 19:39:05Z mike $".
421 */