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