]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdc.h
4 // Definitions for the CUPS PPD Compiler.
6 // Copyright 2007 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
78 // Printer description data...
81 class ppdcShared
//// Shared Data Value
85 int use
; // Use count (delete when 0)
90 virtual ~ppdcShared();
96 class ppdcArray
//// Shared Array
101 int count
, // Number of elements
102 alloc
, // Allocated elements
103 current
; // Current element
104 ppdcShared
**data
; // Elements
106 ppdcArray(ppdcArray
*a
= 0);
109 void add(ppdcShared
*d
);
112 void remove(ppdcShared
*d
);
115 class ppdcString
//// Shared String
120 char *value
; // String value
122 ppdcString(const char *v
);
126 class ppdcInteger
//// Shared integer
131 int *value
; // Integer value
133 ppdcInteger(int *v
) { value
= v
; }
136 class ppdcMessage
//// Translation message
141 ppdcString
*id
, // Translation ID
142 *string
; // Translation string
144 ppdcMessage(const char *i
, const char *s
);
148 class ppdcCatalog
//// Translation catalog
153 ppdcString
*locale
; // Name of locale
154 ppdcString
*filename
; // Name of translation file
155 ppdcArray
*messages
; // Array of translation messages
157 ppdcCatalog(const char *l
, const char *f
= 0);
160 void add_message(ppdcMessage
*m
) { messages
->add(m
); }
161 void add_message(const char *id
);
162 const char *find_message(const char *id
);
163 int load_messages(const char *f
);
164 int save_messages(const char *f
);
167 class ppdcAttr
//// Attribute
172 ppdcString
*name
, // Name of attribute
173 *selector
, // Selector string
174 *text
, // Text string
175 *value
; // Value string
177 ppdcAttr(const char *n
, const char *s
, const char *t
, const char *v
);
181 class ppdcFont
//// Shared Font
186 ppdcString
*name
, // Font name
187 *encoding
, // Font base encoding
188 *version
, // Font version
189 *charset
; // Font charset
190 ppdcFontStatus status
; // Font status (ROM or Disk)
192 ppdcFont(const char *n
, const char *e
, const char *v
, const char *c
,
197 class ppdcChoice
//// Option Choice
202 ppdcString
*name
, // Name of choice
203 *text
, // Human-readable text of choice
204 *code
; // PS code of choice
206 ppdcChoice(const char *n
, const char *t
, const char *c
);
210 class ppdcOption
//// Option
215 ppdcOptType type
; // Type of option
216 ppdcString
*name
, // Name of option
217 *text
; // Human-readable text of option
218 ppdcOptSection section
; // Section for option code
219 float order
; // Order number
220 ppdcArray
*choices
; // Choices
221 ppdcString
*defchoice
; // Default choice
223 ppdcOption(ppdcOptType ot
, const char *n
, const char *t
, ppdcOptSection s
,
225 ppdcOption(ppdcOption
*o
);
228 void add_choice(ppdcChoice
*c
) { choices
->add(c
); }
229 ppdcChoice
*find_choice(const char *n
);
230 void set_defchoice(ppdcChoice
*c
);
233 class ppdcGroup
//// Group of Options
238 ppdcString
*name
, // Name of option
239 *text
; // Human-readable text of option
240 ppdcArray
*options
; // Options
242 ppdcGroup(const char *n
, const char *t
);
243 ppdcGroup(ppdcGroup
*g
);
246 void add_option(ppdcOption
*o
) { options
->add(o
); }
247 ppdcOption
*find_option(const char *n
);
250 class ppdcConstraint
//// Constraint
255 ppdcString
*option1
, // First option
256 *choice1
, // First choice
257 *option2
, // Second option
258 *choice2
; // Second choice
260 ppdcConstraint(const char *o1
, const char *c1
, const char *o2
,
265 class ppdcFilter
//// Filter Program
270 ppdcString
*mime_type
, // MIME type
271 *program
; // Filter program
272 int cost
; // Relative cost of filter
274 ppdcFilter(const char *t
, const char *p
, int c
);
278 class ppdcMediaSize
//// Media Size
283 ppdcString
*name
, // Name of size
284 *text
; // Human-readable text
285 float width
, // Width in points
286 length
, // Length in points
287 left
, // Left limit in points
288 bottom
, // Bottom limit in points
289 right
, // Right limit in points
290 top
; // Top limit in points
291 ppdcString
*size_code
, // PageSize code, if any
292 *region_code
; // PageRegion code, if any
294 ppdcMediaSize(const char *n
, const char *t
, float w
, float l
,
295 float lm
, float bm
, float rm
, float tm
,
296 const char *sc
= 0, const char *rc
= 0);
300 class ppdcProfile
//// Color Profile
305 ppdcString
*resolution
, // Resolution name
306 *media_type
; // Media type name
307 float density
, // Color profile density
308 gamma
, // Color profile gamma
309 profile
[9]; // Color profile matrix
311 ppdcProfile(const char *r
, const char *m
, float d
, float g
, const float *p
);
317 class ppdcDriver
//// Printer Driver Data
322 ppdcDrvType type
; // Driver type
323 ppdcArray
*copyright
; // Copyright strings
324 ppdcString
*manufacturer
, // Manufacturer
325 *model_name
, // Name of printer model
326 *pc_file_name
, // 8 character PC filename for PPD
327 *version
; // Version number
328 int model_number
, // Model number for driver
329 manual_copies
, // Do manual copies?
330 color_device
, // Support color?
331 throughput
; // Throughput in pages per minute
332 ppdcArray
*attrs
, // Attributes
333 *constraints
, // Constraints
336 *groups
, // Option groups
337 *profiles
, // Color profiles
338 *sizes
; // Fixed sizes
339 ppdcString
*default_font
, // Default font
340 *default_size
; // Default size option
341 int variable_paper_size
; // Support variable sizes?
342 ppdcString
*custom_size_code
; // Custom page size code, if any
343 float left_margin
, // Margins for device in points
347 max_width
, // Maximum width (points)
348 max_length
, // Maximum length (points)
349 min_width
, // Minimum width (points)
350 min_length
; // Minimum length (points)
352 ppdcDriver(ppdcDriver
*d
= 0);
355 void add_attr(ppdcAttr
*a
) { attrs
->add(a
); }
356 void add_constraint(ppdcConstraint
*c
) { constraints
->add(c
); }
357 void add_copyright(const char *c
) {
358 copyright
->add(new ppdcString(c
));
360 void add_filter(ppdcFilter
*f
) { filters
->add(f
); }
361 void add_font(ppdcFont
*f
) { fonts
->add(f
); }
362 void add_group(ppdcGroup
*g
) { groups
->add(g
); }
363 void add_profile(ppdcProfile
*p
) { profiles
->add(p
); }
364 void add_size(ppdcMediaSize
*m
) { sizes
->add(m
); }
366 ppdcAttr
*find_attr(const char *k
, const char *s
);
367 ppdcGroup
*find_group(const char *n
);
368 ppdcOption
*find_option(const char *n
);
370 void set_custom_size_code(const char *c
);
371 void set_default_font(ppdcFont
*f
);
372 void set_default_size(ppdcMediaSize
*m
);
373 void set_manufacturer(const char *m
);
374 void set_model_name(const char *m
);
375 void set_pc_file_name(const char *f
);
376 void set_version(const char *v
);
378 int write_ppd_file(cups_file_t
*fp
, ppdcCatalog
*catalog
,
379 ppdcArray
*locales
, ppdcSource
*src
,
383 class ppdcVariable
//// Variable Definition
388 ppdcString
*name
, // Name of variable
389 *value
; // Value of variable
391 ppdcVariable(const char *n
, const char *v
);
394 void set_value(const char *v
);
397 class ppdcFile
//// File
401 cups_file_t
*fp
; // File pointer
402 const char *filename
; // Filename
403 int line
; // Line in file
405 ppdcFile(const char *f
);
412 class ppdcSource
//// Source File
417 static ppdcArray
*includes
; // Include directories
418 static const char *driver_types
[]; // Driver types
420 ppdcString
*filename
; // Filename
421 ppdcArray
*base_fonts
, // Base fonts
422 *drivers
, // Printer drivers
423 *po_files
, // Message catalogs
424 *sizes
, // Predefined media sizes
425 *vars
; // Defined variables
427 ppdcSource(const char *f
= 0);
430 static void add_include(const char *d
);
431 ppdcDriver
*find_driver(const char *f
);
432 static char *find_include(const char *f
, const char *base
, char *n
,
434 ppdcCatalog
*find_po(const char *l
);
435 ppdcMediaSize
*find_size(const char *s
);
436 ppdcVariable
*find_variable(const char *n
);
437 ppdcAttr
*get_attr(ppdcFile
*fp
);
438 int get_boolean(ppdcFile
*fp
);
439 ppdcChoice
*get_choice(ppdcFile
*fp
);
440 ppdcChoice
*get_color_model(ppdcFile
*fp
);
441 int get_color_order(const char *co
);
442 ppdcProfile
*get_color_profile(ppdcFile
*fp
);
443 int get_color_space(const char *cs
);
444 ppdcConstraint
*get_constraint(ppdcFile
*fp
);
445 ppdcMediaSize
*get_custom_size(ppdcFile
*fp
);
446 void get_duplex(ppdcFile
*fp
, ppdcDriver
*d
);
447 ppdcFilter
*get_filter(ppdcFile
*fp
);
448 float get_float(ppdcFile
*fp
);
449 ppdcFont
*get_font(ppdcFile
*fp
);
450 ppdcChoice
*get_generic(ppdcFile
*fp
, const char *keyword
,
451 const char *tattr
, const char *nattr
);
452 ppdcGroup
*get_group(ppdcFile
*fp
, ppdcDriver
*d
);
453 ppdcOption
*get_installable(ppdcFile
*fp
);
454 int get_integer(const char *v
);
455 int get_integer(ppdcFile
*fp
);
456 float get_measurement(ppdcFile
*fp
);
457 ppdcOption
*get_option(ppdcFile
*fp
, ppdcDriver
*d
, ppdcGroup
*g
);
458 ppdcCatalog
*get_po(ppdcFile
*fp
);
459 ppdcChoice
*get_resolution(ppdcFile
*fp
);
460 ppdcProfile
*get_simple_profile(ppdcFile
*fp
);
461 ppdcMediaSize
*get_size(ppdcFile
*fp
);
462 char *get_token(ppdcFile
*fp
, char *buffer
, int buflen
);
463 ppdcVariable
*get_variable(ppdcFile
*fp
);
464 int import_ppd(const char *f
);
465 int quotef(cups_file_t
*fp
, const char *format
, ...);
466 void read_file(const char *f
);
467 void scan_file(ppdcFile
*fp
, ppdcDriver
*td
= 0, bool inc
= false);
468 ppdcVariable
*set_variable(const char *name
, const char *value
);
469 int write_file(const char *f
);