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