Subject: printer daemon and other stuff

From: [email-masked]

Hi all,
I want to set up my printer daemon correctly. I think i did most of it correctly
but now i need some help. If i do lpr filename i only get some rubbish on my 
printer. If  i send pcl-files (from TeX) with cp filename /dev/par all seems to
be correct. If i understand it correctly a filter is a program that reads 
from standard input and writes to the printer-device. A printcap entry for
such a filter is done by :if=/usr/lib/filter: . Am i right?
I wrote a little program:
nclude <stdio.h>
main()
{
int a;
FILE *outfile;
fopen("/dev/par","w");
while((a=getchar())!=EOF)
	{
	if(a==12){putw(10,outfile);a=13;};
/*	fprintf(stderr,"es ist ein %i\n",a);*/
/*	fflush(stdout);*/
/*	fflush(stderr);*/
	putw(a,outfile);
	}
}
	
it is not possible to write a 10 or 13 to stdout it seems.
if i start the program with filter|od -b it always says there is a 12 in the
output. What functionality prevents this program from doing what i expected?
is it possible to do such a thing?(substitute the 10+13 for 12)
ciao

---

From: [email-masked]

Hi,

[...]
> I wrote a little program:

"#i" is gone ? (Sorry, couldn't resist.)

> fopen("/dev/par","w");

outfile = fopen ... (But I am sure this was also in your code, because
otherwise you wouldn't have seen anything, but maybe a core dump)

> it is not possible to write a 10 or 13 to stdout it seems.

Wrong conclusion. The problem is, that 12 never appears in the input-stream.

> if i start the program with filter|od -b it always says there is a 12 in the

You forgot, that od -b outpus in octal numbers, so octal 12 is decimal 10,
which appears goes straight through your filter, as there is no if
condition concering this case.

> is it possible to do such a thing?(substitute the 10+13 for 12)

An while I am on:
Although I still don't have a suitable machine to run NetBSD on, I
volunteered to continue the FAQ. Unfortunately, I haven't been able
to work on it, because I have been working at SNI for the last two
month and I hadn't access to the needed tools (LaTeX, emacs) and
was missing an internet-connection.
I hope to get a extended FAQ out during the next week. I archived
everything on the mailing list and will try to put all the
information I get into it.

That's all for now.

  Guenther

([email-masked])

P.S.: Please write any comments to the list or to my above email-address,
as the address I am using at the moment will expire on friday this week.

---

From: [email-masked] (Markus Wild)

> I want to set up my printer daemon correctly. I think i did most of it correctly

First: I don't have any experiences with lpr/lpd/etc.

> 	putw(a,outfile);

Why do you use putw???? I think putc would be the right
choice.. putw is used to output a WORD, not a character...

-Markus
-- 
CHUUG/EUnet Switzerland				Markus Wild
Zweierstrasse 35	Tel: +41 1 291 45 80	[email-masked]
CH-8004 Zuerich		Fax: +41 1 291 46 42	S=mw;P=EUnet;A=EUnet;C=CH

---

From: [email-masked] (Eduardo E. Horvath [email-masked])

>  Hi all, I want to set up my printer daemon correctly. I think i did
> most of it correctly

What problems are you having with lpd?  I have been using it with no
problems.  I would not recommend writing a printfilter.  It's a
delicate operation, and the best way to do it is to start from an
existing print filter.

Here's a copy of my printcap.  It does not use printfilters.  Try it,
and if it doesn't work, get a copy of the source to some one of the
standard BSD print filters.

#	@(#)printcap	5.3 (Berkeley) 6/30/90
lp|local line printer:\
	:lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs:sb:pw#80:

=========================================================================
Eduardo Horvath				[email-masked]
					..!{decwrl,mips,fernwood}!btr!eeh
	"Trust me, I am cognizant of what I am doing." - Hammeroid

---

From: [email-masked]

> delicate operation, and the best way to do it is to start from an
It seems to be a problem to send ff to my hp4L. To copy text-file to /dev/par
is not enough. The printer does not do a cr. I tried to send him the
sequence for interpreting ff as ff+cr, but it doesnt change anything.
What is the problem with writing a printfilter? 
> 	:lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs:sb:pw#80:
                                                                ^=?
There is no /dev/lp in my /dev direc. Is it your par device?
Or your filter? I have sent the source of the program (the crippled source:))
that writes to /dev/par. I did the test with |od -b with the programm
writing to stdout first, this was not the problem. I used putchar() first 
and this is doesnt work either. 
ciao

---

From: [email-masked]

Hi,
[...]
> sequence for interpreting ff as ff+cr, but it doesnt change anything.

I think you mean lf and lf+cr. Did you get my reply to your last posting?
I think you simply have to putc(10,outfile), putc(13,outfile) when
lf (10) occurs in the input stream, not (12).

> that writes to /dev/par. I did the test with |od -b with the programm

od is short for octal display, which means that the output is in octal
bytes (-b). So don't get confused by the octal number 12, which is actually
decimal 10.

> writing to stdout first, this was not the problem. I used putchar() first 

use putc(<int>,outfile) instead.
If you got my last posting, then I can't understand, what your problems
are. Sorry, maybe I just didn't get your point.

  Guenther

[email-masked], maeuschen@irc (will be back next week)

---

From: [email-masked] (Eduardo E. Horvath [email-masked])

> > 	:lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs:sb:pw#80:
							sb -> short banner
							pw -> page width
								(default 132)

> There is no /dev/lp in my /dev direc. Is it your par device?

I made /dev/lp a symlink to /dev/par.  You may also need to create a
/var/spool/lpd directory.

The way I have my system set up, lf is automagically being translated
to cr+lf.  If you still think you need a print filter, take a look at
the printcap(5) man page.  It has a short description of what a print
filter does.  You should read data from stdin and write the data to
stdout.

Try something like this:

#include <stdio.h>

main()
{
int ch;

	while( (ch=getchar()) >=0) {
		if( ch == '\n' )
			putchar('\r');
		putchar(ch);
	}
}