home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / DVI_MGR / dvimgr_s.lzh / dvimgr / dvihead.h < prev    next >
Text File  |  1993-08-06  |  17KB  |  361 lines

  1. /* -*-C-*- dvihead.h */
  2. /*-->dvihead*/
  3. /**********************************************************************/
  4. /****************************** dvihead *******************************/
  5. /**********************************************************************/
  6.  
  7. /**********************************************************************/
  8. /*************************  Revision History  *************************/
  9. /**********************************************************************/
  10.  
  11. /***********************************************************************
  12. [Begin Revision History]
  13. Added OS_OSK.   23-Jun-1993  lcs
  14.  
  15. <BEEBE.TEX.DVI.NEW>DVIHEAD.H.2, 24-Jun-86 18:11:55, Edit by BEEBE
  16. Added saving of all ten TeX  page counters in prtpage() in global  array
  17. tex_counter[], and  function tctos()  to convert  them to  a string  for
  18. printing.  All warning and error messages are now accompanied by a  list
  19. of the non-zero page counters to  help relate errors to output  document
  20. pages.
  21.  
  22. <BEEBE.TEX.DVI>DVIHEADER.H.21, 13-Mar-86 10:43:33, Edit by BEEBE
  23. Added use of  getenv() for  Unix and PC-DOS  to pick  up definitions  of
  24. texinputs and texfonts at runtime; if these are available, they override
  25. built-in choices.   This makes  it  possible to  move compiled  code  to
  26. similar machines with different  directory structures without having  to
  27. recompile.  For TOPS-20, this is unnecessary, since the defaults already
  28. point to these, and a name of the form /texinputs/foo.bar is  translated
  29. by PCC-20 to texinputs:foo.bar, from which the current definition of the
  30. logical name "texinputs:" is used to find the desired directory.  It can
  31. even be a  chain of directories;  in Unix  and PC-DOS, we  will need  to
  32. introduce  a  special  version  of  fopen()  to  handle  filenames  with
  33. environment variable prefixes which might represent directory chains.
  34.  
  35. Removed variable-length  argument lists  to  fatal() and  warning()  for
  36. portability.  Changed all preprocessor  #ifdef's and #ifndef's to  #if's
  37. for  portability;  all  symbols  for  devices,  operating  systems,  and
  38. implementations are now explicitly defined to be 0 or 1.  IBM PC Lattice
  39. C will not accept the operators  "!", "||", or "&&" in #if  expressions,
  40. although they should be perfectly legal; rearranged several  expressions
  41. to avoid these (introduce #else, use "|" and "&").
  42.  
  43. Added procedures fontfile() and fontsub() to encapsulate construction of
  44. system-dependent font file names  and provide for user-specifiable  font
  45. substitutions  for   unavailable   font  files   (new   runtime   option
  46. -ffontfile).
  47.  
  48. Removed old #ifdef FOOBAR ... #endif code sections in several procedures
  49. which were  completely obsolete.   Added header  comment line  to  every
  50. file; it  contains  the  EMACS  "-*-C-*-"  mode  string  and  the  exact
  51. (case-sensive) filename,  since many  functions have  been defined  with
  52. names  in  mixed  case  for  readability  (probably  should  have   used
  53. underscore instead, but none do), and on Unix, the letter case matters.
  54.  
  55. Replaced index()  and  rindex(),  which have  different  definitions  in
  56. different C  implementations, by  4.2BSD (and  coming ANSI  C  standard)
  57. functions strchr() and strrchr(), for which .h files are provided.
  58.  
  59.  
  60. <BEEBE.TEX.DVI>DVIHEADER.H.11,  8-Jan-86 16:55:59, Edit by BEEBE
  61. Added DVITYPE  Version 2.6  MAXDRIFT  correction to  pixel  coordinates.
  62. This  adds  function  fixpos()   called  from  movedown(),   moveover(),
  63. setchar(), and setrule(), and #include'd  in DVI*.c with definitions  in
  64. gblprocs.h and machdefs.h.  Revision level incremented by 0.01 (most are
  65. now at 2.01)
  66.  
  67.  
  68. <BEEBE.TEX.DVI>DVIHEADER.H.7, 22-Jul-85 12:51:02, Edit by BEEBE
  69. Added PostScript driver for Apple LaserWriter.
  70.  
  71. Added support for multiple input DVI  files to each of which all  switch
  72. options apply.
  73.  
  74.  
  75. <BEEBE.TEX>DVIJET.C.70, 30-May-85 00:33:51, Edit by BEEBE
  76. Revised "int" type  declarations to signed  types (INT8, INT16,  INT32),
  77. unsigned  types  (BYTE,   UNSIGN16,  UNSIGN32),   and  coordinate   type
  78. (COORDINATE) as  a  prelude  to moving  to  microprocessors  where  long
  79. integers impose a serious runtime penalty.
  80.  
  81. Type casts added to many assignments and arguments.
  82.  
  83. "double" changed to "float".
  84.  
  85. Added a few more "register" declarations and deleted unused variables.
  86.  
  87. Device-dependent code  sections identified  as prelude  to code  sharing
  88. between device  drivers via  "#include"  statements for  each  shareable
  89. procedure.
  90.  
  91. Added -c, -o, -r, -x, -y options and inch() procedure.
  92.  
  93. Several passes with "lint" under VAX Unix to detect further problems
  94.  
  95.  
  96. <BEEBE.TEX>DVIJET.C.18, 27-May-85 23:44:34, Edit by BEEBE
  97. Revise copy of Printronix driver for output on Hewlett-Packard Laser Jet
  98.  
  99.  
  100. <BEEBE.TEX>DVIPRX.C.125, 20-Oct-84 14:02:27, Edit by BEEBE
  101. Add mag_table[] and rewrite actfact() to use it.  Add code to readfont()
  102. and openfont()  to  choose  nearest available  font  magnification  when
  103. required one is  unavailable.  Enable  USEGLOBALMAG since  code now  can
  104. handle it properly.  Allow upper-case  option letters as equivalents  of
  105. lower-case ones -- non-Unix folks abhor such distinctions.
  106.  
  107.  
  108. <BEEBE.TEX>DVIPRX.C.118, 30-Sep-84 14:42:10, Edit by BEEBE
  109. Change = to  == in "if  (...)" in procedure  warning, change g_dolog  to
  110. BOOLEAN.
  111.  
  112.  
  113. [End Revision History]
  114. ***********************************************************************/
  115.  
  116. /**********************************************************************/
  117. /************************  Development History  ***********************/
  118. /**********************************************************************/
  119.  
  120. /***********************************************************************
  121. **
  122. **  The code is arranged  to allow easy modification  of the output  for
  123. **  display on other dot matrix printers, and for porting to a new  host
  124. **  computing environment.  The  sections labelled "Device  Definitions"
  125. **  and "Global Definitions"  below definitely  need to  be modified  in
  126. **  such a case.  A couple of the  40 or so procedures in the  '#include
  127. **  "xxx.h"' section may need to be adjusted as well, but almost all the
  128. **  rest should be both host- and output-device-independent.
  129. **
  130. **  The runtime switches will be similar for most devices, but some will
  131. **  require additional ones.  Device-name conditionals should be used to
  132. **  bracket these, so that code  can be lifted without modification  for
  133. **  use in a new dvi driver.
  134. **
  135. **  Instead of building up a bit map corresponding to the final  printer
  136. **  file, we keep a  large array which  has a one-to-one  correspondence
  137. **  with the printed page; dots in  a horizontal raster on the page  are
  138. **  consecutive in memory.   This allows  us to OR  in character  raster
  139. **  patterns without having to unpack every single bit.  At  end-of-page
  140. **  time, each  raster  row  is  trimmed of  trailing  white  space  and
  141. **  formatted into a line of data to  be sent to the printer file.   For
  142. **  those devices which  pack dots for  6, 7,  or 8 rows  into a  single
  143. **  character, some merging of raster lines will be necessary.
  144. **
  145. **  To use the program, type:
  146. **
  147. **  dvixxx {-b} {-c#} {-d#} {-ffontsubfile} {-l} {-m#} {-o#:#} {-o#} {-p}
  148. **       {-r#} {-v} {-x#units} {-y#units} dvifile(s)
  149. **
  150. **  The order of command options and DVI file names is not  significant;
  151. **  all switch values apply to all  DVI files.  DVI files are  processed
  152. **  in order from left to right.   The command options are (letter  case
  153. **  is IGNORED):
  154. **
  155. **    b    Backwards order printing from the default.  For example,
  156. **        laser printers using the Canon engine print normally
  157. **        receive pages in reverse order because they stack printed
  158. **        side up.  Some have page handling mechanisms that stack
  159. **        them face down, and in such a case -b will ensure that
  160. **        they come out in order 1,2,... instead of n,n-1,n-2,...
  161. **
  162. **    c#    Print # copies of each output page.
  163. **
  164. **    d#    Debug output to stderr if non-zero value given.
  165. **
  166. **    ffontsubfile    Define an alternate font substitution file which
  167. **        is to be used instead of the default ones (see below).
  168. **
  169. **    l    Inhibit logging.
  170. **
  171. **    m#    Reset magnification  to  #.   The  default  is  "-m603",
  172. **        corresponding   to  (1/1.2**5)  magnification of  300dpi
  173. **        fonts.   Legal  values  are int(1000*(1.2)**(k/2)) (k  =
  174. **        -16,16); other values will be set to the nearest in this
  175. **        family.   Not all fonts  will be available in  this wide
  176. **        range, and most installations will probably have  only a
  177. **        half dozen or so magnifications.
  178. **
  179. **    o# and
  180. **    o#:#    Specify a page number,  or range of page numbers,  to be
  181. **        selected for output.  This  option may be specified  any
  182. **        number of times.  If it is not specified, then all pages
  183. **        will be printed.  Pages are numbered in order  1,2,3,...
  184. **        in the file, but any page number recorded by TeX on  the
  185. **        printed page will in general be different.  As pages are
  186. **        selected  for  printing,  "[#{#}"  will  be  printed  on
  187. **        stderr, where the first is the page number in the  file,
  188. **        and the second is the value of the TeX counter, \count0,
  189. **        which usually records the printed page number.  When the
  190. **        page is completely output, a closing "]" will be printed
  191. **        on stderr.  Any error  messages from processing of  that
  192. **        page will therefore occur  between the square  brackets.
  193. **        For example, "-o1:3 -o12 -o17:23" would select pages  1,
  194. **        2, 3, 12, 17, 18, 19,  20, 21, 22, and 23 for  printing.
  195. **        Pages will always be printed in an order appropriate for
  196. **        the device so that the first document page occurs  first
  197. **        face up in the document stack.
  198. **
  199. **    p    Inhibit font preloading.  This may produce output a  few
  200. **        seconds earlier when  all pages are  output, but  should
  201. **        have  negligible  effect  on  the  execution  time,  and
  202. **        consequently, should  normally not  be specified.   When
  203. **        individual pages are being printed with the -o#  option,
  204. **        preloading is necessary (and  will be forced) to  ensure
  205. **        that all fonts are defined before they are referenced.
  206. **
  207. **    q    Quiet mode.   Status displays to stderr are  suppressed,
  208. **        unless warning or error messages are issued.
  209. **
  210. **    r#    (Device =  HP Laser Jet  only).  Specify the  Laser  Jet
  211. **        output resolution in dots per inch.  "#" must be one  of
  212. **        75, 100, 150, or 300.  The actual plot file is identical
  213. **        in each  case;  only the  size  on the  output  page  is
  214. **        changed, because the  resolution change  is effected  by
  215. **        printing 1 x 1, 2 x 2, 3 x 3, or 4 x 4 pixel blocks.
  216. **
  217. **    r    (Device  =  Golden Laser 100 only).   Select  run-length
  218. **        encoding of the  output file.  This  reduces disk  space
  219. **        typically by 10% to 40%, but increases host CPU time for
  220. **        the preparation of the output file.
  221. **
  222. **    r    (Device  = Apple ImageWriter only).   Select  run-length
  223. **        encoding of the output file.
  224. **
  225. **    r    (Device  =  Toshiba  P-1351  only).   Select  run-length
  226. **        encoding of the  output file.  This  reduces disk  space
  227. **        typically by 10% to 40%, but increases host CPU time for
  228. **        the preparation of the output file, and because of  poor
  229. **        logic in the  printer, may double  the print time!   The
  230. **        print quality  is  also  substantially  worse,  so  this
  231. **        option is generally NOT recommended.
  232. **
  233. **    s#    (Device =  Apple  LaserWriter only).   Force  characters
  234. **        larger than # pixels  wide or high  to be reloaded  each
  235. **        time they  are required.   The Version  23.0  PostScript
  236. **        interpreter has a  bug which manifests  itself in  fatal
  237. **        'VM error' messages when  large characters are sent.   A
  238. **        reasonable default  value has  been set  for this  which
  239. **        should normally avoid the problem.  Specifying -s0  will
  240. **        cause reloading of every character each time it is used.
  241. **
  242. **    v    (Device = Apple LaserWriter  only).  Force reloading  of
  243. **        all required fonts at start of each page.
  244. **
  245. **    x#bp    big point (1in = 72bp)
  246. **    x#cc    cicero (1cc = 12dd)
  247. **    x#cm    centimeter
  248. **    x#dd    didot point (1157dd = 1238pt)
  249. **    x#in    inch
  250. **    x#mm    millimeter (10mm = 1cm)
  251. **    x#pc    pica (1pc = 12pt)
  252. **    x#pt    point (72.27pt = 1in)
  253. **    x#sp    scaled point (65536sp = 1pt)
  254. **        Specify the left margin  of the TeX  page on the  output
  255. **        page in any of the indicated units.  Letter case is  not
  256. **        significant  in  the  unit  field,  which  must  not  be
  257. **        separated from  the  number  by any  space.   #  may  be
  258. **        fractional.    For   example,   "-x1.0in",   "-x2.54cm",
  259. **        "-x72.27pt", and  "-x6.0225pc" all  specify a  one  inch
  260. **        left margin.  Negative values  are permissible, and  may
  261. **        be  used  to  shift  the  output  page  left   (possibly
  262. **        truncating it on the  left) in order  to display a  wide
  263. **        TeX page.
  264. **
  265. **    y#    inch
  266. **    y#bp    big point (1in = 72bp)
  267. **    y#cc    cicero (1cc = 12dd)
  268. **    y#cm    centimeter
  269. **    y#dd    didot point (1157dd = 1238pt)
  270. **    y#in    inch
  271. **    y#mm    millimeter (10mm = 1cm)
  272. **    y#pc    pica (1pc = 12pt)
  273. **    y#pt    point (72.27pt = 1in)
  274. **    y#sp    scaled point (65536sp = 1pt)
  275. **        Specify the top  margin of  the TeX page  on the  output
  276. **        page in any of the indicated units.  Letter case is  not
  277. **        significant  in  the  unit  field,  which  must  not  be
  278. **        separated from  the  number  by any  space.   #  may  be
  279. **        fractional.    For   example,   "-y1.0in",   "-y2.54cm",
  280. **        "-y72.27pt", and "-y6.0225pc" all specify a one inch top
  281. **        margin.  Negative  values are  permissible, and  may  be
  282. **        used to shift the output page up (possibly truncating it
  283. **        on the top) in order to display a long TeX page.
  284. **
  285. **
  286. **  If no  -ffontsubfile  option  is given,  and  font  substitution  is
  287. **  required,   the   files   "dvifile.sub"   (minus   any   extension),
  288. **  "texfonts.sub", and "texinputs:texfonts.sub" will be tried in order.
  289. **  The first two will be found  on the current directory, and the  last
  290. **  is the system default.  This gives the option of  document-specific,
  291. **  user-specific, and system-specific substitutions, and the -f  option
  292. **  allows all of these to be overridden.
  293. **
  294. **  This program can only process DVI format 2 files.
  295. **
  296. **  Mark Senn  at Purdue  University wrote  the first  BitGraph  driver,
  297. **  dvibit.  This was further worked on at the University of  Washington
  298. **  by Stephen  Bechtolsheim,  Bob  Brown, Richard  Furuta,  and  Robert
  299. **  Wells.  The transformation to about  ten other device drivers,  plus
  300. **  the massive code rearrangement for many new features as well as easy
  301. **  identification of host- and  device-dependent sections, was  carried
  302. **  out at the University of Utah by Nelson H.F. Beebe.
  303. **
  304. **  Support for  pixel file  caching and  character raster  caching  was
  305. **  added by NHFB;  this should give  a decided performance  improvement
  306. **  provided the cache  sizes, MAXCACHE and  MAXOPEN, defined below  are
  307. **  sufficiently large.
  308. **
  309. **  MAXOPEN can be  set as low  as 1,  but should ideally  be about  15,
  310. **  since this may be more typical of the number of different font files
  311. **  required in mathematical manuscripts.
  312. **
  313. **  In the current version,  MAXCACHE is not  actually used, because  it
  314. **  appears sufficient raster storage will always be available even  for
  315. **  relatively complex  manuscripts.  However,  a record  is kept  which
  316. **  will permit dynamic freeing and reallocation of raster storage;  see
  317. **  procedure loadchar for details.
  318. **
  319. ***********************************************************************/
  320.  
  321.  
  322. /**********************************************************************/
  323. /************************  Global Definitions  ************************/
  324. /**********************************************************************/
  325.  
  326. /* All host-specific material resides in machdefs.h and typedefs.h;
  327. they must be revised when this dvi driver is rehosted to a new machine */
  328.  
  329. #define DEBUG    1        /* for optional massive trace printing */
  330. #undef DEBUG            /* do not want this now */
  331.  
  332. #include "machdefs.h"        /* all host-specific defines */
  333.  
  334. #include "typedefs.h"        /* typedefs (also host-specific) */
  335.  
  336. #include <stdio.h>        /* must come after the others to */
  337.                 /* enable type checking */
  338. #include <errno.h>        /* needed only for DISKFULL() definition */
  339. #if    (BSD41 | BSD42)
  340. extern int errno;        /* not in all errno.h files, sigh... */
  341. #endif
  342.  
  343. #if    IBM_PC_MICROSOFT
  344. #include <io.h>
  345. #include <stdlib.h>
  346. #include <string.h>
  347. #include <time.h>
  348. #endif
  349.  
  350. /* types.h and stat.h are needed for fstat(), which is used by special()
  351. and the virtual font mechanism in openfont.h to get the input file size. */
  352.  
  353. #if    (OS_ATARI | OS_VAXVMS | KCC_20 | OS_OSK)     /* 23-Jun-1993  lcs */
  354. #include <types.h>
  355. #include <stat.h>
  356. #else /* NOT (OS_ATARI | OS_VAXVMS | KCC_20) */
  357. #include <sys/types.h>
  358. #include <sys/stat.h>
  359. #endif /* (OS_ATARI | OS_VAXVMS | KCC_20) */
  360.  
  361.