                                     BJFILT.EXE (Version 1.1)

This program has two purposes. The main purpose is to stop the Canon Bubble Jet printer driver(version 1.2)
 for the BJ200 to stop printing out the extra two letters "ab" at the end of every print job coming from Dos, 
Winos2, or from a copy <file> lptn command.

The second purpose is to provide a parallel port "monitor" which can print out every character sent to the
 parallel port, for purpose of debugging parallel port problems. This purpose is independent of the first but 
once I had figured out how to so the first, the second was easy to do.

This code is based on K. Rommel's printmon.exe program which he has supplied with his port of ghostscript
 to OS2, and thanks must go to him for his guidance through the source he provided. All errors are of course
 my own.

REASON:

The Canon bubble jet driver (Version 1.2)  for the BJ200 has a very strange behaviour in that it will print out
 an extra "ab" at the end of every print job that originates in a Dos or a Windows session, or that originates 
from doing "copy <file> lpt1" (where I am assuming that lpt1 is the port to which the BJ200 is attached). It does 
not do this for print jobs sent directly through OS2 ( eg, when you push "PrintScreen" on a desktop window). This 
behaviour is especially strange because it can be traced to the BJ printer driver sending the sequence 
" Esc ( a 01 Null Null Esc ( b 01 Null Null  Esc @" at the end of the job. (If it comes from the Windows BJ driver 
there are in fact two of these sequences at the end of the job). What is weird is that exactly the same sequence is
 at the end of an OS2 print job, where it does not result in the extra "ab" output. This filter simply nulls out 
everything in this sequence except the "Esc @", which seems to solve the problem. If anyone can understnd the
 reason for this I would appreciate hearing it.

This behaviour is especially annoying because the Canon driver is far faster than the IBM4070 or 4072 drivers
 which can also run the BJ200.

PROGRAM:

This program is run by the command

<Path>bjfilt  lpt#  [quiet] [monitor] [noreplace]
 <Path> - path to the location of the program
   lpt#-- lpt1, lpt2 or lpt3 = the parallel port to which the bubble jet is attached
  [<flag>]- optional flag parameter.
         quiet- do not put any output to the standard output (screen) Used when running bjfilt from config.sys or
                   detached.
        monitor- put all of the output sent to the printer out the standard output as well.
        noreplace- Do not replace the string which produces the "ab" for the BJ200.

The usual way of running this would be either to type ( assuming the printer is attached to port 1)

detach bjfilt lpt1 quiet

or to put the line

run=c:\spool\bjfilt.exe lpt1 quiet

at the end of your config.sys file. (You must give the full path and name of the program in the run command.
 I am assuming here that the program was installed in the c:\spool directory.)  To kill the program in the first 
case, use a program like killem to kill the PID reported by the detach command. 


Other Features.

The  two other flags are the "monitor" and the "noreplace" flags. The latter only makes sense in combination
 with the former, as it disables the replacement of the string that is the purpose of the program. All the
 "noreplace" flag on its own should do is to slightly slow the printer driver down (although I have noticed
 that sometimes it actually speeds it up significantly.)

The "monitor" flag dumps to the standard output all of the data that it is dumping to the printer. Thus you
 can see exactly what is being shovelled out the printer port by the BJ driver or by any other driver. With
 the "noreplace" and "monitor" flags together, this program does nothing to the data sent to the printer,
 but send a copy of the data to the standard output.  

(To be exact, the this program is installed as a "monitor" on the parallel port device driver, with the request
 that it be installed "last". However each new monitor which requests "last" is placed BEFORE all of the
 previously installed monitors that requestd "last". Thus it is possible that there are other monitors installed 
by the system earlier that  modify the data after this one has relesed the data.)

The output from the monitor command can be redirected to a file.  Since print jobs tend to generate a huge
 number of bytes, be careful of this and kill  bjfilt ( with ^C if in forground or a program like killem
 if detached) after you have collected enough data. (A single full page graphics will produce something of
 order 1MB of output, rapidly filling your disk if you are not careful.)

The final flag is the "quiet" flag. By default, on starting the job, the program prints out its title, and if the
 options are incorrect it will print out a help screen. It also prints out error messages. At the beginning of
 every print job, it will type out the name of the job, and at the end it will type out
a summary- the number of bytes it processed, and the number of times it replaced the filter string. (If the file
came from WinOS2, this number of filter strings replaced  will tend to be two,  otherwise it will tend to be one.) 
The quiet flag suppresses all of this output.

SUMMARY:

bjfilt lpt#  [quiet] [monitor] [noreplace]

# = Number of the parallel port to which the printer is attached.
quiet = do not "print" out (to the screen) the statistics of each job
monitor=print out (to screen or redirected standard output) every byte processed by the
                     program
noreplace= do not replace the string which produces the "ab". This means the program does
                     nothing unless the monitor flag is also used.

SOURCE:
Source code is provided, together with a make file. The program was compiled using the emx port of gcc under 
emx .8h with the emxfix05 installed, and using the gnu make utility. (Earlier emx fixes need the mon subroutines 
explicitely defined. Get the mon.{h,c,imp} from K Rommel's printmon package in his port of ghostscript.)  
 Emx is a gcc port to OS2 plus OS2 subroutine library by Eberhard Mattes, and the gnu make utility was 
ported to OS2 by K. Rommel. It does not require the emx runtime libraries.

AUTHOR:
	W. G. Unruh 
	unruh@physics.ubc.ca

COPYRIGHT:
	For the files bjfilt.c, bjfilt.exe, findstr.c
		W. G. Unruh

The programs and the files whose copyright is owned by W. G. Unruh may be  copied, used, and given to others 
without charge as long as they are not sold or otherwise transfered for any monetary consideration. Except as 
noted herein, the author, W.  G. Unruh, retains all copyrights for the material he has created. These files may
 be included in distributions for which a nominal fee for the medium and distribution is charged. This copyright 
notice is in all cases to remain with the files, and they are to be transmitted unaltered, and with the complete source
 files as well as the executable file. If alterations are made in any of these files, the author of those alterations is to
 be clearly identified.

DISCLAIMER: The materials included in thsi distribution are provided for the free use of anyone subject to the
 above copyright restrictions. The author disclaims any and all  liability for any and all damages of any kind 
caused by this software. All risks are born by the user of this software for any and all damages no matter how
 caused,  whether those damages are  direct or consequential. This software is experimental, and if you do not
 wish to assume any risks involved, do not use it. 