OSDN Git Service

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