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