From: Thomas Hiller (hiller@fzi.de)
Date: 05/17/93


From: hiller@fzi.de (Thomas Hiller)
Subject: Printer filter for Canon BJ
Date: 17 May 1993 08:10:15 GMT

Someone (sorry I forgot who) has posted a filter for HP Deskjet. This is the
same filter adapted to Canon BJ300 (and maybe other BJ's).

Greetings Thomas

/* Original filter by: ????? */
/* "bjf", a Canon BJ (300) Printer, PRINT FILTER */
/* The filter MUST be an input filter, otherwise it wont work */

/*

The following is the "/etc/printcap" entry I use with the filter:

lp|canon|bj|BubbleJet:\
        :lp=/dev/lp1:if=/usr/lib/bjf:sd=/usr/spool/hpdj:\
        :lf=/usr/adm/lpd-errs:sh

*/

/* This is brain dead it uses: */
/* Draft mode, 80 chars x 66 lines */
/* Added Postscript conversion in filter -- Ian Daniel, 29/4/93 */
/* This is less brain dead now I think....... */

#define _POSIX_SOURCE 1
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

main ()
{

int d_char;
FILE *og;
char command[256], test[256];

/* Change Paper size and Printer here */
/* One - is for stdout the other is to tell gs it's reading stdin */

sprintf(command, "/usr/bin/gs -sDEVICE=bj10e -sPAPERSIZE=a4 -dNOPAUSE -q -sOutputFile=- -");

if((gets(test)) == NULL)
  {
  fprintf(stderr, "Can't get a line from stdin, help!\n");
  exit(1);
  }
else
  {
    if((strstr(test, "%!")) == NULL)
      {
       /* Set up printer */
       /* Auto CR */
       printf("\033\133\113\004");
       putchar('\000'); putchar('\004'); putchar('\045');
       printf("\021\200");
       puts(test);
       while ((d_char=getchar()) != EOF)
         putchar(d_char);
       printf("\033\133\113\001");
       putchar('\000'); putchar('\000'); /* Reset Printer */
      }
   else
      {
        if((og = popen(command , "w")) == NULL)
           {
           fprintf(stderr, "Can't execute gs\n");
           exit(1);
           }
        else
           {
            fputs(test,og);
            while ((d_char=getchar()) != EOF)
                 fputc(d_char, og);
            pclose(og);
           }
      }
  }
}

-- 
Thomas Hiller                                   email: hiller@fzi.de
Forschungszentrum Informatik
Abtl. Mikrorechnertechnik
Haid-und-Neu-Strasse 10-14                      Fax : +49-721-9654-809
D - 7500 Karlsruhe 1                            Tel.: +49-721-9654-832