OSDN Git Service

updated all sources.
[putex/putex.git] / src / texsourc / texd.h
1 /* Copyright 2014 Clerk Ma
2
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7
8    This program is distributed in the hope that it will be useful, but
9    WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    General Public License for more details.
12
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16    02110-1301 USA.  */
17
18 #ifndef _YANDYTEX_TEXD_H
19 #define _YANDYTEX_TEXD_H
20 /* headers and pragmas */
21
22 #ifdef _WIN32
23   #pragma warning(disable:4201) // nameless struct/union
24   #pragma warning(disable:4267)
25   #pragma warning(disable:4996) // a function that was marked with deprecated
26   #pragma warning(disable:4701) // potentially uninitialized local variable 'name' used
27   #pragma warning(disable:4135) // conversion between different integral types
28   #pragma warning(disable:4127) // conditional expression is constant
29 #endif
30
31 #include <stdarg.h>
32 #include <setjmp.h>
33 #include <time.h>
34 #include <math.h>
35 #include <signal.h>
36
37 #include <kpathsea/c-auto.h>
38 #include <kpathsea/c-std.h>
39 #include <kpathsea/c-pathmx.h>
40 #include <kpathsea/c-fopen.h>
41 #include <kpathsea/c-ctype.h>
42 #include <kpathsea/c-proto.h>
43 #include <kpathsea/config.h>
44 #include <kpathsea/getopt.h>
45 #include <kpathsea/lib.h>
46 #include <kpathsea/line.h>
47 #include <kpathsea/readable.h>
48 #include <kpathsea/types.h>
49 #include <kpathsea/tex-file.h>
50 #include <kpathsea/variable.h>
51 #include <kpathsea/absolute.h>
52 #ifdef _WIN32
53   #include <kpathsea/win32lib.h>
54 #endif
55 #include "zlib.h"
56 #include "md5.h"
57
58 typedef long long integer;
59 typedef double    glue_ratio;
60 typedef double    real;
61 typedef FILE * alpha_file;
62 typedef FILE * byte_file;
63 typedef FILE * word_file;
64 typedef unsigned char  ASCII_code;
65 typedef unsigned short KANJI_code;
66 typedef unsigned char  eight_bits;
67 typedef unsigned short sixteen_bits;
68 typedef integer pool_pointer;
69 typedef integer str_number;
70 typedef unsigned char packed_ASCII_code;
71 typedef integer scaled;
72 typedef integer nonnegative_integer;
73 typedef unsigned char small_number;
74
75 #ifdef link
76   #undef link
77 #endif
78
79 //#define abs(x)   ((integer)(x) >= 0 ? (integer)(x) : (integer)-(x))
80 //#define fabs(x)  ((x) >= 0.0 ? (x) : -(x))
81 #define chr(x)   (x)
82 #define odd(x)   ((x) % 2)
83 #define round(x) web2c_round((double) (x))
84 #define decr(x)  --(x)
85 #define incr(x)  ++(x)
86 #define toint(x) ((integer) (x))
87
88 EXTERN integer web2c_round (double r);
89 EXTERN boolean open_input  (FILE ** f, kpse_file_format_type file_fmt, const char * fopen_mode);
90 EXTERN boolean open_output (FILE ** f, const char * fopen_mode);
91 EXTERN int check_fclose    (FILE * f);
92
93 #define show_line(str, flag) (void) fputs(str, stdout)
94
95 #define wterm(s)    (void) putc(s, stdout)
96 #define wlog(s)     (void) putc(s, log_file)
97 #define wterm_cr()  (void) putc('\n', stdout);
98 #define wlog_cr()   (void) putc('\n', log_file);
99
100 enum
101 {
102   out_dvi_flag = (1 << 0),
103   out_pdf_flag = (1 << 1),
104   out_xdv_flag = (1 << 2),
105   out_dpx_flag = (1 << 3),
106 };
107
108 EXTERN boolean input_line (FILE * f);
109 #define input_ln(stream, flag) input_line(stream)
110 /* sec 0027 */
111 #define a_open_in(f, p) open_input  (&(f), p, FOPEN_R_MODE)
112 #define a_open_out(f)   open_output (&(f), FOPEN_W_MODE)
113 #define b_open_in(f)    open_input  (&(f), kpse_tfm_format, FOPEN_RBIN_MODE)
114 #define b_open_out(f)   open_output (&(f), FOPEN_WBIN_MODE)
115 #define w_open_in(f)    open_input  (&(f), kpse_fmt_format, FOPEN_RBIN_MODE)
116 #define w_open_out(f)   open_output (&(f), FOPEN_WBIN_MODE)
117 #define a_close(f)          (void) check_fclose(f)
118 #define b_close         a_close
119 #define w_close         a_close
120 #define gz_w_close      gzclose
121
122 /* If we're running under Unix, use system calls instead of standard I/O
123 to read and write the output files; also, be able to make a core dump. */
124 #ifndef unix
125   #define dumpcore() exit(1)
126 #else /* unix */
127   #define dumpcore abort
128 #endif
129
130 #ifdef COMPACTFORMAT
131 EXTERN int do_dump(char * p, int item_size, int nitems, gzFile out_file);
132 EXTERN int do_undump(char * p, int item_size, int nitems, gzFile out_file);
133 #define dump_file gz_fmt_file
134 #else
135 EXTERN int do_dump(char * p, int item_size, int nitems, FILE * out_file);
136 EXTERN int do_undump(char * p, int item_size, int nitems, FILE * out_file);
137 #define dump_file fmt_file
138 #endif
139
140 #define dumpthings(base, len)           \
141   do_dump   ((char *) &(base), sizeof (base), (int) (len), dump_file)
142
143 #define undumpthings(base, len)         \
144   do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file)
145
146 /* Use the above for all the other dumping and undumping. */
147 #define generic_dump(x)   dumpthings(x, 1)
148 #define generic_undump(x) undumpthings(x, 1)
149
150 #define dump_wd     generic_dump
151 #define undump_wd   generic_undump
152 #define dump_hh     generic_dump
153 #define undump_hh   generic_undump
154 #define dump_qqqq   generic_dump
155 #define undump_qqqq generic_undump
156
157 #define dump_int(x)       \
158 do                        \
159   {                       \
160     integer x_val = (x);  \
161     generic_dump (x_val); \
162   }                       \
163 while (0)
164
165 #define undump_int  generic_undump
166
167 #define undump_size(arg1, arg2, arg3, arg4)                     \
168 do                                                              \
169 {                                                               \
170   undump_int(x);                                                \
171                                                                 \
172   if (x < arg1)                                                 \
173     goto bad_fmt;                                               \
174                                                                 \
175   if (x > arg2)                                                 \
176   {                                                             \
177     fprintf(stdout, "%s%s\n", "---! Must increase the " , arg3);\
178     goto bad_fmt;                                               \
179   }                                                             \
180   else                                                          \
181     arg4 = x;                                                   \
182 }                                                               \
183 while (0)
184
185 #endif