# $Id: typerules 1103 2012-06-11 22:50:17Z faxguy $ # # HylaFAX Facsimile Software # # Copyright (c) 1990-1996 Sam Leffler # Copyright (c) 1991-1996 Silicon Graphics, Inc. # HylaFAX is a trademark of Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. # # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. # # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # # # HylaFAX file type rules. # # This file contains the file typing rules used by the sendfax # program to deduce how input files should be prepared for fax # transmission. The format of this file is based on the System V # /etc/magic file used by the file(1) program. The code that # reads this file was written entirely based on the comments that # exist at the top of the magic file and describe how it works. # The use of magic-style rules is intended to make it easier for # users to reuse rules already designed for use with file(1). # # Each entry defines a type rule. Entries normally are terminated # by the end of a line, thought they can be continued across lines # with a ``\'' (when this is done leading white space is converted # to a single space). ``#'' is a comment character; when it appears # on a line, everything to the right is ignored. # # The fields in each entry are: # # offset: a byte offset in the file at which data should be extracted # and compared to a matching string or value. If this value # begins with '>', then an additional rule is used and scanning # continues to the next type rule line that does not begin with # a '>'. Only a single level of '>' is permitted. # datatype: the type of data value to extract the specified offset in the # for comparison purposes. This can be byte, short, long, ascii, # string (a not necessarily null-terminated string of bytes), or # filename (the name of the file being typed). # A byte is 8 bits, short 16 bits, and long 32 bits. # match: the value and operation to use in matching; the value used is # based on the datatype field. This value may be "x" to mean # "match anything". The operation is "=" if nothing is specified; # otherwise it can be one of ">", "<", "<=", ">=", "!=", "&" # (for and-ing and comparing to zero), "^" (for xor-ing and # comparing to zero), and "!" (for taking one's complement and # comparing to zero). # For string and ascii data, no comparison operator is allowed, # and embedded spaces, but not embedded tabs, are allowed. # These data are taken literally; no C-style character escapes # are meaningful. # result: one of "PS", "TIFF", "PDF", "PCL", or "error" (case insensitive). # The first two results specifiy whether the rule generates a PostScript # file or a bilevel TIFF image. The "error" result indicates a # file is unsuitable for transmission and if supplied as an # argument to sendfax, the command should be aborted. # rule: a string passed to the shell to convert the input file # to the result format (suitable for sending as facsimile). # The rule string is a printf-like string that should use the # following "%" escapes: # %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 pathname of the fax library (e.g./usr/local/lib/fax) # %<x> the <x> character (e.g. ``%%'' results in ``%'' # # These are the "null rules"--i.e. for matching formats handled # directly by the server. # #offset datatype match result rule 0 string %! ps 0 short 0x4d4d tiff 0 short 0x4949 tiff # 0 short 000732 tiff %F/sgi2fax -%f -o %o -v %V\ -s %s %i 0 short 017436 error packed data support not configured 0 short 017635 error compressed data support not configured 0 short 0x0506 ps showcase -p -f %i 0 short 0x5343 ps showcase -p -f %i 0 short 0xf702 ps dvips -q -o %o %i 0 long 0x59a66a95 tiff ras2tiff -%f -v %V %i %o 0 short 0x1b45 pcl 0 short 0x1b25 pcl 0 short 0x1b26 pcl 0 short 0x1b2a pcl # # To do client-side PCL conversion to PostScript comment-out the above 4 # lines and uncomment the following, which decides a file is a PCL file # if its first two characters are <ESC> E (0x1b45), the PCL reset command. # #0 short 0x1b45 tiff pcl6 -dNOPAUSE -sDEVICE=tiffg3 -sOutputFile=- %i > %o #0 short 0x1b25 ps pcl6 -dNOPAUSE -sDEVICE=pswrite -sOutputFile=%o %i #0 filename ^.*\.xps$ pdf pcl6 -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=%o %i # # HylaFAX now has server-side PDF conversion, so no need for pdf2ps. # If you have trouble or if you prefer to use pdf2ps, comment this # next line and uncomment the second. 0 string %PDF pdf #0 string %PDF ps pdf2ps %i %o # # pdftk has the ability to auto-rotate pages to all make them portrait... # #0 string %PDF pdf pdftk %i cat 1-endN output %o # # NB: psdit is the Adobe Transcript program for converting ditroff output 0 string x T psc ps psdit <%i >%o # # These are from the PBMPLUS package's auxiliary magic numbers file # Most of these entries use the "string" format so that they will work on # both big-endian and little-endian machines. # 0 string begin error uuencoded file support not configured 0 string xbtoa error btoa'd file support not configured 0 string P1 error PBM file support not configured 0 string P2 error PGM file support not configured 0 string P3 error PPM file support not configured 0 string P4 error PBM "rawbits" file support not configured 0 string P5 error PGM "rawbits" file support not configured 0 string P6 error PPM "rawbits" file support not configured # 0 string WNGZWZSS error Wingz spreadsheet support not configured 0 string #Inventor V error IRIS Inventor file support not configured >15 string binary error binary IRIS Inventor file support not configured >15 string ascii ps %F/textfmt -B -f Courier-Bold\ -Ml=0.4in -p 11 -s %s >%o <%i # The following image types are not handled natively, but # can be used when a converter is installed. Enable the # conversion match and disable the corresponding error. 0 string GIF error filetype conversion support not configured #>3 string 87a tiff gif2tiff -%f -v %V %i %o #>3 string 87a ps gif2ps -y %i > %o #>3 string 89a ps gif2ps -y %i > %o >3 string 87a error GIF (version 87a) support not configured >3 string 89a error GIF (version 89a) support not configured 0 byte 0x89 error filetype conversion support not configured #>1 string PNG ps pngtopnm %i | pnmtops > %o >1 string PNG error PNG support not configured 0 short 0xffd8 error filetype conversion support not configured #>6 string Exif ps jpeg2ps -a -o %o %i #>6 string JFIF ps jpeg2ps -a -o %o %i #>47 string JFIF ps jpeg2ps -a -o %o %i >6 string Exif error JPEG support not configured >6 string JFIF error JPEG support not configured >47 string JFIF error JPEG support not configured 0 short 0xd8ff error filetype conversion support not configured 0 string #FIG error FIG support not configured # MS Office (Word) conversion using antiword or unoconv. Install antiword or unoconv # (which uses OpenOffice/LibreOffice) and enable this if you want it. It may produce # imperfect renderings, but they're better than nothing, perhaps. LibreOffice can also # be used in a "headless" mode, but you'll need a wrapper to specify an outfile... # # libreoffice --headless --invisible --convert-to pdf --outdir /path/somewhere %i # #0 short 0xd0cf ps antiword -p letter -m 8859-1.txt %i > %o #0 short 0xd0cf pdf unoconv -f pdf -o %o %i 0 short 0xd0cf error Microsoft Word Document support not configured # Office 2007 uses a zipped Open-XML file format. Magic typing # cannot distinguish between those files and other zip v2.0 files. 0 long 0x504b0304 error filetype conversion support not configured >4 byte 0x14 error Zip v2.0 support not configured # faxmail can be used to convert e-mail files to Postscript. #0 filename ^.*\.eml$ ps cat %i | faxmail > %o # # You can try to use html2ps for HTML documents. (unoconv may work also.) # #0 istring <!DOCTYPE HTML ps html2ps %i >%o #0 istring <HTML ps html2ps %i >%o #0 istring <TITLE ps html2ps %i >%o #0 istring <HEAD ps html2ps %i >%o #0 istring <BODY ps html2ps %i >%o #0 istring <DIV ps html2ps %i >%o #0 filename ^.*\.htm$ pdf unoconv -f pdf -o %o %i #0 filename ^.*\.html$ pdf unoconv -f pdf -o %o %i # # Japanization (should help other iso-2022 variants too) # #>15 string asciiesc ps a2ps-j -l '' -p -ns -nt <%i >%o #0 asciiesc x ps a2ps-j -l '' -p -ns -nt <%i >%o # # # This causes anything else with ascii-only data to be treated as text. # 0 ascii x ps %F/textfmt -B -f Courier-Bold\ -Ml=0.4in -p 11 -s %s >%o <%i # # Use enscript, instead of HylaFAX textfmt, for converting text into ps. # 1) Comment out the 2 lines above referring to textfmt # 2) Un-comment the following 3 lines # Notes: - The '--margins' and '-s' params are set to produce output similar # to the textfmt invocation above. # - Page size is fixed, since enscript doesn't handle the values # assigned to the %s macro. Use: # '-M Letter' (not 'letter', not 'LETTER') for US letter # '-M A4' (not 'a4') for ISO A4 #0 ascii x ps enscript -B -f Courier-Bold@11 \ # --margins=24::60:36 -s 2.2 \ # -q -M A4 -p %o %i # Support 7-bit text which would otherwise be seen as binary. # #0 byte x ps %F/textfmt -B -f Courier-Bold \ # -p 11 -s %s >%o <%i