home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / tex / tex31 / texsrc.lzh / COMMON.LZH / TEXMF.H < prev   
Encoding:
C/C++ Source or Header  |  1991-01-13  |  4.6 KB  |  165 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).  The file-opening routines are also used by
  4.    BibTeX.  */
  5.  
  6. #include "../common/fileio.h"
  7. #include "../common/extra.h"
  8.  
  9. #ifdef TeX
  10. #define dump_file fmtfile
  11. #define dump_path TEXFORMATPATH
  12. #define write_out writedvi
  13. #define out_file dvifile
  14. #define out_buf dvibuf
  15. #else /* not TeX */
  16. #define dump_file basefile
  17. #define dump_path MFBASEPATH
  18. #define write_out writegf
  19. #define out_file gffile
  20. #define out_buf gfbuf
  21. #endif /* not TeX */
  22.  
  23.  
  24.  
  25. /* File types.  */
  26. typedef FILE *bytefile, *wordfile;
  27.  
  28.  
  29.  
  30. /* Read a line of input as quickly as possible.  */
  31. #define    inputln(stream, flag)    input_line (stream)
  32. extern boolean input_line ();
  33.  
  34. /* We don't know how to implement `clear_terminal' or `wake_up_terminal'
  35.    except on BSD systems, but they aren't crucial to TeX.  */
  36. #ifdef BSD
  37. #define clearterminal bsd_clear_terminal
  38. #define wakeupterminal bsd_wake_up_terminal
  39. #else
  40. #define clearterminal()
  41. #define wakeupterminal()
  42. #endif
  43.  
  44. /* We need to read an integer from stdin if we're debugging.  */
  45. #ifdef DEBUG
  46. #define getint()  inputint (stdin)
  47. #else
  48. #define getint()
  49. #endif
  50.  
  51.  
  52.  
  53. /* 
  54.    `bopenin' (and out) is used only for reading (and writing) .tfm
  55.    files; `wopenin' (and out) only for dump files.  The filenames are
  56.    passed in as a global variable, `nameoffile'.  */
  57. #define bopenin(f)    open_input (&(f), TFMFILEPATH)
  58. #define wopenin(f)    open_input (&(f), dump_path)
  59. #define bopenout    aopenout
  60. #define wopenout    aopenout
  61. #define bclose        aclose
  62. #define wclose        aclose
  63.  
  64.  
  65. /* This routine has to return four values.  */
  66. #define    dateandtime(i, j, k, l)    get_date_and_time (&(i), &(j), &(k), &(l))
  67.  
  68.  
  69.  
  70. /* If we're running under Unix, use system calls instead of standard I/O
  71.    to read and write the output files; also, be able to make a core dump. */ 
  72. #ifndef unix
  73. #define    dumpcore()    exit (1)
  74.  
  75. #ifdef TeX
  76. #define    writedvi(a, b)    (void) fwrite((char *) &dvibuf[a], \
  77.                                       sizeof(dvibuf[a]), (int)(b-a+1), dvifile)
  78. #else
  79. #define    writegf(a, b)    (void) fwrite((char *) &gfbuf[a], \
  80.                                       sizeof(gfbuf[a]), (int)(b-a+1), gffile)
  81. #endif
  82.  
  83. #else /* unix */
  84. #define    dumpcore    abort
  85. #ifdef TeX
  86. #define    writedvi(start, end)                        \
  87.   (void) write (fileno (dvifile), (char *) &dvibuf[start],        \
  88.                 (int) (end - start + 1))
  89. #else
  90. #define    writegf(start, end)                        \
  91.   (void) write (fileno (gffile), (char *) &gfbuf[start],        \
  92.                 (int) (end - start + 1))
  93. #endif
  94. #endif /* unix */
  95.  
  96.  
  97. /* Reading and writing the dump files.  */
  98. #define    dumpthings(base, len) \
  99.   (void) fwrite ((char *) &(base), sizeof (base), (int) (len), dump_file)
  100. #define    undumpthings(base,len) \
  101.   (void) fread ((char *) &(base), sizeof (base), (int) (len), dump_file)
  102.  
  103. #define    generic_dump(x) \
  104.   (void) fwrite ((char *) &(x), sizeof (x), 1, dump_file)
  105. #define    generic_undump(x) \
  106.   (void) fread ((char *) &(x), sizeof (x), 1, dump_file)
  107.  
  108. #define dumpwd        generic_dump
  109. #define undumpwd    generic_undump
  110. #define dumphh        generic_dump
  111. #define undumphh    generic_undump
  112. #define dumpqqqq       generic_dump
  113. #define    undumpqqqq    generic_undump
  114.  
  115.  
  116. #if defined(SIXTEENBIT) || defined(atarist)
  117. #define    dumpint(x)                            \
  118.   do                                    \
  119.     {                                     \
  120.        integer x_val = (x);                        \
  121.        (void) fwrite ((char *) &x_val, sizeof (x_val), 1, dump_file);    \
  122.     }                                    \
  123.   while (0)
  124. #define    undumpint(x)    fread ((char *) &(x), sizeof (x), 1, dump_file)
  125. #else
  126. #define    dumpint(x)    (void) putw ((int) (x), dump_file)}
  127. #define    undumpint(x)    (x) = getw (dump_file)
  128. #endif
  129.  
  130.  
  131. /* Metafont wants to write bytes to the TFM file.  The idea behind the
  132.    `do..while(0)' is to swallow a semicolon before a possible else
  133.    (since C syntax is archaic), as suggested in the GNU C preprocessor
  134.    manual.  The casts in these routines are important, since otherwise
  135.    memory is clobbered in some strange way, which causes ``13 font
  136.    metric dimensions to be decreased'' in the trap test, instead of 4.  */
  137. #define bwritebyte(f, b)    putc ((char) b, f)
  138.  
  139. #define bwrite2bytes(f, h)                        \
  140.   do                                    \
  141.     {                                    \
  142.       integer v = (integer) h;                        \
  143.       putc (v >> 8, f);  putc (v & 0xff, f);                \
  144.     }                                    \
  145.   while (0)
  146.  
  147. #define bwrite4bytes(f, w)                        \
  148.   do                                    \
  149.     {                                    \
  150.       integer v = (integer) w;                        \
  151.       putc (v >> 24, f); putc (v >> 16, f);                \
  152.       putc (v >> 8, f);  putc (v & 0xff, f);                \
  153.     }                                    \
  154.   while (0)
  155.  
  156.  
  157.  
  158. /* If we're running on an ASCII system, there is no need to use the
  159.    `xchr' array to convert characters to the external encoding.  */
  160. #ifdef NONASCII
  161. #define    Xchr(x)        xchr[x]
  162. #else
  163. #define    Xchr(x)        ((char) (x))
  164. #endif
  165.