TYPERULES(5)
๐ TYPERULES(5) ๐
okay so this is the TYPERULES(5) page, straight out of the File Formats Manual, and it's all about typerules โ HylaFAX's file type identification and conversion rules. bestie, this is the glow-up guide for your fax server's taste in files. let's get into it ๐ฆ
๐ธ NAME ๐ธ
typerules โ HylaFAX file type identification and conversion rules
โจ DESCRIPTION โจ
okay so here's the vibe check first: the HylaFAX server is picky. it only accepts three types of files for transmission as facsimile:
- POSTSCRIPTยฎ files
- PDF files
- TIFF Class F (bilevel Group 3-encoded) files
that's it. that's the whole list. every other type of file has to be converted</> into one of those three formats before it gets to go anywhere. no exceptions, bestie ๐
so what happens is, the facsimile submission program runs a set of rules against the contents of each input file. it uses those rules to figure out what the file's type is, and then to figure out how to convert it into something that's actually suitable for transmission. icon behaviour, honestly.
these rules live in the file /etc/hylafax/typerules โ an ASCII file that's patterned after the /etc/magic file used by the System V file(1) program. but (and this is important) there are significant differences, and they're noted below. don't just assume it's the same thing, iykyk.
๐ง how type rules actually work
type rules work by matching data patterns in a file โ typically patterns that show up in the first few bytes of the file (i.e. magic numbers). there are two types of rules:
- primary rules โ the main character rules
- secondary rules โ they specify additional rules to apply after a primary rule has been matched
when secondary rules are used, rule scanning continues up to the next primary type rule in the file. periodt.
๐ the anatomy of a rule
each rule consists of a set of whitespace-separated fields:
offset datatype match result command
if a line is terminated with a backslash character, the entry is continued on the next line with any leading whitespace characters compressed to a single space. ๐ซ
comments are marked with the `#` character; everything from there to the end of the line is discarded. gone. bye. ๐
secondary rules have a `>` character in the first column of the line; primary rules do not.
๐ the fields, one by one
offsetโ the byte offset in the file at which data should be extracted and compared to a matching string or value.datatypeโ the type of data value to extract at the specified offset, for comparison purposes. it's one of:`byte`(8 bit unsigned number)`short`(16 bit unsigned number)`long`(32 bit unsigned number)`string`(an array of bytes)`istring`(a case-insensitive array of bytes)`ascii`(an array of ASCII-only bytes)
matchโ the value and the operation to use in matching; the value used is based on thedatatypefield. if value is`x`, then it's interpreted to mean match anything. otherwise the following operators are supported (where data is the value extracted from the file and value is specified in thematchfield) โ except for the types`string`,`istring`, and`ascii`:
= data == value != data != value
> data > value < data < value
<= data <= value >= data >= value
& (data & value) == value ! (data & value) != value
^ (data ^ value) != 0
if no operation is specified then `=` is used. (the default is the default, bestie ๐
)
for `string`, `istring`, and `ascii` no operator is allowed; the implicit operation is always `=`. in these cases, the field is terminated by a tab or end of line, not by `#`. characters in the field have their literal value; there are no C-style character escapes. none. zero. nada.
resultโ one of`ps`,`tiff`, or`error`(case insensitive). the first two results specify whether the rule generates a POSTSCRIPT file or a TIFF/F file (Group 3-encoded bilevel data), respectively. the`error`result indicates that a file is unsuitable for transmission and, if supplied for transmission, should cause the job to be aborted with thecommandfield used in an error message. ๐ญcommandโ a command description that is expanded and passed to the shell to convert the input file to theresultformat (suitable for sending as facsimile). before the string is passed to the shell, it's scanned and the following`%`escape codes are substituted for:`%i`โ input file name`%o`โ output file name`%r`โ output horizontal resolution in pixels/mm`%R`โ output horizontal resolution in pixels/inch`%v`โ output vertical resolution in lines/mm`%V`โ output vertical resolution in lines/inch`%f`โ data format,`1`for 1-d encoding or`2`for 2-d encoding`%w`โ page width in pixels`%W`โ page width in mm`%l`โ page length in pixels`%L`โ page length in mm`%s`โ page size by name`%F`โ the directory where HylaFAX filter programs reside`%<x>`โ the<x>character (e.g.`%%`results in`%`)
see below for example uses of these codes. ๐
๐ EXAMPLES ๐
the following rules are used to match the formats that are handled directly by the server:
#offset datatype match result command
0 string %! ps # POSTSCRIPT
0 string %PDF ps # POSTSCRIPT by Ghostscript
0 short 0x4d4d tiff # big-endian TIFF
0 short 0x4949 tiff # little-endian TIFF
these rules are used to process the ASCII version of IRIS Inventor database files while blocking the transmission of the binary format variant:
#offset datatype match result command
0 string #Inventor V error IRIS Inventor file
>15 string binary error binary IRIS Inventor file
>15 string ascii ps %F/textfmt -fCourier-Bold -p11bp\
-U -q >%o <%i
this rule is typically the last entry in the file and is used to convert all unmatched ASCII data files to POSTSCRIPT:
#offset datatype match result command
0 ascii x ps %F/textfmt -fCourier-Bold -p11bp -U -q >%o <%i
๐ซถ NOTES ๐ซถ
it is much better to convert data that is to be transmitted to POSTSCRIPT, because this data format permits the facsimile server to do the final imaging according to the optimal transfer parameters (resolution, binary encoding, etc.). like, genuinely, do this. it's the move. ๐
it might be better to allow secondary rules to augment a primary rule rather than just replace them. this would allow, for example, command line options to be selected based on file type. (it's a thought. a vibe. a maybe. ๐ง)
โญ SEE ALSO โญ
okay that's the whole page bestie, you ate ๐ this one's dated May 12, 1993 and it belongs to TYPERULES(5) โ go forth and convert responsibly, no cap ๐ฆโจ๐
๐ฆ where this page comes from
- debian bookworm: hylafax-client 3:6.0.7-5
- debian trixie: hylafax-client 3:6.0.7-11.1
- ubuntu noble: hylafax-client 3:6.0.7-7
- ubuntu questing: hylafax-client 3:6.0.7-13
- ubuntu resolute: hylafax-client 3:6.0.7-13build1
- ubuntu stonking: hylafax-client 3:6.0.7-13build1
- Copyright (c) 1993-1996 Sam Leffler
- Copyright (c) 1993-1996 Silicon Graphics, Inc
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms