[cups-devel] Calling a CUPS filter under different names so that it behaves differently

Till Kamppeter till.kamppeter at gmail.com
Mon Jun 27 13:41:20 PDT 2016


Hi,

cups-filters contains a filter named gstoraster, which is a CUPS filter 
written in C which calls Ghostscript to convert PDF or PostScript input 
into CUPS or PWG Raster output.

There are also two other filters, pstopdf and gstopxl which are shell 
scripts. Problem of these filters is that they directly read the print 
queues PPD file (/etc/cups/ppd/*.ppd) and this does not work any more 
due to file permission changes.

Therefore I want to replace these two filters by equivalent filters 
written in C. And as these filters call Ghostscript like gstoraster does 
they would get very similar to gstoraster. Now I want to avoid duplicate 
code and therefore I modify gstoraster to be able to also output PDF or 
PCL-XL, depending on the name of the executable (gstopdf, gstopxl) and 
add gstopdf and gstopxl links to gstoraster in /usr/lib/cups/filter/.

First, I have used symbolic links and tried to read argv[0], but this 
does not work as CUPS sends the print queue name to its filters using 
argv[0].

So I tried an alternative approach, reading the /proc/self/exe symlink 
which points to the executable file. This has two problems:

- /proc/self/exe exists only under Linux, on other systems it has 
another name or there is perhaps even no /proc file system

- The alternative filter names in /usr/lib/cups/filter/ must be hard 
links, if they are symbolic links, /proc/self/exe only points to the 
name of the actual executable file, not of the symbolic link through 
which it was called.

Any suggestions to how to implement this the best way?

    Till





More information about the cups mailing list