SUMMARY: Printer accounting, HPGL plotter

From: Russ Poffenberger (poffen@sj.ate.slb.com)
Date: Wed Dec 09 1992 - 03:57:25 CST


My original question:

>I know these questions have come up before, but the solutions don't work,
>or don't fit my need.
>
>Basically, we have an HP 7600 electrostatic plotter that is used by a couple
>different departments. I need to setup accounting because the departments
>are always bickering about buying the paper and other maintenance. Each dept.
>thinks the other uses it the most.
>
>I know that Sun's lpd doesn't do any accounting, I need an 'if' filter to
>actually do this, but where can I get such a filter? A summary a while back
>in this mailing list mentions "/usr/lib/lpf". When I try this, then jobs
>don't get printed properly. It appears as though after a few vectors, the
>rest of the file gets lost, so I never get a full plot. If I remove the if
>and of entries from the printcap, then the plots work, but of course, I don't
>get any accounting info.
>
>The files being printed are hpgl. I think that "lpf" does not like hpgl, hence
>the problems. Oh, yeah, this is SunOS 4.1.1 if it matters.
>
>Any suggestions will be appreciated, and I will post a summary.

Many thanks to jpd@usl.edu (James Dugal) who sent me his modified BSD 4.3
lpd source package.

Using this, I was able to determine (since there is a lack of ANY documentation
on printer filters) that the lpf filter shipped with SunOS is not exactly a
generic pass all printer filter. Perhaps this was causing some problems.

Using the source, I hacked out a generic printer filter that simply passes
stdin to stdout, and counts the characters. It then logs them to the
accounting file. This is a very crude measurement of course, but it will
give me some information in the short term, and allows me to modify the
source in my spare time to actually read the HPGL and calculate the number
of feet of paper.

Here is the code if anyone is interested.

/*
 * Copyright (c) 1983 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by the University of California, Berkeley. The name of the
 * University may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1983 Regents of the University of California.\n\
 All rights reserved.\n";
#endif /* not lint */

#ifndef lint
static char sccsid[] = "@(#)lpf.c 5.3 (Berkeley) 6/30/88";
#endif /* not lint */

/*
 * filter which reads the output of nroff and converts lines
 * with ^H's to overwritten lines. Thus this works like 'ul'
 * but is much better: it can handle more than 2 overwrites
 * and it is written with some style.
 * modified by kls to use register references instead of arrays
 * to try to gain a little speed.
 *
 * Modified by jpd@usl.edu to support printer_order (PO) [see lpc].
 */

#include <stdio.h>
#include <signal.h>
#include <sys/types.h>

#define MAXWIDTH 132
#define MAXREP 10
#define OUTSIDE_PAGE 3

int nchars ;
char *name; /* user's login name */
char *host; /* user's machine name */
char *acctfile; /* accounting information file */

main(argc, argv)
        int argc;
        char *argv[];
{
  register FILE *p = stdin, *o = stdout;
  register char *cp;
  int done;
  int ch = 0;
  time_t now;
  char timestr[26];
/* pause();*/
  while (--argc) {
    if (*(cp = *++argv) == '-') {
      switch (cp[1]) {
      case 'n':
        argc--;
        name = *++argv;
        break;

      case 'h':
        argc--;
        host = *++argv;
        break;
        
      }
    }
    else
      acctfile = cp;
  }

  done = nchars = 0;
        
  while (!done) {
    switch (ch = getc(p)) {
    case EOF:
      done = 1;
      break;

    default:
      putc(ch,o);
      nchars++;
      if (!(nchars % 8192))
        fflush(o);
      break;
    }
  }
  fflush(o);
  now = time((time_t *)0); /* Get the current time and convert to ascii */
  strcpy(timestr,ctime(&now));
  if (name && acctfile && access(acctfile, 02) >= 0 &&
      freopen(acctfile, "a", stdout) != NULL) {
    printf("%7.2f\t%s:%s\t%.15s\n", (float)nchars, host, name, &timestr[4]);
  }
  exit(0);
}

Thanks to all who replied.

applebau@apollo.aoe.vt.edu (Mike Applebaum)
ruck@alpha.ee.ufl.edu (John R Ruckstuhl Jr)
aahvdl@eye.psych.umn.edu (Andrew Luebker)
mdl@cypress.com (J. Matt Landrum)

Russ Poffenberger DOMAIN: poffen@sj.ate.slb.com
Schlumberger Technologies ATE UUCP: {uunet,decwrl,amdahl}!sjsca4!poffen
1601 Technology Drive CIS: 72401,276
San Jose, Ca. 95110 Voice: (408)437-5254 FAX: (408)437-5246



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:54 CDT