summaryrefslogtreecommitdiff
path: root/contrib/FAQ/code/printcap01/hpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/FAQ/code/printcap01/hpf.c')
-rw-r--r--contrib/FAQ/code/printcap01/hpf.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/contrib/FAQ/code/printcap01/hpf.c b/contrib/FAQ/code/printcap01/hpf.c
new file mode 100644
index 0000000000000..8d78c092f902f
--- /dev/null
+++ b/contrib/FAQ/code/printcap01/hpf.c
@@ -0,0 +1,38 @@
+/*
+source to my hp filter, installed as /usr/libexec/lpr/hpf:
+*/
+#include "stdio.h"
+#include <signal.h>
+#include <sys/file.h>
+#include <sys/ioctl.h>
+#include <sgtty.h>
+
+main(ac, av)
+int ac;
+char **av;
+{
+ int c;
+ struct sgttyb nbuf;
+ unsigned long lbits;
+
+ setbuf(stdout, NULL);
+ lbits = LDECCTQ | LPASS8 | LLITOUT;
+ ioctl(fileno(stdout), TIOCLSET, &lbits);
+ ioctl(fileno(stdout), TIOCGETP, &nbuf);
+ nbuf.sg_flags &= ~(ECHO | XTABS | CRMOD);
+ ioctl(fileno(stdout), TIOCSETP, &nbuf);
+
+ fputs("\033E\033&k2G", stdout);
+
+ while (1) {
+ if ((c = getchar()) != EOF) {
+ putchar(c);
+ } else {
+ break;
+ }
+ }
+
+ fputs("\033&l0H", stdout);
+
+ exit(0);
+}