home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / tex / texsrc1 / Src / lib / h / texmf < prev    next >
Encoding:
Text File  |  1992-12-12  |  4.7 KB  |  171 lines

  1. /* Main include file for TeX in C.  Originally by Tim Morgan,
  2.    December 23, 1987.  These routines are also used by Metafont (with
  3.    some name changes).  */
  4.  
  5. #include "config.h"
  6.  
  7. #ifdef TeX
  8. #define dump_file fmtfile
  9. #define dump_path TEXFORMATPATH
  10. #define write_out writedvi
  11. #define out_file dvifile
  12. #define out_buf dvibuf
  13. #else /* not TeX */
  14. #define dump_file basefile
  15. #define dump_path MFBASEPATH
  16. #define write_out writegf
  17. #define out_file gffile
  18. #define out_buf gfbuf
  19. #endif /* not TeX */
  20.  
  21.  
  22.  
  23. /* File types.  */
  24. typedef FILE *bytefile, *wordfile;
  25.  
  26.  
  27.  
  28. /* Read a line of input as quickly as possible.  */
  29. #define    inputln(stream, flag)    input_line (stream)
  30. extern boolean input_line ();
  31.  
  32.  
  33. /* We need to read an integer from stdin if we're debugging.  */
  34. #ifdef DEBUG
  35. #define getint()  inputint (stdin)
  36. #else
  37. #define getint()
  38. #endif
  39.  
  40.  
  41.  
  42. /* `bopenin' (and out) is used only for reading (and writing) .tfm
  43.    files; `wopenin' (and out) only for dump files.  The filenames are
  44.    passed in as a global variable, `nameoffile'.  */
  45.    
  46. #define bopenin(f)    open_input (&(f), TFMFILEPATH, FOPEN_RBIN_MODE)
  47. #define wopenin(f)    open_input (&(f), dump_path, FOPEN_RBIN_MODE)
  48. #define bopenout(f)    open_output (&(f), FOPEN_WBIN_MODE)
  49. #define wopenout    bopenout
  50. #define bclose        aclose
  51. #define wclose        aclose
  52.  
  53. /* This routine has to return four values.  */
  54. #define    dateandtime(i, j, k, l)    get_date_and_time (&(i), &(j), &(k), &(l))
  55.  
  56.  
  57.  
  58. /* If we're running under Unix, use system calls instead of standard I/O
  59.    to read and write the output files; also, be able to make a core dump. */ 
  60. #ifndef unix
  61. #define    dumpcore()    exit (1)
  62.  
  63. #ifdef TeX
  64. #define    writedvi(a, b)                            \
  65.   (void) fwrite ((char *) &dvibuf[a], sizeof (dvibuf[a]),        \
  66.                  (int) ((b) - (a) + 1), dvifile)
  67. #else
  68. #define    writegf(a, b)                            \
  69.   (void) fwrite ((char *) &gfbuf[a], sizeof (gfbuf[a]),            \
  70.                  (int) ((b) - (a) + 1), gffile)
  71. #endif /* not TeX */
  72.  
  73. #else /* unix */
  74. #define    dumpcore    abort
  75.  
  76. #ifdef TeX
  77. #define    writedvi(start, end)                        \
  78.   if (write (fileno (dvifile), (char *) &dvibuf[start],            \
  79.              (int) ((end) - (start) + 1))                \
  80.       != (int) ((end) - (start) + 1))                    \
  81.     FATAL_PERROR ("dvi file")
  82. #else
  83. #define    writegf(start, end)                        \
  84.   if (write (fileno (gffile), (char *) &gfbuf[start],            \
  85.              (int) ((end) - (start) + 1))                \
  86.       != (int) ((end) - (start) + 1))                    \
  87.     FATAL_PERROR ("gf file")
  88. #endif /* not TeX */
  89. #endif /* unix */
  90.  
  91.  
  92. /* Reading and writing the dump files.  `(un)dumpthings' is called from
  93.    the change file.*/
  94. #define    dumpthings(base, len)                        \
  95.   do_dump ((char *) &(base), sizeof (base), (int) (len), dump_file)
  96.  
  97. #define    undumpthings(base, len)                        \
  98.   do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file)
  99.  
  100. /* We define the routines to do the actual work in texmf.c.  */
  101. extern void do_dump (), do_undump ();
  102.  
  103. /* Use the above for all the other dumping and undumping.  */
  104. #define generic_dump(x) dumpthings (x, 1)
  105. #define generic_undump(x) undumpthings (x, 1)
  106.  
  107. #define dumpwd        generic_dump
  108. #define undumpwd    generic_undump
  109. #define dumphh        generic_dump
  110. #define undumphh    generic_undump
  111. #define dumpqqqq       generic_dump
  112. #define    undumpqqqq    generic_undump
  113.  
  114. /* `dump_int' is called with constant integers, so we put them into a
  115.    variable first.  */
  116. #define    dumpint(x)                            \
  117.   do                                    \
  118.     {                                    \
  119.       integer x_val = (x);                        \
  120.       generic_dump (x_val);                        \
  121.     }                                    \
  122.   while (0)
  123.  
  124. /* web2c/regfix puts variables in the format file loading into
  125.    registers.  Some compilers aren't willing to take addresses of such
  126.    variables.  So we must kludge.  */
  127. #ifdef REGFIX
  128. #define undumpint(x)                            \
  129.   do                                    \
  130.     {                                    \
  131.       integer x_val;                            \
  132.       generic_undump (x_val);                        \
  133.       x = x_val;                            \
  134.     }                                    \
  135.   while (0)
  136. #else
  137. #define    undumpint    generic_undump
  138. #endif
  139.  
  140. /* Metafont wants to write bytes to the TFM file.  The casts in these
  141.    routines are important, since otherwise memory is clobbered in some
  142.    strange way, which causes ``13 font metric dimensions to be
  143.    decreased'' in the trap test, instead of 4.  */
  144.  
  145. #define bwritebyte(f, b)    putc ((char) (b), f)
  146. #define bwrite2bytes(f, h)                        \
  147.   do                                    \
  148.     {                                    \
  149.       integer v = (integer) (h);                    \
  150.       putc (v >> 8, f);  putc (v & 0xff, f);                \
  151.     }                                    \
  152.   while (0)
  153. #define bwrite4bytes(f, w)                        \
  154.   do                                    \
  155.     {                                    \
  156.       integer v = (integer) (w);                    \
  157.       putc (v >> 24, f); putc (v >> 16, f);                \
  158.       putc (v >> 8, f);  putc (v & 0xff, f);                \
  159.     }                                    \
  160.   while (0)
  161.  
  162.  
  163.  
  164. /* If we're running on an ASCII system, there is no need to use the
  165.    `xchr' array to convert characters to the external encoding.  */
  166. #ifdef NONASCII
  167. #define    Xchr(x)        xchr[x]
  168. #else
  169. #define    Xchr(x)        ((char) (x))
  170. #endif
  171.