Back to index

tetex-bin  3.0
texmfmp.h
Go to the documentation of this file.
00001 /* texmf.h: Main include file for TeX and Metafont in C. This file is
00002    included by {tex,mf}d.h, which is the first include in the C files
00003    output by web2c.  */
00004 
00005 #include "cpascal.h"
00006 #include <kpathsea/c-pathch.h> /* for IS_DIR_SEP, used in the change files */
00007 #include <kpathsea/tex-make.h> /* for kpse_make_tex_discard_errors */
00008 
00009 /* If we have these macros, use them, as they provide a better guide to
00010    the endianess when cross-compiling. */
00011 #if defined (BYTE_ORDER) && defined (BIG_ENDIAN) && defined (LITTLE_ENDIAN)
00012 #ifdef WORDS_BIGENDIAN
00013 #undef WORDS_BIGENDIAN
00014 #endif
00015 #if BYTE_ORDER == BIG_ENDIAN
00016 #define WORDS_BIGENDIAN
00017 #endif
00018 #endif
00019 /* More of the same, but now NeXT-specific. */
00020 #ifdef NeXT
00021 #ifdef WORDS_BIGENDIAN
00022 #undef WORDS_BIGENDIAN
00023 #endif
00024 #ifdef __BIG_ENDIAN__
00025 #define WORDS_BIGENDIAN
00026 #endif
00027 #endif
00028 
00029 /* Some things are the same except for the name.  */
00030 #ifdef TeX
00031 #if defined (pdfeTeX)
00032 #define TEXMFPOOLNAME "pdfetex.pool"
00033 #define TEXMFENGINENAME "pdfetex"
00034 #elif defined (pdfxTeX)
00035 #define TEXMFPOOLNAME "pdfxtex.pool"
00036 #define TEXMFENGINENAME "pdfxtex"
00037 #elif defined (pdfTeX)
00038 #define TEXMFPOOLNAME "pdftex.pool"
00039 #define TEXMFENGINENAME "pdftex"
00040 #elif defined (eTeX)
00041 #define TEXMFPOOLNAME "etex.pool"
00042 #define TEXMFENGINENAME "etex"
00043 #elif defined (Omega)
00044 #define TEXMFPOOLNAME "omega.pool"
00045 #define TEXMFENGINENAME "omega"
00046 #elif defined (eOmega)
00047 #define TEXMFPOOLNAME "eomega.pool"
00048 #define TEXMFENGINENAME "eomega"
00049 #elif defined (Aleph)
00050 #define TEXMFPOOLNAME "aleph.pool"
00051 #define TEXMFENGINENAME "aleph"
00052 #else
00053 #define TEXMFPOOLNAME "tex.pool"
00054 #define TEXMFENGINENAME "tex"
00055 #endif
00056 #define DUMP_FILE fmtfile
00057 #define DUMP_FORMAT kpse_fmt_format
00058 #define writedvi write_out
00059 #define flushdvi flush_out
00060 #define OUT_FILE dvifile
00061 #define OUT_BUF dvibuf
00062 #endif /* TeX */
00063 #ifdef MF
00064 #define TEXMFPOOLNAME "mf.pool"
00065 #define TEXMFENGINENAME "metafont"
00066 #define DUMP_FILE basefile
00067 #define DUMP_FORMAT kpse_base_format
00068 #define writegf write_out
00069 #define OUT_FILE gffile
00070 #define OUT_BUF gfbuf
00071 #endif /* MF */
00072 #ifdef MP
00073 #define TEXMFPOOLNAME "mp.pool"
00074 #define TEXMFENGINENAME "metapost"
00075 #define DUMP_FILE memfile
00076 #define DUMP_FORMAT kpse_mem_format
00077 #endif /* MP */
00078 
00079 /* Restore underscores.  */
00080 #define kpsedvipsconfigformat kpse_dvips_config_format
00081 #define kpsefontmapformat kpse_fontmap_format
00082 #define kpsemfpoolformat kpse_mfpool_format
00083 #define kpsempformat kpse_mp_format
00084 #define kpsemppoolformat kpse_mppool_format
00085 #define kpsetexpoolformat kpse_texpool_format
00086 #define kpsetexformat kpse_tex_format
00087 
00088 /* Hacks for TeX that are better not to #ifdef, see texmfmp.c.  */
00089 extern int tfmtemp, texinputtype;
00090 
00091 /* TeX, MF and MetaPost use this.  */
00092 extern boolean openinnameok P1H(const_string);
00093 extern boolean openoutnameok P1H(const_string);
00094 
00095 /* All but the Omega family use this. */
00096 #if !defined(Omega) && !defined(eOmega) && !defined(Aleph)
00097 extern void readtcxfile P1H(void);
00098 extern string translate_filename;
00099 #define translatefilename translate_filename
00100 #endif
00101 
00102 #ifdef TeX
00103 /* The type `glueratio' should be a floating point type which won't
00104    unnecessarily increase the size of the memoryword structure.  This is
00105    the basic requirement.  On most machines, if you're building a
00106    normal-sized TeX, then glueratio must probably meet the following
00107    restriction: sizeof(glueratio) <= sizeof(integer).  Usually, then,
00108    glueratio must be `float'.  But if you build a big TeX, you can (on
00109    most machines) and should make it `double' to avoid loss of precision
00110    and conversions to and from double during calculations.  (All this
00111    also goes for Metafont.)  Furthermore, if you have enough memory, it
00112    won't hurt to have this defined to be `double' for running the
00113    trip/trap tests.
00114    
00115    This type is set automatically to `float' by configure if a small TeX
00116    is built.  */
00117 #ifndef GLUERATIO_TYPE
00118 #define GLUERATIO_TYPE double
00119 #endif
00120 typedef GLUERATIO_TYPE glueratio;
00121 
00122 #ifdef IPC
00123 extern void ipcpage P1H(int);
00124 #endif /* IPC */
00125 #endif /* TeX */
00126 
00127 /* How to output to the GF or DVI file.  */
00128 #define       write_out(a, b)                                                \
00129   if (fwrite ((char *) &OUT_BUF[a], sizeof (OUT_BUF[a]),              \
00130                  (int) ((b) - (a) + 1), OUT_FILE)                     \
00131       != (int) ((b) - (a) + 1))                                       \
00132     FATAL_PERROR ("fwrite");
00133 
00134 #define flush_out() fflush (OUT_FILE)
00135 
00136 /* Used to write to a TFM file.  */
00137 #define put2bytes(f, h) do { \
00138     integer v = (integer) (h); putbyte (v >> 8, f);  putbyte (v & 0xff, f); \
00139   } while (0)
00140 #define put4bytes(f, w) do { \
00141     integer v = (integer) (w); \
00142     putbyte (v >> 24, f); putbyte (v >> 16, f); \
00143     putbyte (v >> 8, f);  putbyte (v & 0xff, f); \
00144   } while (0)
00145 
00146 /* Read a line of input as quickly as possible.  */
00147 #define       inputln(stream, flag) input_line (stream)
00148 extern boolean input_line P1H(FILE *);
00149 
00150 /* This routine has to return four values.  */
00151 #define       dateandtime(i,j,k,l) get_date_and_time (&(i), &(j), &(k), &(l))
00152 extern void get_date_and_time P4H(integer *, integer *, integer *, integer *);
00153 
00154 /* This routine has to return a scaled value. */
00155 extern integer getrandomseed P1H(void);
00156 
00157 /* Copy command-line arguments into the buffer, despite the name.  */
00158 extern void topenin P1H(void);
00159 
00160 /* Can't prototype this since it uses poolpointer and ASCIIcode, which
00161    are defined later in mfd.h, and mfd.h uses stuff from here.  */
00162 /* Therefore the department of ugly hacks decided to move this declaration
00163    to the *coerce.h files. */
00164 /* extern void calledit (); */
00165 
00166 /* Set an array size from texmf.cnf.  */
00167 extern void setupboundvariable P3H(integer *, const_string, integer);
00168 
00169 /* `bopenin' (and out) is used only for reading (and writing) .tfm
00170    files; `wopenin' (and out) only for dump files.  The filenames are
00171    passed in as a global variable, `nameoffile'.  */
00172 #define bopenin(f)   open_input (&(f), kpse_tfm_format, FOPEN_RBIN_MODE)
00173 #define ocpopenin(f) open_input (&(f), kpse_ocp_format, FOPEN_RBIN_MODE)
00174 #define ofmopenin(f) open_input (&(f), kpse_ofm_format, FOPEN_RBIN_MODE)
00175 #define bopenout(f)  open_output (&(f), FOPEN_WBIN_MODE)
00176 #define bclose              aclose
00177 #define wopenin(f)   open_input (&(f), DUMP_FORMAT, FOPEN_RBIN_MODE)
00178 #define wopenout     bopenout
00179 #define wclose              aclose
00180 
00181 /* Used in tex.ch (section 1338) to get a core dump in debugging mode.  */
00182 #ifdef unix
00183 #define dumpcore abort
00184 #else
00185 #define dumpcore uexit (1)
00186 #endif
00187 
00188 #ifdef MP
00189 extern boolean callmakempx P2H(string, string);
00190 #endif
00191 
00192 #ifdef MF
00193 extern boolean initscreen P1H(void);
00194 extern void updatescreen P1H(void);
00195 /* Can't prototype these for same reason as `calledit' above.  */
00196 #if 0  /* Therefore the real declaration is found in the coerce.h files.  */
00197 extern void blankrectangle (/*screencol, screencol, screenrow, screenrow*/);
00198 extern void paintrow (/*screenrow, pixelcolor, transspec, screencol*/);
00199 #endif
00200 #endif /* MF */
00201 
00202 /* (Un)dumping.  These are called from the change file.  */
00203 #define       dumpthings(base, len) \
00204   do_dump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
00205 #define       undumpthings(base, len) \
00206   do_undump ((char *) &(base), sizeof (base), (int) (len), DUMP_FILE)
00207 
00208 /* Like do_undump, but check each value against LOW and HIGH.  The
00209    slowdown isn't significant, and this improves the chances of
00210    detecting incompatible format files.  In fact, Knuth himself noted
00211    this problem with Web2c some years ago, so it seems worth fixing.  We
00212    can't make this a subroutine because then we lose the type of BASE.  */
00213 #define undumpcheckedthings(low, high, base, len)                     \
00214   do {                                                                  \
00215     unsigned i;                                                         \
00216     undumpthings (base, len);                                           \
00217     for (i = 0; i < (len); i++) {                                       \
00218       if ((&(base))[i] < (low) || (&(base))[i] > (high)) {              \
00219         FATAL5 ("Item %u (=%ld) of .fmt array at %lx <%ld or >%ld",     \
00220                 i, (integer) (&(base))[i], (unsigned long) &(base),     \
00221                 (integer) low, (integer) high);                         \
00222       }                                                                 \
00223     }                                                          \
00224   } while (0)
00225 
00226 /* Like undump_checked_things, but only check the upper value. We use
00227    this when the base type is unsigned, and thus all the values will be
00228    greater than zero by definition.  */
00229 #define undumpuppercheckthings(high, base, len)                       \
00230   do {                                                                  \
00231     unsigned i;                                                         \
00232     undumpthings (base, len);                                           \
00233     for (i = 0; i < (len); i++) {                                       \
00234       if ((&(base))[i] > (high)) {                             \
00235         FATAL4 ("Item %u (=%ld) of .fmt array at %lx >%ld",           \
00236                 i, (integer) (&(base))[i], (unsigned long) &(base),     \
00237                 (integer) high);                                      \
00238       }                                                                 \
00239     }                                                          \
00240   } while (0)
00241 
00242 /* We define the routines to do the actual work in texmf.c.  */
00243 extern void do_dump P4H(char *, int, int, FILE *);
00244 extern void do_undump P4H(char *, int, int, FILE *);
00245 
00246 /* Use the above for all the other dumping and undumping.  */
00247 #define generic_dump(x) dumpthings (x, 1)
00248 #define generic_undump(x) undumpthings (x, 1)
00249 
00250 #define dumpwd   generic_dump
00251 #define dumphh   generic_dump
00252 #define dumpqqqq generic_dump
00253 #define undumpwd   generic_undump
00254 #define undumphh   generic_undump
00255 #define       undumpqqqq generic_undump
00256 
00257 /* `dump_int' is called with constant integers, so we put them into a
00258    variable first.  */
00259 #define       dumpint(x)                                              \
00260   do                                                           \
00261     {                                                          \
00262       integer x_val = (x);                                     \
00263       generic_dump (x_val);                                    \
00264     }                                                          \
00265   while (0)
00266 
00267 /* web2c/regfix puts variables in the format file loading into
00268    registers.  Some compilers aren't willing to take addresses of such
00269    variables.  So we must kludge.  */
00270 #if defined(REGFIX) || defined(WIN32)
00271 #define undumpint(x)                                           \
00272   do                                                           \
00273     {                                                          \
00274       integer x_val;                                           \
00275       generic_undump (x_val);                                         \
00276       x = x_val;                                               \
00277     }                                                          \
00278   while (0)
00279 #else
00280 #define       undumpint generic_undump
00281 #endif