3
Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
4
Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
6
This file is part of LuaTeX.
8
LuaTeX is free software; you can redistribute it and/or modify it under
9
the terms of the GNU General Public License as published by the Free
10
Software Foundation; either version 2 of the License, or (at your
11
option) any later version.
13
LuaTeX is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16
License for more details.
18
You should have received a copy of the GNU General Public License along
19
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
21
/* $Id: ptexmac.h 2333 2009-04-18 17:45:46Z hhenkel $ */
26
/* Not all systems define it. */
28
# define M_PI 3.14159265358979323846
30
# define M_PI_2 1.5707963267948966192E0
31
/* Hex 2^ 0 * 1.921FB54442D18 */
32
# define M_PI_4 7.8539816339744830962E-1
33
/* Hex 2^-1 * 1.921FB54442D18 */
37
/* Why relying on gmalloc() ???*/
38
# define gmalloc(n) xmalloc(n)
39
# define gfree(p) free(p)
40
# define inline __inline
41
# define srandom(n) srand(n)
42
# define random() rand()
45
/**********************************************************************/
46
/* Pascal WEB macros */
48
# define max_integer 0x7FFFFFFF
49
# define max_dimen 0x3FFFFFFF
51
# define obj_info(a) obj_tab[(a)].int0
52
# define obj_link(a) obj_tab[(a)].int1
53
# define obj_offset(a) obj_tab[(a)].int2
54
# define obj_os_idx(a) obj_tab[(a)].int3
55
# define obj_aux(a) obj_tab[(a)].int4
56
# define obj_data_ptr obj_aux
58
/* types of objects */
59
# define obj_type_others 0 /* objects which are not linked in any list */
60
# define obj_type_page 1 /* index of linked list of Page objects */
61
# define obj_type_font 2 /* index of linked list of Fonts objects */
62
# define obj_type_outline 3 /* index of linked list of outline objects */
63
# define obj_type_dest 4 /* index of linked list of destination objects */
64
# define obj_type_obj 5 /* index of linked list of raw objects */
65
# define obj_type_xform 6 /* index of linked list of XObject forms */
66
# define obj_type_ximage 7 /* index of linked list of XObject image */
67
# define obj_type_thread 8 /* index of linked list of num article threads */
68
# define head_tab_max obj_type_thread /* max index of |head_tab| */
70
# define pdfroom(n) do { \
71
if ((unsigned)(n + pdf_ptr) > (unsigned)pdf_buf_size) { \
73
zpdf_os_get_os_buf(n); \
75
if ((unsigned)(n) > (unsigned)pdf_buf_size) \
76
pdftex_fail("PDF output buffer overflowed"); \
83
# define pdfout(c) do { \
85
pdf_buf[pdf_ptr++] = c; \
88
# define pdfoffset() (pdf_gone + pdf_ptr)
90
/**********************************************************************/
92
# define PRINTF_BUF_SIZE 1024
93
# define MAX_CSTRING_LEN 1024 * 1024
94
# define MAX_PSTRING_LEN 1024
95
# define SMALL_BUF_SIZE 256
96
# define SMALL_ARRAY_SIZE 256
98
# define check_buf(size, buf_size) \
99
if ((unsigned)(size) > (unsigned)(buf_size)) \
100
pdftex_fail("buffer overflow: %d > %d at file %s, line %d", \
101
(int)(size), (int)(buf_size), __FILE__, __LINE__ )
103
# define append_char_to_buf(c, p, buf, buf_size) do { \
106
if (c == 13 || c == EOF) \
108
if (c != ' ' || (p > buf && p[-1] != 32)) { \
109
check_buf(p - buf + 1, (buf_size)); \
114
# define append_eol(p, buf, buf_size) do { \
115
check_buf(p - buf + 2, (buf_size)); \
116
if (p - buf > 1 && p[-1] != 10) \
118
if (p - buf > 2 && p[-2] == 32) { \
125
# define remove_eol(p, buf) do { \
126
p = strend(buf) - 1; \
131
# define skip(p, c) if (*p == c) p++
133
# define alloc_array(T, n, s) do { \
134
if (T##_array == NULL) { \
136
if ((unsigned)(n) > T##_limit) \
138
T##_array = xtalloc(T##_limit, T##_entry); \
139
T##_ptr = T##_array; \
141
else if ((unsigned)(T##_ptr - T##_array + (n)) > (unsigned)(T##_limit)) { \
142
last_ptr_index = T##_ptr - T##_array; \
144
if ((unsigned)(T##_ptr - T##_array + (n)) > (unsigned)(T##_limit)) \
145
T##_limit = T##_ptr - T##_array + (n); \
146
xretalloc(T##_array, T##_limit, T##_entry); \
147
T##_ptr = T##_array + last_ptr_index; \
151
# define define_array(T) \
152
T##_entry *T##_ptr, *T##_array = NULL; \
155
# define xfree(p) do { if (p != NULL) free(p); p = NULL; } while (0)
156
# define strend(s) strchr(s, 0)
157
# define xtalloc XTALLOC
158
# define xretalloc XRETALLOC
160
# define set_cur_file_name(s) \
162
pack_file_name(maketexstring(cur_file_name), get_nullstr(), get_nullstr())
164
# define cmp_return(a, b) \
170
# define str_prefix(s1, s2) (strncmp((s1), (s2), strlen(s2)) == 0)
172
#endif /* PTEXMAC_H */