OSDN Git Service

ef61ad69347fec9cd0b98070b81288f8e68a4820
[putex/putex.git] / src / texsourc / texmf.h
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    Copyright 1992 Karl Berry
6    Copyright 2007 TeX Users Group
7    Copyright 2014 Clerk Ma
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22    02110-1301 USA.  */
23
24 #include "config.h"
25
26 #include <stdarg.h>
27
28 #ifdef _MSC_VER
29   #define INLINE __inline
30 #else
31   #define INLINE inline
32 #endif
33
34 #ifdef TeX
35   #define dump_file  fmt_file
36   #define dump_path  TEXFORMATPATH
37   #define mwrite_out write_dvi
38   #define out_file   dvi_file
39   #define out_buf    dvi_buf
40 #endif /* not TeX */
41
42 /* File types. */
43 typedef FILE * byte_file;
44 typedef FILE * word_file;
45
46 /* Read a line of input as quickly as possible.  */
47 extern bool input_line (FILE *);
48 #define input_ln(stream, flag) input_line(stream)
49
50 /* We need to read an integer from stdin if we're debugging.  */
51 #ifdef DEBUG
52   #define getint() inputint(stdin)
53 #else
54   #define getint()
55 #endif
56
57 /* `b_open_in' (and out) is used only for reading (and writing) .tfm
58    files; `w_open_in' (and out) only for dump files.  The filenames are
59    passed in as a global variable, `name_of_file'.  */
60    
61 #define b_open_in(f)  open_input  (&(f), TFMFILEPATH, FOPEN_RBIN_MODE)
62 #define w_open_in(f)  open_input  (&(f), dump_path, FOPEN_RBIN_MODE)
63 #define b_open_out(f) open_output (&(f), FOPEN_WBIN_MODE)
64 #define w_open_out    b_open_out
65 #define b_close       a_close
66 #define w_close       a_close
67
68 /* sec 0241 */
69 #define fix_date_and_time() get_date_and_time (&(tex_time), &(day), &(month), &(year))
70
71 /* If we're running under Unix, use system calls instead of standard I/O
72    to read and write the output files; also, be able to make a core dump. */ 
73 #ifndef unix
74   #define dumpcore() exit(1)
75 #else /* unix */
76   #define dumpcore abort
77 #endif
78
79 #ifndef unix
80 #ifdef TeX
81 #define write_dvi(a, b)                                                 \
82   if (fwrite ((char *) &dvi_buf[a], sizeof (dvi_buf[a]),                \
83          (int) ((b) - (a) + 1), dvi_file) != (size_t) ((b) - (a) + 1))  \
84      FATAL_PERROR ("\n! dvi file")
85 #endif /* not TeX */
86 #endif /* unix */
87
88 extern int do_dump (char *, int, int, FILE *);
89 extern int do_undump (char *, int, int, FILE *);
90
91 /* Reading and writing the dump files.  `(un)dumpthings' is called from
92    the change file.*/
93 #define dumpthings(base, len)           \
94   do_dump ((char *) &(base), sizeof (base), (int) (len), dump_file)
95
96 #define undumpthings(base, len)           \
97   do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file)
98
99 /* Use the above for all the other dumping and undumping.  */
100 #define generic_dump(x)   dumpthings (x, 1)
101 #define generic_undump(x) undumpthings (x, 1)
102
103 #define dump_wd     generic_dump
104 #define undump_wd   generic_undump
105 #define dump_hh     generic_dump
106 #define undump_hh   generic_undump
107 #define dump_qqqq   generic_dump
108 #define undump_qqqq generic_undump
109
110 /* `dump_int' is called with constant integers, so we put them into a
111    variable first.  */
112 #define dump_int(x)         \
113   do                        \
114     {                       \
115       integer x_val = (x);  \
116       generic_dump (x_val); \
117     }                       \
118   while (0)
119
120 /* web2c/regfix puts variables in the format file loading into
121    registers.  Some compilers aren't willing to take addresses of such
122    variables.  So we must kludge.  */
123 #ifdef REGFIX
124 #define undump_int(x)         \
125   do                          \
126     {                         \
127       integer x_val;          \
128       generic_undump (x_val); \
129       x = x_val;              \
130     }                         \
131   while (0)
132 #else
133 #define undump_int  generic_undump
134 #endif
135
136
137 /* If we're running on an ASCII system, there is no need to use the
138    `xchr' array to convert characters to the external encoding.  */
139
140 #define Xchr(x) xchr[x]
141
142 /* following added from new texmf.c file 1996/Jan/12 */
143 /* these, of course are useless definitions since parameters not given */
144
145 /* Declare routines in texmf.c.  */
146 extern void get_date_and_time();
147 extern void t_open_in();
148 extern bool input_line();