rms@gorf.UUCP (Roger M. Shimada) (06/30/91)
From the README: This is a replacement screen dump program of users of AT&T 3B1/7300s who have Epson compatible 24-pin printers. It has only been tested on the author's Panasonic KX-P1124 in Epson mode. -- Roger M. Shimada rms@gorf.mn.org -or- rms@gorf.sialis.com (Whichever works for you! :-() #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: Makefile README sprint.c # Wrapped by rms@gorf.mn.org on Sat Jun 29 15:33:13 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f Makefile -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"Makefile\" else echo shar: Extracting \"Makefile\" \(324 characters\) sed "s/^X//" >Makefile <<'END_OF_Makefile' XCFLAGS = -O XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile X Xsprint: sprint.o X $(LD) -s -o $@ $(SHAREDLIB) sprint.o X Xinstall: sprint X -test -f /usr/bin/sprint -a ! -f /usr/bin/sprint.old \ X && mv /usr/bin/sprint /usr/bin/sprint.old X cp sprint /usr/bin X Xdeinstall: X mv /usr/bin/sprint.old /usr/bin/sprint X Xclean: X rm -f sprint *.o END_OF_Makefile if test 324 -ne `wc -c <Makefile`; then echo shar: \"Makefile\" unpacked with wrong size! fi # end of overwriting check fi if test -f README -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"README\" else echo shar: Extracting \"README\" \(1722 characters\) sed "s/^X//" >README <<'END_OF_README' XThis is a replacement screen dump program of users of AT&T 3B1/7300s who have XEpson compatible 24-pin printers. It has only been tested on the author's XPanasonic KX-P1124 in Epson mode. To work at all, /usr/spool/lp/default must Xcontain the name of the appropriate printer. X XIf running UA, type: X X make install X Xwhich will save your current screen dump program and install this one. Note Xthat the Makefile is smart enough to detect whether it has previously saved Xthe "old" version, so typing "make install" repeatably is harmless. X XThis program takes the liberty of printing a blank line before and after the Xactual screen dump and assumes 1/6 inch linefeeds. X XUnlike the current screen dump program, this program gives a list of formats Xto print in. One can also decide not to print at all. The sizes are big, Xmedium, and small. Big creates a dump almost as large as the screen itself X(and too big to fit two dumps on an 11 inch sheet - it's as high as the normal XEpson screen dump, but wider). Medium fits two screen dumps on an 11 inch Xsheet easily. Small is half the width of big, and half the height of medium X(plain 180 dpi x 180 dpi) and the KX-P1124 has pins too big to make such a Xdump clearly readable. The default size is normal. X XRequired control sequences: X ESC 2 set linefeed to 1/6 inch (all) X ESC 3 n set linefeed to n/180 inch (all) X ESC * n1 n2 print n2*256+n1 graphic columns at 90 dpi (Big) X ESC ! n1 n2 print n2*256+n1 graphic columns at 120 dpi (Medium) X ESC ' n1 n2 print n2*256+n1 graphic columns at 180 dpi (Small) X XAll this just 'cuz I wanted two screen dumps per page... :-) X X-- XRoger M. Shimada rms@gorf.mn.org -or- rms@gorf.sialis.com X (Whichever works for you! :-() END_OF_README if test 1722 -ne `wc -c <README`; then echo shar: \"README\" unpacked with wrong size! fi # end of overwriting check fi if test -f sprint.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"sprint.c\" else echo shar: Extracting \"sprint.c\" \(4997 characters\) sed "s/^X//" >sprint.c <<'END_OF_sprint.c' X/* X Replacement screen dump program for AT&T 3B1/7300 for owners of Epson X compatible 24-pin printers (only tested on the Panasonic KX-P1124.) X X To be installed as /usr/bin/sprint (the program called when X shift-Print is pressed using UA.) X X Yes, the code could be smaller...but I wanted to save a few cycles. X X Roger M. Shimada rms@gorf.mn.org -or- rms@gorf.sialis.com X (Whichever works for you! :-() X*/ X X#include <fcntl.h> X#include <kcodes.h> X#include <menu.h> X#include <message.h> X#include <stdio.h> X#include <tam.h> X#include <sys/window.h> X X#define SROWS 348 X#define SCOLS 720 X X#define SLINE (SCOLS/16) X Xmitem_t Myitems[] = { X "Big - Almost size of screen", 0, 0, X "Medium - Two fit per 11 inch page", 0, 1, X "Small - Show off printer's 180 dpi", 0, 2, X 0, 0, 0, X}; X Xmenu_t Mymenu = { X "Screen dump size", X "Should work with Epson compatible 24-pin printers", X "Select with ENTER, or press CANCEL to bail out", X 0, 1, 0, 0, X M_SINGLE, X "", X 0, 0, 0, 0, 0, X Myitems, X &Myitems[1], X 0, X}; X Xchar *Window = "/dev/window"; Xchar *LpDefault = "/usr/spool/lp/default"; X Xunsigned short Screen[SROWS + 23][SLINE]; Xunsigned short Current[24]; X XFILE *Pipe; X XBigGroup(SRow) Xint SRow; X{ X register char *Data; X int Out; X int Short; X register int SBit; X register int PBit; X register int PRow; X X Data = ((char *)&Out) + 1; X fprintf(Pipe, "\033*&%c%c", SCOLS & 0xff, SCOLS >> 8); /* 90 dpi */ X for (Short = 0; Short < SLINE; ++Short) { X for (PRow = 0; PRow < 8; ++PRow) X Current[PRow] = Screen[SRow + PRow][Short]; X for (SBit = 1; SBit < 0x10000; SBit <<= 1) { X PBit = 7 << 21; X Out = 0; X for (PRow = 0; PRow < 8; ++PRow) { X if (Current[PRow] & SBit) X Out |= PBit; X X PBit >>= 3; X } X fwrite(Data, 3, 1, Pipe); X } X } X fputc('\n', Pipe); X} X XMediumGroup(SRow) Xint SRow; X{ X register char *Data; X int Out; X int Short; X register int SBit; X register int PBit; X register int PRow; X X Data = ((char *)&Out) + 1; X fprintf(Pipe, "\033*!%c%c", SCOLS & 0xff, SCOLS >> 8); /* 120 dpi */ X for (Short = 0; Short < SLINE; ++Short) { X for (PRow = 0; PRow < 12; ++PRow) X Current[PRow] = Screen[SRow + PRow][Short]; X for (SBit = 1; SBit < 0x10000; SBit <<= 1) { X PBit = 3 << 22; X Out = 0; X for (PRow = 0; PRow < 12; ++PRow) { X if (Current[PRow] & SBit) X Out |= PBit; X X PBit >>= 2; X } X fwrite(Data, 3, 1, Pipe); X } X } X fputc('\n', Pipe); X} X XSmallGroup(SRow) Xint SRow; X{ X register char *Data; X int Out; X int Short; X register int SBit; X register int PBit; X register int PRow; X X Data = ((char *)&Out) + 1; X fprintf(Pipe, "\033*'%c%c", SCOLS & 0xff, SCOLS >> 8); /* 180 dpi */ X for (Short = 0; Short < SLINE; ++Short) { X for (PRow = 0; PRow < 24; ++PRow) X Current[PRow] = Screen[SRow + PRow][Short]; X for (SBit = 1; SBit < 0x10000; SBit <<= 1) { X PBit = 1 << 23; X Out = 0; X for (PRow = 0; PRow < 24; ++PRow) { X if (Current[PRow] & SBit) X Out |= PBit; X X PBit >>= 1; X } X fwrite(Data, 3, 1, Pipe); X } X } X fputc('\n', Pipe); X} X Xmain() X{ X char PipeCmd[128]; X char Default[64]; X int Bytes; X int Fd; X int I; X int OrgWin; X int Ret; X int MenuOp; X extern int errno; X X Fd = open(Window, O_RDWR); X if (Fd < 0) { X fprintf(stderr, "Can't open %s\n", Window); X exit(errno); X } X if (ioctl(Fd, WIOCREAD, Screen) < 0) { X fprintf(stderr, "Read of screen failed\n"); X exit(errno); X } X close(Fd); X Fd = open(LpDefault, O_RDONLY); X if (Fd < 0) { X fprintf(stderr, "Open of %s failed\n", LpDefault); X exit(errno); X } X Bytes = read(Fd, Default, sizeof(Default)); X if (Bytes < 1) { X fprintf(stderr, "Read of %s failed\n", LpDefault); X exit(errno); X } X close(Fd); X Default[Bytes - 1] = 0; X sprintf(PipeCmd, "lp -d%s_R", Default); X switch (fork()) { X case -1: X I = errno; X fprintf(stderr, "fork() failed\n"); X exit(I); X X case 0: X close(0); X close(1); X Fd = open(Window, O_RDWR); X if (Fd < 0) { X I = errno; X fprintf(stderr, "open of %s failed\n", Window); X exit(I); X } X dup(Fd); X winit(); X keypad(0, 1); X MenuOp = M_BEGIN | M_INPUT; X do { X Ret = menu(&Mymenu, MenuOp); X MenuOp &= ~M_BEGIN; X if (Ret < 0) { X fprintf(stderr, X "Error %d from menu()\n", Ret); X wexit(127); X } X if (Ret == Exit || Ret == Cancl || Ret == Close) X wexit(126); X } while (Ret != Enter); X wexit(Mymenu.m_curi->mi_val); X X default: X wait(&Ret); X if (Ret & 0xff) X exit(0); X X Ret >>= 8; X if (Ret == 126) X exit(0); X X if (Ret > 2) X exit(1); X X break; X } X Pipe = popen(PipeCmd, "w"); X if (Pipe == NULL) { X I = errno; X fprintf(stderr, "Popen of %s failed\n", PipeCmd); X exit(I); X } X fprintf(Pipe, "\n\0333%c", 24); /* lf is 24/180" */ X switch (Ret) { X case 0: /* big */ X for (I = 0; I < SROWS; I += 8) X BigGroup(I); X break; X X case 1: /* medium */ X for (I = 0; I < SROWS; I += 12) X MediumGroup(I); X break; X X case 2: /* small */ X for (I = 0; I < SROWS; I += 24) X SmallGroup(I); X break; X } X fprintf(Pipe, "\0332\n"); /* lf is 1/6" */ X pclose(Pipe); X exit(0); X} END_OF_sprint.c if test 4997 -ne `wc -c <sprint.c`; then echo shar: \"sprint.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of shell archive. exit 0