home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / hp2pbm / patch02 next >
Text File  |  1992-03-15  |  39KB  |  1,461 lines

  1. Newsgroups: comp.sources.misc
  2. From: clewis@ferret.ocunix.on.ca (Chris Lewis)
  3. Subject:  REPOST: v28i081:  hp2pbm - HP PCL to Portable Bit Map converter, Patch02
  4. Message-ID: <1992Mar9.003812.26658@sparky.imd.sterling.com>
  5. X-Md4-Signature: b3c93d36766a06631346ea38936dc3a0
  6. Date: Mon, 9 Mar 1992 00:38:12 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: clewis@ferret.ocunix.on.ca (Chris Lewis)
  10. Posting-number: Volume 28, Issue 81
  11. Archive-name: hp2pbm/patch02
  12. Environment: UNIX
  13. Patch-To: hp2pbm: Volume 26, Issue 102-104
  14.  
  15. [ I'm not sure how but somehow the patch instructions were not 
  16. [ included in the first posting.  This is being reposted to assure 
  17. [ the instructions are available.             -Kent+
  18.  
  19. This is official patch 02 for Hp2pbm.
  20.     Please apply it by:
  21.     cd <hp2pbm source directory>
  22.     touch g3.h g3.c (some versions of patch don't need this)
  23.     patch -N -p < <this file>
  24.     
  25.     The initial release of hp2pbm was in volume 26 of
  26.     comp.sources.misc.
  27.  
  28. This patch introduces direct built-in support for G3 FAX modems.
  29. Plus performance improvements on the order of 10 to 25%.
  30. The G3 code was borrowed from Jef Poskanzer's PBMPLUS
  31. package, written by Paul Haeberli, and integrated
  32. by Roberto Biancardi.  Roberto also did the performance
  33. improvements.  The G3 personality is relatively slow, but
  34. apparently a lot faster than going through a separate
  35. pbm2g3 step.
  36.  
  37. ./hp2pbm.S
  38. ./Makefile
  39. ./hpfntwrite.c
  40. ./hpp.c
  41. ./hptopbm.h
  42. ./g3.h
  43. ./g3.c
  44.  
  45. Patchwrapped: 920305022036
  46.  
  47. Index: ./hp2pbm.S
  48. *** /tmp/PATCHold/./hp2pbm.S    Thu Mar  5 02:18:57 1992
  49. --- ./hp2pbm.S    Thu Mar  5 02:18:58 1992
  50. ***************
  51. *** 1,7 ****
  52. ! .\"Copyright 1989, 1990, 1991 by Chris Lewis 1.2 92/01/05
  53.   .TH HP2PBM %%MANEXT%% "standalone"
  54.   .SH NAME
  55. ! hp2pbm,hp2hifax,hp2lofax,hp2sun,hp2e24 \- Translate HPLJ codes to to Postscript or PBM
  56.   .SH SYNOPSIS
  57.   .B hp2pbm
  58.   .B "[\-v]"
  59. --- 1,7 ----
  60. ! .\"Copyright 1989, 1990, 1991 by Chris Lewis 1.3 92/03/05
  61.   .TH HP2PBM %%MANEXT%% "standalone"
  62.   .SH NAME
  63. ! hp2pbm,hp2hifax,hp2lofax,hp2sun,hp2e24,hp2hig3,hp2log3 \- Translate HPLJ codes to PostScript or PBM or G3
  64.   .SH SYNOPSIS
  65.   .B hp2pbm
  66.   .B "[\-v]"
  67. ***************
  68. *** 18,25 ****
  69.   (Hewlett Packard Printer Control Language - the language of HP Laserjets)
  70.   escape code sequences.
  71.   .B Hp2pbm
  72.   can then generate an english description of the codes, translate the input
  73. ! into Postscript, or generate PBM files (Jef Poskanzer's Portable Bitmap Format).
  74.   .P
  75.   .B "hp2pbm -V"
  76.   prints the version string.
  77. --- 18,30 ----
  78.   (Hewlett Packard Printer Control Language - the language of HP Laserjets)
  79.   escape code sequences.
  80.   .B Hp2pbm
  81. + is intended to be fully compliant with HP's ``PCL4''-level language.
  82. + Which means it should fully emulate any of HP's printers except for
  83. + some features of the HP Laserjet III.
  84. + .B Hp2pbm
  85.   can then generate an english description of the codes, translate the input
  86. ! into PostScript, or generate PBM files (Jef Poskanzer's Portable Bitmap Format),
  87. ! or generate G3 format files for G3 FAX modems.
  88.   .P
  89.   .B "hp2pbm -V"
  90.   prints the version string.
  91. ***************
  92. *** 49,60 ****
  93.   including (some) built in and all downloaded fonts (except
  94.   compressed ones) and including built in and downloaded graphics and rasters.
  95.   .B Hp2pbm
  96.   can be used to drive a number of different configurations, such as
  97. ! Postscript printers, Klaus Schallhorn's
  98.   .B faxpak
  99.   (to transmit faxes using a fax modem),
  100.   or other devices using PBM converters, such as Epson 24 pin printers,
  101.   Sun displays, 3b1 consoles etc.
  102.   .P
  103.   If the
  104.   .B \-v
  105. --- 54,73 ----
  106.   including (some) built in and all downloaded fonts (except
  107.   compressed ones) and including built in and downloaded graphics and rasters.
  108.   .B Hp2pbm
  109. + does not support PCL5 features such as scalable fonts and HPGL.
  110. + .B Hp2pbm
  111.   can be used to drive a number of different configurations, such as
  112. ! PostScript printers, Klaus Schallhorn's
  113.   .B faxpak
  114.   (to transmit faxes using a fax modem),
  115.   or other devices using PBM converters, such as Epson 24 pin printers,
  116.   Sun displays, 3b1 consoles etc.
  117. + With the G3 variants, such as
  118. + .B hp2hig3
  119. + or
  120. + .BR hp2log3 ,
  121. + G3 format files can be generated directly without going through an
  122. + additional PBM step.
  123.   .P
  124.   If the
  125.   .B \-v
  126. ***************
  127. *** 68,74 ****
  128.   .B \-p
  129.   option tells
  130.   .B hp2pbm
  131. ! to emit Postscript to standard output.
  132.   Specifying both \-v and \-p at the same time is rather confusing.
  133.   Note: unless
  134.   .B hp2pbm
  135. --- 81,87 ----
  136.   .B \-p
  137.   option tells
  138.   .B hp2pbm
  139. ! to emit PostScript to standard output.
  140.   Specifying both \-v and \-p at the same time is rather confusing.
  141.   Note: unless
  142.   .B hp2pbm
  143. ***************
  144. *** 106,113 ****
  145.   If the
  146.   .BI \-r value
  147.   option is specified,
  148. ! .B hp2pbm
  149. ! (hp2??fax and hp2e24) creates PBM files.
  150.   The associated argument is the basename for the generated files.
  151.   The first page is named ``value.0'', second ``value.1'' etc.
  152.   If
  153. --- 119,126 ----
  154.   If the
  155.   .BI \-r value
  156.   option is specified,
  157. ! hp2??fax and hp2e24 create PBM files.
  158. ! hp2??g3 creates G3 files.
  159.   The associated argument is the basename for the generated files.
  160.   The first page is named ``value.0'', second ``value.1'' etc.
  161.   If
  162. ***************
  163. *** 146,153 ****
  164.   .B Hp2pbm
  165.   is also linked to several different names as a convenience
  166.   for supplying the dots per inch.
  167. ! The names are: hp2hifax (high resolution FAX), hp2lofax (low resolution FAX)
  168. ! hp2sun (Sun mono display) and hp2e24 (Epson 24 pin printer at 180 dpi).
  169.   .SH FILES
  170.   .if t .ta 2.5i
  171.   .if n .ta 3.5i
  172. --- 159,168 ----
  173.   .B Hp2pbm
  174.   is also linked to several different names as a convenience
  175.   for supplying the dots per inch.
  176. ! The names are: hp2hifax (high resolution PBM FAX), hp2lofax
  177. ! (low resolution PBM FAX)
  178. ! hp2sun (Sun mono display), hp2e24 (Epson 24 pin printer at 180 dpi),
  179. ! hp2log3 (low resolution G3 FAX), and hp2hig3 (high resolution G3 FAX).
  180.   .SH FILES
  181.   .if t .ta 2.5i
  182.   .if n .ta 3.5i
  183. ***************
  184. *** 158,164 ****
  185.   %%LIBDIR%%/BITMAPS    rasters, patterns and builtin font clones.
  186.   .SH "SEE ALSO"
  187.   Hewlett Packard Laserjet documentation.
  188. ! Adobe Systems Postscript documentation.
  189.   .SH WARNINGS
  190.   .P
  191.   .B "Hp2pbm output can be huge!"
  192. --- 173,179 ----
  193.   %%LIBDIR%%/BITMAPS    rasters, patterns and builtin font clones.
  194.   .SH "SEE ALSO"
  195.   Hewlett Packard Laserjet documentation.
  196. ! Adobe Systems PostScript documentation.
  197.   .SH WARNINGS
  198.   .P
  199.   .B "Hp2pbm output can be huge!"
  200. ***************
  201. *** 168,178 ****
  202.   .P
  203.   .B "Hp2pbm's"
  204.   handling of downloaded macros is not fully tested.
  205. ! Compressed fonts (Laserjet II) and scalable built in fonts (Laserjet
  206. ! III) are not supported.
  207.   Except for these limitations
  208.   .B Hp2pbm
  209. ! should be fully compatible with Laserjet II printers.
  210.   .P
  211.   The
  212.   .B \-p
  213. --- 183,193 ----
  214.   .P
  215.   .B "Hp2pbm's"
  216.   handling of downloaded macros is not fully tested.
  217. ! Compressed fonts, scalable built in fonts, and HPGL mode
  218. ! personalities in PCL5 are not supported.
  219.   Except for these limitations
  220.   .B Hp2pbm
  221. ! should be fully compatible with all HP Laserjet printers.
  222.   .P
  223.   The
  224.   .B \-p
  225. ***************
  226. *** 180,186 ****
  227.   option of
  228.   .B "psroff \-Tlj"
  229.   without having a laserjet printer.
  230. ! The Postscript generating code isn't complete, but this will
  231.   probably be rectified in future.
  232.   .P
  233.   .B Hp2pbm
  234. --- 195,201 ----
  235.   option of
  236.   .B "psroff \-Tlj"
  237.   without having a laserjet printer.
  238. ! The PostScript generating code isn't complete, but this will
  239.   probably be rectified in future.
  240.   .P
  241.   .B Hp2pbm
  242. ***************
  243. *** 193,203 ****
  244.   to be radically different from a LJ's), so the widths may be different and
  245.   the mappings of non-ASCII characters certainly will be.
  246.   .PP
  247. ! Most Postscript printers have relatively little memory for additional
  248.   bitmapped fonts.
  249. ! Do not be surprised by VMerrors from your Postscript printer if you've
  250.   selected more than a few fonts in your Laserjet output.
  251.   .SH AUTHORS
  252.   This manual page and the HP PCL parsing code was written by Chris Lewis,
  253.   as was psroff.
  254.   The PBM generation code was written by Klaus Schallhorn.
  255. --- 208,220 ----
  256.   to be radically different from a LJ's), so the widths may be different and
  257.   the mappings of non-ASCII characters certainly will be.
  258.   .PP
  259. ! Most PostScript printers have relatively little memory for additional
  260.   bitmapped fonts.
  261. ! Do not be surprised by VMerrors from your PostScript printer if you've
  262.   selected more than a few fonts in your Laserjet output.
  263.   .SH AUTHORS
  264.   This manual page and the HP PCL parsing code was written by Chris Lewis,
  265.   as was psroff.
  266.   The PBM generation code was written by Klaus Schallhorn.
  267. + The G3 code was written by Paul Haeberli and Jef Poskanzer and
  268. + appears in PBMPLUS, and was integrated into hp2pbm by Roberto Biancardi.
  269. Index: ./Makefile
  270. *** /tmp/PATCHold/./Makefile    Thu Mar  5 02:19:16 1992
  271. --- ./Makefile    Thu Mar  5 02:19:17 1992
  272. ***************
  273. *** 1,4 ****
  274. ! # Makefile for hptopbm standalone release 1.3 92/01/05
  275.   
  276.   #    Configuration:
  277.   
  278. --- 1,4 ----
  279. ! # Makefile for hptopbm standalone release 1.6 92/03/05
  280.   
  281.   #    Configuration:
  282.   
  283. ***************
  284. *** 11,16 ****
  285. --- 11,19 ----
  286.   #    Compilation flags.  Including strip (-s) if desired
  287.   #    Add -DBSD if BSD or V7.
  288.   #    Add -DNOMEM if you don't have memcpy and memset.
  289. + #    Add -DZYXFAX if you generate g3 fax files to be sent with zyxel mdms.
  290. + #    Add -DVERBOSE to include dbprint() code.
  291. + #    Add -fcombine-regs -fpcc-struct-return -finline-functions for gcc
  292.   CCFLAGS    = -O
  293.   #    Page size (LETTER, LEGAL, B5, A4)
  294.   PAGE    = A4
  295. ***************
  296. *** 24,36 ****
  297.   #    Dinna touch from here on.
  298.   
  299.   SHELL =        /bin/sh
  300. ! CFLAGS    =    $(CCFLAGS) -D'LIBDIR="$(LIBDIR)"' -D$(PAGE) -DPS
  301.   
  302.   LIBFILES =    cour.sfp lp.sfp \
  303.           hppat1 hppat2 hppat3 hppat4 hppat5 hppat6 \
  304.           hprast1 hprast2 hprast3 hprast4 hprast5 hprast6 hprast7 hprast8
  305.   
  306. ! ALTNAMES    = p2hifax hp2lofax hp2sun hp2e24
  307.   
  308.   .SUFFIXES:    .S~ .S
  309.   
  310. --- 27,40 ----
  311.   #    Dinna touch from here on.
  312.   
  313.   SHELL =        /bin/sh
  314. ! CFLAGS    =    $(CCFLAGS) -D'LIBDIR="$(LIBDIR)"' -D$(PAGE) -DPS -DG3
  315.   
  316.   LIBFILES =    cour.sfp lp.sfp \
  317.           hppat1 hppat2 hppat3 hppat4 hppat5 hppat6 \
  318.           hprast1 hprast2 hprast3 hprast4 hprast5 hprast6 hprast7 hprast8
  319.   
  320. ! ALTNAMES    = hp2hifax hp2lofax hp2sun hp2e24 hp2hig3 hp2hig3r hp2log3 hp2log3r
  321. ! HP2OBJ        = hpp.o hpfntwrite.o g3.o mem.o
  322.   
  323.   .SUFFIXES:    .S~ .S
  324.   
  325. ***************
  326. *** 37,44 ****
  327.   all:    README hp2pbm pbm2e24 hp2pbm.m $(LIBFILES)
  328.   
  329.   # programs
  330. ! hp2pbm:    hpp.o hpfntwrite.o mem.o
  331. !         $(CC) $(CFLAGS) -o hp2pbm hpp.o hpfntwrite.o mem.o $(LIBFLAGS)
  332.   
  333.   hp2pbm.m:    hp2pbm.S Makefile
  334.           sed -e 's;%%LIBDIR%%;$(LIBDIR);' \
  335. --- 41,48 ----
  336.   all:    README hp2pbm pbm2e24 hp2pbm.m $(LIBFILES)
  337.   
  338.   # programs
  339. ! hp2pbm:        $(HP2OBJ)
  340. !         $(CC) $(CFLAGS) -o hp2pbm $(HP2OBJ) $(LIBFLAGS)
  341.   
  342.   hp2pbm.m:    hp2pbm.S Makefile
  343.           sed -e 's;%%LIBDIR%%;$(LIBDIR);' \
  344. ***************
  345. *** 60,75 ****
  346.           cat $@.S > $@
  347.           @chmod 444 $@
  348.   
  349. ! # components
  350. ! #mem.o:        mem.c
  351. ! #        $(CC) -c $(CFLAGS) mem.c
  352.   
  353. ! hpp.o:        hptopbm.h # hpp.c
  354. ! #        $(CC) -c $(CFLAGS) hpp.c
  355.   
  356. - hpfntwrite.o:    hptopbm.h hpfntwrite.c
  357. - #        $(CC) -c $(CFLAGS) hpfntwrite.c
  358.   pbm2e24:    pbm2e24.o mem.o
  359.           $(CC) $(CFLAGS) -o pbm2e24 pbm2e24.o mem.o $(LIBFLAGS)
  360.   
  361. --- 64,73 ----
  362.           cat $@.S > $@
  363.           @chmod 444 $@
  364.   
  365. ! hpp.o hpfntwrite.o hpp.o g3.o:    hptopbm.h
  366.   
  367. ! g3.o:        g3.h
  368.   
  369.   pbm2e24:    pbm2e24.o mem.o
  370.           $(CC) $(CFLAGS) -o pbm2e24 pbm2e24.o mem.o $(LIBFLAGS)
  371.   
  372. ***************
  373. *** 87,95 ****
  374.   
  375.   regression:    hp2pbm
  376.           psroff -t -Tlj testdoc > /tmp/testdoc.lj
  377. !         ./hp2pbm -r/tmp/new -d80,80 < /tmp/testdoc.lj
  378. !         $(BINDIR)/hp2pbm -r/tmp/old -d80,80 < /tmp/testdoc.lj
  379. !         ./hp2pbm '-r|pbm2e24' -d80,80 > /tmp/pipe < /tmp/testdoc.lj
  380.   
  381.   install:    hp2pbm myuid
  382.           test "`./myuid`" = 0 || \
  383. --- 85,97 ----
  384.   
  385.   regression:    hp2pbm
  386.           psroff -t -Tlj testdoc > /tmp/testdoc.lj
  387. !         time $(BINDIR)/hp2pbm -r/tmp/old -d80,80 < /tmp/testdoc.lj 2> /tmp/old.t
  388. !         time ./hp2pbm -r/tmp/new -d80,80 < /tmp/testdoc.lj 2> /tmp/new.t
  389. !         time $(BINDIR)/hp2pbm '-r|pbm2e24' -d80,80 > /tmp/old.pipe < /tmp/testdoc.lj 2> /tmp/old.pipe.t
  390. !         time ./hp2pbm '-r|pbm2e24' -d80,80 > /tmp/new.pipe < /tmp/testdoc.lj 2> /tmp/new.pipe.t
  391. ! g3test:
  392. !         time ./hp2hig3 -r/tmp/FOO < /tmp/testdoc.lj > /tmp/g3 2> /tmp/g3.t
  393.   
  394.   install:    hp2pbm myuid
  395.           test "`./myuid`" = 0 || \
  396. ***************
  397. *** 99,104 ****
  398. --- 101,107 ----
  399.           test -d $(LIBDIR)/BITMAPS || mkdir $(LIBDIR)/BITMAPS
  400.           cd $(BINDIR) ; rm -f hp2pbm $(ALTNAMES)
  401.           cp hp2pbm $(BINDIR)/hp2pbm
  402. +         cp pbm2e24 $(BINDIR)/pbm2e24
  403.           $(IGNORESH) cd $(BINDIR) ; \
  404.           for i in $(ALTNAMES) ; \
  405.           do \
  406. Index: ./hpfntwrite.c
  407. *** /tmp/PATCHold/./hpfntwrite.c    Thu Mar  5 02:19:28 1992
  408. --- ./hpfntwrite.c    Thu Mar  5 02:19:32 1992
  409. ***************
  410. *** 17,24 ****
  411.   
  412.   #include "hptopbm.h"
  413.   
  414.   #ifndef    lint
  415. ! char SCCSid[] = "@(#)hpfntwrite.c: 1.3 92/01/05 23:16:27";
  416.   #endif
  417.   
  418.   #ifdef    FAXPAK
  419. --- 17,30 ----
  420.   
  421.   #include "hptopbm.h"
  422.   
  423. + #ifndef    G3
  424. + g3start() {}
  425. + g3write() {}
  426. + g3stop() {}
  427. + #endif
  428.   #ifndef    lint
  429. ! char SCCSid[] = "@(#)hpfntwrite.c: 1.4 92/03/01 02:04:25";
  430.   #endif
  431.   
  432.   #ifdef    FAXPAK
  433. ***************
  434. *** 38,43 ****
  435. --- 44,52 ----
  436.   
  437.   #define    ESC        '\033'
  438.   #define    setpix(y,x)    (block[y][x>>3] |= bit[x&7])
  439. + static unsigned char *pforsetxpix;
  440. + #define    setyforsetxpix(y)    (pforsetxpix=block[y])
  441. + #define    setxpix(x)        (pforsetxpix[x>>3]|=bit[x&7])
  442.   
  443.   #ifndef    min
  444.   #define    min(a,b)    ((a<b)?a:b)
  445. ***************
  446. *** 421,439 ****
  447.   char *tname;
  448.   {
  449.       int i, j, xmax, pipe;
  450. !     FILE *fp;
  451.   
  452. !     if (tname[0] == '|') {
  453. !         fp = popen(tname+1, "w");
  454. !         pipe = 1;
  455. !     } else {
  456. !         fp = fopen(tname, "w");
  457. !         pipe = 0;
  458.       }
  459.   
  460. -     if (fp == NULL)
  461. -         die("cannot create pbm file `%s'\n",tname);
  462.       ymax_used = yscale[max_ln-1];
  463.   #ifdef    FAXPAK
  464.       xmax = min(216, xscale[(max_col+7)/8]);        /* max 1728 pels */
  465. --- 430,453 ----
  466.   char *tname;
  467.   {
  468.       int i, j, xmax, pipe;
  469. !     static FILE *fp;
  470. !     static int g3mode = -1;
  471. !     static int zyxelm = 0;
  472. !     extern char *PGM;
  473.   
  474. !     if ( g3mode == -1 )
  475. !     {
  476. !         if ( !strcmp(PGM,"hp2hig3") || !strcmp(PGM,"hp2log3") )
  477. !             g3mode = 1;
  478. !         else if ( !strcmp(PGM,"hp2hig3r") || !strcmp(PGM,"hp2log3r") )
  479. !             g3mode = 2;
  480. !         else
  481. !             g3mode = 0;
  482. ! #ifdef    ZYXFAX
  483. !         zyxelm = 1;
  484. ! #endif
  485.       }
  486.   
  487.       ymax_used = yscale[max_ln-1];
  488.   #ifdef    FAXPAK
  489.       xmax = min(216, xscale[(max_col+7)/8]);        /* max 1728 pels */
  490. ***************
  491. *** 440,460 ****
  492.   #else
  493.       xmax = xscale[(max_col+7)/8];
  494.   #endif
  495. !     if (fprintf(fp,"P4\n%d %d\n",xmax*8,ymax_used) == EOF)
  496. !         die("can't init pbmfile %s\n",tname);
  497.   
  498.       for (i=0; i<ymax_used; i++)
  499.       {
  500. !         if ((j = fwrite((char*)block[i], 1, xmax, fp)) != xmax)
  501.               die("premature EOF after %d bytes of %d, line %d of %d\n",
  502.                   j,xmax,i,ymax_used);
  503.           (void)memset((char*)block[i], '\0', xmax);
  504.       }
  505. !     if (pipe) {
  506. !         if (pclose(fp))
  507. !         die("Pipe failure in `%s'\n", tname);
  508. !     } else
  509. !         fclose(fp);
  510.   
  511.       ymax_used = xmax_used = 0;
  512.       orgenv.top_margin = new_topmargin;
  513. --- 454,501 ----
  514.   #else
  515.       xmax = xscale[(max_col+7)/8];
  516.   #endif
  517. !     if ( zyxelm == 0 || fp == NULL )
  518. !     {
  519. !         if (tname[0] == '|') {
  520. !             fp = popen(tname+1, "w");
  521. !             pipe = 1;
  522. !         } else {
  523. !             fp = fopen(tname, "w");
  524. !             pipe = 0;
  525. !         }
  526. !         if (fp == NULL)
  527. !             die("cannot create pbm file `%s'\n",tname);
  528. !         if ( g3mode )
  529. !             g3start(fp,xmax*8,g3mode==2?1:0);
  530. !         else
  531. !             if (fprintf(fp,"P4\n%d %d\n",xmax*8,ymax_used) == EOF)
  532. !             die("can't init pbmfile %s\n",tname);
  533. !     }
  534.   
  535.       for (i=0; i<ymax_used; i++)
  536.       {
  537. !         if ( g3mode ) {
  538. !             if ( !g3write((char*)block[i]) )
  539. !             {
  540. !                 die("premature EOF at line %d of %d\n",
  541. !                     i,ymax_used);
  542. !             }
  543. !         } else if ((j = fwrite((char*)block[i], 1, xmax, fp)) != xmax)
  544.               die("premature EOF after %d bytes of %d, line %d of %d\n",
  545.                   j,xmax,i,ymax_used);
  546.           (void)memset((char*)block[i], '\0', xmax);
  547.       }
  548. !     if ( !zyxelm )
  549. !     {
  550. !         if ( g3mode )
  551. !             g3stop();
  552. !         if (pipe) {
  553. !             if (pclose(fp))
  554. !             die("Pipe failure in `%s'\n", tname);
  555. !         } else
  556. !             fclose(fp);
  557. !     }
  558.   
  559.       ymax_used = xmax_used = 0;
  560.       orgenv.top_margin = new_topmargin;
  561. ***************
  562. *** 1103,1109 ****
  563.   uchar *pels;
  564.   int len;
  565.   {
  566. !     int i, k, localy, inc, graphx, graphy;
  567.   
  568.       if (see_thru)
  569.           return;
  570. --- 1144,1150 ----
  571.   uchar *pels;
  572.   int len;
  573.   {
  574. !     register int i, k, localy, inc, graphx, graphy;
  575.   
  576.       if (see_thru)
  577.           return;
  578. ***************
  579. *** 1116,1122 ****
  580.       graphx = (int)(GRAPHX + .5);
  581.       if (graphy < 0 || inc+graphy >= max_ln)
  582.           return;
  583. !     localy = yscale[graphy];
  584.   
  585.       if (graphx + (inc*len*8) > max_col)
  586.           len = ((max_col-graphx)/8)/inc;
  587. --- 1157,1163 ----
  588.       graphx = (int)(GRAPHX + .5);
  589.       if (graphy < 0 || inc+graphy >= max_ln)
  590.           return;
  591. !     setyforsetxpix(localy = yscale[graphy]);
  592.   
  593.       if (graphx + (inc*len*8) > max_col)
  594.           len = ((max_col-graphx)/8)/inc;
  595. ***************
  596. *** 1123,1139 ****
  597.   
  598.       switch(curenv->dpi)    /* hey, who says we're trying to be efficient? */
  599.       {
  600. !     case 300:    for (i=0; i<len; i++, pels++)
  601. !                 for (k=0; k<8; k++, graphx++)
  602. !                     if (*pels & bit[k])
  603. !                         setpix(localy, xscale[graphx]);
  604.               break;
  605.       case 150:    for (i=0; i<len; i++, pels++)
  606.                   for (k=0; k<8; k++, graphx += inc)
  607.                       if (*pels & bit[k])
  608.                       {
  609. !                         setpix(localy, xscale[graphx]);
  610. !                         setpix(localy, xscale[graphx+1]);
  611.   
  612.                           setpix(localy+1, xscale[graphx]);
  613.                           setpix(localy+1, xscale[graphx+1]);
  614. --- 1164,1190 ----
  615.   
  616.       switch(curenv->dpi)    /* hey, who says we're trying to be efficient? */
  617.       {
  618. !     case 300:    for (i=len; i-- > 0; )
  619. !             {
  620. !                 register unsigned ch = *pels++;
  621. !                 if ( ch == 0 ) {graphx+=8;continue;}
  622. !                 if ( ch&0x80 ) setxpix(xscale[graphx]);graphx++;
  623. !                 if ( ch&0x40 ) setxpix(xscale[graphx]);graphx++;
  624. !                 if ( ch&0x20 ) setxpix(xscale[graphx]);graphx++;
  625. !                 if ( ch&0x10 ) setxpix(xscale[graphx]);graphx++;
  626. !                 if ( ch&0x08 ) setxpix(xscale[graphx]);graphx++;
  627. !                 if ( ch&0x04 ) setxpix(xscale[graphx]);graphx++;
  628. !                 if ( ch&0x02 ) setxpix(xscale[graphx]);graphx++;
  629. !                 if ( ch&0x01 ) setxpix(xscale[graphx]);graphx++;
  630. !             }
  631.               break;
  632.       case 150:    for (i=0; i<len; i++, pels++)
  633.                   for (k=0; k<8; k++, graphx += inc)
  634.                       if (*pels & bit[k])
  635.                       {
  636. !                         setxpix(xscale[graphx]);
  637. !                         setxpix(xscale[graphx+1]);
  638.   
  639.                           setpix(localy+1, xscale[graphx]);
  640.                           setpix(localy+1, xscale[graphx+1]);
  641. ***************
  642. *** 1143,1151 ****
  643.                   for (k=0; k<8; k++, graphx += inc)
  644.                       if (*pels & bit[k])
  645.                       {
  646. !                         setpix(localy, xscale[graphx]);
  647. !                         setpix(localy, xscale[graphx+1]);
  648. !                         setpix(localy, xscale[graphx+2]);
  649.   
  650.                           setpix(localy+1, xscale[graphx]);
  651.                           setpix(localy+1, xscale[graphx+1]);
  652. --- 1194,1202 ----
  653.                   for (k=0; k<8; k++, graphx += inc)
  654.                       if (*pels & bit[k])
  655.                       {
  656. !                         setxpix(xscale[graphx]);
  657. !                         setxpix(xscale[graphx+1]);
  658. !                         setxpix(xscale[graphx+2]);
  659.   
  660.                           setpix(localy+1, xscale[graphx]);
  661.                           setpix(localy+1, xscale[graphx+1]);
  662. ***************
  663. *** 1160,1169 ****
  664.                   for (k=0; k<8; k++, graphx += inc)
  665.                       if (*pels & bit[k])
  666.                       {
  667. !                         setpix(localy, xscale[graphx]);
  668. !                         setpix(localy, xscale[graphx+1]);
  669. !                         setpix(localy, xscale[graphx+2]);
  670. !                         setpix(localy, xscale[graphx+3]);
  671.   
  672.                           setpix(localy+1, xscale[graphx]);
  673.                           setpix(localy+1, xscale[graphx+1]);
  674. --- 1211,1220 ----
  675.                   for (k=0; k<8; k++, graphx += inc)
  676.                       if (*pels & bit[k])
  677.                       {
  678. !                         setxpix(xscale[graphx]);
  679. !                         setxpix(xscale[graphx+1]);
  680. !                         setxpix(xscale[graphx+2]);
  681. !                         setxpix(xscale[graphx+3]);
  682.   
  683.                           setpix(localy+1, xscale[graphx]);
  684.                           setpix(localy+1, xscale[graphx+1]);
  685. ***************
  686. *** 1285,1291 ****
  687.   int c;
  688.   {
  689.       struct CHAR_BITMAP *cbm, *ubm;
  690. !     int i, j, k, curx, cury, localy, before,startx,endx,curcol,newcol;
  691.       double clen;
  692.   
  693.       if (see_thru)
  694. --- 1336,1342 ----
  695.   int c;
  696.   {
  697.       struct CHAR_BITMAP *cbm, *ubm;
  698. !     int i, j, curx, cury, localy, before,startx,endx,curcol,newcol;
  699.       double clen;
  700.   
  701.       if (see_thru)
  702. ***************
  703. *** 1336,1348 ****
  704.       if (c != ' ' && c != '\b')
  705.           for (i=0; i<cbm->hite; i++)
  706.           {
  707.               curx = before;
  708. !             localy = yscale[cury+i];
  709.   
  710. !             for (j=0; j<cbm->len; j++)
  711. !                 for (k=0; k<8; k++,curx++)
  712. !                     if (cbm->CH[i][j] & bit[k])
  713. !                         setpix(localy, xscale[curx]);
  714.           }
  715.   
  716.       if (c > ' ')
  717. --- 1387,1411 ----
  718.       if (c != ' ' && c != '\b')
  719.           for (i=0; i<cbm->hite; i++)
  720.           {
  721. +             register unsigned char *chptr = cbm->CH[i];
  722.               curx = before;
  723. !             setyforsetxpix(localy = yscale[cury+i]);
  724.   
  725. !             for (j=cbm->len; j-- > 0; )
  726. !             {
  727. !                 register unsigned char ch = *chptr++;
  728. !                 if ( ch == 0 )    {curx+=8;continue;}
  729. !                 if ( ch&0x80 )    setxpix(xscale[curx]);curx++;
  730. !                 if ( ch&0x40 )    setxpix(xscale[curx]);curx++;
  731. !                 if ( ch&0x20 )    setxpix(xscale[curx]);curx++;
  732. !                 if ( ch&0x10 )    setxpix(xscale[curx]);curx++;
  733. !                 if ( ch&0x08 )    setxpix(xscale[curx]);curx++;
  734. !                 if ( ch&0x04 )    setxpix(xscale[curx]);curx++;
  735. !                 if ( ch&0x02 )    setxpix(xscale[curx]);curx++;
  736. !                 if ( ch&0x01 )    setxpix(xscale[curx]);curx++;
  737. !             }
  738.           }
  739.   
  740.       if (c > ' ')
  741. ***************
  742. *** 1365,1373 ****
  743.           for (i = 5; i < 8 ; i++)        /* fixed underlining */
  744.           {
  745.               curx = startx;
  746. !             localy = yscale[bmy+i];
  747.               for (j=0; curx<endx ; curx++)
  748. !                 setpix(localy,xscale[curx]);
  749.           }
  750.       }
  751.       dotted = TRUE;
  752. --- 1428,1436 ----
  753.           for (i = 5; i < 8 ; i++)        /* fixed underlining */
  754.           {
  755.               curx = startx;
  756. !             setyforsetxpix(localy = yscale[bmy+i]);
  757.               for (j=0; curx<endx ; curx++)
  758. !                 setxpix(xscale[curx]);
  759.           }
  760.       }
  761.       dotted = TRUE;
  762. Index: ./hpp.c
  763. *** /tmp/PATCHold/./hpp.c    Thu Mar  5 02:19:51 1992
  764. --- ./hpp.c    Thu Mar  5 02:19:54 1992
  765. ***************
  766. *** 21,27 ****
  767.   
  768.   #ifndef    lint
  769.   static char SCCSID[] =
  770. !     "@(#)hpp.c 1.4 92/01/05 23:16:48";
  771.   #endif
  772.   
  773.   #include "hptopbm.h"
  774. --- 21,27 ----
  775.   
  776.   #ifndef    lint
  777.   static char SCCSID[] =
  778. !     "@(#)hpp.c 1.5 92/03/01 02:04:54";
  779.   #endif
  780.   
  781.   #include "hptopbm.h"
  782. ***************
  783. *** 29,35 ****
  784.   #define    XSIZE        (RITE_MARGIN+8)*30
  785.   #define    YSIZE        (PAGE_LEN*50)+50
  786.   
  787. ! #define    dbprintf(x)    if (verbose) printf x
  788.   #define    ESCAPE    0x1b
  789.   
  790.   #define    TRANSFER    1
  791. --- 29,40 ----
  792.   #define    XSIZE        (RITE_MARGIN+8)*30
  793.   #define    YSIZE        (PAGE_LEN*50)+50
  794.   
  795. ! #ifdef    VERBOSE
  796. ! #define    dbprintf(x)    
  797. ! #else
  798. ! #define    dbprintf(x)    
  799. ! #endif
  800.   #define    ESCAPE    0x1b
  801.   
  802.   #define    TRANSFER    1
  803. ***************
  804. *** 172,177 ****
  805. --- 177,187 ----
  806.   
  807.   /*    code    name            parnam    exec    rastfunc   */
  808.   
  809. +     {"*pX",    "Horizontal cursor (dots)",NULL,movex },
  810. +     {"*pY",    "Vertical cursor (dots)",NULL,    movey },
  811. +     {"*cD",    "Font ID" },
  812. +     {"*cE",    "Character Code" },
  813. +     {"*cF",    "Font/Char control",    fchcont,NULL,    rs_fc_ctl },
  814.       {"&lO",    "Orientation"    /* don't want to go into landscaping */ },
  815.       {"(sP",    "Primary Spacing",    spcont, spset },
  816.       {"(sH",    "Primary Pitch",    NULL,    NULL,    rs_pitch },
  817. ***************
  818. *** 185,198 ****
  819.       {")sS",    "Secondary Style",    stcont },
  820.       {")sB",    "Secondary Stroke" },
  821.       {")sT",    "Secondary Typeface" },
  822. -     {"&lP",    "Page Length",        NULL,    NULL,    rs_plen },
  823. -     {"&lE",    "Top Margin",        NULL,    NULL,    rs_mtop },
  824. -     {"&lF",    "Text Length",        NULL,    NULL,    rs_tlen },
  825. -     {"&aL",    "Left Margin",        NULL,    NULL,    rs_mleft },
  826. -     {"&aM",    "Right Margin",        NULL,    NULL,    rs_mright },
  827. -     {"&lC",    "Motion Index",        NULL,    NULL,    rs_vmi },
  828. -     {"&lD",    "Lines/Inch",        NULL,    NULL,    rs_lpi },
  829. -     {"*tR",    "Resolution",        NULL,    NULL,    rs_dpi },
  830.       {"*rA",    "Start Graphics",    sgcont,    NULL,    rs_graphxy },
  831.       {"*bW",    "Transfer" },
  832.       {"*rB",    "End Graphics" },
  833. --- 195,200 ----
  834. ***************
  835. *** 202,207 ****
  836. --- 204,217 ----
  837.       {"&aV",    "Move to Row (Decipoints)",NULL,movedy },
  838.       {"&dD",    "Underline on",        NULL,    NULL,    rs_ul },
  839.       {"&d@",    "Underline off",    NULL,    NULL,    rs_ul_off },
  840. +     {"&lP",    "Page Length",        NULL,    NULL,    rs_plen },
  841. +     {"&lE",    "Top Margin",        NULL,    NULL,    rs_mtop },
  842. +     {"&lF",    "Text Length",        NULL,    NULL,    rs_tlen },
  843. +     {"&aL",    "Left Margin",        NULL,    NULL,    rs_mleft },
  844. +     {"&aM",    "Right Margin",        NULL,    NULL,    rs_mright },
  845. +     {"&lC",    "Motion Index",        NULL,    NULL,    rs_vmi },
  846. +     {"&lD",    "Lines/Inch",        NULL,    NULL,    rs_lpi },
  847. +     {"*tR",    "Resolution",        NULL,    NULL,    rs_dpi },
  848.       {"&pX",    "Transparent Print",    NULL,    NULL,    rs_thru },
  849.       {"&lL",    "Perf Skip",         pscont },
  850.       {"&kH",    "HMI",            NULL,    NULL,    rs_hmi },
  851. ***************
  852. *** 210,220 ****
  853.       {"&sC",    "Line Wrap" },
  854.       {"&lX",    "Number of Copies" },
  855.       {"&lH",    "Paper Input Control",    NULL,    papinctrl },
  856. -     {"*pX",    "Horizontal cursor (dots)",NULL,movex },
  857. -     {"*pY",    "Vertical cursor (dots)",NULL,    movey },
  858. -     {"*cD",    "Font ID" },
  859. -     {"*cE",    "Character Code" },
  860. -     {"*cF",    "Font/Char control",    fchcont,NULL,    rs_fc_ctl },
  861.       {")sW",    "Create Font Header" },
  862.       {"(sW",    "Download Character" },
  863.       {"&fY",    "Macro ID",        NULL,    NULL,    macro_id },
  864. --- 220,225 ----
  865. ***************
  866. *** 769,783 ****
  867.           strcpy(pbmname, optarg);
  868.           break;
  869.           case '?':
  870. !         fprintf(stderr, "usage: hpinterp [-dx[,y]][-p][-v][-c][-rpbm]< file\n");
  871.           exit(1);
  872.       }
  873.       
  874.       if (!resdone) {
  875.   
  876. !     if (!strcmp(PGM,    "hp2hifax"))
  877.           rs_rastsize(    204.15, 195.58);
  878. !     else if (!strcmp(PGM,    "hp2lofax"))
  879.           rs_rastsize(    204.15, 97.79);
  880.       else if (!strcmp(PGM,    "hp2sun"))
  881.           rs_rastsize(     84.0,  84.0);
  882. --- 774,792 ----
  883.           strcpy(pbmname, optarg);
  884.           break;
  885.           case '?':
  886. !         fprintf(stderr, "usage: %s [-dx[,y]][-p][-v][-c][-rpbm]< file\n",PGM);
  887.           exit(1);
  888.       }
  889.       
  890.       if (!resdone) {
  891.   
  892. !     if (     !strcmp(PGM,    "hp2hifax")
  893. !         ||   !strcmp(PGM,    "hp2hig3")
  894. !         ||   !strcmp(PGM,    "hp2hig3r"))
  895.           rs_rastsize(    204.15, 195.58);
  896. !     else if (!strcmp(PGM,    "hp2lofax")
  897. !         ||   !strcmp(PGM,    "hp2log3")
  898. !         ||   !strcmp(PGM,    "hp2log3r"))
  899.           rs_rastsize(    204.15, 97.79);
  900.       else if (!strcmp(PGM,    "hp2sun"))
  901.           rs_rastsize(     84.0,  84.0);
  902. ***************
  903. *** 805,816 ****
  904.       pbmeject(FALSE);
  905.       if (genps)
  906.       ps_endemit();
  907.       exit(0);
  908.   /*NOTREACHED*/
  909.   }
  910.   
  911.   hptoany() {
  912. !     int c;
  913.   
  914.       while ((c = (*getchar_func)()) != EOF) {
  915.       if (c == ESCAPE)
  916. --- 814,833 ----
  917.       pbmeject(FALSE);
  918.       if (genps)
  919.       ps_endemit();
  920. + #ifdef    ZYXFAX
  921. +     if (  !strcmp(PGM,    "hp2hig3")
  922. +         ||!strcmp(PGM,    "hp2hig3r")
  923. +         ||!strcmp(PGM,    "hp2log3")
  924. +         ||!strcmp(PGM,    "hp2log3r"))
  925. +     g3stop();
  926. + #endif
  927.       exit(0);
  928.   /*NOTREACHED*/
  929.   }
  930.   
  931.   hptoany() {
  932. !     register int c;
  933.   
  934.       while ((c = (*getchar_func)()) != EOF) {
  935.       if (c == ESCAPE)
  936. Index: ./hptopbm.h
  937. *** /tmp/PATCHold/./hptopbm.h    Thu Mar  5 02:20:13 1992
  938. --- ./hptopbm.h    Thu Mar  5 02:20:14 1992
  939. ***************
  940. *** 16,25 ****
  941.       Canada K0A 1T0
  942.       (613) 832-0541
  943.   
  944. !     Function: Header file for hp2pbm.  1.3 92/01/05 23:17:02
  945.    */
  946.   
  947. ! #define    VERSION    "hp2pbm V1.01"
  948.   
  949.   #include <stdio.h>
  950.   #include <ctype.h>
  951. --- 16,25 ----
  952.       Canada K0A 1T0
  953.       (613) 832-0541
  954.   
  955. !     Function: Header file for hp2pbm.  1.4 92/03/01 02:05:16
  956.    */
  957.   
  958. ! #define    VERSION    "hp2pbm V1.02"
  959.   
  960.   #include <stdio.h>
  961.   #include <ctype.h>
  962. Index: ./g3.h
  963. *** /tmp/PATCHold/./g3.h    Thu Mar  5 02:20:20 1992
  964. --- ./g3.h    Thu Mar  5 02:20:23 1992
  965. ***************
  966. *** 0 ****
  967. --- 1,242 ----
  968. + /*
  969. +  * g3.h - G3 definitions
  970. +  * 
  971. +  * Copyright (C) 1989 by Paul Haeberli <paul@manray.sgi.com>. *
  972. +  * 
  973. +  * Permission to use, copy, modify, and distribute this software and its *
  974. +  * documentation for any purpose and without fee is hereby granted, provided *
  975. +  * that the above copyright notice appear in all copies and that both that *
  976. +  * copyright notice and this permission notice appear in supporting *
  977. +  * documentation.  This software is provided "as is" without express or *
  978. +  * implied warranty.
  979. +  * 1.1 92/03/05 from Jef Poskanzer's PBMPLUS
  980. +  */
  981. + #ifndef _G3_H_
  982. + #define _G3_H_
  983. + typedef struct tableentry {
  984. +     int tabid;
  985. +     int code;
  986. +     int length;
  987. +     int count;
  988. +     } tableentry;
  989. + #define TWTABLE        23
  990. + #define MWTABLE        24
  991. + #define TBTABLE        25
  992. + #define MBTABLE        26
  993. + #define EXTABLE        27
  994. + #define VRTABLE        28
  995. + static struct tableentry twtable[] = {
  996. +     { TWTABLE, 0x35, 8, 0 },
  997. +     { TWTABLE, 0x7, 6, 1 },
  998. +     { TWTABLE, 0x7, 4, 2 },
  999. +     { TWTABLE, 0x8, 4, 3 },
  1000. +     { TWTABLE, 0xb, 4, 4 },
  1001. +     { TWTABLE, 0xc, 4, 5 },
  1002. +     { TWTABLE, 0xe, 4, 6 },
  1003. +     { TWTABLE, 0xf, 4, 7 },
  1004. +     { TWTABLE, 0x13, 5, 8 },
  1005. +     { TWTABLE, 0x14, 5, 9 },
  1006. +     { TWTABLE, 0x7, 5, 10 },
  1007. +     { TWTABLE, 0x8, 5, 11 },
  1008. +     { TWTABLE, 0x8, 6, 12 },
  1009. +     { TWTABLE, 0x3, 6, 13 },
  1010. +     { TWTABLE, 0x34, 6, 14 },
  1011. +     { TWTABLE, 0x35, 6, 15 },
  1012. +     { TWTABLE, 0x2a, 6, 16 },
  1013. +     { TWTABLE, 0x2b, 6, 17 },
  1014. +     { TWTABLE, 0x27, 7, 18 },
  1015. +     { TWTABLE, 0xc, 7, 19 },
  1016. +     { TWTABLE, 0x8, 7, 20 },
  1017. +     { TWTABLE, 0x17, 7, 21 },
  1018. +     { TWTABLE, 0x3, 7, 22 },
  1019. +     { TWTABLE, 0x4, 7, 23 },
  1020. +     { TWTABLE, 0x28, 7, 24 },
  1021. +     { TWTABLE, 0x2b, 7, 25 },
  1022. +     { TWTABLE, 0x13, 7, 26 },
  1023. +     { TWTABLE, 0x24, 7, 27 },
  1024. +     { TWTABLE, 0x18, 7, 28 },
  1025. +     { TWTABLE, 0x2, 8, 29 },
  1026. +     { TWTABLE, 0x3, 8, 30 },
  1027. +     { TWTABLE, 0x1a, 8, 31 },
  1028. +     { TWTABLE, 0x1b, 8, 32 },
  1029. +     { TWTABLE, 0x12, 8, 33 },
  1030. +     { TWTABLE, 0x13, 8, 34 },
  1031. +     { TWTABLE, 0x14, 8, 35 },
  1032. +     { TWTABLE, 0x15, 8, 36 },
  1033. +     { TWTABLE, 0x16, 8, 37 },
  1034. +     { TWTABLE, 0x17, 8, 38 },
  1035. +     { TWTABLE, 0x28, 8, 39 },
  1036. +     { TWTABLE, 0x29, 8, 40 },
  1037. +     { TWTABLE, 0x2a, 8, 41 },
  1038. +     { TWTABLE, 0x2b, 8, 42 },
  1039. +     { TWTABLE, 0x2c, 8, 43 },
  1040. +     { TWTABLE, 0x2d, 8, 44 },
  1041. +     { TWTABLE, 0x4, 8, 45 },
  1042. +     { TWTABLE, 0x5, 8, 46 },
  1043. +     { TWTABLE, 0xa, 8, 47 },
  1044. +     { TWTABLE, 0xb, 8, 48 },
  1045. +     { TWTABLE, 0x52, 8, 49 },
  1046. +     { TWTABLE, 0x53, 8, 50 },
  1047. +     { TWTABLE, 0x54, 8, 51 },
  1048. +     { TWTABLE, 0x55, 8, 52 },
  1049. +     { TWTABLE, 0x24, 8, 53 },
  1050. +     { TWTABLE, 0x25, 8, 54 },
  1051. +     { TWTABLE, 0x58, 8, 55 },
  1052. +     { TWTABLE, 0x59, 8, 56 },
  1053. +     { TWTABLE, 0x5a, 8, 57 },
  1054. +     { TWTABLE, 0x5b, 8, 58 },
  1055. +     { TWTABLE, 0x4a, 8, 59 },
  1056. +     { TWTABLE, 0x4b, 8, 60 },
  1057. +     { TWTABLE, 0x32, 8, 61 },
  1058. +     { TWTABLE, 0x33, 8, 62 },
  1059. +     { TWTABLE, 0x34, 8, 63 },
  1060. +     };
  1061. + static struct tableentry mwtable[] = {
  1062. +     { MWTABLE, 0x1b, 5, 64 },
  1063. +     { MWTABLE, 0x12, 5, 128 },
  1064. +     { MWTABLE, 0x17, 6, 192 },
  1065. +     { MWTABLE, 0x37, 7, 256 },
  1066. +     { MWTABLE, 0x36, 8, 320 },
  1067. +     { MWTABLE, 0x37, 8, 384 },
  1068. +     { MWTABLE, 0x64, 8, 448 },
  1069. +     { MWTABLE, 0x65, 8, 512 },
  1070. +     { MWTABLE, 0x68, 8, 576 },
  1071. +     { MWTABLE, 0x67, 8, 640 },
  1072. +     { MWTABLE, 0xcc, 9, 704 },
  1073. +     { MWTABLE, 0xcd, 9, 768 },
  1074. +     { MWTABLE, 0xd2, 9, 832 },
  1075. +     { MWTABLE, 0xd3, 9, 896 },
  1076. +     { MWTABLE, 0xd4, 9, 960 },
  1077. +     { MWTABLE, 0xd5, 9, 1024 },
  1078. +     { MWTABLE, 0xd6, 9, 1088 },
  1079. +     { MWTABLE, 0xd7, 9, 1152 },
  1080. +     { MWTABLE, 0xd8, 9, 1216 },
  1081. +     { MWTABLE, 0xd9, 9, 1280 },
  1082. +     { MWTABLE, 0xda, 9, 1344 },
  1083. +     { MWTABLE, 0xdb, 9, 1408 },
  1084. +     { MWTABLE, 0x98, 9, 1472 },
  1085. +     { MWTABLE, 0x99, 9, 1536 },
  1086. +     { MWTABLE, 0x9a, 9, 1600 },
  1087. +     { MWTABLE, 0x18, 6, 1664 },
  1088. +     { MWTABLE, 0x9b, 9, 1728 },
  1089. +     };
  1090. + static struct tableentry tbtable[] = {
  1091. +     { TBTABLE, 0x37, 10, 0 },
  1092. +     { TBTABLE, 0x2, 3, 1 },
  1093. +     { TBTABLE, 0x3, 2, 2 },
  1094. +     { TBTABLE, 0x2, 2, 3 },
  1095. +     { TBTABLE, 0x3, 3, 4 },
  1096. +     { TBTABLE, 0x3, 4, 5 },
  1097. +     { TBTABLE, 0x2, 4, 6 },
  1098. +     { TBTABLE, 0x3, 5, 7 },
  1099. +     { TBTABLE, 0x5, 6, 8 },
  1100. +     { TBTABLE, 0x4, 6, 9 },
  1101. +     { TBTABLE, 0x4, 7, 10 },
  1102. +     { TBTABLE, 0x5, 7, 11 },
  1103. +     { TBTABLE, 0x7, 7, 12 },
  1104. +     { TBTABLE, 0x4, 8, 13 },
  1105. +     { TBTABLE, 0x7, 8, 14 },
  1106. +     { TBTABLE, 0x18, 9, 15 },
  1107. +     { TBTABLE, 0x17, 10, 16 },
  1108. +     { TBTABLE, 0x18, 10, 17 },
  1109. +     { TBTABLE, 0x8, 10, 18 },
  1110. +     { TBTABLE, 0x67, 11, 19 },
  1111. +     { TBTABLE, 0x68, 11, 20 },
  1112. +     { TBTABLE, 0x6c, 11, 21 },
  1113. +     { TBTABLE, 0x37, 11, 22 },
  1114. +     { TBTABLE, 0x28, 11, 23 },
  1115. +     { TBTABLE, 0x17, 11, 24 },
  1116. +     { TBTABLE, 0x18, 11, 25 },
  1117. +     { TBTABLE, 0xca, 12, 26 },
  1118. +     { TBTABLE, 0xcb, 12, 27 },
  1119. +     { TBTABLE, 0xcc, 12, 28 },
  1120. +     { TBTABLE, 0xcd, 12, 29 },
  1121. +     { TBTABLE, 0x68, 12, 30 },
  1122. +     { TBTABLE, 0x69, 12, 31 },
  1123. +     { TBTABLE, 0x6a, 12, 32 },
  1124. +     { TBTABLE, 0x6b, 12, 33 },
  1125. +     { TBTABLE, 0xd2, 12, 34 },
  1126. +     { TBTABLE, 0xd3, 12, 35 },
  1127. +     { TBTABLE, 0xd4, 12, 36 },
  1128. +     { TBTABLE, 0xd5, 12, 37 },
  1129. +     { TBTABLE, 0xd6, 12, 38 },
  1130. +     { TBTABLE, 0xd7, 12, 39 },
  1131. +     { TBTABLE, 0x6c, 12, 40 },
  1132. +     { TBTABLE, 0x6d, 12, 41 },
  1133. +     { TBTABLE, 0xda, 12, 42 },
  1134. +     { TBTABLE, 0xdb, 12, 43 },
  1135. +     { TBTABLE, 0x54, 12, 44 },
  1136. +     { TBTABLE, 0x55, 12, 45 },
  1137. +     { TBTABLE, 0x56, 12, 46 },
  1138. +     { TBTABLE, 0x57, 12, 47 },
  1139. +     { TBTABLE, 0x64, 12, 48 },
  1140. +     { TBTABLE, 0x65, 12, 49 },
  1141. +     { TBTABLE, 0x52, 12, 50 },
  1142. +     { TBTABLE, 0x53, 12, 51 },
  1143. +     { TBTABLE, 0x24, 12, 52 },
  1144. +     { TBTABLE, 0x37, 12, 53 },
  1145. +     { TBTABLE, 0x38, 12, 54 },
  1146. +     { TBTABLE, 0x27, 12, 55 },
  1147. +     { TBTABLE, 0x28, 12, 56 },
  1148. +     { TBTABLE, 0x58, 12, 57 },
  1149. +     { TBTABLE, 0x59, 12, 58 },
  1150. +     { TBTABLE, 0x2b, 12, 59 },
  1151. +     { TBTABLE, 0x2c, 12, 60 },
  1152. +     { TBTABLE, 0x5a, 12, 61 },
  1153. +     { TBTABLE, 0x66, 12, 62 },
  1154. +     { TBTABLE, 0x67, 12, 63 },
  1155. +     };
  1156. + static struct tableentry mbtable[] = {
  1157. +     { MBTABLE, 0xf, 10, 64 },
  1158. +     { MBTABLE, 0xc8, 12, 128 },
  1159. +     { MBTABLE, 0xc9, 12, 192 },
  1160. +     { MBTABLE, 0x5b, 12, 256 },
  1161. +     { MBTABLE, 0x33, 12, 320 },
  1162. +     { MBTABLE, 0x34, 12, 384 },
  1163. +     { MBTABLE, 0x35, 12, 448 },
  1164. +     { MBTABLE, 0x6c, 13, 512 },
  1165. +     { MBTABLE, 0x6d, 13, 576 },
  1166. +     { MBTABLE, 0x4a, 13, 640 },
  1167. +     { MBTABLE, 0x4b, 13, 704 },
  1168. +     { MBTABLE, 0x4c, 13, 768 },
  1169. +     { MBTABLE, 0x4d, 13, 832 },
  1170. +     { MBTABLE, 0x72, 13, 896 },
  1171. +     { MBTABLE, 0x73, 13, 960 },
  1172. +     { MBTABLE, 0x74, 13, 1024 },
  1173. +     { MBTABLE, 0x75, 13, 1088 },
  1174. +     { MBTABLE, 0x76, 13, 1152 },
  1175. +     { MBTABLE, 0x77, 13, 1216 },
  1176. +     { MBTABLE, 0x52, 13, 1280 },
  1177. +     { MBTABLE, 0x53, 13, 1344 },
  1178. +     { MBTABLE, 0x54, 13, 1408 },
  1179. +     { MBTABLE, 0x55, 13, 1472 },
  1180. +     { MBTABLE, 0x5a, 13, 1536 },
  1181. +     { MBTABLE, 0x5b, 13, 1600 },
  1182. +     { MBTABLE, 0x64, 13, 1664 },
  1183. +     { MBTABLE, 0x65, 13, 1728 },
  1184. +     };
  1185. + static struct tableentry extable[] = {
  1186. +     { EXTABLE, 0x8, 11, 1792 },
  1187. +     { EXTABLE, 0xc, 11, 1856 },
  1188. +     { EXTABLE, 0xd, 11, 1920 },
  1189. +     { EXTABLE, 0x12, 12, 1984 },
  1190. +     { EXTABLE, 0x13, 12, 2048 },
  1191. +     { EXTABLE, 0x14, 12, 2112 },
  1192. +     { EXTABLE, 0x15, 12, 2176 },
  1193. +     { EXTABLE, 0x16, 12, 2240 },
  1194. +     { EXTABLE, 0x17, 12, 2304 },
  1195. +     { EXTABLE, 0x1c, 12, 2368 },
  1196. +     { EXTABLE, 0x1d, 12, 2432 },
  1197. +     { EXTABLE, 0x1e, 12, 2496 },
  1198. +     { EXTABLE, 0x1f, 12, 2560 },
  1199. +     };
  1200. + #endif /*_G3_H_*/
  1201. Index: ./g3.c
  1202. *** /tmp/PATCHold/./g3.c    Thu Mar  5 02:20:29 1992
  1203. --- ./g3.c    Thu Mar  5 02:20:32 1992
  1204. ***************
  1205. *** 0 ****
  1206. --- 1,228 ----
  1207. + /*
  1208. +  * g3 output routines for hp2pbm - bob@usixth.sublink.org. Mon Jan 20
  1209. +  * 20:44:06 EST 1992
  1210. +  * 
  1211. +  * From: 1.1 92/03/05
  1212. +  */
  1213. + /*
  1214. +  * pbmtog3.c - read a portable bitmap and produce a Group 3 FAX file *
  1215. +  * 
  1216. +  * Copyright (C) 1989 by Paul Haeberli <paul@manray.sgi.com>. *
  1217. +  * 
  1218. +  * Permission to use, copy, modify, and distribute this software and its *
  1219. +  * documentation for any purpose and without fee is hereby granted, provided *
  1220. +  * that the above copyright notice appear in all copies and that both that *
  1221. +  * copyright notice and this permission notice appear in supporting *
  1222. +  * documentation.  This software is provided "as is" without express or *
  1223. +  * implied warranty.
  1224. +  */
  1225. + #include <stdio.h>
  1226. + #include "g3.h"
  1227. + #ifdef    __STDC_
  1228. + #define    ARGS(a)    a
  1229. + #else
  1230. + #define    ARGS(a)    ()
  1231. + #endif
  1232. + static void putwhitespan ARGS((int c));
  1233. + static void putblackspan ARGS((int c));
  1234. + static void putcode ARGS((tableentry * te));
  1235. + static void puteol ARGS((void));
  1236. + static void putinit ARGS((void));
  1237. + static void putbit ARGS((int d));
  1238. + static void flushbits ARGS((void));
  1239. + static int      reversebits;
  1240. + static FILE     *fp;
  1241. + static int      bigcols;
  1242. + static int      shdata;
  1243. + static int      shbit;
  1244. + static
  1245. + #ifdef    __GNUC__
  1246. + inline
  1247. + #endif
  1248. + void
  1249. + putbit(d)
  1250. +     int             d;
  1251. + {
  1252. +     if (d)
  1253. +         shdata = shdata | shbit;
  1254. +     if (reversebits)
  1255. +         shbit = shbit << 1;
  1256. +     else
  1257. +         shbit = shbit >> 1;
  1258. +     if ((shbit & 0xff) == 0) {
  1259. +         putc(shdata,fp);
  1260. +         shdata = 0;
  1261. +         shbit = reversebits ? 0x01 : 0x80;
  1262. +     }
  1263. + }
  1264. + g3start(filep, xmax, rev)
  1265. +     FILE            *filep;
  1266. + {
  1267. +     char            bitrow[1728 / 8];
  1268. +     fp = filep;
  1269. +     reversebits = rev;
  1270. +     bigcols = xmax;
  1271. +     if (bigcols > 1728)
  1272. +         bigcols = 1728;
  1273. +     shdata = 0;
  1274. +     shbit = reversebits ? 0x01 : 0x80;
  1275. +     memset(bitrow, 0, sizeof(bitrow));
  1276. +     g3write(bitrow);
  1277. +     g3write(bitrow);
  1278. +     g3write(bitrow);
  1279. +     g3write(bitrow);
  1280. + }
  1281. + g3stop()
  1282. + {
  1283. +     puteol();
  1284. +     puteol();
  1285. +     puteol();
  1286. +     puteol();
  1287. +     puteol();
  1288. +     puteol();
  1289. +     flushbits();
  1290. + }
  1291. + g3write(bitrow)
  1292. +     register unsigned char *bitrow;
  1293. + {
  1294. +     register int             n = bigcols;
  1295. +     register int             c;
  1296. +     register unsigned char    mask, byte;
  1297. +     byte = *bitrow++;
  1298. +     mask = 0x80;
  1299. +     while (n > 0) {
  1300. +         for ( c=0; (byte&mask) == 0 && n > 0; c++, n-- )
  1301. +         {
  1302. +             mask >>= 1;
  1303. +             if ( mask == 0 )
  1304. +             {
  1305. +                 mask = 0x80;
  1306. +                 byte = *bitrow++;
  1307. +                 while ( n >= 8 && byte == 0 )
  1308. +                 {
  1309. +                     c += 8;
  1310. +                     n -= 8;
  1311. +                     byte = *bitrow++;
  1312. +                 }
  1313. +             }
  1314. +         }
  1315. +         putwhitespan(c);
  1316. +         if (n == 0)
  1317. +             break;
  1318. +         for ( c=0; (byte&mask) && n > 0; c++, n-- )
  1319. +         {
  1320. +             mask >>= 1;
  1321. +             if ( mask == 0 )
  1322. +             {
  1323. +                 mask = 0x80;
  1324. +                 byte = *bitrow++;
  1325. +                 while ( n >= 8 && byte == 0xff )
  1326. +                 {
  1327. +                     c += 8;
  1328. +                     n -= 8;
  1329. +                     byte = *bitrow++;
  1330. +                 }
  1331. +             }
  1332. +         }
  1333. +         putblackspan(c);
  1334. +     }
  1335. +     puteol();
  1336. +     return 1;
  1337. + }
  1338. + static
  1339. + #ifdef    __GNUC__
  1340. + inline
  1341. + #endif
  1342. + void
  1343. + putwhitespan(c)
  1344. +     int             c;
  1345. + {
  1346. +     int             tpos;
  1347. +     tableentry      *te;
  1348. +     if (c >= 64) {
  1349. +         tpos = (c / 64) - 1;
  1350. +         te = mwtable + tpos;
  1351. +         c -= te->count;
  1352. +         putcode(te);
  1353. +     }
  1354. +     tpos = c;
  1355. +     te = twtable + tpos;
  1356. +     putcode(te);
  1357. + }
  1358. + static
  1359. + #ifdef    __GNUC__
  1360. + inline
  1361. + #endif
  1362. + void
  1363. + putblackspan(c)
  1364. +     int             c;
  1365. + {
  1366. +     int             tpos;
  1367. +     tableentry      *te;
  1368. +     if (c >= 64) {
  1369. +         tpos = (c / 64) - 1;
  1370. +         te = mbtable + tpos;
  1371. +         c -= te->count;
  1372. +         putcode(te);
  1373. +     }
  1374. +     tpos = c;
  1375. +     te = tbtable + tpos;
  1376. +     putcode(te);
  1377. + }
  1378. + static void
  1379. + putcode(te)
  1380. +     register tableentry      *te;
  1381. + {
  1382. +     register unsigned int    mask;
  1383. +     register int             code;
  1384. +     mask = 1 << (te->length - 1);
  1385. +     code = te->code;
  1386. +     while (mask) {
  1387. +         if (code & mask)
  1388. +             putbit(1);
  1389. +         else
  1390. +             putbit(0);
  1391. +         mask >>= 1;
  1392. +     }
  1393. + }
  1394. + static void
  1395. + puteol()
  1396. + {
  1397. +     int             i;
  1398. +     for (i = 0; i < 11; ++i)
  1399. +         putbit(0);
  1400. +     putbit(1);
  1401. + }
  1402. + static void
  1403. + flushbits()
  1404. + {
  1405. +     if ((reversebits && shbit != 0x01) ||
  1406. +         (!reversebits && shbit != 0x80)) {
  1407. +         putc(shdata,fp);
  1408. +         shdata = 0;
  1409. +         shbit = reversebits ? 0x01 : 0x80;
  1410. +     }
  1411. + }
  1412.  
  1413. -- 
  1414. Chris Lewis; clewis@ferret.ocunix.on.ca; Phone: Canada 613 832-0541
  1415. Psroff 3.0 info: psroff-request@ferret.ocunix.on.ca
  1416. Ferret list: ferret-request@ferret.ocunix.on.ca
  1417.  
  1418. exit 0 # Just in case...
  1419.