home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / TeX / common / extra.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-11  |  5.4 KB  |  184 lines

  1. /* Main include file for this implementation.  Everybody includes this.  */
  2.  
  3. #ifndef EXTRA_H
  4. #define EXTRA_H
  5.  
  6. #include <stdio.h>
  7. #include "site.h"
  8. #include "common.h"
  9.  
  10. /* Path searching.  The `...PATH' constants are used both as indices and
  11.    just as enumeration values.  Their values must match the
  12.    initialization of `env_var_names' in extra.c.  The `...PATHBIT'
  13.    constants are used in the argument to `setpaths'.  */
  14. #define BIBINPUTPATH    0
  15. #define BIBINPUTPATHBIT (1 << BIBINPUTPATH)
  16. #define GFFILEPATH    1
  17. #define GFFILEPATHBIT (1 << GFFILEPATH)
  18. #define MFBASEPATH    2
  19. #define MFBASEPATHBIT (1 << MFBASEPATH)
  20. #define MFINPUTPATH    3
  21. #define MFINPUTPATHBIT (1 << MFINPUTPATH)
  22. #define MFPOOLPATH    4
  23. #define MFPOOLPATHBIT (1 << MFPOOLPATH)
  24. #define PKFILEPATH    5
  25. #define PKFILEPATHBIT (1 << PKFILEPATH)
  26. #define TEXFORMATPATH    6
  27. #define TEXFORMATPATHBIT (1 << TEXFORMATPATH)
  28. #define TEXINPUTPATH    7
  29. #define TEXINPUTPATHBIT (1 << TEXINPUTPATH)
  30. #define TEXPOOLPATH    8
  31. #define TEXPOOLPATHBIT (1 << TEXPOOLPATH)
  32. #define TFMFILEPATH    9
  33. #define TFMFILEPATHBIT (1 << TFMFILEPATH)
  34. #define VFFILEPATH     10
  35. #define VFFILEPATHBIT (1 << VFFILEPATH)
  36. #ifdef TEXCONFIG
  37. #define TEXCONFIGPATH     11
  38. #define TEXCONFIGPATHBIT (1 << TEXCONFIGPATH)
  39. #endif
  40.  
  41. /* Globally needed routines we can implement as macros.  */
  42.  
  43. /* Absolute value.  Without the casts to integer here, the Ultrix and
  44.    AIX compilers (at least) produce bad code (or maybe it's that I don't
  45.    understand all the casting rules in C) for tests on memory fields. 
  46.    Specifically, a test in diag_round (in Metafont) on a quarterword
  47.    comes out differently without the cast, thus causing the trap test to
  48.    fail.  (A path at line 86 is constructed slightly differently).  */
  49. /* For atarist: The (integer) cast is unnecessary ...*/
  50. #if defined(atarist) || defined(AMIGA)
  51. # ifdef __GNUC__
  52. #  if defined AMIGA
  53. #   ifndef abs
  54. #    define abs(x)  ((x) >= 0 ? (x) : -(x))
  55. #   endif
  56. #  else
  57. #   include <macros.h>    /* includes generic abs macro */
  58. #  endif
  59. # else
  60. #  ifndef abs
  61. #   define abs(x)  ((x) >= 0 ? (x) : -(x))
  62. #  endif
  63. # endif
  64. #else
  65. # define abs(x)  ((integer) (x) >= 0 ? (integer) (x) : (integer) -(x))
  66. #endif
  67.  
  68. #define    chr(x)        (x)
  69. #define    decr(x)        --(x)
  70. #define eof(f)        test_eof (f)
  71. #define    fabs(x)        ((x) >= 0.0 ? (x) : -(x))
  72. #define flush(f)    (void) fflush (f)
  73. #define    Fputs(f, s)    (void) fputs (s, f)  /* fixwrites outputs this.  */
  74. #define    incr(x)        ++(x)
  75. #define    input3ints(a, b, c)  zinput3ints (&a, &b, &c)
  76. #ifdef __GNUC__
  77. #define    odd(x)        ((x) % 2)
  78. #else
  79. #define    odd(x)        ((x) & 1)
  80. #endif
  81. #define ord(x)        (x)
  82. #define printreal(r, n, m)  fprintreal (stdout, r, n, m)
  83. #define    putbyte(x, f)    putc ((char) (x) & 255, f)
  84. #ifdef atarist
  85.    /* nur mit _binmode(1) !!! */
  86.    /* kein undef, damit GCC einen daran erinnert */
  87. #define getc(fp)    ((--(fp)->_cnt >= 0)?((int)*(fp)->_ptr++):_filbuf(fp))
  88. #endif
  89. #define read(f, b)    ((b) = getc (f))
  90. #define    readln(f)    { register c; \
  91.                           while ((c = getc (f)) != '\n' && c != EOF); }
  92. #if defined(atarist) || defined(AMIGA)
  93. #define    round(x)    ((integer) (((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)))
  94. #else
  95. #define    round(x)    zround ((double) (x))
  96. #endif
  97.  
  98. /* Open files for reading and writing.  */
  99. #define    reset(f, n) \
  100.   ((f) ? fclose (f) : 0), (f) = checked_fopen ((char *) (n), "r")
  101. #define rewrite(f, n) \
  102.   (f) = checked_fopen ((char *) (n), "w")
  103.  
  104. #define    toint(x)    ((integer) (x))
  105.  
  106. /* Pascal's predefined `trunc' routine.  */
  107. #define trunc(x)    ((integer) (x))
  108.  
  109. /* ``Unix exit'', since WEB already defines the symbol `exit'.  */
  110. #define    uexit        exit
  111.  
  112. /* For throwing away input from the file F.  */
  113. #define vgetc(f)    (void) getc (f)
  114.  
  115. /* If we don't care that strcpy(3) returns A.  */
  116. #define vstrcpy(a, b)    (void) strcpy (a, b)
  117.  
  118. /* Write out elements START through END of BUF to the file F.  */
  119. #define writechunk(f, buf, start, end) \
  120.   (void) fwrite (&buf[start], sizeof (buf[start]), end - start + 1, f)
  121.  
  122. /* Like fseek(3), but cast the arguments and ignore the return value.  */
  123. #define checkedfseek(f, n, w)  (void) fseek(f, (long) n, (int) w)
  124.  
  125.  
  126. /* C doesn't distinguish between text files and other files.  */
  127. typedef FILE *text, *file_ptr;
  128.  
  129. /* For some initializations of constant strings.  */
  130. typedef char *ccharpointer;
  131.  
  132. #ifndef TeX
  133. /* We need one global variable.  */
  134. extern integer argc;
  135. #endif
  136.  
  137. /* Routines in extra.c and main.c.  */
  138. #ifdef ANSI
  139. /* extern void argv (int, char[]);        ?????????? */
  140. #ifndef TeX
  141. extern FILE *checked_fopen (char *, char *);
  142. #endif
  143. extern boolean eoln (FILE *);
  144. extern void fprintreal (FILE *, double, int, int);
  145. extern integer inputint (FILE *);
  146. extern char *xmalloc (unsigned long), *xrealloc (char *, unsigned long);
  147. #if !defined(atarist) && !defined(AMIGA)
  148. extern integer zround (double);
  149. #endif
  150. extern FILE *testreadaccess(char *, int);
  151.  
  152. extern void end_with_null(char *);
  153. extern void end_with_space(char *);
  154. #ifdef atarist
  155. extern void replace_slash(char *);
  156. extern void replace_backslash(char *);
  157. #endif
  158. #if defined(atarist) || defined(AMIGA)
  159. extern int get_env_var_index(char *);
  160. #endif
  161. extern void do_path(unsigned, char *);
  162. extern void setpaths(int);
  163.  
  164. #else /* not ANSI */
  165. /* extern void argv ();                ?????????? */
  166. #ifndef TeX
  167. extern FILE *checked_fopen ();
  168. #endif
  169. extern boolean eoln ();
  170. extern void fprintreal ();
  171. extern integer inputint();
  172. extern void fprintreal ();
  173. extern char *xmalloc (), *xrealloc ();
  174. #if !defined(atarist) && !defined(AMIGA)
  175. extern integer zround ();
  176. #endif
  177. extern FILE *testreadaccess();
  178.  
  179. extern void do_path();
  180. extern void setpaths();
  181. #endif /* not ANSI */
  182.  
  183. #endif /* not EXTRA_H */
  184.