1 /* texmf.h: Main include file for TeX and MF in C. This file is
2 included by {tex,mf}d.h, which is the first include in the C files
6 #include <kpathsea/c-pathch.h> /* for IS_DIR_SEP, used in the change files */
7 #include <kpathsea/tex-make.h> /* for kpse_make_tex_discard_errors */
11 /* include this here to avoid conflict between clang's emmintrin.h and
12 * texmfmem.h. Should be removed once a fixed clang is widely available
13 * http://llvm.org/bugs/show_bug.cgi?id=14964 */
14 #include <ApplicationServices/ApplicationServices.h>
16 /* added typedefs for unicodefile and voidpointer */
17 #define XETEX_UNICODE_FILE_DEFINED 1
25 typedef UFILE
* unicodefile
;
27 typedef void* voidpointer
;
30 /* If we have these macros, use them, as they provide a better guide to
31 the endianess when cross-compiling. */
32 #if defined (BYTE_ORDER) && defined (BIG_ENDIAN) && defined (LITTLE_ENDIAN)
33 #ifdef WORDS_BIGENDIAN
34 #undef WORDS_BIGENDIAN
36 #if BYTE_ORDER == BIG_ENDIAN
37 #define WORDS_BIGENDIAN
40 /* More of the same, but now NeXT-specific. */
42 #ifdef WORDS_BIGENDIAN
43 #undef WORDS_BIGENDIAN
46 #define WORDS_BIGENDIAN
50 /* Some things are the same except for the name. */
53 #define TEXMFPOOLNAME "pdftex.pool"
54 #define TEXMFENGINENAME "pdftex"
56 #define TEXMFPOOLNAME "etex.pool"
57 #define TEXMFENGINENAME "etex"
59 #define TEXMFPOOLNAME "xetex.pool"
60 #define TEXMFENGINENAME "xetex"
62 #define TEXMFPOOLNAME "aleph.pool"
63 #define TEXMFENGINENAME "aleph"
65 #define TEXMFPOOLNAME "ptex.pool"
66 #define TEXMFENGINENAME "ptex"
67 #include "ptexdir/kanji.h"
69 #define TEXMFPOOLNAME "eptex.pool"
70 #define TEXMFENGINENAME "eptex"
71 #include "ptexdir/kanji.h"
73 #define TEXMFPOOLNAME "uptex.pool"
74 #define TEXMFENGINENAME "uptex"
75 #include "uptexdir/kanji.h"
76 #elif defined (eupTeX)
77 #define TEXMFPOOLNAME "euptex.pool"
78 #define TEXMFENGINENAME "euptex"
79 #include "uptexdir/kanji.h"
81 #define TEXMFPOOLNAME "tex.pool"
82 #define TEXMFENGINENAME "tex"
84 #define DUMP_FILE fmtfile
85 #define DUMP_FORMAT kpse_fmt_format
86 #define writedvi WRITE_OUT
87 #define flushdvi flush_out
88 #define OUT_FILE dvifile
89 #define OUT_BUF dvibuf
93 #define TEXMFPOOLNAME "mflua.pool"
94 #define TEXMFENGINENAME "mflua"
95 #elif defined(MFLuaJIT)
96 #define TEXMFPOOLNAME "mfluajit.pool"
97 #define TEXMFENGINENAME "mfluajit"
99 #define TEXMFPOOLNAME "mf.pool"
100 #define TEXMFENGINENAME "metafont"
102 #define DUMP_FILE basefile
103 #define DUMP_FORMAT kpse_base_format
104 #define writegf WRITE_OUT
105 #define OUT_FILE gffile
106 #define OUT_BUF gfbuf
109 /* Restore underscores. */
110 #define dumpname dump_name
111 #define kpsedvipsconfigformat kpse_dvips_config_format
112 #define kpsefontmapformat kpse_fontmap_format
113 #define kpsemfpoolformat kpse_mfpool_format
114 #define kpsempformat kpse_mp_format
115 #define kpsemppoolformat kpse_mppool_format
116 #define kpsetexpoolformat kpse_texpool_format
117 #define kpsetexformat kpse_tex_format
119 /* Hacks for TeX that are better not to #ifdef, see lib/openclose.c. */
120 extern int tfmtemp
, texinputtype
;
122 /* pdfTeX routines also used for e-pTeX, e-upTeX, and XeTeX */
123 #if defined (pdfTeX) || defined (epTeX) || defined (eupTeX) || defined(XeTeX)
124 #if !defined (pdfTeX)
125 extern void pdftex_fail(const char *fmt
, ...);
128 extern char start_time_str
[];
129 extern void initstarttime(void);
130 extern char *makecstring(integer s
);
131 extern char *makecfilename(integer s
);
132 extern void getcreationdate(void);
133 extern void getfilemoddate(integer s
);
134 extern void getfilesize(integer s
);
135 extern void getfiledump(integer s
, int offset
, int length
);
137 extern void convertStringToHexString(const char *in
, char *out
, int lin
);
138 extern void getmd5sum(integer s
, int file
);
141 /* pdftex etc. except for tex use these for pipe support */
142 #if defined(TeX) && !defined(onlyTeX)
143 extern boolean
open_in_or_pipe (FILE **, int, const_string fopen_mode
);
144 extern boolean
open_out_or_pipe (FILE **, const_string fopen_mode
);
145 extern void close_file_or_pipe (FILE *);
146 #define ENABLE_PIPES 1
148 #define ENABLE_PIPES 0
151 /* Executing shell commands. */
152 extern int runsystem (const char *cmd
);
154 /* The entry point. */
155 extern void maininit (int ac
, string
*av
);
156 #if defined(WIN32) && !defined(__MINGW32__) && defined(DLLPROC)
157 extern __declspec(dllexport
) int DLLPROC (int ac
, string
*av
);
162 /* All but the Omega family use this. */
164 extern void readtcxfile (void);
165 extern string translate_filename
;
166 #define translatefilename translate_filename
170 /* The type `glueratio' should be a floating point type which won't
171 unnecessarily increase the size of the memoryword structure. This is
172 the basic requirement. On most machines, if you're building a
173 normal-sized TeX, then glueratio must probably meet the following
174 restriction: sizeof(glueratio) <= sizeof(integer). Usually, then,
175 glueratio must be `float'. But if you build a big TeX, you can (on
176 most machines) and should make it `double' to avoid loss of precision
177 and conversions to and from double during calculations. (All this
178 also goes for Metafont.) Furthermore, if you have enough memory, it
179 won't hurt to have this defined to be `double' for running the
182 This type is set automatically to `float' by configure if a small TeX
184 #ifndef GLUERATIO_TYPE
185 #define GLUERATIO_TYPE double
187 typedef GLUERATIO_TYPE glueratio
;
189 #if defined(__DJGPP__) && defined (IPC)
194 extern void ipcpage (int);
198 /* How to flush the DVI file. */
199 #define flush_out() fflush (OUT_FILE)
201 /* Used to write to a TFM file. */
202 #define put2bytes(f, h) do { \
203 integer v = (integer) (h); putbyte (v >> 8, f); putbyte (v & 0xff, f); \
205 #define put4bytes(f, w) do { \
206 integer v = (integer) (w); \
207 putbyte (v >> 24, f); putbyte (v >> 16, f); \
208 putbyte (v >> 8, f); putbyte (v & 0xff, f); \
211 /* Read a line of input as quickly as possible. */
212 #define inputln(stream, flag) input_line (stream)
214 extern boolean
input_line (UFILE
*);
216 extern boolean
input_line (FILE *);
219 /* This routine has to return four values. */
220 #define dateandtime(i,j,k,l) get_date_and_time (&(i), &(j), &(k), &(l))
221 extern void get_date_and_time (integer
*, integer
*, integer
*, integer
*);
224 /* Get high-res time info. */
225 #define secondsandmicros(i,j) get_seconds_and_micros (&(i), &(j))
226 extern void get_seconds_and_micros (integer
*, integer
*);
229 /* Copy command-line arguments into the buffer, despite the name. */
230 extern void topenin (void);
232 /* Can't prototype this since it uses poolpointer and ASCIIcode, which
233 are defined later in mfd.h, and mfd.h uses stuff from here. */
234 /* Therefore the department of ugly hacks decided to move this declaration
235 to the *coerce.h files. */
236 /* extern void calledit (); */
238 /* These defines reroute the file i/o calls to the new pipe-enabled
239 functions in texmfmp.c*/
245 #define aopenin(f,p) open_in_or_pipe(&(f),p,FOPEN_RBIN_MODE)
246 #define aopenout(f) open_out_or_pipe(&(f),FOPEN_W_MODE)
247 #define aclose(f) close_file_or_pipe(f)
250 /* `bopenin' (and out) is used only for reading (and writing) .tfm
251 files; `wopenin' (and out) only for dump files. The filenames are
252 passed in as a global variable, `nameoffile'. */
253 #define bopenin(f) open_input (&(f), kpse_tfm_format, FOPEN_RBIN_MODE)
254 #define ocpopenin(f) open_input (&(f), kpse_ocp_format, FOPEN_RBIN_MODE)
255 #define ofmopenin(f) open_input (&(f), kpse_ofm_format, FOPEN_RBIN_MODE)
257 #define bopenout(f) open_output (&(f), FOPEN_WBIN_MODE)
258 #define bclose aclose
260 /* f is declared as gzFile, but we temporarily use it for a FILE *
261 so that we can use the standard open calls */
262 #define wopenin(f) (open_input ((FILE**)&(f), DUMP_FORMAT, FOPEN_RBIN_MODE) \
263 && (f = gzdopen(fileno((FILE*)f), FOPEN_RBIN_MODE)))
264 #define wopenout(f) (open_output ((FILE**)&(f), FOPEN_WBIN_MODE) \
265 && (f = gzdopen(fileno((FILE*)f), FOPEN_WBIN_MODE)) \
266 && (gzsetparams(f, 1, Z_DEFAULT_STRATEGY) == Z_OK))
267 #define wclose(f) gzclose(f)
269 #define wopenin(f) open_input (&(f), DUMP_FORMAT, FOPEN_RBIN_MODE)
270 #define wopenout bopenout
271 #define wclose aclose
276 extern boolean
u_open_in_or_pipe(unicodefile
* f
, integer filefmt
, const_string fopen_mode
, integer mode
, integer encodingData
);
277 #define uopenin(f,p,m,d) u_open_in_or_pipe(&(f), p, FOPEN_RBIN_MODE, m, d)
279 #define uopenin(f,p,m,d) u_open_in(&(f), p, FOPEN_RBIN_MODE, m, d)
283 /* Used in tex.ch (section 1338) to get a core dump in debugging mode. */
285 #define dumpcore abort
287 #define dumpcore uexit (1)
291 extern boolean
initscreen (void);
292 extern void updatescreen (void);
293 /* Can't prototype these for same reason as `calledit' above. */
294 #if 0 /* Therefore the real declaration is found in the coerce.h files. */
295 extern void blankrectangle (/*screencol, screencol, screenrow, screenrow*/);
296 extern void paintrow (/*screenrow, pixelcolor, transspec, screencol*/);
301 /* (Un)dumping. These are called from the change file. */
302 #define dumpthings(base, len) \
303 do_dump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
304 #define undumpthings(base, len) \
305 do_undump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
307 /* Like do_undump, but check each value against LOW and HIGH. The
308 slowdown isn't significant, and this improves the chances of
309 detecting incompatible format files. In fact, Knuth himself noted
310 this problem with Web2c some years ago, so it seems worth fixing. We
311 can't make this a subroutine because then we lose the type of BASE. */
312 #define undumpcheckedthings(low, high, base, len) \
315 undumpthings (base, len); \
316 for (i = 0; i < (len); i++) { \
317 if ((&(base))[i] < (low) || (&(base))[i] > (high)) { \
318 FATAL5 ("Item %u (=%ld) of .fmt array at %lx <%ld or >%ld", \
319 i, (unsigned long) (&(base))[i], (unsigned long) &(base),\
320 (unsigned long) low, (unsigned long) high); \
325 /* Like undump_checked_things, but only check the upper value. We use
326 this when the base type is unsigned, and thus all the values will be
327 greater than zero by definition. */
328 #define undumpuppercheckthings(high, base, len) \
331 undumpthings (base, len); \
332 for (i = 0; i < (len); i++) { \
333 if ((&(base))[i] > (high)) { \
334 FATAL4 ("Item %u (=%ld) of .fmt array at %lx >%ld", \
335 i, (unsigned long) (&(base))[i], (unsigned long) &(base),\
336 (unsigned long) high); \
341 /* We define the routines to do the actual work in texmf.c. */
344 extern void do_dump (char *, int, int, gzFile
);
345 extern void do_undump (char *, int, int, gzFile
);
347 extern void do_dump (char *, int, int, FILE *);
348 extern void do_undump (char *, int, int, FILE *);
351 /* Use the above for all the other dumping and undumping. */
352 #define generic_dump(x) dumpthings (x, 1)
353 #define generic_undump(x) undumpthings (x, 1)
355 #define dumpwd generic_dump
356 #define dumphh generic_dump
357 #define dumpqqqq generic_dump
358 #define undumpwd generic_undump
359 #define undumphh generic_undump
360 #define undumpqqqq generic_undump
362 /* `dump_int' is called with constant integers, so we put them into a
367 integer x_val = (x); \
368 generic_dump (x_val); \
372 /* web2c/regfix puts variables in the format file loading into
373 registers. Some compilers aren't willing to take addresses of such
374 variables. So we must kludge. */
375 #if defined(REGFIX) || defined(WIN32)
376 #define undumpint(x) \
380 generic_undump (x_val); \
385 #define undumpint generic_undump
388 /* Handle SyncTeX, if requested */
390 # if defined(__SyncTeX__)
391 # include "synctexdir/synctex-common.h"
392 extern char *generic_synctex_get_current_name(void);