home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume19 / dvi / part01 next >
Text File  |  1991-05-14  |  53KB  |  1,950 lines

  1. Newsgroups: comp.sources.misc
  2. From: Parag Patel <parag@hpsdeb.sde.hp.com>
  3. Subject:  v19i064:  dvi - C++ DVI filter for HP LaserJets, Part01/03
  4. Message-ID: <1991May14.182222.14212@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 04a8266e4a42ef204209d1cec74bdebc
  6. Date: Tue, 14 May 1991 18:22:22 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Parag Patel <parag@hpsdeb.sde.hp.com>
  10. Posting-number: Volume 19, Issue 64
  11. Archive-name: dvi/part01
  12.  
  13. This is my fairly old C++ DVI filter for HP LaserJets.  I'd rewritten it
  14. from C about 4 years ago to learn C++ and to have a fast DVI filter.
  15. This package has been submitted to this year's HP INTEREX contrib tape
  16. and thus is already available with no warantee of any kind.  I hope
  17. it'll prove as useful to people outside HP as it been inside.
  18.  
  19. Dvi currently compiles right up on HP-UX 7.0, 6.5, and 6.2 (s300s or
  20. s800s), BSD4.3 (Tahoe) on hp300 hardware, and Zortech C++ on MSDOS.  I
  21. use AT&T's C++ 2.0 (cfront) and not G++ on all my Unix boxes.  I do NOT
  22. use C++ streams, but do use stdio.  I have NO idea how much work it'll
  23. take to get it running on other systems or using G++, but it shouldn't
  24. be too hard.
  25.  
  26. The man-page lists all the pertinent details, but here's some
  27. highlights:
  28.  
  29. o       fast
  30. o       written in C++
  31. o       supports LaserJetII, LaserJetIID, LaserJet2000, and LaserJet+
  32. o       supports double-sided printing on LJs which can do double-sided
  33. o       supports landscape printing for slides
  34. o       handles big fonts, like, for instance, SliTeX dumps
  35. o       supports JTeX - the Japanese version of TeX which heavily
  36.         exercises the font capabilities of the LJs and of "dvi"
  37. o       allows selecting particular pages and page ranges from the
  38.         command line (OK - it ain't clean or friendly, but it works)
  39. o       supports various \specials for dumping raw PCL files - it is also
  40.         pretty easy to add new specials
  41. o       completely demand driven - not even the font info much less the
  42.         info for a particular character is downloaded unless that character
  43.         is actually going to be printed on the paper
  44. o       does NOT send a hard-reset escape-sequence, which allows one to
  45.         wrap anything around this dvi's output that one wishes
  46. o       has cool (well - entertaining anyway) -v verbose mode
  47. o       actually has a man-page
  48. o       the price is right
  49.  
  50. The code is somewhat commented.  Feel free to hack away, add new
  51. devices, or optimize any of my screwups.  If you make mods you feel are
  52. useful, or fix some bug, please send me the cdiffs so I can make them
  53. available to others too.
  54.  
  55.     -- Parag Patel <parag@sde.hp.com>
  56.  
  57. ---- Cut Here and feed the following to sh ----
  58. #!/bin/sh
  59. # This is dvi, a shell archive (produced by shar 3.49)
  60. # To extract the files from this archive, save it to a file, remove
  61. # everything above the "!/bin/sh" line above, and type "sh file_name".
  62. #
  63. # made 05/09/1991 20:26 UTC by parag@tin
  64. # Source directory /users/parag/tools/tex/dvi
  65. #
  66. # existing files will NOT be overwritten unless -c is specified
  67. #
  68. # This shar contains:
  69. # length  mode       name
  70. # ------ ---------- ------------------------------------------
  71. #   3405 -r--r--r-- README
  72. #  10332 -r--r--r-- dvi.1
  73. #   2546 -r--r--r-- Makefile
  74. #   4621 -r--r--r-- main.C
  75. #    654 -r--r--r-- dev.C
  76. #  11294 -r--r--r-- hp2686.C
  77. #   1807 -r--r--r-- hp33440.C
  78. #    606 -r--r--r-- hp2684.C
  79. #   4481 -r--r--r-- util.C
  80. #   4109 -r--r--r-- global.C
  81. #    970 -r--r--r-- stack.C
  82. #   2199 -r--r--r-- dirs.C
  83. #  11617 -r--r--r-- dvi.C
  84. #  12300 -r--r--r-- font.C
  85. #   5861 -r--r--r-- readfont.C
  86. #   7918 -r--r--r-- gffont.C
  87. #  10380 -r--r--r-- pkfont.C
  88. #   3331 -r--r--r-- bitvec.C
  89. #    632 -r--r--r-- hp2684.h
  90. #   1015 -r--r--r-- hp33440.h
  91. #   1357 -r--r--r-- hp2686.h
  92. #   4214 -r--r--r-- defs.h
  93. #   2904 -r--r--r-- extern.h
  94. #    506 -r--r--r-- dirs.h
  95. #   3299 -r--r--r-- font.h
  96. #   3077 -r--r--r-- dev.h
  97. #   1656 -r--r--r-- darray.h
  98. #    258 -r--r--r-- boolean.h
  99. #   1665 -r--r--r-- bitvec.h
  100. #   3296 -r--r--r-- ljdump.c
  101. #
  102. # ============= README ==============
  103. if test -f 'README' -a X"$1" != X"-c"; then
  104.     echo 'x - skipping README (File already exists)'
  105. else
  106. echo 'x - extracting README (Text)'
  107. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  108. $Header: README,v 1.10 91/02/22 16:31:45 hmgr Exp $
  109. X
  110. Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  111. You can do what you wish with this as long as
  112. X    (1) you do not claim it or any part of it as yours and
  113. X    (2) you do not remove or alter my copyright in any file.
  114. This software is provided "AS IS" without any implied or express warranty
  115. as to its performance or to the results that may be obtained by using this
  116. software.  It is completely unsupported.  You're on your own.
  117. X
  118. X
  119. This is version 1.4 of my TeX DVI filter.  I'd written it about 4 years
  120. ago since, at that time, the only LaserJet DVI filters available to me
  121. were in Pascal and ungodly slow.  Anyway, it's been pointed out to me
  122. that "dvi" still one of the better DVIs around, so I figured it was time
  123. to get off my duff and make it available to the world at large.  Or at
  124. small - I'm not picky.
  125. X
  126. The man-page lists all the pertinent details, but here's some
  127. highlights:
  128. X
  129. o    fast
  130. o    written in C++
  131. o    supports LaserJetII, LaserJetIID, LaserJet2000, and LaserJet+
  132. o    supports double-sided printing on LJs which can do double-sided
  133. o    supports landscape printing for slides
  134. o    handles big fonts, like, for instance, SliTeX dumps
  135. o    supports JTeX - the Japanese version of TeX which heavily
  136. X    exercises the font capabilities of the LJs and of "dvi"
  137. o    allows selecting particular pages and page ranges from the
  138. X    command line (OK - it ain't clean or friendly, but it works)
  139. o    supports various \specials for dumping raw PCL files - it is also
  140. X    pretty easy to add new specials
  141. o    completely demand driven - not even the font info much less the
  142. X    info for a particular character is downloaded unless that character
  143. X    is actually going to be printed on the paper
  144. o    does NOT send a hard-reset escape-sequence, which allows one to
  145. X    wrap anything around this dvi's output that one wishes
  146. o    has cool (well - entertaining anyway) -v verbose mode
  147. o    actually has a man-page
  148. o    the price is right
  149. X
  150. I've also gotten into C++, and I've long since converted my old C DVI
  151. code into C++.  There are still plenty of C-isms in here though.  Still,
  152. the virtual baseclass "Device" should make adding new devices a lot
  153. easier.  (I still need to design some sort of FontFileFormat class,
  154. among other things.)
  155. X
  156. Dvi currently compiles right up on HP-UX 7.0, 6.5, and 6.2 (s300s or
  157. s800s), BSD4.3 (Tahoe) on hp300 hardware, and Zortech C++ on MSDOS.  I
  158. use AT&T's C++ 2.0 (cfront) and not G++ on all my Unix boxes.  I do NOT
  159. use C++ streams, but do use stdio.  I have NO idea how much work it'll
  160. take to get it running on other systems or using G++, but it shouldn't
  161. be too hard.
  162. X
  163. X
  164. Anyway, just type "make" to build a debug version of "dvi".  Then copy
  165. "dvi" and "dvi.1" to whatever names and whatever places you want them.
  166. You will have to define -DMSDOS or -DBSD in the Makefile if you are on
  167. those systems.
  168. X
  169. Use "make ljdump" to build the "ljdump" program.  This is useful for
  170. debugging dvi by converting PCL to a semi-human-readable dump.
  171. X
  172. There's also a machine-dependency in "bitvec.[hC]".  If your "unsigned
  173. long" type is NOT 32 bits, you're hosed, and the code will require some
  174. hacking.  Sorry.
  175. X
  176. The code is somewhat commented.  Feel free to hack away, add new
  177. devices, or optimize any of my screwups.  If you make mods you feel are
  178. useful, or fix some bug, please send me the cdiffs so I can make them
  179. available to others too.
  180. X
  181. X
  182. X
  183. X    -- Parag Patel <parag@sde.hp.com>
  184. SHAR_EOF
  185. chmod 0444 README ||
  186. echo 'restore of README failed'
  187. Wc_c="`wc -c < 'README'`"
  188. test 3405 -eq "$Wc_c" ||
  189.     echo 'README: original size 3405, current size' "$Wc_c"
  190. fi
  191. # ============= dvi.1 ==============
  192. if test -f 'dvi.1' -a X"$1" != X"-c"; then
  193.     echo 'x - skipping dvi.1 (File already exists)'
  194. else
  195. echo 'x - extracting dvi.1 (Text)'
  196. sed 's/^X//' << 'SHAR_EOF' > 'dvi.1' &&
  197. .\" Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  198. .\" $Header: dvi.1,v 1.29 91/02/22 15:53:38 hmgr Exp $
  199. .TH DVI 1 unsupported
  200. .ad b
  201. .SH NAME
  202. dvi \- TeX DVI filter for various printers
  203. .SH SYNOPSIS
  204. .B dvi
  205. .RB [\- vrlc ]
  206. .RB [\- o device]
  207. .RB [\- 2 h|v|\-]
  208. .RB [\- d fontpath]
  209. .RB [\- i inputpath]
  210. .RB [\- p page-list]
  211. .RB [\- m magnification-value]
  212. [ dvifile ]
  213. .SH DESCRIPTION
  214. This filter converts the DeVice Independent (DVI) output of TeX
  215. into commands for various printers.
  216. The type of printer is selected via a command-line option (below).
  217. The printer commands are put on
  218. .I stdout
  219. to be redirected directly to the printer
  220. or to be printed via the lp spooler using some "raw" option.
  221. .P
  222. By default,
  223. .I dvi
  224. takes no arguments and only prints fatal error messages on
  225. .IR stderr .
  226. The DVI file is assumed to be on
  227. .I stdin
  228. unless specified on the
  229. command line.
  230. .I Dvi
  231. appends the extension
  232. .RB `` .dvi ''
  233. to the file name if necessary.
  234. .PP
  235. Optional arguments:
  236. .TP
  237. .RB \- o device
  238. Specify the name of a printer that
  239. .I dvi
  240. supports.
  241. This basically selects the type of command sequences that
  242. .I dvi
  243. generates.
  244. The default values of other options (such as reverse, landscape, and
  245. double-sided)
  246. may be affected by the choice of printer.
  247. The names of the currently supported printers as well as their
  248. default options are listed in the PRINTER DEPENDENCIES section below.
  249. .TP
  250. .RB \- v
  251. Verbose mode.
  252. Display the page and section number of each page in the DVI file
  253. as it is processed on
  254. .IR stderr .
  255. Also display the name of each raster file as it is dumped and the
  256. name of each font type as it is downloaded to the printer.
  257. .TP
  258. .RB \- r
  259. Switch page reversal off.
  260. For some printers, this option switches page reversal on instead of
  261. switching it off.
  262. This option works as expected with the
  263. .B -p
  264. option below.
  265. .TP
  266. .RB \- l
  267. Generate output in landscape mode instead of portrait mode.
  268. This is especially handy for certain SliTeX slides.
  269. This may switch off landscape mode for certain printers.
  270. .TP
  271. .RB \- c
  272. Normally,
  273. .I dvi
  274. will compare the checksums and designsize
  275. values in the font files and the input file to
  276. ensure that both were built from the same font sources.
  277. This option switches this feature off so that no consistency
  278. checking is performed.
  279. Use at your own risk.
  280. .RI ( Dvi
  281. still prints a warning in 
  282. .B \-v
  283. verbose mode but doesn't croak.)
  284. .TP
  285. .RB \- 2 h|v|\-
  286. This switches on the double-sided printing features of
  287. .IR dvi 
  288. to print odd and even pages on the front and back of a
  289. single sheet of paper.
  290. It is ignored by printers incapable of double-sided printing.
  291. The argument
  292. .B h
  293. specifies horizontal binding so that the output may be bound along
  294. a horizontal spine like a flip-top notebook.
  295. A
  296. .B v
  297. specifies vertical binding like a paperback book.
  298. A
  299. .B \-
  300. forces double-sided printing completely off for any printer.
  301. .TP
  302. .RB \- m mag-value
  303. Use the specified magnification value to resize the final output.
  304. This may be either in units of 1000 as TeX understands magnification,
  305. or it may be specified as a floating 1.000 value.
  306. If there are no fonts available at the desired magnification,
  307. .I dvi
  308. may fail.
  309. .TP
  310. .RB \- d fontpath
  311. Specify the font directory search path where
  312. .I dvi
  313. should look for either the GF or PK format font files.
  314. The directories should have subdirectories for various magnifications.
  315. Overrides the value of the environment var
  316. .B FONTPATH
  317. if it exists.
  318. The separator between the various path is platform dependent.
  319. See the section on PLATFORM DEPENDENCIES for details.
  320. .TP
  321. .RB \- i inputpath
  322. Specify the directory search path for \\special files.
  323. Overrides the value of the environment var
  324. .B DVIINPUT
  325. if it exists.
  326. .TP
  327. \-\fBp\fRpage[.section[=page2[.section2]]][,\ .\ .\ .\ ]
  328. Print only the specified pages in the optional sections.
  329. Both the pages and sections may be specified as ranges.
  330. (\-\fBp\fI3.2=5.3\fR
  331. is the same as
  332. \-\fBp\fI3.2,4.2,5.2,3.3,4.3,5.3\fR)
  333. The ending page/section number in a range may be a
  334. .RB `` \(** ''
  335. to signify the last page or section.
  336. (\-\fBp\fI3.2=\(**\fR
  337. means
  338. \-\fBp\fI3.2,4.2,5.2,.\ .\ .\fR
  339. and
  340. \-\fBp\fI2.3=\(**.\(**\fR
  341. means
  342. \-\fBp\fI2.3,3.3,.\ .\ .,2.4,3.4,.\ .\ .\fR)
  343. (The ``='' character is used instead of ``-'' so that negative
  344. numbers may be entered for page/sections.)
  345. .PP
  346. The format of the DVI file puts some peculiar restrictions on
  347. page and section numbering:
  348. .PP
  349. The page numbers for the
  350. .B \-p
  351. option are the numbers printed on each page of the output.
  352. (For the contents pages, page
  353. .B i
  354. is numbered
  355. .BR 1 ,
  356. .B ii
  357. is
  358. .BR 2 ,
  359. etc.)
  360. Unfortunately, there can be more than one page
  361. .I 1 
  362. (or of other pages)
  363. in the file.
  364. The section number is used to disambiguate pages.
  365. .PP
  366. The section number does not correspond with any real section
  367. number in the output.
  368. Here, the section is each part of the file that is numbered in sequence.
  369. When the page numbering changes from, say, 3 back to 1, this is
  370. considered to be the start of another section.
  371. By default, if no section number is specified, the last section is
  372. assumed to be the one desired, which is usually correct for LaTeX output
  373. and usually wrong for TeX output.  (Oh well.)
  374. Thus
  375. .BI \-p 3.3
  376. is the same as
  377. .BI \-p 3
  378. if there are only 3 sections in the file.
  379. .PP
  380. The section numbers always match those displayed by the
  381. .B \-v
  382. command, so run
  383. .I dvi
  384. with
  385. .B \-v
  386. piped to /dev/null to get the section and page numbers, then run
  387. .I dvi
  388. again to the printer to select specific pages and sections.
  389. .SS Fonts
  390. .I Dvi
  391. now handles both the GF and the PK font formats.
  392. It searches along a default directory path for a printer
  393. to find the necessary fonts.
  394. The environment variable
  395. .B FONTPATH
  396. or the
  397. .B \-d
  398. option
  399. may be used to override this if desired.
  400. The default FONTPATHs are listed in the PRINTER DEPENDENCIES section below.
  401. .PP
  402. The GF format is part of the normal output from the Metafont program.
  403. The PK format is a packed version of the GF file and is
  404. is usually about half its size.
  405. However, the GF file is slightly faster to read because
  406. the entire file does not have to be scanned to find the
  407. character data for all the characters.
  408. .SS Special commands
  409. .I Dvi
  410. supports the \\special commands generated via TeX.
  411. The \\special commands are basically strings of bytes imbeddeded
  412. within TeX output.
  413. (See your TeX or LaTeX manual for more details.)
  414. .I Dvi
  415. uses the \\special command to merge printer-specific
  416. commands into the final output.
  417. .PP
  418. A \\special command string may look like one of the following:
  419. .nf
  420. X
  421. X          \\special{escapeseq<space>string}
  422. X          \\special{rawstring<space>string}
  423. X          \\special{rasterfile<space>filename}
  424. X          \\special{filename}
  425. X
  426. .fi
  427. The keyword
  428. .I escapeseq
  429. specifies that the
  430. .I string
  431. is to be taken literally and sent directly to the output.
  432. The
  433. .I string
  434. may contain special escapes such as
  435. .B \\\\e
  436. for the ESCAPE character,
  437. .B \\\\?
  438. for the DELETE character,
  439. and
  440. .B \\\\^<alpha>
  441. for an arbitrary CONTROL character in addition to ALL
  442. the normal C character escapes.
  443. The forms
  444. .B \\\\0o<octal> \\\\0d<decimal> \\\\0b<binary> \\\\0x<hexadecimal>
  445. are supported for describing a character as a number.
  446. Also, a grave-accent
  447. .B `
  448. character may be used instead of a backslash
  449. .B \\\\
  450. character in case you have a screwy version of TeX.
  451. Naturally, 
  452. .B ``
  453. generates a single
  454. .B `
  455. just as 
  456. .B \\\\\\\\
  457. generates a single
  458. .B \\\\
  459. character.
  460. .PP
  461. The
  462. .I rawstring
  463. special dumps the
  464. .I string
  465. as raw characters with none of the special
  466. processing that
  467. .I escapeseq
  468. does.
  469. .PP
  470. The keyword
  471. .I rasterfile
  472. specifies that the contents of
  473. .I filename
  474. are directly sent into the output without any modifications.
  475. This allows merging in pictures generated from other systems
  476. directly into TeX output.
  477. .PP
  478. The last form without a keyword is only included
  479. for backward-compatibility with older
  480. .I dvi
  481. programs and should not be used.
  482. It is the same as
  483. .IR rasterfile .
  484. .PP
  485. The rasterfiles should only have cursor-relative positioning
  486. commands since TeX should already have decided where
  487. to place the image.
  488. .I Dvi
  489. always restores the cursor position after every \\special command
  490. so that the TeX output should never screwed be up - much.
  491. .PP
  492. The environment var
  493. .B DVIINPUT
  494. or the
  495. .B \-i
  496. option
  497. may be used to provide a colon-separated directory
  498. search path for
  499. .IR filename .
  500. This is handy when a document with a picture has to be included
  501. within another document in a completely different directory.
  502. .PP
  503. Other commands may be supported in the future.
  504. .SH PLATFORM DEPENDENCIES
  505. The separator between the component parts
  506. in either the FONTPATH environment variable
  507. or the optional fontpath specification is platform dependent.
  508. Default separator for UNIX is the colon character,
  509. for MSDOS it is the semicolon character.
  510. .SH PRINTER DEPENDENCIES
  511. .TP
  512. .B HP2686 LaserJet+ ljet laser lj+
  513. HP LaserJet+ \-
  514. The old plain-vanilla HP LaserJet is NOT
  515. suported as it does not support downloadable fonts.
  516. The LJ+ Does support 8-bit fonts, and may support JTeX.
  517. .br
  518. Default options: page-reversal on, portrait
  519. .br
  520. Default FONTPATH for UNIX:
  521. /usr/lib/tex/fontbits/laser:/usr/lib/tex/fnt:/usr/local/tex/fontbits/laser
  522. .br
  523. Default FONTPATH for MSDOS:
  524. /usr/lib/tex/fontbits/laser;/usr/lib/tex/fnt;/usr/local/tex/fontbits/laser
  525. .TP
  526. .B HP33440 LaserJetII ljII lj2 laser2 laserII default
  527. HP LaserJetII \-
  528. This is the default printer if one is not specified on the command line.
  529. Just like a LaserJet+, except pages are not automatically reversed, and
  530. it can handle more fonts per page.
  531. Definitely supports both JTeX and 8-bit fonts.
  532. .br
  533. Default options: page-reversal off, portrait
  534. .br
  535. Default FONTPATH: <same as LJ+>
  536. .TP
  537. .B HP33447 LaserJetIID ljIId lj2d laser2D laserIID
  538. HP LaserJetIID \-
  539. Just like a LaserJetII except that it can also print double-sided.
  540. .br
  541. Default options: page-reversal off, portrait, double-sided vertical binding
  542. .br
  543. Default FONTPATH: <same as LJ+>
  544. .TP
  545. .B HP2684 JumboJet lj2000 laser2000 lj2k
  546. HP LaserJet 2000 \-
  547. A much bigger and much faster LaserJetIID with a lot more RAM.
  548. It can handle a lot more downloaded fonts and fonts per page too.
  549. .br
  550. Default options: page-reversal off, portrait, double-sided vertical binding
  551. .br
  552. Default FONTPATH: <same as LJ+>
  553. .SH FILES
  554. .nf
  555. /usr/lib/tex/fontbits/<printer>/<magdirs>/<PK fonts>
  556. /usr/lib/tex/fnt/<magdirs>/<GF fonts>
  557. /usr/local/tex/fontbits/<printer>/<magdirs>/<PK fonts>
  558. .fi
  559. .SH AUTHOR
  560. Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  561. SHAR_EOF
  562. chmod 0444 dvi.1 ||
  563. echo 'restore of dvi.1 failed'
  564. Wc_c="`wc -c < 'dvi.1'`"
  565. test 10332 -eq "$Wc_c" ||
  566.     echo 'dvi.1: original size 10332, current size' "$Wc_c"
  567. fi
  568. # ============= Makefile ==============
  569. if test -f 'Makefile' -a X"$1" != X"-c"; then
  570.     echo 'x - skipping Makefile (File already exists)'
  571. else
  572. echo 'x - extracting Makefile (Text)'
  573. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  574. # Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  575. # $Header: Makefile,v 1.22 91/05/09 14:25:22 hmgr Exp $
  576. X
  577. CXX = CC
  578. .SUFFIXES: .C
  579. .C.o:
  580. X    $(CXX) $(CFLAGS) -c $<
  581. X
  582. # other system-dependent options - use only one of the -D<sys> macros:
  583. #CFLAGS = -O -DBSD -DMSDOS
  584. CFLAGS = -g
  585. LIBS = -lm
  586. X
  587. SRCS = README dvi.1 Makefile main.C dev.C hp2686.C hp33440.C hp2684.C \
  588. X    util.C global.C stack.C dirs.C dvi.C font.C readfont.C gffont.C \
  589. X    pkfont.C bitvec.C hp2684.h hp33440.h hp2686.h defs.h extern.h \
  590. X    dirs.h font.h dev.h darray.h boolean.h bitvec.h \
  591. X    ljdump.c
  592. X
  593. OBJS = main.o dev.o hp2686.o hp33440.o hp2684.o util.o global.o stack.o \
  594. X    dirs.o dvi.o font.o readfont.o gffont.o pkfont.o bitvec.o
  595. X
  596. dvi : $(OBJS)
  597. X    $(CXX) $(CFLAGS) -o dvi $(OBJS) $(LIBS)
  598. X
  599. ljdump : ljdump.c
  600. X    $(CC) $(CFLAGS) -o ljdump ljdump.c
  601. X
  602. tar: $(SRCS)
  603. X    tar -cvf - $(SRCS) | compress >dvi.tar.Z 
  604. X
  605. shar: $(SRCS)
  606. X    shar -ac -ndvi -l50 -odvi-shar $(SRCS)
  607. X
  608. clean:
  609. X    rm -f dvi *.o ljdump dvi.tar.Z* dvi.shar
  610. X
  611. files:
  612. X    @echo $(SRCS)
  613. X
  614. msdos-files:
  615. X    ln bitvec.C bitvec.cpp
  616. X    ln dev.C dev.cpp
  617. X    ln dirs.C dirs.cpp
  618. X    ln dvi.C dvi.cpp
  619. X    ln font.C font.cpp
  620. X    ln gffont.C gffont.cpp
  621. X    ln global.C global.cpp
  622. X    ln hp2684.C hp2684.cpp
  623. X    ln hp2686.C hp2686.cpp
  624. X    ln hp33440.C hp33440.cpp
  625. X    ln main.C main.cpp
  626. X    ln pkfont.C pkfont.cpp
  627. X    ln readfont.C readfont.cpp
  628. X    ln stack.C stack.cpp
  629. X    ln util.C util.cpp
  630. X
  631. main.o : main.C defs.h extern.h dirs.h font.h dev.h darray.h boolean.h
  632. dev.o : dev.C defs.h extern.h dirs.h font.h dev.h darray.h boolean.h
  633. hp2686.o : hp2686.C hp2686.h defs.h extern.h dirs.h font.h dev.h \
  634. X        darray.h boolean.h
  635. hp33440.o : hp33440.C hp33440.h hp2686.h defs.h extern.h dirs.h font.h \
  636. X        dev.h darray.h boolean.h
  637. hp2684.o : hp2684.C hp2684.h hp33440.h hp2686.h defs.h extern.h dirs.h \
  638. X        font.h dev.h darray.h boolean.h
  639. util.o : util.C defs.h extern.h dirs.h font.h dev.h darray.h boolean.h
  640. global.o : global.C hp2684.h hp33440.h hp2686.h defs.h extern.h dirs.h \
  641. X        font.h dev.h darray.h boolean.h
  642. stack.o : stack.C defs.h extern.h dirs.h font.h dev.h darray.h boolean.h
  643. dirs.o : dirs.C dirs.h defs.h extern.h font.h dev.h darray.h boolean.h
  644. dvi.o : dvi.C defs.h extern.h dirs.h font.h dev.h darray.h boolean.h
  645. font.o : font.C defs.h extern.h dirs.h font.h dev.h bitvec.h \
  646. X        darray.h boolean.h
  647. readfont.o : readfont.C defs.h extern.h dirs.h font.h dev.h \
  648. X        darray.h boolean.h
  649. gffont.o : gffont.C defs.h extern.h dirs.h font.h dev.h bitvec.h \
  650. X        darray.h boolean.h
  651. pkfont.o : pkfont.C defs.h extern.h dirs.h font.h dev.h bitvec.h \
  652. X        darray.h boolean.h
  653. bitvec.o : bitvec.C bitvec.h boolean.h
  654. SHAR_EOF
  655. chmod 0444 Makefile ||
  656. echo 'restore of Makefile failed'
  657. Wc_c="`wc -c < 'Makefile'`"
  658. test 2546 -eq "$Wc_c" ||
  659.     echo 'Makefile: original size 2546, current size' "$Wc_c"
  660. fi
  661. # ============= main.C ==============
  662. if test -f 'main.C' -a X"$1" != X"-c"; then
  663.     echo 'x - skipping main.C (File already exists)'
  664. else
  665. echo 'x - extracting main.C (Text)'
  666. sed 's/^X//' << 'SHAR_EOF' > 'main.C' &&
  667. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  668. static const char rcsid[] = "$Header: main.C,v 1.31 91/04/02 17:50:33 hmgr Exp $";
  669. X
  670. // TeX DVI filter main() - just parses arguments and calls functions
  671. //
  672. // by Parag Patel
  673. X
  674. #include "defs.h"
  675. X
  676. static char *const whatid = "@(#) dvi 1.6 (02 April 1991)";
  677. X
  678. static void say_hello()
  679. {
  680. X    // hello message like (but unlike) TeX - the following mess should
  681. X    // strip out the revision number out of the build ID string "whatid"
  682. X    char *s = strchr(whatid, ' ');
  683. X    while (*s == ' ')
  684. X    s++;
  685. X    char *t = s;
  686. X    while (*t != ' ' && *t != '$' && *t != '\0')
  687. X    t++;
  688. X    *t = '\0';
  689. X    mesg("TeX DVI filter version %s for ", s);
  690. }
  691. X
  692. static long strtonum(char *s, char **ptr)
  693. {
  694. X    long ret = 0;
  695. X    int neg = 0;
  696. X
  697. X    while (isspace(*s))
  698. X    s++;
  699. X    if (*s == '-')
  700. X    {
  701. X    neg = 1;
  702. X    s++;
  703. X    }
  704. X    while (*s == '0')
  705. X    s++;
  706. X    while (isdigit(*s))
  707. X    ret = ret * 10 + *s++ - '0';
  708. X    if (ptr != NULL)
  709. X    *ptr = s;
  710. X    return neg ? -ret : ret;
  711. }
  712. X
  713. X
  714. extern char *optarg;
  715. extern int optind;
  716. X
  717. main(int argc, char *argv[])
  718. {
  719. X    int op;
  720. X    char *next, *str;
  721. X    Pagespec pages;
  722. #ifdef    __ZTC__
  723. X    // there must be a function for this somewhere!
  724. X    // we do not want <CR> prepended to an <NL> on a putchar('\n')
  725. X    stdout->_flag &= ~_IOTRAN;
  726. #endif
  727. X    while ((op = getopt(argc, argv, "vcd:i:rp:o:l2:m:=:")) != EOF)
  728. X    switch (op)
  729. X    {
  730. X    Case '=':         // debug mode - undocumented!!!
  731. X        debuglevel = atoi(optarg);
  732. X
  733. X    Case 'v':         // verbose mode
  734. X        verbose = TRUE;
  735. X
  736. X    Case 'c':         // no checksum checking
  737. X        dochecksum = FALSE;
  738. X
  739. X    Case 'l':         // landscape (sideways) mode
  740. X        landscape = TRUE;
  741. X
  742. X    Case 'r':         // do not reverse pages
  743. X        reverse = FALSE;
  744. X
  745. X    Case '2':         // double-sided output
  746. X        duparg = TRUE;
  747. X        if (*optarg == '-' || *optarg == '!')
  748. X        duplexh = duplexv = FALSE;
  749. X        else if (*optarg == 'h' || *optarg == 'H')
  750. X        duplexh = TRUE, duplexv = FALSE;
  751. X        else
  752. X        duplexh = FALSE, duplexv = TRUE;
  753. X
  754. X    Case 'o':         // get device type for output
  755. X        devname = optarg;
  756. X
  757. X    Case 'd':         // set font directory search path
  758. X        fontpath = optarg;
  759. X
  760. X    Case 'i':         // set special file search path
  761. X        dviinput = optarg;
  762. X
  763. X    Case 'm':        // user-specified magnification value
  764. X        if (strchr(optarg, '.') != NULL)
  765. X        usermag = (long)(atof(optarg) * 1000.0);
  766. X        else
  767. X        usermag = atol(optarg);
  768. X
  769. X    Case 'p':         // specific pages only
  770. X        // format: -p page[.num[-endpage[.endsect]]][,more]
  771. X        // the following code is really really ugly...
  772. X        for (str = optarg; str != NULL && *str != '\0'; str = next)
  773. X        {
  774. X        // setup for the next page spec in the list
  775. X        next = strchr(str, ',');
  776. X        if (next != NULL)
  777. X            *next++ = '\0';
  778. X
  779. X        // get the next entry
  780. X        char *ptr = str;// generic string pointer
  781. X        long p = 0;    // page to print
  782. X        long s = MAXLONG;    // section of page
  783. X
  784. X        // get the first number
  785. X        p = strtonum(ptr, &ptr);
  786. X
  787. X        // empty spec - ignore it
  788. X        if (ptr == str)
  789. X            continue;
  790. X
  791. X        // a '*' here doesn't mean anything so skip it
  792. X        if (*ptr == '*')
  793. X            ptr++;
  794. X
  795. X        // do we have a section spec?
  796. X        if (*ptr == '.')
  797. X        {
  798. X            s = strtonum(ptr + 1, &ptr);
  799. X            if (*ptr == '*')    // ignore '*'
  800. X            ptr++;
  801. X        }
  802. X
  803. X        long pe = p;    // ending page for range
  804. X        long se = s;    // ending section for range
  805. X
  806. X        // do we have a range?
  807. X        if (*ptr == '=')
  808. X        {
  809. X            // get ending page
  810. X            pe = strtonum(ptr + 1, &ptr);
  811. X            if (*ptr == '*')
  812. X            {
  813. X            // this means "to the end"
  814. X            pe = MAXLONG;
  815. X            ptr++;
  816. X            }
  817. X
  818. X            // ending section?
  819. X            if (*ptr == '.')
  820. X            {
  821. X            se = strtonum(ptr + 1, &ptr);
  822. X            if (*ptr == '*')    // to the end
  823. X                se = MAXLONG;
  824. X            }
  825. X        }
  826. X
  827. X        // setup this page specifier
  828. X        long pg = pages.size();
  829. X        pages[pg].page = p;
  830. X        pages[pg].section = s;
  831. X        pages[pg].endpage = pe;
  832. X        pages[pg].endsection = se;
  833. X        }
  834. X
  835. X    Default: 
  836. X        fprintf(stderr,
  837. X            "Usage:\t%s [-vrlc] [-d fontpath] [-i inputpath] [-2 -|v|h]\n\t[-o device] [-p page[.sect[=page2[.sect2]]][, ...]] [file]\n",
  838. X            argv[0]);
  839. X        exit(11);
  840. X    }
  841. X
  842. X    // initialize
  843. X    say_hello();
  844. X    init_globals();
  845. X    mesg(NULL);
  846. X
  847. X    // no arguments? assume stdin is set to a DVI file
  848. X    if (optind >= argc)
  849. X    {
  850. X    dodvi(stdin, pages);
  851. X    fini_globals();
  852. X    return 0;
  853. X    }
  854. X
  855. X    // else the first file argument
  856. X    // - ignore other args since this code is currently not re-entrant
  857. X    FILE *fp = fopen(argv[optind], F_READ);
  858. X    if (fp == NULL)
  859. X    {
  860. X    char *name = new char[strlen(argv[optind]) + 10];
  861. X    strcpy(name, argv[optind]);
  862. X    strcat(name, ".dvi");
  863. X    if ((fp = fopen(name, F_READ)) == NULL)
  864. X        quit("Cannot open %s for reading", argv[optind]);
  865. X    }
  866. X    dodvi(fp, pages);
  867. X    fclose(fp);
  868. X    fini_globals();
  869. X    return 0;
  870. }
  871. SHAR_EOF
  872. chmod 0444 main.C ||
  873. echo 'restore of main.C failed'
  874. Wc_c="`wc -c < 'main.C'`"
  875. test 4621 -eq "$Wc_c" ||
  876.     echo 'main.C: original size 4621, current size' "$Wc_c"
  877. fi
  878. # ============= dev.C ==============
  879. if test -f 'dev.C' -a X"$1" != X"-c"; then
  880.     echo 'x - skipping dev.C (File already exists)'
  881. else
  882. echo 'x - extracting dev.C (Text)'
  883. sed 's/^X//' << 'SHAR_EOF' > 'dev.C' &&
  884. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  885. X
  886. // Base-class device stuff.
  887. //
  888. // by Parag Patel
  889. X
  890. #include "defs.h"
  891. X
  892. X
  893. Device::Device(int maxf, int maxc, int maxpg, int maxld, int res,
  894. X        int ho, int vo, int fhmn, int fhmx, int fvmn, int fvmx,
  895. X        int fwd, int fhg, char *deffp) :
  896. X    maxfonts(maxf), maxchars(maxc), maxonpage(maxpg), maxloaded(maxld),
  897. X    resolution(res), hoff(ho), voff(vo),
  898. X    fhmin(fhmn), fhmax(fhmx), fvmin(fvmn), fvmax(fvmx),
  899. X    fwidth(fwd), fheight(fhg), deffontpath(deffp)
  900. {
  901. }
  902. X
  903. Device::~Device()
  904. {
  905. }
  906. X
  907. /*****
  908. void Device::color(long red, long green, long blue)
  909. {
  910. X    // for future support for devices like PaintJets, etc.
  911. }
  912. *****/
  913. SHAR_EOF
  914. chmod 0444 dev.C ||
  915. echo 'restore of dev.C failed'
  916. Wc_c="`wc -c < 'dev.C'`"
  917. test 654 -eq "$Wc_c" ||
  918.     echo 'dev.C: original size 654, current size' "$Wc_c"
  919. fi
  920. # ============= hp2686.C ==============
  921. if test -f 'hp2686.C' -a X"$1" != X"-c"; then
  922.     echo 'x - skipping hp2686.C (File already exists)'
  923. else
  924. echo 'x - extracting hp2686.C (Text)'
  925. sed 's/^X//' << 'SHAR_EOF' > 'hp2686.C' &&
  926. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  927. static const char rcsid[] = "$Header: hp2686.C,v 1.20 91/02/22 15:55:21 hmgr Exp $";
  928. X
  929. // HP2686 LaserJet+ and LaserJetII device-specific functions.
  930. // The various Reference Manuals should be consulted for more
  931. // information on the various escape-sequences.
  932. //
  933. // by Parag Patel
  934. X
  935. #include "defs.h"
  936. #include "hp2686.h"
  937. X
  938. X
  939. static int hoffset = HP2686_HOFFSET;
  940. static int voffset = HP2686_VOFFSET;
  941. X
  942. X
  943. // put a 16-bit word on the output as two bytes
  944. // 
  945. inline void put16(long n)
  946. {
  947. X    putchar((char)((n >> 8) & 0xFF));
  948. X    putchar((char)(n & 0xFF));
  949. }
  950. X
  951. static void initlj()
  952. {
  953. X    if (landscape)
  954. X    {
  955. X    fputs("\033&l1O", stdout);
  956. X    hoffset -= 60;
  957. X    voffset -= 10;
  958. X    }
  959. X    else
  960. X    fputs("\033&l0O", stdout);
  961. X    fputs("\033&l0E", stdout);
  962. }
  963. X
  964. HP2686::HP2686(int maxf, int maxc, int maxpg, int maxld, int res,
  965. X        int ho, int vo, int fhmn, int fhmx, int fvmn, int fvmx,
  966. X        int fwd, int fhg, char *deffp) :
  967. X    Device(maxf, maxc, maxpg, maxld, res, ho, vo,
  968. X        fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp)
  969. {
  970. X    initlj();
  971. }
  972. X
  973. // initialize the LaserJet
  974. // 
  975. HP2686::HP2686() :
  976. X    Device(257, 256, 16, 32, 300, hoffset, voffset,
  977. X        -128, 127, -128, 127, 128, 128, HP2686_FPATH)
  978. {
  979. X    initlj();
  980. }
  981. X
  982. // clean up after dumping a DVI file
  983. // 
  984. HP2686::~HP2686()
  985. {
  986. X    fputs("\033&l0O", stdout);
  987. }
  988. X
  989. // convert a character number to something that the device can deal with
  990. // for a LaserJet
  991. //
  992. const char *HP2686::char2dev(int ch, int &len)
  993. {
  994. X    static char buf[20];
  995. X    if ((ch >= 32 && ch <= 127) || ch >= 160)
  996. X    sprintf(buf, "%c", ch);
  997. X    else
  998. X    sprintf(buf, "\033&p1X%c", ch);
  999. X    len = strlen(buf);
  1000. X    if (ch == 0)
  1001. X    len++;
  1002. X    return buf;
  1003. }
  1004. X
  1005. // convert a scaled point to a device pixel coordinate
  1006. //
  1007. long HP2686::sp2dev(double sp)
  1008. {
  1009. X    return long(sp / 72.27 * 300.0 / double(1 << 16L) + 0.5);
  1010. }
  1011. X
  1012. // convert a device pixel coordinate to a scaled point
  1013. //
  1014. double HP2686::dev2sp(long pix)
  1015. {
  1016. X    return double(pix) / 300.0 * 72.27 * double(1 << 16L);
  1017. }
  1018. X
  1019. X
  1020. // download a big character to the LaserJet in graphics mode
  1021. // 
  1022. void HP2686::bigchar(font &, fontchar &g, int)
  1023. {
  1024. X    long width = g.maxm - g.minm + 1;
  1025. X    long height = g.maxn - g.minn + 1;
  1026. X    int res = 1;        // 1==300dpi 2==150dpi
  1027. X
  1028. X    makecurrent();
  1029. X    push();            // save current location
  1030. X
  1031. X    // move (relative) up - printf() may not handle the sign properly
  1032. X    // with the "%+ld" specification, so we do it ourselves
  1033. X    long rel = -g.maxn;
  1034. X    if (rel < 0)
  1035. X    printf("\033*p%ldY", rel);
  1036. X    else
  1037. X    printf("\033*p+%ldY", rel);
  1038. X
  1039. X    // move (relative) right
  1040. X    rel = landscape ? g.maxm : g.minm;
  1041. X    if (rel < 0)
  1042. X    printf("\033*p%ldX", rel);
  1043. X    else
  1044. X    printf("\033*p+%ldX", rel);
  1045. X
  1046. X    if (width > 300 || height > 300)
  1047. X    {
  1048. X    // use 150 dots per inch for REALLY big characters
  1049. X    res = 2;
  1050. X    fputs("\033*t150R", stdout);
  1051. X    }
  1052. X    else
  1053. X    fputs("\033*t300R", stdout);
  1054. X    fputs("\033*r1A", stdout);    // start graphics mode
  1055. X
  1056. X    if (landscape)
  1057. X    for (register long j = g.maxm - g.minm; j >= 0; j -= res)
  1058. X    {
  1059. X        int b = 0;
  1060. X        int bp = 0x80;
  1061. X        register long count = (height + 7) >> (2 + res);
  1062. X
  1063. X        printf("\033*b%ldW", count);
  1064. X
  1065. X        for (register long i = g.maxn - g.minn; i >= 0; i -= res)
  1066. X        {
  1067. X        if (bp == 0)
  1068. X        {
  1069. X            putchar(b);
  1070. X            bp = 0x80;
  1071. X            b = 0;
  1072. X            count--;
  1073. X        }
  1074. X        if (res == 1)    // 300 dpi
  1075. X        {
  1076. X            if (fontbits[i]->isin(j))
  1077. X            b |= bp;
  1078. X        }
  1079. X        else        // 150 dpi
  1080. X        {
  1081. X            // use the "or" of the 4 pixels at this location
  1082. X            if (fontbits[i]->isin(j)
  1083. X                || fontbits[i - 1]->isin(j)
  1084. X                || fontbits[i]->isin(j + 1)
  1085. X                || fontbits[i - 1]->isin(j + 1))
  1086. X            b |= bp;
  1087. X        }
  1088. X        bp >>= 1;
  1089. X        }
  1090. X
  1091. X        putchar(b);
  1092. X        if (count != 1 && count != 0)
  1093. X        quit("Code for downloading bigchars is hosed: count=%ld",
  1094. X            count);
  1095. X    }
  1096. X    else
  1097. X    // we use "res" as an incrementer for 150 or 300 dpi
  1098. X    for (register long i = g.maxn - g.minn; i >= 0; i -= res)
  1099. X    {
  1100. X        int b = 0;
  1101. X        int bp = 0x80;
  1102. X        register long count = (width + 7) >> (2 + res);
  1103. X
  1104. X        printf("\033*b%ldW", count);
  1105. X
  1106. X        for (register long j = 0; j <= g.maxm - g.minm; j += res)
  1107. X        {
  1108. X        if (bp == 0)
  1109. X        {
  1110. X            putchar(b);
  1111. X            bp = 0x80;
  1112. X            b = 0;
  1113. X            count--;
  1114. X        }
  1115. X        if (res == 1)// 300 dpi
  1116. X        {
  1117. X            if (fontbits[i]->isin(j))
  1118. X            b |= bp;
  1119. X        }
  1120. X        else        // 150 dpi
  1121. X        {
  1122. X            // use the "or" of the 4 pixels at this location
  1123. X            if (fontbits[i]->isin(j)
  1124. X                || fontbits[i - 1]->isin(j)
  1125. X                || fontbits[i]->isin(j + 1)
  1126. X                || fontbits[i - 1]->isin(j + 1))
  1127. X            b |= bp;
  1128. X        }
  1129. X        bp >>= 1;
  1130. X        }
  1131. X
  1132. X        putchar(b);
  1133. X        if (count != 1 && count != 0)
  1134. X        quit("Code for downloading bigchars is hosed: count=%ld",
  1135. X            count);
  1136. X    }
  1137. X
  1138. X    fputs("\033*rB", stdout);    // end graphics mode
  1139. X    pop();            // restore saved location
  1140. }
  1141. X
  1142. X
  1143. // download a character for a particular font
  1144. // 
  1145. void HP2686::downchar(font &f, fontchar &g, int ch)
  1146. {
  1147. X    // describe the character and its font to the LaserJet
  1148. X    printf("\033*c%ldd%dE", f.num, ch);
  1149. X    downljchar(f, g, ch);
  1150. }
  1151. X
  1152. // this sets up this character in the LaserJet memory so that
  1153. // it can be typeset later
  1154. // - assumes that the font has already been downloaded to the printer
  1155. // 
  1156. void HP2686::downljchar(font &, fontchar &g, int)
  1157. {
  1158. X    long width = g.maxm - g.minm + 1;
  1159. X    long height = g.maxn - g.minn + 1;
  1160. X
  1161. X    // number of bytes for a bit-map of the character
  1162. X    long count;
  1163. X    if (landscape)
  1164. X    {
  1165. X    count = width * ((height + 7) >> 3);
  1166. X    if (count < 1)
  1167. X        count = 1;
  1168. X    }
  1169. X    else
  1170. X    count = height * ((width + 7) >> 3);
  1171. X
  1172. X    printf("\033(s%ldW", count + 16);
  1173. X    putchar(4);            // these 4 bytes are magic -
  1174. X    putchar(0);            // they must be here for some
  1175. X    putchar(14);        // unknown reason...
  1176. X    putchar(1);
  1177. X
  1178. X    if (landscape)
  1179. X    {
  1180. X    putchar(1);        // landscape mode
  1181. X    putchar(0);        // <magic>
  1182. X    put16(-g.maxn);        // # pixels above the baseline
  1183. X    put16(g.maxm);        // # pixels to the right of origin
  1184. X    put16(height);        // width of char in pixels
  1185. X    put16(width);        // height in pixels
  1186. X    }
  1187. X    else
  1188. X    {
  1189. X    put16(0);        // portrait mode | magic
  1190. X    put16(g.minm);        // # pixels to the left of origin
  1191. X    put16(g.maxn);        // # pixels above the baseline
  1192. X    put16(width);        // width of char in pixels
  1193. X    put16(height);        // height in pixels
  1194. X    }
  1195. X    put16(g.dx >> 14);        // delta-x in pixels * 4
  1196. X
  1197. X    // download the bitmap for this character one byte at a time - we
  1198. X    // also decrement the "count" var to make sure that we send down
  1199. X    // exactly the correct number of bytes to the LaserJet
  1200. X    // (OK OK - there are more effecient ways to do this, but this works
  1201. X    // and is simple to code.  It'll do for now.)
  1202. X
  1203. X    register long n;
  1204. X    register long m;
  1205. X    if (landscape)
  1206. X    for (m = g.maxm - g.minm; m >= 0; m--)
  1207. X    {
  1208. X        // we will build the byte "b" to download - "bp" is the bit
  1209. X        // pointer used to set the next bit in the current byte - it
  1210. X        // is shifted by one each time around the inner loop
  1211. X        int b = 0;
  1212. X        int bp = 0x80;
  1213. X
  1214. X        for (n = g.maxn - g.minn; n >= 0; n--)
  1215. X        {
  1216. X        if (bp == 0)
  1217. X        {
  1218. X            // we have put the last bit that this byte can hold
  1219. X            // into "b" - download it, then reset the bit pointer
  1220. X            putchar(b);
  1221. X            bp = 0x80;
  1222. X            b = 0;
  1223. X            count--;
  1224. X        }
  1225. X
  1226. X        // set this bit in the byte if the current bit is set in
  1227. X        // the bitmap - then shift bp to point to the next bit
  1228. X        if (fontbits[n]->isin(m))
  1229. X            b |= bp;
  1230. X        bp >>= 1;
  1231. X        }
  1232. X
  1233. X        // put the remaining byte out - note that the last byte will
  1234. X        // always be downloaded here and not in the previous loop
  1235. X        putchar(b);
  1236. X        count--;
  1237. X    }
  1238. X    else
  1239. X    for (n = g.maxn - g.minn; n >= 0; n--)
  1240. X    {
  1241. X        // we will build the byte "b" to download - "bp" is the bit
  1242. X        // pointer used to set the next bit in the current byte - it
  1243. X        // is shifted by one each time around the inner loop
  1244. X        int b = 0;
  1245. X        int bp = 0x80;
  1246. X
  1247. X        for (m = 0; m <= g.maxm - g.minm; m++)
  1248. X        {
  1249. X        if (bp == 0)
  1250. X        {
  1251. X            // we have put the last bit that this byte can hold
  1252. X            // into "b" - download it, then reset the bit pointer
  1253. X            putchar(b);
  1254. X            bp = 0x80;
  1255. X            b = 0;
  1256. X            count--;
  1257. X        }
  1258. X
  1259. X        // set this bit in the byte if the current bit is set in
  1260. X        // the bitmap - then shift bp to point to the next bit
  1261. X        if (fontbits[n]->isin(m))
  1262. X            b |= bp;
  1263. X        bp >>= 1;
  1264. X        }
  1265. X
  1266. X        // put the remaining byte out - note that the last byte will
  1267. X        // always be downloaded here and not in the previous loop
  1268. X        putchar(b);
  1269. X        count--;
  1270. X    }
  1271. X
  1272. X    // see if we have a bug in the above code
  1273. X    if (count != 0)
  1274. X    quit("Code for downloading chars is hosed: count=%ld", count);
  1275. }
  1276. X
  1277. X
  1278. // flush out (print) the current page in the LaserJet - get ready to
  1279. // print a new page
  1280. // 
  1281. void HP2686::newpage(boolean odd, boolean first)
  1282. {
  1283. X    if (first)
  1284. X    return;
  1285. X    odd = FALSE;
  1286. X    putchar('\f');
  1287. }
  1288. X
  1289. X
  1290. // move the LaserJet cursor to the specified (h,v) spot on the paper
  1291. // - add the appropriate "fuhj" offsets to the coordinates
  1292. // 
  1293. void HP2686::movehv(long h, long v)
  1294. {
  1295. X    printf("\033*p%ldx%ldY", h + hoffset, v + voffset);
  1296. }
  1297. X
  1298. X
  1299. // just move along the horizontal to the specified pixel
  1300. // 
  1301. void HP2686::moveh(long h)
  1302. {
  1303. X    printf("\033*p%ldX", h + hoffset);
  1304. }
  1305. X
  1306. X
  1307. // vertical move
  1308. // 
  1309. void HP2686::movev(long v)
  1310. {
  1311. X    printf("\033*p%ldY", v + voffset);
  1312. }
  1313. X
  1314. X
  1315. // push the current spot - fortunately the LaserJet already does this
  1316. // or we would save the current location in our own stack
  1317. // 
  1318. void HP2686::push()
  1319. {
  1320. X    fputs("\033&f0S", stdout);
  1321. }
  1322. X
  1323. X
  1324. // pop the current location and restore the last one
  1325. // 
  1326. void HP2686::pop()
  1327. {
  1328. X    fputs("\033&f1S", stdout);
  1329. }
  1330. X
  1331. X
  1332. // delete the specified font from the LaserJet's memory
  1333. // 
  1334. void HP2686::delfont(font &f)
  1335. {
  1336. X    printf("\033*c%ldd2F", f.num);
  1337. }
  1338. X
  1339. X
  1340. // download this font to the LaserJet's memory - this just defines
  1341. // the font but doesn't actually download any characters into it yet
  1342. // 
  1343. void HP2686::newfont(font &f)
  1344. {
  1345. X    long width = f.maxm - f.minm + 1;
  1346. X    if (width < 1)
  1347. X    width = 1;
  1348. X    long height = f.maxn - f.minn + 1;
  1349. X    if (height < 1)
  1350. X    height = 1;
  1351. X
  1352. X    printf("\033*c%ldD\033)s26W", f.num);    // font number
  1353. X    put16(26);            // length of the this+rest in bytes
  1354. X    put16(1);            // 0 <magic>  |  font-type
  1355. X    put16(0);            // <magic>
  1356. X    put16(f.maxn);        // baseline position
  1357. X    put16(width);        // cell width
  1358. X    put16(height);        // cell height
  1359. X    putchar(landscape ? 1 : 0);    // orientation
  1360. X    putchar(1);            //         fixed/proportional
  1361. X    putchar(1);            // symbol set
  1362. X    putchar(21);        //         symbol set II
  1363. X    put16(width << 2);        // pitch (default HMI)
  1364. X    put16(height << 2);        // height
  1365. X    put16(0);            // 0 <magic>
  1366. X    put16(0);            // 0 <magic> | style
  1367. X    put16(0);            // stroke width | typeface
  1368. }
  1369. X
  1370. X
  1371. // make this font the current font in the LaserJet - we are about to
  1372. // typeset (print) some characters from it
  1373. // 
  1374. void HP2686::usefont(font &f)
  1375. {
  1376. X    printf("\033(%ldX", f.num);
  1377. }
  1378. X
  1379. X
  1380. // typeset (print) a rule (box) of the specified length and width at
  1381. // the current cursor location
  1382. // 
  1383. void HP2686::rule(double A, double B)
  1384. {
  1385. X    long aa = sp2dev(A);
  1386. X    long bb = sp2dev(B);
  1387. X
  1388. X    debug(5, "rule: a=%f b=%f  H=%f V=%f  aa=%ld bb=%ld", A, B, H, V, aa, bb);
  1389. X
  1390. X    // now typeset the rule - again the LaserJet makes this easy with
  1391. X    // the fill area command - unfortunately the origin must be at the
  1392. X    // top-left corner and not the bottom-left like a normal character
  1393. X    movedown(-A);
  1394. X    makecurrent();
  1395. X    printf("\033*c%lda%ldb0P", bb <= 0 ? 1 : bb, aa <= 0 ? 1 : aa);
  1396. X    movedown(A);
  1397. }
  1398. SHAR_EOF
  1399. chmod 0444 hp2686.C ||
  1400. echo 'restore of hp2686.C failed'
  1401. Wc_c="`wc -c < 'hp2686.C'`"
  1402. test 11294 -eq "$Wc_c" ||
  1403.     echo 'hp2686.C: original size 11294, current size' "$Wc_c"
  1404. fi
  1405. # ============= hp33440.C ==============
  1406. if test -f 'hp33440.C' -a X"$1" != X"-c"; then
  1407.     echo 'x - skipping hp33440.C (File already exists)'
  1408. else
  1409. echo 'x - extracting hp33440.C (Text)'
  1410. sed 's/^X//' << 'SHAR_EOF' > 'hp33440.C' &&
  1411. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  1412. // $Header: hp33440.C,v 1.13 91/02/22 15:56:21 hmgr Exp $
  1413. X
  1414. // LaserJetII series device-specific functions.
  1415. // The LaserJetII Reference Manual should be consulted for more
  1416. // information on various the escape-sequences.
  1417. //
  1418. // by Parag Patel
  1419. X
  1420. #include "defs.h"
  1421. #include "hp2686.h"
  1422. #include "hp33440.h"
  1423. X
  1424. X
  1425. // LaserJetII:
  1426. X
  1427. // initialize the LaserJet II
  1428. HP33440::HP33440() :
  1429. X    HP2686(257, 256, 32, 32, 300, HP2686_HOFFSET, HP2686_VOFFSET,
  1430. X            -128, 127, -128, 127, 128, 128, HP2686_FPATH)
  1431. {
  1432. }
  1433. X
  1434. // LaserJetIID:
  1435. X
  1436. // initialize the LaserJet IID using explicit args - handle 2-sided
  1437. //
  1438. HP33447::HP33447(int maxf, int maxc, int maxpg, int maxld, int res,
  1439. X        int ho, int vo, int fhmn, int fhmx, int fvmn,
  1440. X        int fvmx, int fwd, int fhg, char *deffp) :
  1441. X    HP33440(maxf, maxc, maxpg, maxld, res, ho, vo,
  1442. X    fhmn, fhmx, fvmn, fvmx, fwd, fhg, deffp)
  1443. {
  1444. X    if (duplexv)
  1445. X    fputs("\033&l1S", stdout);
  1446. X    else if (duplexh)
  1447. X    fputs("\033&l2S", stdout);
  1448. }
  1449. X
  1450. // initialize the LaserJet IID - use defaults for LJII & handled 2-sided
  1451. //
  1452. HP33447::HP33447() : HP33440()
  1453. {
  1454. X    if (duplexv)
  1455. X    fputs("\033&l1S", stdout);
  1456. X    else if (duplexh)
  1457. X    fputs("\033&l2S", stdout);
  1458. }
  1459. X
  1460. // back to normal mode - switch off 2-sided
  1461. //
  1462. HP33447::~HP33447()
  1463. {
  1464. X    if (duplexv || duplexh)
  1465. X    fputs("\033&l0S", stdout);
  1466. }
  1467. X
  1468. // flush out (print) the current page in the LJIID - get ready to
  1469. // print a new page
  1470. // 
  1471. void HP33447::newpage(boolean odd, boolean first)
  1472. {
  1473. X    // print even pages on "front" for reverse output, else odd
  1474. X    debug(2, "newpage: odd=%d reverse=%d odd^reverse=%d first=%d",
  1475. X        odd, reverse, odd ^ reverse, first);
  1476. X    if (duplexv || duplexh)
  1477. X    {
  1478. X    if (odd ^ reverse)
  1479. X        fputs("\033&a1G", stdout);
  1480. X    else
  1481. X        fputs("\033&a2G", stdout);
  1482. X    }
  1483. X    else if (!first)
  1484. X    putchar('\f');
  1485. }
  1486. SHAR_EOF
  1487. chmod 0444 hp33440.C ||
  1488. echo 'restore of hp33440.C failed'
  1489. Wc_c="`wc -c < 'hp33440.C'`"
  1490. test 1807 -eq "$Wc_c" ||
  1491.     echo 'hp33440.C: original size 1807, current size' "$Wc_c"
  1492. fi
  1493. # ============= hp2684.C ==============
  1494. if test -f 'hp2684.C' -a X"$1" != X"-c"; then
  1495.     echo 'x - skipping hp2684.C (File already exists)'
  1496. else
  1497. echo 'x - extracting hp2684.C (Text)'
  1498. sed 's/^X//' << 'SHAR_EOF' > 'hp2684.C' &&
  1499. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  1500. // $Header: hp2684.C,v 1.11 91/02/22 15:56:31 hmgr Exp $
  1501. X
  1502. // HP2684 LaserJet 2000 device-specific functions.
  1503. // The LaserJet 2000 Reference Manual should be consulted for more
  1504. // information on various the escape-sequences.
  1505. //
  1506. // by Parag Patel
  1507. X
  1508. #include "defs.h"
  1509. #include "hp2686.h"
  1510. #include "hp33440.h"
  1511. #include "hp2684.h"
  1512. X
  1513. X
  1514. // similar to the LJIID but we can download more and larger fonts
  1515. //
  1516. HP2684::HP2684() :
  1517. X    HP33447(257, 256, 64, 64, 300, HP2686_HOFFSET, HP2686_VOFFSET,
  1518. X        -16384, 16384, -16384, 16384, 16384, 16384, HP2686_FPATH)
  1519. {
  1520. }
  1521. SHAR_EOF
  1522. chmod 0444 hp2684.C ||
  1523. echo 'restore of hp2684.C failed'
  1524. Wc_c="`wc -c < 'hp2684.C'`"
  1525. test 606 -eq "$Wc_c" ||
  1526.     echo 'hp2684.C: original size 606, current size' "$Wc_c"
  1527. fi
  1528. # ============= util.C ==============
  1529. if test -f 'util.C' -a X"$1" != X"-c"; then
  1530.     echo 'x - skipping util.C (File already exists)'
  1531. else
  1532. echo 'x - extracting util.C (Text)'
  1533. sed 's/^X//' << 'SHAR_EOF' > 'util.C' &&
  1534. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  1535. static const char rcsid[] = "$Header: util.C,v 1.14 91/02/22 15:56:43 hmgr Exp $";
  1536. X
  1537. // various utility functions
  1538. //
  1539. // by Parag Patel
  1540. X
  1541. #include "defs.h"
  1542. #include <stdarg.h>
  1543. X
  1544. X
  1545. // get an unsigned value that is "num" bytes long from the file
  1546. // - the "switch" speeds up the 1|2|3|4 byte reads
  1547. //
  1548. long getuval(int num, FILE *fp)
  1549. {
  1550. X    register long val = 0;
  1551. X    register unsigned long b;
  1552. X
  1553. X    b = getc(fp);
  1554. X    switch (num)
  1555. X    {
  1556. X    case 4:
  1557. X    val = b << 24;
  1558. X    b = getc(fp);
  1559. X    case 3:
  1560. X    val |= b << 16;
  1561. X    b = getc(fp);
  1562. X    case 2:
  1563. X    val |= b << 8;
  1564. X    b = getc(fp);
  1565. X    case 1:
  1566. X    val |= b;
  1567. X    break;
  1568. X
  1569. X    default:
  1570. X    quit("dvi bug: getuval called with count of %d\n", num);
  1571. X    }
  1572. X    return val;
  1573. }
  1574. X
  1575. X
  1576. // get a signed twos-complement value of "num" bytes from file
  1577. //
  1578. long getsval(int num, FILE *fp)
  1579. {
  1580. X    register long val;
  1581. X    register unsigned long b;
  1582. X    register char c;
  1583. X
  1584. X    // this sets "val" to the right sign
  1585. X    c = getc(fp);
  1586. X
  1587. X    // this shifts the 8-bit value to the right part of the word so
  1588. X    // that we can do the fall-through "case" statement
  1589. X
  1590. X    val = (long)c << ((num - 1) << 3);
  1591. X    switch (num)
  1592. X    {
  1593. X    case 4:
  1594. X    b = getc(fp);
  1595. X    val |= b << 16;
  1596. X    case 3:
  1597. X    b = getc(fp);
  1598. X    val |= b << 8;
  1599. X    case 2:
  1600. X    b = getc(fp);
  1601. X    val |= b;
  1602. X    case 1:
  1603. X    break;
  1604. X
  1605. X    default:
  1606. X    quit("dvi bug: getsval called with count of %d\n", num);
  1607. X    }
  1608. X    return val;
  1609. }
  1610. X
  1611. X
  1612. // ignore next n bytes in file
  1613. //
  1614. void skipbytes(long num, FILE *fp)
  1615. {
  1616. X    while (num-- > 0)
  1617. X    (void)getc(fp);
  1618. }
  1619. X
  1620. X
  1621. X
  1622. // for debugging output only
  1623. // 
  1624. void debug(int level, char *fmt, ...)
  1625. {
  1626. X    if (level > debuglevel)
  1627. X    return;
  1628. X
  1629. X    va_list ap;
  1630. X
  1631. X    va_start(ap, fmt);
  1632. X    vfprintf(stderr, fmt, ap);
  1633. X    fprintf(stderr, "\n");
  1634. X    va_end(ap);
  1635. }
  1636. X
  1637. X
  1638. // print informative messages only if verbose mode is on
  1639. // - break lines to fit on screen
  1640. // 
  1641. void mesg(char *fmt, ...)
  1642. {
  1643. X    if (!verbose)
  1644. X    return;
  1645. X
  1646. X    static col = 0;
  1647. X
  1648. X    // just print a newline on a null format string
  1649. X    // - this is to end a sequence of messages with a nice newline
  1650. X    if (fmt == NULL || *fmt == '\0')
  1651. X    {
  1652. X    if (col != 0)
  1653. X        fprintf(stderr, "\n");
  1654. X    col = 0;
  1655. X    return;
  1656. X    }
  1657. X
  1658. X    va_list ap;
  1659. X    char buf[256];
  1660. X    char *s = buf;
  1661. X
  1662. X    va_start(ap, fmt);
  1663. X    vsprintf(s, fmt, ap);
  1664. X    va_end(ap);
  1665. X
  1666. X    int len = strlen(s);
  1667. X
  1668. X    if (col + len > 72)
  1669. X    {
  1670. X    fprintf(stderr, "\n");
  1671. X    col = 0;
  1672. X    }
  1673. X    if (col == 0)
  1674. X    while (*s == ' ')
  1675. X        s++, len--;
  1676. X    col += len;
  1677. X
  1678. X    fputs(s, stderr);
  1679. X    fflush(stderr);
  1680. }
  1681. X
  1682. // print a warning only if we are in verbose mode
  1683. // - otherwise be silent
  1684. //
  1685. void warn(char *fmt, ...)
  1686. {
  1687. X    if (!verbose)
  1688. X    return;
  1689. X
  1690. X    va_list ap;
  1691. X
  1692. X    mesg(NULL);
  1693. X    va_start(ap, fmt);
  1694. X    fprintf(stderr, "WARNING: ");
  1695. X    vfprintf(stderr, fmt, ap);
  1696. X    fprintf(stderr, ".\n");
  1697. X    va_end(ap);
  1698. }
  1699. X
  1700. // print an error message
  1701. //
  1702. void error(char *fmt, ...)
  1703. {
  1704. X    va_list ap;
  1705. X
  1706. X    mesg(NULL);
  1707. X    va_start(ap, fmt);
  1708. X    vfprintf(stderr, fmt, ap);
  1709. X    fprintf(stderr, ".\n");
  1710. X    va_end(ap);
  1711. }
  1712. X
  1713. // print error message, then exit
  1714. // 
  1715. void quit(char *fmt, ...)
  1716. {
  1717. X    va_list ap;
  1718. X
  1719. X    mesg(NULL);
  1720. X    va_start(ap, fmt);
  1721. X    vfprintf(stderr, fmt, ap);
  1722. X    fprintf(stderr, "!\n");
  1723. X    va_end(ap);
  1724. X    exit(1);
  1725. }
  1726. X
  1727. X
  1728. FILE *
  1729. fopenp(char *path, char *file, char *type)
  1730. {
  1731. X    // if we have a null path, just do a normal fopen()
  1732. X    if (path == NULL || *path == '\0')
  1733. X    return fopen(file, type);
  1734. X
  1735. X    // just try the file straight if it is an absolute path
  1736. X    if (*file == '/')
  1737. X    {
  1738. X    FILE *ret = fopen(file, type);
  1739. X    if (ret != NULL)
  1740. X        return ret;
  1741. X    }
  1742. X
  1743. X    // we look through the path for a directory, append the filename to
  1744. X    // that directory, and then try to open the file - we are finished
  1745. X    // when we are out of directories to try (return NULL) or we found a
  1746. X    // file (return that file)
  1747. X
  1748. X    char *p = path;
  1749. X    while (p != NULL && *p != '\0') // do until end of "path"
  1750. X    {
  1751. X    // copy the directory name pointed to by "p" into "buf"
  1752. X    char buf[MAXPATHLEN];
  1753. X    char *s = buf;
  1754. X    while (*p != PATHSEP && *p != '\0')
  1755. X        *s++ = *p++;
  1756. X
  1757. X    // bump "p" to the start of the next directory
  1758. X    if (*p != '\0')
  1759. X        p++;
  1760. X
  1761. X    // append a '/' to "buf" if necessary & then null-terminate it
  1762. X    if (s != buf && *(s - 1) != '/')
  1763. X        *s++ = '/';
  1764. X    *s = '\0';
  1765. X
  1766. X    // append the filename to the directory name
  1767. X    strcat(s == buf ? s : s - 1, file);
  1768. X
  1769. X    // try to open the file - return it if the fopen succeeded
  1770. X    FILE *ret = fopen(buf, type);
  1771. X    if (ret != NULL)
  1772. X        return ret;
  1773. X    }
  1774. X
  1775. X    return NULL;        // we struck out
  1776. }
  1777. SHAR_EOF
  1778. chmod 0444 util.C ||
  1779. echo 'restore of util.C failed'
  1780. Wc_c="`wc -c < 'util.C'`"
  1781. test 4481 -eq "$Wc_c" ||
  1782.     echo 'util.C: original size 4481, current size' "$Wc_c"
  1783. fi
  1784. # ============= global.C ==============
  1785. if test -f 'global.C' -a X"$1" != X"-c"; then
  1786.     echo 'x - skipping global.C (File already exists)'
  1787. else
  1788. echo 'x - extracting global.C (Text)'
  1789. sed 's/^X//' << 'SHAR_EOF' > 'global.C' &&
  1790. // Copyright (c) 1991 by Parag Patel.  All Rights Reserved.
  1791. static const char rcsid[] = "$Header: global.C,v 1.24 91/02/22 15:56:57 hmgr Exp $";
  1792. X
  1793. // Global variables for DVI filter.
  1794. // All globally visible variables are here.
  1795. //
  1796. // by Parag Patel
  1797. X
  1798. #include "defs.h"
  1799. #include "hp2686.h"
  1800. #include "hp33440.h"
  1801. #include "hp2684.h"
  1802. X
  1803. X
  1804. // implement macros for the declare in "extern.h"
  1805. implement_array(Fontlist, fontptr);
  1806. implement_array(Pageinfo, pageinfo);
  1807. implement_array(Pagespec, pagespec);
  1808. X
  1809. X
  1810. // command-line argument values:
  1811. char *fontpath = NULL;            // default font library path
  1812. char *dviinput = NULL;            // default special file search path
  1813. int debuglevel = 0;            // this is only for debugging
  1814. boolean verbose = FALSE;        // this is just for the hell of it
  1815. boolean dochecksum = TRUE;        // actually check the checksums?
  1816. char *devname = NULL;            // default device
  1817. boolean reverse = TRUE;            // reverse pages?
  1818. boolean landscape = FALSE;        // landscape mode
  1819. boolean duplexh = FALSE;        // double-sided printing (duplex) mode
  1820. boolean duplexv = FALSE;        // - horizontal and vertical binding
  1821. boolean duparg  = FALSE;        // got a duplex option on command-line?
  1822. long usermag = 0;            // user-specified mag value
  1823. X
  1824. Device *device = NULL;            // particular device for output
  1825. font *currfont = NULL;            // current font being used
  1826. Fontlist fontlist;            // list of all fonts for this file
  1827. Bitvec **fontbits = NULL;        // draw fonts into this space
  1828. double H, V, W, X, Y, Z;        // DVI stack vars
  1829. X
  1830. X
  1831. void init_globals()
  1832. {
  1833. X    // convert the device name to lower-case for comparing
  1834. X    for (char *s = devname; s != NULL && *s != '\0'; s++)
  1835. X    if (isupper(*s))
  1836. X        *s = tolower(*s);
  1837. X
  1838. X    // default is LaserJetII
  1839. X    if (devname == NULL || *devname == '\0' || streq("default", devname))
  1840. X    devname = "hp33440";
  1841. X
  1842. X    // heuristics for figuring out Devices from device names
  1843. X    if (streq("hp2684", devname)
  1844. X        || streq("laser2000", devname)
  1845. X        || streq("lj2000", devname)
  1846. X        || streq("jumbojet", devname)
  1847. X        || streq("lj2k", devname))
  1848. X    {
  1849. X    reverse = !reverse;
  1850. X    if (!duparg && !duplexv && !duplexh)
  1851. X        duplexv = TRUE;
  1852. X    device = new HP2684;
  1853. X    mesg("HP LaserJet 2000 (HP2684)");
  1854. X    }
  1855. X    else if (streq("hp33447", devname)
  1856. X        || streq("laserjetiid", devname)
  1857. X        || streq("laserjet2d", devname)
  1858. X        || streq("laseriid", devname)
  1859. X        || streq("laser2d", devname)
  1860. X        || streq("ljiid", devname)
  1861. X        || streq("lj2d", devname))
  1862. X    {
  1863. X    reverse = !reverse;
  1864. X    if (!duparg && !duplexv && !duplexh)
  1865. X        duplexv = TRUE;
  1866. X    device = new HP33447;
  1867. X    mesg("HP LaserJet IID (HP33447)");
  1868. X    }
  1869. X    else if (streq("hp33440", devname)
  1870. X        || streq("laserjetii", devname)
  1871. X        || streq("laserjet2", devname)
  1872. X        || streq("laserii", devname)
  1873. X        || streq("laser2", devname)
  1874. X        || streq("ljii", devname)
  1875. X        || streq("lj2", devname))
  1876. X    {
  1877. X    reverse = !reverse;
  1878. X    device = new HP33440;
  1879. X    mesg("HP LaserJet II (HP33440)");
  1880. X    if (duparg && (duplexv || duplexh))
  1881. X        warn("Cannot do double-sided for HP33440");
  1882. X    }
  1883. X    else if (streq("hp2686", devname)
  1884. X        || streq("laserjet+", devname)
  1885. X        || streq("laserjet", devname)
  1886. X        || streq("laser", devname)
  1887. X        || streq("ljet", devname)
  1888. X        || streq("lj+", devname)
  1889. X        || streq("lj", devname))
  1890. X    {
  1891. X    device = new HP2686;
  1892. X    mesg("HP LaserJet+ (HP2686)");
  1893. X    if (duparg && (duplexv || duplexh))
  1894. X        warn("Cannot do double-sided for HP2686");
  1895. X    }
  1896. X
  1897. X    if (duplexh && duplexv)
  1898. X    quit("Must choose only ONE type of double-sided binding");
  1899. X
  1900. X    if (device == NULL)
  1901. X    {
  1902. X    if (!streq("help", devname) && !streq("?", devname))
  1903. X        error("Sorry - don't know device ``%s''", devname);
  1904. X    error("Currently supported devices are: HP2686 HP33440 HP33447 HP2684");
  1905. X    quit("No point in continuing, eh?");
  1906. X    }
  1907. X
  1908. X    char *str;
  1909. X    if (fontpath == NULL)
  1910. X    {
  1911. X    str = getenv("FONTPATH");
  1912. X    if (str != NULL && *str != '\0')
  1913. X        fontpath = str;
  1914. X    }
  1915. X    if (fontpath == NULL)
  1916. X    fontpath = DEFFONTPATH;
  1917. X
  1918. X    if (dviinput == NULL)
  1919. X    {
  1920. X    str = getenv("DVIINPUT");
  1921. X    if (str != NULL && *str != '\0')
  1922. X        dviinput = str;
  1923. X    }
  1924. X
  1925. X    debug(3, "MAXFONTS=%d  MAXCHARS=%d  MAXONPAGE=%d  MAXLOADED=%d",
  1926. X        MAXFONTS, MAXCHARS, MAXONPAGE, MAXLOADED);
  1927. }
  1928. X
  1929. void fini_globals()
  1930. {
  1931. X    delete device;
  1932. }
  1933. SHAR_EOF
  1934. chmod 0444 global.C ||
  1935. echo 'restore of global.C failed'
  1936. Wc_c="`wc -c < 'global.C'`"
  1937. test 4109 -eq "$Wc_c" ||
  1938.     echo 'global.C: original size 4109, current size' "$Wc_c"
  1939. fi
  1940. true || echo 'restore of stack.C failed'
  1941. echo End of part 1, continue with part 2
  1942. exit 0
  1943.  
  1944. exit 0 # Just in case...
  1945. -- 
  1946. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1947. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1948. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1949. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1950.