Subject: Re: Filters
To: None <port-atari@netbsd.org>
From: Thomas Gerner <thomas@murmel.camelot.de>
List: port-atari
Date: 08/18/1998 22:34:01
Hello Mike,

On Mon, Aug 17, 1998 at 11:26:08PM -0500, Mike Sienicki wrote:
> Are there any filters included with NetBSD that I can set up to add a
> carriage return after each line feed when I send text to my laser printer?
> If so, how would the "if" entry appear in the printcap file to add the CR?
> Have I given enough facts for you to even answer this request?

I don't know about a filter included in NetBSD. I wrote my own one. It is
very simple and works with a HP Deskjet. It converts lf to cr:

#include <stdio.h>

int main(int argc, char **argv)
{
    FILE *in = stdin, *out = stdout;
    char ch;

    while (!feof(in)) {
	switch(ch = getc(in)) {
	    case '\n':
		putc('\r', out);
	    default:
		putc(ch, out);
	}
    }
    putc('\r', out);
    exit(0);
}

If you need crlf for lf move the 'putc(ch, out);' after the switch (behind the closing
brace) and remove the 'default:'.

For this filter I use this printcap entry:

lp|text printer:\
        :lp=/dev/lpt0:\
	:of=/usr/libexec/lpr/crlf:\
	:pl#80:\
	:pw#60:\
	:sd=/var/spool/lpd:\
	:sh:\
	:tf=/usr/libexec/lpr/lpf:\
	:lf=/var/log/lpd-errs:

Thomas