Cups ignores filename extensions?

John Meshkoff johnpipe at sonic.net
Thu Mar 13 14:43:59 PDT 2008


I'm neither a CS major nor programmer, so understanding configuration files is slow with me. The following experience indicates that CUPS ignores filename extensions, even though they are included in rules in /etc/cups/mime.types.

I came across this while trying to get CUPS to render an HP-GL file (NOT "HP-GL/2"). My first try at printing a "filename.plt" to a LaserJet 4p over my home network gave me a 7-page output of HP-GL ascii!

After much time searching the documentation, I came to the comprehension that the answer was in the mime.types file. Here are the "hpgl" rules, as I finally modified them:

application/vnd.hp-HPGL         plt hpgl string(0,<1B>&)\
                                string(0,<1B>E<1B>%0B) string(0,<201B>)\
                                string(0,BP;) string(0,IN;) string(0,DF;) \
                                string(0,BPINPS;) \
                                (contains(0,128,<1B>%-12345X) + \
                                 (contains(9,512,"LANGUAGE=HPGL") \
                                  contains(9,512,"LANGUAGE = HPGL"))) \
                                string(21,IN;SC;PU;PU;)
# AutoCad HP-GL rule added to bottom of list, 12 Mar 2008.

The documentation and rules suggest that CUPS should identify the filetype either by the extension or an identifier string contained within the file; however, printing an HP-GL file with either the "hpgl" or added "plt" extension gave the same ascii output.

I examined a test plot for comparison with the rules:

linus:/u2/home2/johnpipe$ xxd testplt.plt
0000000: 1b2e 283b 1b2e 4938 313b 3b31 373a 1b2e  ..(;..I81;;17:..
0000010: 4e3b 3139 3a49 4e3b 5343 3b50 553b 5055  N;19:IN;SC;PU;PU
0000020: 3b53 5031 3b4c 543b 5653 3336 3b50 412d  ;SP1;LT;VS36;PA-
0000030: 3136 3736 342c 2d31 3036 3638 3b50 443b  16764,-10668;PD;
0000040: 5041 2d32 3534 302c 2d31 3036 3638 3b50  PA-2540,-10668;P
0000050: 412d 3235 3430 2c33 3535 363b 5041 2d31  A-2540,3556;PA-1
0000060: 3637 3634 2c33 3535 363b 5041 2d31 3637  6764,3556;PA-167
0000070: 3634 2c2d 3130 3636 383b 5055 3b50 4130  64,-10668;PU;PA0
0000080: 2c30 3b53 503b                                               ,0;SP;

The HP-GL was generated by AutoCad 10, and as may be seen, none of the rules following the extension match (HP-GL was never exactly standardized). I therefore added the rule to match the "IN;" command that begins at offset 21d, and the first few following HP-GL command strings to eliminate random filetype mis-identification.

The new rule results in correct rendering of the acad HP-GL.

But, if the filetype extension is included in what are purported to be matching logical OR  rules, why is the extension ignored, and, therefore, why is it even included?

Thanks for any explanaton you may be able to give on this subject,

John




More information about the cups mailing list