]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc.h
4 // Definitions for the CUPS PPD Compiler.
6 // Copyright 2007-2008 by Apple Inc.
7 // Copyright 2002-2007 by Easy Software Products.
9 // These coded instructions, statements, and computer programs are the
10 // property of Apple Inc. and are protected by Federal copyright
11 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 // which should have been included with this file. If this file is
13 // file is missing or damaged, see the license at "http://www.cups.org/".
20 // Include necessary headers...
23 # include <cups/string.h>
25 # include <cups/file.h>
34 enum ppdcDrvType
//// Driver type
36 PPDC_DRIVER_CUSTOM
, // Custom driver
37 PPDC_DRIVER_PS
, // PostScript driver
38 PPDC_DRIVER_ESCP
, // rastertoescpx driver
39 PPDC_DRIVER_PCL
, // rastertopclx driver
40 PPDC_DRIVER_LABEL
, // rastertolabel/rastertodymo driver
41 PPDC_DRIVER_EPSON
, // rastertoepson driver
42 PPDC_DRIVER_HP
, // rastertohp driver
43 PPDC_DRIVER_MAX
// Number of driver types defined
46 enum ppdcFontStatus
//// Load status of font
48 PPDC_FONT_ROM
, // Font is in ROM
49 PPDC_FONT_DISK
// Font is on disk
52 enum ppdcOptSection
//// Option section
54 PPDC_SECTION_ANY
, // AnySetup
55 PPDC_SECTION_DOCUMENT
, // DocumentSetup
56 PPDC_SECTION_EXIT
, // ExitServer
57 PPDC_SECTION_JCL
, // JCLSetup
58 PPDC_SECTION_PAGE
, // PageSetup
59 PPDC_SECTION_PROLOG
// Prolog
62 enum ppdcOptType
//// Option type
64 PPDC_BOOLEAN
, // True/false option
65 PPDC_PICKONE
, // Single choice from list
66 PPDC_PICKMANY
// Multiple choices from list
69 enum ppdcLineEnding
//// Line endings
71 PPDC_LFONLY
, // LF only
72 PPDC_CRONLY
, // CR only
76 enum ppdcCondFlags
//// Condition flags
78 PPDC_COND_NORMAL
= 0, // Normal state
79 PPDC_COND_SKIP
= 1, // Skip state
80 PPDC_COND_SATISFIED
= 2 // At least one condition satisfied
85 // Printer description data...
88 class ppdcShared
//// Shared Data Value
92 int use
; // Use count (delete when 0)
97 virtual ~ppdcShared();
103 class ppdcArray
//// Shared Array
108 int count
, // Number of elements
109 alloc
, // Allocated elements
110 current
; // Current element
111 ppdcShared
**data
; // Elements
113 ppdcArray(ppdcArray
*a
= 0);
116 void add(ppdcShared
*d
);
119 void remove(ppdcShared
*d
);
122 class ppdcString
//// Shared String
127 char *value
; // String value
129 ppdcString(const char *v
);
133 class ppdcInteger
//// Shared integer
138 int *value
; // Integer value
140 ppdcInteger(int *v
) { value
= v
; }
143 class ppdcMessage
//// Translation message
148 ppdcString
*id
, // Translation ID
149 *string
; // Translation string
151 ppdcMessage(const char *i
, const char *s
);
155 class ppdcCatalog
//// Translation catalog
160 ppdcString
*locale
; // Name of locale
161 ppdcString
*filename
; // Name of translation file
162 ppdcArray
*messages
; // Array of translation messages
164 ppdcCatalog(const char *l
, const char *f
= 0);
167 void add_message(ppdcMessage
*m
) { messages
->add(m
); }
168 void add_message(const char *id
);
169 const char *find_message(const char *id
);
170 int load_messages(const char *f
);
171 int save_messages(const char *f
);
174 class ppdcAttr
//// Attribute
179 ppdcString
*name
, // Name of attribute
180 *selector
, // Selector string
181 *text
, // Text string
182 *value
; // Value string
183 bool localizable
; // Should this attribute be localized?
185 ppdcAttr(const char *n
, const char *s
, const char *t
, const char *v
,
190 class ppdcFont
//// Shared Font
195 ppdcString
*name
, // Font name
196 *encoding
, // Font base encoding
197 *version
, // Font version
198 *charset
; // Font charset
199 ppdcFontStatus status
; // Font status (ROM or Disk)
201 ppdcFont(const char *n
, const char *e
, const char *v
, const char *c
,
206 class ppdcChoice
//// Option Choice
211 ppdcString
*name
, // Name of choice
212 *text
, // Human-readable text of choice
213 *code
; // PS code of choice
215 ppdcChoice(const char *n
, const char *t
, const char *c
);
219 class ppdcOption
//// Option
224 ppdcOptType type
; // Type of option
225 ppdcString
*name
, // Name of option
226 *text
; // Human-readable text of option
227 ppdcOptSection section
; // Section for option code
228 float order
; // Order number
229 ppdcArray
*choices
; // Choices
230 ppdcString
*defchoice
; // Default choice
232 ppdcOption(ppdcOptType ot
, const char *n
, const char *t
, ppdcOptSection s
,
234 ppdcOption(ppdcOption
*o
);
237 void add_choice(ppdcChoice
*c
) { choices
->add(c
); }
238 ppdcChoice
*find_choice(const char *n
);
239 void set_defchoice(ppdcChoice
*c
);
242 class ppdcGroup
//// Group of Options
247 ppdcString
*name
, // Name of option
248 *text
; // Human-readable text of option
249 ppdcArray
*options
; // Options
251 ppdcGroup(const char *n
, const char *t
);
252 ppdcGroup(ppdcGroup
*g
);
255 void add_option(ppdcOption
*o
) { options
->add(o
); }
256 ppdcOption
*find_option(const char *n
);
259 class ppdcConstraint
//// Constraint
264 ppdcString
*option1
, // First option
265 *choice1
, // First choice
266 *option2
, // Second option
267 *choice2
; // Second choice
269 ppdcConstraint(const char *o1
, const char *c1
, const char *o2
,
274 class ppdcFilter
//// Filter Program
279 ppdcString
*mime_type
, // MIME type
280 *program
; // Filter program
281 int cost
; // Relative cost of filter
283 ppdcFilter(const char *t
, const char *p
, int c
);
287 class ppdcMediaSize
//// Media Size
292 ppdcString
*name
, // Name of size
293 *text
; // Human-readable text
294 float width
, // Width in points
295 length
, // Length in points
296 left
, // Left limit in points
297 bottom
, // Bottom limit in points
298 right
, // Right limit in points
299 top
; // Top limit in points
300 ppdcString
*size_code
, // PageSize code, if any
301 *region_code
; // PageRegion code, if any
303 ppdcMediaSize(const char *n
, const char *t
, float w
, float l
,
304 float lm
, float bm
, float rm
, float tm
,
305 const char *sc
= 0, const char *rc
= 0);
309 class ppdcProfile
//// Color Profile
314 ppdcString
*resolution
, // Resolution name
315 *media_type
; // Media type name
316 float density
, // Color profile density
317 gamma
, // Color profile gamma
318 profile
[9]; // Color profile matrix
320 ppdcProfile(const char *r
, const char *m
, float d
, float g
, const float *p
);
326 class ppdcDriver
//// Printer Driver Data
331 ppdcDrvType type
; // Driver type
332 ppdcArray
*copyright
; // Copyright strings
333 ppdcString
*manufacturer
, // Manufacturer
334 *model_name
, // Name of printer model
335 *file_name
, // Output filename for PPD
336 *pc_file_name
, // 8 character PC filename for PPD
337 *version
; // Version number
338 int model_number
, // Model number for driver
339 manual_copies
, // Do manual copies?
340 color_device
, // Support color?
341 throughput
; // Throughput in pages per minute
342 ppdcArray
*attrs
, // Attributes
343 *constraints
, // Constraints
346 *groups
, // Option groups
347 *profiles
, // Color profiles
348 *sizes
; // Fixed sizes
349 ppdcString
*default_font
, // Default font
350 *default_size
; // Default size option
351 int variable_paper_size
; // Support variable sizes?
352 ppdcString
*custom_size_code
; // Custom page size code, if any
353 float left_margin
, // Margins for device in points
357 max_width
, // Maximum width (points)
358 max_length
, // Maximum length (points)
359 min_width
, // Minimum width (points)
360 min_length
; // Minimum length (points)
362 ppdcDriver(ppdcDriver
*d
= 0);
365 void add_attr(ppdcAttr
*a
) { attrs
->add(a
); }
366 void add_constraint(ppdcConstraint
*c
) { constraints
->add(c
); }
367 void add_copyright(const char *c
) {
368 copyright
->add(new ppdcString(c
));
370 void add_filter(ppdcFilter
*f
) { filters
->add(f
); }
371 void add_font(ppdcFont
*f
) { fonts
->add(f
); }
372 void add_group(ppdcGroup
*g
) { groups
->add(g
); }
373 void add_profile(ppdcProfile
*p
) { profiles
->add(p
); }
374 void add_size(ppdcMediaSize
*m
) { sizes
->add(m
); }
376 ppdcAttr
*find_attr(const char *k
, const char *s
);
377 ppdcGroup
*find_group(const char *n
);
378 ppdcOption
*find_option(const char *n
);
380 void set_custom_size_code(const char *c
);
381 void set_default_font(ppdcFont
*f
);
382 void set_default_size(ppdcMediaSize
*m
);
383 void set_file_name(const char *f
);
384 void set_manufacturer(const char *m
);
385 void set_model_name(const char *m
);
386 void set_pc_file_name(const char *f
);
387 void set_version(const char *v
);
389 int write_ppd_file(cups_file_t
*fp
, ppdcCatalog
*catalog
,
390 ppdcArray
*locales
, ppdcSource
*src
,
394 class ppdcVariable
//// Variable Definition
399 ppdcString
*name
, // Name of variable
400 *value
; // Value of variable
402 ppdcVariable(const char *n
, const char *v
);
405 void set_value(const char *v
);
408 class ppdcFile
//// File
412 cups_file_t
*fp
; // File pointer
413 const char *filename
; // Filename
414 int line
; // Line in file
416 ppdcFile(const char *f
);
423 class ppdcSource
//// Source File
428 static ppdcArray
*includes
; // Include directories
429 static const char *driver_types
[]; // Driver types
431 ppdcString
*filename
; // Filename
432 ppdcArray
*base_fonts
, // Base fonts
433 *drivers
, // Printer drivers
434 *po_files
, // Message catalogs
435 *sizes
, // Predefined media sizes
436 *vars
; // Defined variables
437 int cond_state
, // Cummulative conditional state
438 *cond_current
, // Current #if state
439 cond_stack
[101]; // #if state stack
442 ppdcSource(const char *f
= 0);
445 static void add_include(const char *d
);
446 ppdcDriver
*find_driver(const char *f
);
447 static char *find_include(const char *f
, const char *base
, char *n
,
449 ppdcCatalog
*find_po(const char *l
);
450 ppdcMediaSize
*find_size(const char *s
);
451 ppdcVariable
*find_variable(const char *n
);
452 ppdcAttr
*get_attr(ppdcFile
*fp
, bool loc
= false);
453 int get_boolean(ppdcFile
*fp
);
454 ppdcChoice
*get_choice(ppdcFile
*fp
);
455 ppdcChoice
*get_color_model(ppdcFile
*fp
);
456 int get_color_order(const char *co
);
457 ppdcProfile
*get_color_profile(ppdcFile
*fp
);
458 int get_color_space(const char *cs
);
459 ppdcConstraint
*get_constraint(ppdcFile
*fp
);
460 ppdcMediaSize
*get_custom_size(ppdcFile
*fp
);
461 void get_duplex(ppdcFile
*fp
, ppdcDriver
*d
);
462 ppdcFilter
*get_filter(ppdcFile
*fp
);
463 float get_float(ppdcFile
*fp
);
464 ppdcFont
*get_font(ppdcFile
*fp
);
465 ppdcChoice
*get_generic(ppdcFile
*fp
, const char *keyword
,
466 const char *tattr
, const char *nattr
);
467 ppdcGroup
*get_group(ppdcFile
*fp
, ppdcDriver
*d
);
468 ppdcOption
*get_installable(ppdcFile
*fp
);
469 int get_integer(const char *v
);
470 int get_integer(ppdcFile
*fp
);
471 float get_measurement(ppdcFile
*fp
);
472 ppdcOption
*get_option(ppdcFile
*fp
, ppdcDriver
*d
, ppdcGroup
*g
);
473 ppdcCatalog
*get_po(ppdcFile
*fp
);
474 ppdcChoice
*get_resolution(ppdcFile
*fp
);
475 ppdcProfile
*get_simple_profile(ppdcFile
*fp
);
476 ppdcMediaSize
*get_size(ppdcFile
*fp
);
477 char *get_token(ppdcFile
*fp
, char *buffer
, int buflen
);
478 ppdcVariable
*get_variable(ppdcFile
*fp
);
479 int import_ppd(const char *f
);
480 int quotef(cups_file_t
*fp
, const char *format
, ...);
481 void read_file(const char *f
);
482 void scan_file(ppdcFile
*fp
, ppdcDriver
*td
= 0, bool inc
= false);
483 ppdcVariable
*set_variable(const char *name
, const char *value
);
484 int write_file(const char *f
);