*BSD News Article 78337


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!psgrain!iafrica.com!uct.ac.za!quagga.ru.ac.za!howland.erols.net!news.sprintlink.net!news-peer.sprintlink.net!arclight.uoregon.edu!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail
From: brian@awfulhak.demon.co.uk (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Printing problem with Okidata OLE600.
Date: 14 Sep 1996 23:12:25 +0100
Organization: Coverform Ltd.
Lines: 62
Message-ID: <51fak9$136@anorak.coverform.lan>
References: <01bb9e93$2739c860$9bc4abc7@glen> <3234727C.6028@www.play-hookey.com> <01bb9f94$4e7e5920$7ac4abc7@glen> <3235D81C.47E6@www.play-hookey.com> <01bba11e$bf0cd280$81c4abc7@glen> <32385AD7.1632@www.play-hookey.com>
NNTP-Posting-Host: localhost.coverform.lan
X-NNTP-Posting-Host: awfulhak.demon.co.uk
X-Newsreader: TIN [version 1.2 PL2]

Ken Bigelow (kbigelow@www.play-hookey.com) wrote:
: Glen wrote:
: > 
: > This is what I can up with!
: > 
: > #include <stdio.h>
: > 
: > main ()
: > 
: > {
: >         int c;
: >                 while (( c = getchar()) != EOF)
: >         {
: >                 if ( c == '/n')
: >                 putchar(13);
: >                 putchar(c);
: >         }
: > return (0);
: > }
: > 
: > My new problem!!!!!!!!!  This is my filter file.
: > 
: > /bin/cat | theaboveprogram > Now I don't know what to do.  How do I write
: > this filter file.  I have tryed all different things.
: > 
: > Thank You.
: > 
: > I do know a little C.  Just don't know how to imply it well.
: > 


: Close. Define c as a char, not an int. Also, I'm not sure whether or not
: this routine will actually see an EOF marker, and I don't think it needs
: one. Remember that here we are dealing with characters being sent to a
: printer. The printer won't recognize an EOF or know what to do with it;
: it will just print what it gets. The filter program just gets into the
: character stream and plays with it a little.

Em, sorry - the int is correct.  The EOF is correct too.  The only thing
that is incorrect is the '/n' (should be '\n'), but I'm sure that's just
a typo.  The lpd program does a pipe()/exec() to execute the filter and
then pumps the file into the open file descriptor.  The getchar function
in the filter returns *int* so that it can say EOF (-1) and not mix that
with the valid range of chars (0-255).  Note from the code, the filter
never sends an EOF (the filters descriptor 1 - stdout is the printer).

: As for using it as a filter, refer to the Handbook. The section on
: Printing is quite detailed, and includes setting up the filter file and
: defining it properly in /etc/printcap. Once you've defined it, the
: filter program will be automatically piped between the source and the
: printer.

: Above all, be willing to tweak it a bit and waste a few sheets of paper
: in testing.

I still think my suggestion of a filter of sed 's/$/^M/' is better !
The beauty of unix is that you don't have to write small programs like
this (usually) - there's always something there that'll do it.

--
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....