PPD Compiler API

Header cups/ppdc.h
Library -lcupsppdc
See Also Programming: Introduction to CUPS Programming

Contents

Overview

The PPD Compiler API provides access to CUPS driver information files and methods for generating and importing PPD files.

Classes

ppdcArray

// Shared Array

class ppdcArray : public ppdcShared {
  public:
    int count, alloc, current;
    ppdcShared **data;
};

Members

current
Current element
data
Elements

PPDC_NAME

void PPDC_NAME (
    void add(ppdcShared *d
);

Parameters
d

add

void add (
    ppdcShared *d
);

Parameters
d

first

Return the first element in the array.

ppdcShared *first (void);

Return Value

next

Return the next element in the array.

ppdcShared *next (void);

Return Value

ppdcArray

void ppdcArray (
    ppdcArray *a
);

Parameters
a

remove

void remove (
    ppdcShared *d
);

Parameters
d
Data element

~ppdcArray

void ~ppdcArray (void);

ppdcAttr

// Attribute

class ppdcAttr : public ppdcShared {
  public:
    bool localizable;
    ppdcString *name, *selector, *text, *value;
};

Members

localizable
Should this attribute be localized?
value
Value string

ppdcAttr

void ppdcAttr (
    const char *n,
    const char *s,
    const char *t,
    const char *v,
    bool loc
);

Parameters
n
Name
s
Spec string
t
Human-readable text
v
Value
loc
Localize this attribute?

~ppdcAttr

void ~ppdcAttr (void);

ppdcCatalog

// Translation catalog

class ppdcCatalog : public ppdcShared {
  public:
    ppdcString *filename;
    ppdcString *locale;
    ppdcArray *messages;
};

Members

filename
Name of translation file
locale
Name of locale
messages
Array of translation messages

PPDC_NAME

void PPDC_NAME (
    void add_message(const char *id,
    const char *string = NULL
);

Parameters
id
string

add_message

void add_message (
    const char *id,
    const char *string
);

Parameters
id
Message ID to add
string
Translation string

find_message

const char *find_message (
    const char *id
);

Parameters
id
Message ID
Return Value

Message text

load_messages

int load_messages (
    const char *f
);

Parameters
f
Message catalog file
Return Value

0 on success, -1 on failure

ppdcCatalog

void ppdcCatalog (
    const char *l,
    const char *f
);

Parameters
l
Locale
f
Message catalog file

save_messages

int save_messages (
    const char *f
);

Parameters
f
File to save to
Return Value

0 on success, -1 on error

~ppdcCatalog

void ~ppdcCatalog (void);

ppdcChoice

// Option Choice

class ppdcChoice : public ppdcShared {
  public:
    ppdcString *name, *text, *code;
};

Members

code
PS code of choice

ppdcChoice

void ppdcChoice (
    const char *n,
    const char *t,
    const char *c
);

Parameters
n
Name of choice
t
Text of choice
c
Code of choice

~ppdcChoice

void ~ppdcChoice (void);

ppdcConstraint

// Constraint

class ppdcConstraint : public ppdcShared {
  public:
    ppdcString *option1, *choice1, *option2, *choice2;
};

Members

choice2
Second choice

ppdcConstraint

void ppdcConstraint (
    const char *o1,
    const char *c1,
    const char *o2,
    const char *c2
);

Parameters
o1
First option
c1
First choice
o2
Second option
c2
Second choice

~ppdcConstraint

void ~ppdcConstraint (void);

ppdcDriver

// Printer Driver Data

class ppdcDriver : public ppdcShared {
  public:
    ppdcArray *copyright;
    ppdcString *custom_size_code;
    ppdcString *default_font, *default_size;
    float left_margin, bottom_margin, right_margin, top_margin, max_width, max_length, min_width, min_length;
    ppdcArray *attrs, *constraints, *filters, *fonts, *groups, *profiles, *sizes;
    int model_number, manual_copies, color_device, throughput;
    ppdcDrvType type;
    int variable_paper_size;
    ppdcString *manufacturer, *model_name, *file_name, *pc_file_name, *version;
};

Members

copyright
Copyright strings
custom_size_code
Custom page size code, if any
default_size
Default size option
min_length
Minimum length (points)
sizes
Fixed sizes
throughput
Throughput in pages per minute
type
Driver type
variable_paper_size
Support variable sizes?
version
Version number

PPDC_NAME

void PPDC_NAME (
    void add_attr(ppdcAttr *a
);

Parameters
a

add_constraint

void add_constraint (
    ppdcConstraint *c
);

Parameters
c

add_copyright

void add_copyright (
    const char *c
);

Parameters
c

add_filter

void add_filter (
    ppdcFilter *f
);

Parameters
f

add_font

void add_font (
    ppdcFont *f
);

Parameters
f

add_group

void add_group (
    ppdcGroup *g
);

Parameters
g

add_profile

void add_profile (
    ppdcProfile *p
);

Parameters
p

add_size

void add_size (
    ppdcMediaSize *m
);

Parameters
m

find_attr

ppdcAttr *find_attr (
    const char *k,
    const char *s
);

Parameters
k
Keyword string
s
Spec string
Return Value

Attribute or NULL

find_group

ppdcGroup *find_group (
    const char *n
);

Parameters
n
Group name
Return Value

Matching group or NULL

find_option

ppdcOption *find_option (
    const char *n
);

Parameters
n
Option name
Return Value

Matching option or NULL

find_option_group

ppdcOption *find_option_group (
    const char *n,
    ppdcGroup **mg
);

Parameters
n
Option name
mg
Matching group or NULL
Return Value

Matching option or NULL

ppdcDriver

void ppdcDriver (
    ppdcDriver *d
);

Parameters
d
Printer driver template

set_custom_size_code

void set_custom_size_code (
    const char *c
);

Parameters
c
CustomPageSize code

set_default_font

void set_default_font (
    ppdcFont *f
);

Parameters
f
Font

set_default_size

void set_default_size (
    ppdcMediaSize *m
);

Parameters
m
Media size

set_file_name

void set_file_name (
    const char *f
);

Parameters
f
Filename

set_manufacturer

void set_manufacturer (
    const char *m
);

Parameters
m
Model name

set_model_name

void set_model_name (
    const char *m
);

Parameters
m
Model name

set_pc_file_name

void set_pc_file_name (
    const char *f
);

Parameters
f
Filename

set_version

void set_version (
    const char *v
);

Parameters
v
Version

write_ppd_file

int write_ppd_file (
    cups_file_t *fp,
    ppdcCatalog *catalog,
    ppdcArray *locales,
    ppdcSource *src,
    ppdcLineEnding le
);

Parameters
fp
PPD file
catalog
Message catalog
locales
Additional languages to add
src
Driver source
le
Line endings to use
Return Value

0 on success, -1 on failure

~ppdcDriver

void ~ppdcDriver (void);

ppdcFile

// File

class ppdcFile {
  public:
    bool close_on_delete;
    const char *filename;
    cups_file_t *fp;
    int line;
};

Members

close_on_delete
Close file on delete?
filename
Filename
fp
File pointer
line
Line in file

get

Get a character from a file.

int get (void);

Return Value

peek

int peek (void);

Return Value

Next character in file

ppdcFile

void ppdcFile (
    const char *f,
    cups_file_t *ffp
);

Parameters
f
File to open
ffp
File pointer to use

~ppdcFile

void ~ppdcFile (void);

ppdcFilter

// Filter Program

class ppdcFilter : public ppdcShared {
  public:
    int cost;
    ppdcString *mime_type, *program;
};

Members

cost
Relative cost of filter
program
Filter program

ppdcFilter

void ppdcFilter (
    const char *t,
    const char *p,
    int c
);

Parameters
t
MIME type
p
Filter program
c
Relative cost

~ppdcFilter

void ~ppdcFilter (void);

ppdcFont

// Shared Font

class ppdcFont : public ppdcShared {
  public:
    ppdcString *name, *encoding, *version, *charset;
    ppdcFontStatus status;
};

Members

charset
Font charset
status
Font status (ROM or Disk)

ppdcFont

void ppdcFont (
    const char *n,
    const char *e,
    const char *v,
    const char *c,
    ppdcFontStatus s
);

Parameters
n
Name of font
e
Font encoding
v
Font version
c
Font charset
s
Font status

~ppdcFont

void ~ppdcFont (void);

ppdcGroup

// Group of Options

class ppdcGroup : public ppdcShared {
  public:
    ppdcArray *options;
    ppdcString *name, *text;
};

Members

options
Options
text
Human-readable text of option

PPDC_NAME

void PPDC_NAME (
    void add_option(ppdcOption *o
);

Parameters
o

find_option

Find an option in a group.

ppdcOption *find_option (
    const char *n
);

Parameters
n
Name of option
Return Value

ppdcGroup

void ppdcGroup (
    ppdcGroup *g
);

Parameters
g
Group template

~ppdcGroup

void ~ppdcGroup (void);

ppdcInteger

// Shared integer

class ppdcInteger : public ppdcShared {
  public:
    int *value;
};

Members

value
Integer value

ppdcInteger

Integer value

void ppdcInteger (
    int *v
);

Parameters
v

ppdcMediaSize

// Media Size

class ppdcMediaSize : public ppdcShared {
  public:
    ppdcString *size_code, *region_code;
    ppdcString *name, *text;
    float width, length, left, bottom, right, top;
};

Members

region_code
PageRegion code, if any
text
Human-readable text
top
Top limit in points

ppdcMediaSize

void ppdcMediaSize (
    const char *n,
    const char *t,
    float w,
    float l,
    float lm,
    float bm,
    float rm,
    float tm,
    const char *sc,
    const char *rc
);

Parameters
n
Name of media size
t
Text of media size
w
Width in points
l
Length in points
lm
Left margin in points
bm
Bottom margin in points
rm
Right margin in points
tm
Top margin in points
sc
PageSize code, if any
rc
PageRegion code, if any

~ppdcMediaSize

void ~ppdcMediaSize (void);

ppdcMessage

// Translation message

class ppdcMessage : public ppdcShared {
  public:
    ppdcString *id, *string;
};

Members

string
Translation string

ppdcMessage

void ppdcMessage (
    const char *i,
    const char *s
);

Parameters
i
ID
s
Text

~ppdcMessage

void ~ppdcMessage (void);

ppdcOption

// Option

class ppdcOption : public ppdcShared {
  public:
    ppdcArray *choices;
    ppdcString *defchoice;
    float order;
    ppdcOptSection section;
    ppdcString *name, *text;
    ppdcOptType type;
};

Members

choices
Choices
defchoice
Default choice
order
Order number
section
Section for option code
text
Human-readable text of option
type
Type of option

PPDC_NAME

void PPDC_NAME (
    void add_choice(ppdcChoice *c
);

Parameters
c

find_choice

ppdcChoice *find_choice (
    const char *n
);

Parameters
n
Name of choice
Return Value

Choice or NULL

ppdcOption

void ppdcOption (
    ppdcOption *o
);

Parameters
o
Template option

set_defchoice

void set_defchoice (
    ppdcChoice *c
);

Parameters
c
Choice

~ppdcOption

void ~ppdcOption (void);

ppdcProfile

// Color Profile

class ppdcProfile : public ppdcShared {
  public:
    ppdcString *resolution, *media_type;
    float density, gamma, profile[9];
};

Members

media_type
Media type name
profile[9]
Color profile matrix

ppdcProfile

void ppdcProfile (
    const char *r,
    const char *m,
    float d,
    float g,
    const float *p
);

Parameters
r
Resolution name
m
Media type name
d
Density
g
Gamma
p
3x3 transform matrix

~ppdcProfile

void ~ppdcProfile (void);

ppdcShared

// Shared Data Value

class ppdcShared {
  private:
    int use;
};

Members

use
Use count (delete when 0)

class_name

virtual const char *class_name (void);

Return Value

ppdcShared

void ppdcShared (void);

release

void release (void);

retain

void retain (void);

~ppdcShared

void ~ppdcShared (void);

ppdcSource

// Source File

class ppdcSource : public ppdcShared {
  public:
    int cond_state, *cond_current, cond_stack[101];
    static const char *driver_types[];
    ppdcString *filename;
    static ppdcArray *includes;
    ppdcArray *base_fonts, *drivers, *po_files, *sizes, *vars;
};

Members

cond_stack[101]
#if state stack
driver_types[]
Driver types
filename
Filename
includes
Include directories
vars
Defined variables

PPDC_NAME

void PPDC_NAME (
    static void add_include(const char *d
);

Parameters
d

add_include

void add_include (
    const char *d
);

Parameters
d
Include directory

find_driver

ppdcDriver *find_driver (
    const char *f
);

Parameters
f
Driver file name
Return Value

Driver

find_include

char *find_include (
    const char *f,
    const char *base,
    char *n,
    int nlen
);

Parameters
f
Include filename
base
Current directory
n
Path buffer
nlen
Path buffer length
Return Value

Found path or NULL

find_po

ppdcCatalog *find_po (
    const char *l
);

Parameters
l
Locale name
Return Value

Message catalog or NULL

find_size

ppdcMediaSize *find_size (
    const char *s
);

Parameters
s
Size name
Return Value

Size

find_variable

ppdcVariable *find_variable (
    const char *n
);

Parameters
n
Variable name
Return Value

Variable

get_attr

ppdcAttr *get_attr (
    ppdcFile *fp,
    bool loc
);

Parameters
fp
File to read
loc
Localize this attribute?
Return Value

Attribute

get_boolean

int get_boolean (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Boolean value

get_choice

ppdcChoice *get_choice (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Choice data

get_color_model

ppdcChoice *get_color_model (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Choice data

get_color_order

int get_color_order (
    const char *co
);

Parameters
co
Color order string
Return Value

Color order value

get_color_profile

ppdcProfile *get_color_profile (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Color profile

get_color_space

int get_color_space (
    const char *cs
);

Parameters
cs
Colorspace string
Return Value

Colorspace value

get_constraint

ppdcConstraint *get_constraint (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Constraint

get_custom_size

ppdcMediaSize *get_custom_size (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Media size

get_duplex

void get_duplex (
    ppdcFile *fp,
    ppdcDriver *d
);

Parameters
fp
File to read from
d
Current driver

get_filter

ppdcFilter *get_filter (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Filter

get_float

float get_float (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Number

get_font

ppdcFont *get_font (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Font data

get_generic

ppdcChoice *get_generic (
    ppdcFile *fp,
    const char *keyword,
    const char *tattr,
    const char *nattr
);

Parameters
fp
File to read
keyword
Keyword name
tattr
Text attribute
nattr
Numeric attribute
Return Value

Choice data

get_group

ppdcGroup *get_group (
    ppdcFile *fp,
    ppdcDriver *d
);

Parameters
fp
File to read
d
Printer driver
Return Value

Group

get_installable

ppdcOption *get_installable (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Option

get_integer

int get_integer (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Integer value

get_measurement

float get_measurement (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Measurement value in points

get_option

ppdcOption *get_option (
    ppdcFile *fp,
    ppdcDriver *d,
    ppdcGroup *g
);

Parameters
fp
File to read
d
Printer driver
g
Current group
Return Value

Option

get_po

ppdcCatalog *get_po (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Message catalog

get_resolution

ppdcChoice *get_resolution (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Choice data

get_simple_profile

ppdcProfile *get_simple_profile (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Color profile

get_size

ppdcMediaSize *get_size (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Media size

get_token

char *get_token (
    ppdcFile *fp,
    char *buffer,
    int buflen
);

Parameters
fp
File to read
buffer
Buffer
buflen
Length of buffer
Return Value

Token string or NULL

get_variable

ppdcVariable *get_variable (
    ppdcFile *fp
);

Parameters
fp
File to read
Return Value

Variable

import_ppd

int import_ppd (
    const char *f
);

Parameters
f
Filename
Return Value

1 on success, 0 on failure

ppdcSource

void ppdcSource (
    const char *f,
    cups_file_t *ffp
);

Parameters
f
File to read
ffp
File pointer to use

quotef

int quotef (
    cups_file_t *fp,
    const char *format,
    ...
);

Parameters
fp
File to write to
format
Printf-style format string
...
Additional args as needed
Return Value

Number bytes on success, -1 on failure

read_file

void read_file (
    const char *f,
    cups_file_t *ffp
);

Parameters
f
File to read
ffp
File pointer to use

scan_file

void scan_file (
    ppdcFile *fp,
    ppdcDriver *td,
    bool inc
);

Parameters
fp
File to read
td
Driver template
inc
Including?

set_variable

ppdcVariable *set_variable (
    const char *name,
    const char *value
);

Parameters
name
Name
value
Value
Return Value

Variable

write_file

int write_file (
    const char *f
);

Parameters
f
File to write
Return Value

0 on success, -1 on error

~ppdcSource

void ~ppdcSource (void);

ppdcString

// Shared String

class ppdcString : public ppdcShared {
  public:
    char *value;
};

Members

value
String value

ppdcString

void ppdcString (
    const char *v
);

Parameters
v
String

~ppdcString

void ~ppdcString (void);

ppdcVariable

// Variable Definition

class ppdcVariable : public ppdcShared {
  public:
    ppdcString *name, *value;
};

Members

value
Value of variable

PPDC_NAME

void PPDC_NAME (
    void set_value(const char *v
);

Parameters
v

ppdcVariable

void ppdcVariable (
    const char *n,
    const char *v
);

Parameters
n
Name of variable
v
Value of variable

set_value

void set_value (
    const char *v
);

Parameters
v

~ppdcVariable

void ~ppdcVariable (void);

Data Types

ppdc_cs_t

typedef enum ppdc_cs_t;

Variables

ppdcSource

// Printer Driver Data

class ppdcSource;

Constants

ppdcCondFlags

// Condition flags

Constants

PPDC_COND_NORMAL
Normal state
PPDC_COND_SATISFIED
At least one condition satisfied
PPDC_COND_SKIP
Skip state

ppdcDrvType

// Driver type

Constants

PPDC_DRIVER_CUSTOM
Custom driver
PPDC_DRIVER_EPSON
rastertoepson driver
PPDC_DRIVER_ESCP
rastertoescpx driver
PPDC_DRIVER_HP
rastertohp driver
PPDC_DRIVER_LABEL
rastertolabel/rastertodymo driver
PPDC_DRIVER_MAX
Number of driver types defined
PPDC_DRIVER_PCL
rastertopclx driver
PPDC_DRIVER_PS
PostScript driver

ppdcFontStatus

// Load status of font

Constants

PPDC_FONT_DISK
Font is on disk
PPDC_FONT_ROM
Font is in ROM

ppdcLineEnding

// Line endings

Constants

PPDC_CRLF
CR + LF
PPDC_CRONLY
CR only
PPDC_LFONLY
LF only

ppdcOptSection

// Option section

Constants

PPDC_SECTION_ANY
AnySetup
PPDC_SECTION_DOCUMENT
DocumentSetup
PPDC_SECTION_EXIT
ExitServer
PPDC_SECTION_JCL
JCLSetup
PPDC_SECTION_PAGE
PageSetup
PPDC_SECTION_PROLOG
Prolog

ppdcOptType

// Option type

Constants

PPDC_BOOLEAN
True/false option
PPDC_PICKMANY
Multiple choices from list
PPDC_PICKONE
Single choice from list