Next Previous Contents

5. Configuration File

This section will cover the ifhp.conf file and the various options and configuration methods used to control the operation of the ifhp filter.

5.1 Configuration File Entries

The ifhp filter uses a simple text based configuration file, usually /usr/local/etc/ifhp.conf or /etc/ifhp.conf to get a set of configuration values which control its operation. The following sample configuration file segment shows how information is specified.

# comment line - first non-blank character is a #
#---- DEFAULTS ----
# we first have the default section
#   - a flag option whose value is 1
on_flag
#   - a flag option whose value is 0
off_flag@
#   - a flag option whose value is a string (single line)
#     its value will be 'this is a string'
strval = this is a string
#   - a flag option whose value is multiple lines
#     each additional line starts with whitespace
#     value is 'this\nis1\na\nstring'
longstrval = this
 is\061
 a
 string
#   - and a list that gets expanded -
#     '[ this ] [ is a\nlist ]' -> [ this is a list ]
longlist = [ this ] [ is a
 list ]
#    we can extend a string.
#    strval will  now be 'this is a string added'
strval += added
#    and we can expand a list
#     '[ this ] [ is a\nlist ] [ more ]' -> [ this is a list more ]
longlist += [ more ]

# a printer specific section
# ---- PRINTER ----
[ hp hp4* ]
# this match model=hp, model=hp4, model=hp4x
# override the default
onflag@
include /usr/local/etc/ifhp.conf.local

The example shows the basic structure of the ifhp.conf file. Comments are lines whose first non-whitespace character is#.

5.2 Option Setting

Syntax             Equivalent To
option             option=1
option@            option=0
option=val
option=[ v v  ... ]
option=val1        val1\nval2\n val3
 val2 
option=val1        val1
option+=val2       val1 val2
option+=val4       val1 val2 val4\nval5
include+=val4       val1 val2 val4\nval5
 val5
include /pathname

If an option's default value is the empty string (''). The ifhp program uses the Perl language convention that this value is equivalent to 0 when used in a numerical context or the empty string when used in a string context.

In general when a string is used in an integer context it is converted to a the appropriate numerical type using the standard Perl/C numerical representation and conversion methods.

The flag syntax sets the value of flag to the string '1', that is, the string with a 1 value, and flag@ sets it to '0'.

The option = value syntax sets the option value to a string. The string can extend across multiple lines. A line starting with a space has its value appended to the previous option with a \n separator.

As shown in the example, the += operator is used to append to a string value The [ option option ...] syntax is used to specify that the value is list. Lists are used to specify a list of options which can be flags or string values. Lists have the property of recursive evaluation which means that the individual list items will be further processed during printing. This is discussed later in detail.

The include facility is currently deprecated, and may not be implemented in future releases. It will cause the specified file to be read and processed at that point in the configuration file.

5.3 Option Use

Options and their values are used to control printer operation. There are two types of options: those with a predefined or builtin meaning to the ifhp filter and those which have their values sent to the printer when appropriate. The builtin options are listed and their use is explained in later sections.

5.4 List Expansion

The ifhp filter configures a printer by sending the values of options to the printer or performing built-in operations. An option can have a flag, string, or list value.

A LIST value has the form [ v1 v2 ... ]. When a list value is to be sent to the printer each of v1, v2, etc. is expanded in turn and the corresponding string value or builtin action is carried out. If the string value of a term is itself a list, the list will be expanded in turn. Recursive list evaluation will result in an error. The following is an example of list expansion:

t1=[ p1 p2 ]
p1=this is
p2=[ p3 p4 ]
p3=a
p4=test

The option t1 is expanded by expanding p1 and then p2; The expansion of p1 produces "this is", and p2 produces [p3 p4]. This list is then expanded to produce "test" and "living end".

Some LIST options are used in printer language specific contexts and their values are processed appropriately. For example, pjl_init=[...] specifies a set of initialization operations for PJL printers, and pcl_init=[...] is used to specify the initialization needed for PCL printing. The expansion of the LIST entries is done in the language specific context. For PJL this requires that the output be well formed PJL commands, and for PCL that all whitespace be removed.

The context dependent expansion is required because sometimes it is necessary to do operations both using PJL and PCL or PJL and PS combinations to ensure correct printer operation. During expansion the language name and an underscore is prefixed to the list entry name and this is used as the option name during expansion. If the prefixed name is not found then the unprefixed name will be used. For example, suppose that we have:

