Run time options are provided by the
command line arguments and values in the configuration files.
By convention,
the configuration files are named
ifhp.conf
.
In order to provide a flexible run time configuration facility, the location of the configuration files is specifed as follows.
./ifhp.conf,/etc/ifhp.conf,./ifhp.conf
-Tconfig=/path,/path,...
Here is a section of a simple configuration file.
# languages
pcl
statusfile=status
status
sync=pcl
sync_interval=20
# we force pagecounting off
#pagecount=pcl
pagecount@
[ HP4Si ]
status@
end
[ HP5Si ]
pjl
sync=pjl
The configuration file is used to set flags, option values, and to cause
various
ifhp
actions.
The file has the following structure.
Syntax Equivalent To Class
flag flag=1 (FLAG)
flag@ flag=0 (FLAG)
flag=val flag=val (string value) STRING
flag=] v v ... [ LIST
ifhp
will substitute the appropriate form or perform the
assocated action if the flag is TRUE.flag@
is used to indicate that the operation
related to this option is not to be performed.
# set string x value 'first\n second\n third'
x= first
second
third
# set list y value [ f1 f2 ]
y=[ f1
f2 ]
[ glob glob ... ]
Selection lines divide the configuration file into sections corresponding to a particular printer model. Configuration information is extracted from a file until either an 'end' line or a selection line is encountered.
The recommended format for a configuration file is to put common (default) flag settings at the start of the configuration file, followed by selection sections with overridding and additional flag values.
To allow a single file to be used for multiple printer configurations, you can specify that a section of the file is to be used ONLY by a various models of printers. This is is controlled by the value of the 'model' flag and selection lines of the form:
[ glob glob ... ]
The first occurrence of a 'model=xx' line in either the -T options or the configuration file will set the model flag value to 'xx'.
The 'model' value is matched against the modelglob values using GLOB matching. For example:
hp* matches hp4 hp5x
hp[45] matches hp4 hp5, but not hp5x
hp[3-6]* matches hp3, hp5, hp5x, but not hpiii
If a matching entry is found, successive lines will be used until either another selection line or an 'end' line is encountered. An 'end' line will terminate reading the current file, and the next configuration file will be read.
The default list of configuration files is:
ifhp.conf, /etc/ifhp.conf, ifhp.conf
This arrangement allows you to read the ifhp.conf file to get various model settings, scan the /etc/ifhp.conf file to get the generic ones, and then to rescan the local ifhp.conf file to provide overrides to values set in the /etc/ifhp.conf file.
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
are simply used to supply values for expansion during operation.
The builtin options are listed in later sections, and their use is explained. These options can have flag, string, or list values as is appropriate to their corresponding actions.
During normal operation,
the
ifhp
filter will perform an operation by producing a set of strings
which will be sent to the printer or output device.
These strings may be obtained by using the values of predefined or builtin
option names,
or by expanding a LIST value.
A LIST value has the form X=[ v1 v2 ... ]. When a list value is expanded each of v1, v2 is examined in turn and the corresponding action or string substitution or builtin evaluation is carried out. If v1 has a string value and is not recognized as a builtin or special option then normally the string value will be used.
t1=[ p1 p2 p3=end ]
p1=this is
p2=[ p3 p4 ]
p3=a
p4=test
p3=living\020\%{p3}
For example,
when expanding
t1
each of
p1
and
p1
is in turn expanded.
This will produce the strings
"this is"
,
"a"
,
"test"
and
"living end"
in turn.
Some LIST variables are used in printer language specific contexts and their values are processed appropriately. For example, pjl_init=[...] specifies a set of operations to be carried out for printers that support PJL, and pcl_init=[...] for PCL printers. 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. For this reason, during expansion the language name and an underscore is prefixed to the list entry name, and this is used as the option name during the search.
For example, suppose that we have:
pjl_init=[ test ]
pcl_init=[ test ]
initstr=NO
pjl_initstr=@PJL ECHO YES
pcl_initstr=\033(*yeS
When PJL initialization is done, the 'pjl_test' LIST will be expanded, and the PJL string '@PJL ECHO YES' will obtained. When PCL language specific processing is done, then the \033(*yeS string will be obtained.
String values are encoded using a simple PERL/C language like method. The \ (escape) character introduces a replacement string. This has the form:
\f \r \n \t \nnn
where nnn are 3 octal digits are replaced
by the standard PERL or C character substutions.
\%format{option} \%format[option]
The option name will be relaced by the formatted option value.
The option value is located using a simple set of rules.
option=word
will push the
option=word
combination onto an evaluation stack.
This stack is searched in oldest to newest order for a match.{option}
then the
-Zoption=value
command line options will be searched for a match.-Toption=value
command line options will be searched for a match.
This allows the
{option}
to start searching from the -Z command line options and
[option]
to start searching from the -T command line options."0"
value is used.The format specifies how the value is to appear, and is similar to the printf format usage:
%[-][0][length[.precision]][format]
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 option string value.
The format is usually not required, except when fractional values of point sizes or string substition rather than numerical substition is required.
For example:
Configuration:
pjl_user_opts=[ ... outbin intray ...]
pjl_outbin=@PJL SET OUTBIN=\%s{outbin}
intraynum=4
pjl_intray=@PJL SET INTRAY=\%{intraynum}
Command:
ifhp -Zoutbin=LEFT
During PJL language processing,
the
-Z
command line options
will be scanned for options which appear in the
pjl_user_opts
list.
The
-Toutbin=LEFT
option will be found and will be expanded in the PJL context
by prefixing
pjl_
and looking for a string or list value.
The
pjl_outbin
option will be found,
and the
@PJL SET OUTBIN=\%s{outbin}
string will be expanded.
Now we need to search for the
outbin
value.
We first search for it on the evaluation stack,
but there is nothing there yet.
We then search the
-Z
options and find the
outbin
value,
and substition yields
@PJL SET OUTBIN=LEFT
.
Next, the
intray
option is found and
pjl_intray
is expanded,
which needs a value for
intraynum
.
This is found in the configuration information,
and finally in
@PJL SET INTRAY=4
.
cpi=5.5
pcl_cpi=\033\%3.2f{cpi}D
During PCL option expansion,
we might need to expand the
pcl_cpi
option.
When the
pcl_cpi=\033\%3.2f{cpi}D
string is expanded,
the result is
\033\%5.00D
.
If the user has specified
-Tcpi=9
on the command line then the result is
\033\%9.00D
.
The Tifhp filter sends initialization and configuration commands to the printer. Depending on the language, these commands have specific forms and requirements. Rather than requiring the user to remember the details, Tifhp uses the following conventions.
A PJL command has the form
@PJL OPCODE ...
.
A command must start with
@PJL
and consist of a single string value.
You cannot patch together options to make a single PJL command.
\033%-12345X
)
string is sent to the printer.pjl_only
and
pjl_except
configuration options.
The OPCODE must appear in the
pjl_only
list and not in the
pjl_except
list.\n
) appended to them before being sent to the printer.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 processing PCL strings.
\033E
) string is sent to the printer.\nnn
escape mechanism.The PostScript language processing is very minimal, as there are few problems sending PostScript to a printer.
\004
or Control-D) is sent.\n
) appended to them before being sent to the printer.