[4381] in Athena Bugs

home help back first fref pref prev next nref lref last post

6.4R: staff_ln03filter

daemon@ATHENA.MIT.EDU (Richard Basch)
Sat Mar 3 17:52:03 1990

Date: Sat, 3 Mar 90 17:51:42 -0500
To: bugs@ATHENA.MIT.EDU
From: Richard Basch <probe@MIT.EDU>

In rel-eng[1904], <paul> suggests changing the ln03filter to reject
PostScript files.  Various other people have requested the same thing.
However, I found a few problems with the changes that Paul provided, so
here is another version:

-Richard

------------------------------- cut here --------------------------------
#include <sys/file.h>
#include <sgtty.h>

#define send(s)		write(1,s,sizeof(s)-1)

char str[]= "\033[!p";			/* Reset printer. */
char lnm[] = "\033[20h";		/* Line feed new line mode on. */

main()
{
    register int count, block=0;
    char buf[1024];

    send(str);
    send(lnm);
    while ((count = read(0, buf, 1024)) > 0) {
	if (!block++ && (count > 1) && (buf[0] == '%') && (buf[1] == '!')) {
	    send("Attempt to print PostScript file rejected");
	    break;
	} else
	    write(1, buf, count);
    }
    send(str);
    send(lnm);
}

home help back first fref pref prev next nref lref last post