Simple accounting filter/backend (With Perl or another script language)

Anonymous anonymous at easysw.com
Tue Jun 15 08:42:18 PDT 2004


Helge Blischke wrote:
> What about using Ghostscript's bbox device within such a filter?
> It would work even for non-DSC-compliant jobs.

Well, I'm quite new to this stuff, so what is the bbox device ?

By the way, I have quite advanced in a few days, and my code now bahaves correctly when called with no code. Thus, my "devices" show up in the device list when adding a new printer in cups, and when printing to it, my backend gets called.

My problem is that, looking at other backend's source (I too learned a lot from Pykota ;-)), I saw that they must expect 6 or 7 parameters:

-------------------------------socket.c
/*
 * 'main()' - Send a file to the printer or server.
 *
 * Usage:
 *
 *    printer-uri job-id user title copies options [file]
 */
[...This seem ok...(some code here)...]
 else if (argc < 6 || argc > 7)
  {
    fprintf(stderr, "Usage: %s job-id user title copies options [file]\n",
            argv[0]);
    return (1);
  }
[... Ah ! argv[0] seems to contain the executable name... But where is the above "printer_uri" in the error message ? ...(Some code here)...]
/*
  * Extract the hostname and port number from the URI...
  */

  httpSeparate(argv[0], method, username, hostname, &port, resource);
[...]
-----------------------------------------------
 ????? HEY !!!
Why now argv[0] should contain "printer_uri" ????

===> My problem is:
- How to receive "printer_uri" from Cups ?
- How to send it to the backends I call ?

Here is a snippet from my filter's code, and the resulting log:

-----------------------------------Snip-----
  print LOG "---> Print job started at ".strftime ("%a %b %e %H:%M:%S %Y", localtime)."\n";
  print LOG "  Command line: $0\n";
  print LOG "  Arguments: ".join("|", @ARGV)."\n\n";
  print LOG "  \$ENV{DEVICE_URI}= ".$ENV{DEVICE_URI}."\n\n";

-----------LOG------------------------------
---> Print job started at mar jun 15 15:36:46 2004
  Command line: /usr/lib/cups/backend/comptage
  Arguments: 85|root|Test Page|1|

  $ENV{DEVICE_URI}= comptage:socket://172.22.144.12:9100
--------------------------------------------

Note in that log that I DO receive the 5th argument ("options"), but it is empty...

Any Idea ? This is the main problem to solve for me, the rest is only database-filling... And maybe problems dealing with different printing formats (I hope not so :-( )




More information about the cups mailing list