pjl_init=[ initstr test ]
pcl_init=[ initstr ]
pjl_initstr=@PJL ECHO YES
pcl_initstr=\033(*0V

When PJL initialization is being done and we want string values for the pjl_init LIST, we expand initstr and test in the pjl_ context. First a defined pjl_initstr value will be looked for and then a defined initstr value. Since there is a value of pjl_initstr it will be used.

Similarly we will check for pjl_test and test values. Since pjl_test does not have a defined value the test value DONE will be used.

When PJC initialization is being done and we want string values for the pjc_init LIST, then we expand initstr and test in a similar way, resulting in \033(*0V and DONE values.

We can use the list entry [ option=value ] to temporarily specify the value of a variable which is then used during language specific expansion. For example, suppose that we have the following set of definitions:

pjl_init=[ initstr=testing ]
pjl_initstr=@PJL INIT=\%s%lcub;initstr%rcub;XQ

As discussed in the next section, the \%s%lcub;initstr%rcub; will cause the value for the initstr value to be substituted into the pjl_initstr string. How this is done is discussed in the section on String Escape Sequences.

5.5 String Escape Sequences

Strings values have a syntax similar to PERL or C. The \ (escape) character indicates the start of an escape sequence string. This has the syntax:

Standard Character Replacement

\f, \r, \n, and \t are replaced in turn by the Ascii character FF, CR, NL, and HT whose values are 014, 015, 012, and 011 respectively.

Octal Character Replacement

\nnn where nnn are 3 octal digits is replaced by the corresponding character with the specified value.

Option Value Replacement

\%format{option} OR \%format[option]

The value of the option will be determined and replaced by a formatted string. The option value is determined by the following algorithm.

  1. When expanding a list value, the option=word will push the option=word combination onto an evaluation stack, and then the option value is expanded in the current language context.
  2. When starting a search for {option} in a language context lang_, the stack of list values is searched in oldest to newest order for a match for lang_option and then for option. The first one found is used as the option value.
  3. After searching the evaluation stack for {option} and no match was found then the -Z command line option values are searched for a matching entry.
  4. If none is found, then the -T command line option values and next the printer configuration will then be searched for lang_option and then for option. If no match is found, then the empty string will be the result if a string is wanted or the value 0 if a number is wanted.
  5. If the result of this lookup is a list then the list will be expanded in turn, and the concatenating values of the expansion will be used.
  6. When starting a search for [option] the -T command line options will be first and next the printer configuration will then be searched for lang_option and then for option. If no match is found, then the empty string will be the result if a string is wanted or the value 0 if a number is wanted.
  7. If the result of this lookup is a list If no match was found, then the search rules for {option} will be used, and the list expansion will be done as described above. If no match was found a null (empty string) value will be used.
Option Value Format

   %[-][0][length[.precision]][format]
   %d{1}   =>  '1'       %s{1}   => '1'
   %3d{1}  =>  '  1'     %3s{1}  => '  1'
   %03d{1} =>  '0001'    %-3s{1} => '1  '
   %4.2f{1} => '1.00'
The format specifies how the value is to appear, and is similar to the printf format usage.

Depending on the format type, a value will be converted and used appropriately. The empty string or null value ('') will be treated as a '0' value when used in an numeric context.

The default format is %d, ie, \%{val} would be \%d{val}. The numerical formats supported are: %d, %o, %x, %X, %e, %f, and %g; The %s format use the string value of the result.

5.6 Language Context and Value Expansion

The ifhp filter sends initialization and configuration commands to the printer. Depending on the type of language of a print file (i.e. - PostScript or PCL), different command formats would need to be used to implement different options. For example, to implement a landscape option for a PJL aware printer you would need to send the PJL command @PJL SET ORIENTATION=LANDSCAPE. For a PostScript printer you would need to send a very strange string which would depend on the actual printer mode.

Our language context also includes various checks for language specific dependencies. This section refers to material that is discussed in depth in later sections of this document, and on first reading may be a little confusing. However, if you are not aware of some of these restrictions then much of the information in the configuration files may be very confusing.

PJL Language

A PJL command has the form @PJL OPCODE ..., and PJL commands must be sent as a block before any other commands. In order to assist with this, the ifhp filter provides the following assistance. When expanding a list value, each list entry is expected to form a well formatted PJL command.

  1. Before sending any PJL command to the printer, the PJL Universal Exit Command (\033%-12345X) string is sent to the printer. This is automatically done if pjl is enabled for the printer.
  2. The list item is expanded, and all value substitutions are done. Leading and trailing whitespace is removed, all characters are converted to uppercase, and a new line (\n) value is appended to the command.
  3. Because not all printers support all PJL commands, the ifhp filter performs uses the pjl_only and pjl_except configuration lists to ensure that the options are allowed by the printer. The OPCODE must appear in the pjl_only list and not in the pjl_except list. For example:
    pjl_only = [ JOB SET STATUS ]
    pjl_except = [ STATUS ]
    

    The pjl_only indicates that the printer supports the PJL JOB, SET, and STATUS commands, but the pjl_except list removes the STATUS from this list. This means that only the JOB and SET commands will be allowed.

  4. If the command is a SET command, then the PJL variable must appear in the pjl_vars_set list and not in the pjl_vars_except list.
    pjl_vars_set = [ PAPER SIZE ORIENTATION ]
    pjl_vars_except = [ PAPER ]
    
    @PJL SET SIZE=A4
    @PJL SET PAPER=LETTER
    

    In the above example, the SIZE=A4 command would be allowed and sent while the PAPER=LETTER command would be rejected and not sent.

PCL Language

When sending PCL initialization strings to a printer, it is essential to send nothing that could cause a printable character to be sent before the actual file contents. Such output could cause the location and positioning of text to be altered in unexpected ways. To avoid this, the following steps are taken when expanding a list in a PCL language context.

  1. Before any PCL string is sent to the printer, the PCL End of Job (\033E) string is sent to the printer.
  2. All whitespace (blanks, tabs, etc) are removed from the string value.
  3. Next, all escaped values are substituted. At this point you can force printable strings containing whitespace into the output by using the \nnn escape mechanism.
  4. All list values are concatenated and then sent to the printer.

PostScript Language

The PostScript language processing is very minimal, as there are few problems sending PostScript to a printer.

  1. Before sending any PostScript initialization strings, the PostScript End of Job indicator (\004 or Control-D) is sent.
  2. Strings are then expanded and the escape sequences are substituted.
  3. Individual strings have a newline (\n) appended to them before being sent to the printer.

5.7 Printer Entries

The ifhp.conf file is divided into printer entries by [ pattern pattern ...] lines. Each pattern is glob matched against the model option value, and if the match is successful then the options on the following lines until the next printer entry header are appended to the specific printer configuration entry.

By convention, each configuration file is assumed to start with the header [ default ], and the initial set of lines are used to set default values for the various ifhp options.

The algorithm for scanning the configuration files first sets the model value to default, and extracts the default information. It then sets the model value to the user specified value, and rescans the configuration file information.

If users need to add or modify the ifhp.conf file, then they should add their entries to the end of the file, and override any default options by specific values in their new entry. To aid with system configuration and maintenance, the distributed ifhp.conf file has the following text at the end of the file:

##### This is the end of the standard ifhp.conf file.
##### Add your local files after this
##### If you want to override some entries, simply change the names to
##### something different, i.e. hp4 hp4.old
##### Here is a script to do this and then append your local file to the
##### end of the ifhp.conf file:
#####
##### #!/bin/sh
##### for i in $* ; do
#####   perl -spi.bak -e 's/ $i / $i.orig /g' ifhp.conf
##### done
#####
##### sed -n -e '1,/XXX END XXX/p' ifhp.conf >ifhp.conf.new
##### sed '1,/XXX END XXX/d' ifhp.old >> ifhp.conf.new
#####
##### You can probably improve on this.
#####
#### XXX END XXX #####

# user adds new default values here for all printer entries
[ default ]
# set default value
pcl_option= \033test

[ mypcl_printer ]
# override default value
pcl_option=

5.8 Printer Models Supported

There are over 500 different printer models, types and configurations supported by IFHP. If your printer is not currently supported and you have documentation about the printer then send mail to the LPRng Mailing List and support will be added.

The ifhp.conf configuration file contains configuration entries for various models of printers. Each entry has a name usually corresponding to the model of printer or its basic capabilities. For example, the HP LaserJet 4 printer has the model=hp4 configuration entry. The default printer configuration covers a wide range of network printers manufactured by Hewlett-Packard, Canon, Epson, and others and is for a printer that has a bidirectional communications connection that allows it to report status information and the following capabilities:

  1. PJL support (pjl) compatible with HP 4 family of printers
  2. PostScript (PS) support (ps).
  3. PCL support (pcl).
  4. Text files printed as PCL (text, default_language=pcl).

There is also support for PostScript only printers (/tt/model=ps/), Tektronics Phasers (model=tek), QMS (model=qmsXXX). The best way to determine the printers currently supported are to examine the ifhp.conf file for the contents. The configuration file has the following entries:

apple           hp4v            hpdj1200c       hpdj750c
hp4             hp5             hpdj1600c       hpdj750cplus
hp4000          hp5l            hpdj200         hpdj755cm
hp4500          hp5m            hpdj2000cp      hpiiisi
hp4l            hp5mp           hpdj220         hpljpro
hp4lc           hp5p            hpdj230         hppjxl300
hp4m            hp5si           hpdj2500cp      lexmark4039
hp4ml           hp5simopier     hpdj250c        lj3pclonly
hp4mp           hp5simx         hpdj330         phaser
hp4mplus        hp6l            hpdj350c        postscript
hp4mv           hp6mp           hpdj430         ps
hp4p            hp6p            hpdj450c        qms1725
hp4pj           hp8100          hpdj455ca       qms2025
hp4plus         hpcolorlj       hpdj600         qms2060
hp4si           hpcolorlj5      hpdj650c        qms860
hp4simx         hpcolorlj5m     hpdj700         tek

Next Previous Contents