OSDN Git Service

fixed call_edit().
[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-pathch.h>
41 #include <kpathsea/c-fopen.h>
42 #include <kpathsea/c-ctype.h>
43 #include <kpathsea/c-proto.h>
44 #include <kpathsea/config.h>
45 #include <kpathsea/getopt.h>
46 #include <kpathsea/lib.h>
47 #include <kpathsea/line.h>
48 #include <kpathsea/readable.h>
49 #include <kpathsea/types.h>
50 #include <kpathsea/tex-file.h>
51 #include <kpathsea/variable.h>
52 #include <kpathsea/absolute.h>
53 #ifdef _WIN32
54   #include <kpathsea/win32lib.h>
55   #include <kpathsea/concatn.h>
56 #endif
57 #include "zlib.h"
58 #include "md5.h"
59
60 typedef long long integer;
61 typedef double    glue_ratio;
62 typedef double    real;
63 typedef FILE * alpha_file;
64 typedef FILE * byte_file;
65 typedef FILE * word_file;
66 typedef unsigned char  ASCII_code;
67 typedef unsigned short KANJI_code;
68 typedef unsigned char  eight_bits;
69 typedef unsigned short sixteen_bits;
70 typedef integer pool_pointer;
71 typedef integer str_number;
72 typedef unsigned char packed_ASCII_code;
73 typedef integer scaled;
74 typedef integer nonnegative_integer;
75 typedef unsigned char small_number;
76
77 #ifdef link
78   #undef link
79 #endif
80
81 //#define abs(x)   ((integer)(x) >= 0 ? (integer)(x) : (integer)-(x))
82 //#define fabs(x)  ((x) >= 0.0 ? (x) : -(x))
83 #define chr(x)   (x)
84 #define odd(x)   ((x) % 2)
85 #define round(x) web2c_round((double) (x))
86 #define decr(x)  --(x)
87 #define incr(x)  ++(x)
88 #define toint(x) ((integer) (x))
89
90 EXTERN integer web2c_round (double r);
91 EXTERN boolean open_input  (FILE ** f, kpse_file_format_type file_fmt, const char * fopen_mode);
92 EXTERN boolean open_output (FILE ** f, const char * fopen_mode);
93 EXTERN int check_fclose    (FILE * f);
94
95 #define show_line(str, flag) (void) fputs(str, stdout)
96
97 #define wterm(s)    (void) putc(s, stdout)
98 #define wlog(s)     (void) putc(s, log_file)
99 #define wterm_cr()  (void) putc('\n', stdout);
100 #define wlog_cr()   (void) putc('\n', log_file);
101
102 enum
103 {
104   out_dvi_flag = (1 << 0),
105   out_pdf_flag = (1 << 1),
106   out_xdv_flag = (1 << 2),
107   out_dpx_flag = (1 << 3),
108 };
109
110 EXTERN boolean input_line (FILE * f);
111 #define input_ln(stream, flag) input_line(stream)
112 /* sec 0027 */
113 #define a_open_in(f, p) open_input  (&(f), p, FOPEN_R_MODE)
114 #define a_open_out(f)   open_output (&(f), FOPEN_W_MODE)
115 #define b_open_in(f)    open_input  (&(f), kpse_tfm_format, FOPEN_RBIN_MODE)
116 #define b_open_out(f)   open_output (&(f), FOPEN_WBIN_MODE)
117 #define w_open_in(f)    open_input  (&(f), kpse_fmt_format, FOPEN_RBIN_MODE)
118 #define w_open_out(f)   open_output (&(f), FOPEN_WBIN_MODE)
119 #define a_close(f)          (void) check_fclose(f)
120 #define b_close         a_close
121 #define w_close         a_close
122 #define gz_w_close      gzclose
123
124 /* If we're running under Unix, use system calls instead of standard I/O
125 to read and write the output files; also, be able to make a core dump. */
126 #ifndef unix
127   #define dumpcore() exit(1)
128 #else /* unix */
129   #define dumpcore abort
130 #endif
131
132 #ifdef COMPACTFORMAT
133 EXTERN int do_dump(char * p, int item_size, int nitems, gzFile out_file);
134 EXTERN int do_undump(char * p, int item_size, int nitems, gzFile out_file);
135 #define dump_file gz_fmt_file
136 #else
137 EXTERN int do_dump(char * p, int item_size, int nitems, FILE * out_file);
138 EXTERN int do_undump(char * p, int item_size, int nitems, FILE * out_file);
139 #define dump_file fmt_file
140 #endif
141
142 #define dumpthings(base, len)           \
143   do_dump   ((char *) &(base), sizeof (base), (int) (len), dump_file)
144
145 #define undumpthings(base, len)         \
146   do_undump ((char *) &(base), sizeof (base), (int) (len), dump_file)
147
148 /* Use the above for all the other dumping and undumping. */
149 #define generic_dump(x)   dumpthings(x, 1)
150 #define generic_undump(x) undumpthings(x, 1)
151
152 #define dump_wd     generic_dump
153 #define undump_wd   generic_undump
154 #define dump_hh     generic_dump
155 #define undump_hh   generic_undump
156 #define dump_qqqq   generic_dump
157 #define undump_qqqq generic_undump
158
159 #define dump_int(x)       \
160 do                        \
161   {                       \
162     integer x_val = (x);  \
163     generic_dump (x_val); \
164   }                       \
165 while (0)
166
167 #define undump_int  generic_undump
168
169 #define undump_size(arg1, arg2, arg3, arg4)                     \
170 do                                                              \
171 {                                                               \
172   undump_int(x);                                                \
173                                                                 \
174   if (x < arg1)                                                 \
175     goto bad_fmt;                                               \
176                                                                 \
177   if (x > arg2)                                                 \
178   {                                                             \
179     fprintf(stdout, "%s%s\n", "---! Must increase the " , arg3);\
180     goto bad_fmt;                                               \
181   }                                                             \
182   else                                                          \
183     arg4 = x;                                                   \
184 }                                                               \
185 while (0)
186
187 #endif