Debian Codegraph @

texk/dvipsk/ptexmac.h

raw
1 /*
2 Copyright (c) 1996-2012 Han The Thanh, <[email protected]>
3
4 This file is part of pdfTeX.
5
6 pdfTeX is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 pdfTeX is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with pdfTeX; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 $Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/ptexmac.h#18 $
21 */
22
23 #ifndef PDFTEXMAC
24 #define PDFTEXMAC
25
26 #ifdef WIN32
27 // Why relying on gmalloc() ???
28 #define gmalloc(n) xmalloc(n)
29 #define gfree(p) free(p)
30 #define inline __inline
31 #define srandom(n) srand(n)
32 #define random() rand()
33 #endif
34
35 /* Pascal WEB macros */
36 #define maxinteger 0x7FFFFFFF
37 #define maxdimen 0x3FFFFFFF
38
39 #define objinfo(n) objtab[n].int0
40
41 #define pdfroom(n) do { \
42 if (pdfbufsize < n) \
43 pdftex_fail("PDF output buffer overflowed"); \
44 if (pdfptr + n > pdfbufsize) \
45 pdfflush(); \
46 } while (0)
47
48 #define pdfout(c) do { \
49 if (pdfptr > pdfbufsize) \
50 pdfflush(); \
51 pdfbuf[pdfptr++] = c; \
52 } while (0)
53
54 #define pdfoffset() (pdfgone + pdfptr)
55 #define pdfinitfont(f) {tmpf = f; pdfcreatefontobj();}
56
57 #define MAX_CHAR_CODE 255
58
59 #define PRINTF_BUF_SIZE 1024
60 #define MAX_CSTRING_LEN 1024
61 #define MAX_PSTRING_LEN 1024
62 #define SMALL_BUF_SIZE 256
63 #define SMALL_ARRAY_SIZE 256
64 #define FONTNAME_BUF_SIZE 128 /* a PDF name can be maximum 127 chars long */
65
66 #define check_buf(size, buf_size) \
67 if ((size) > (buf_size)) \
68 pdftex_fail("buffer overflow", (buf_size))
69
70 #define append_char_to_buf(c, p, buf, buf_size) do { \
71 if (c == 9) \
72 c = 32; \
73 if (c == 13 || c == EOF) \
74 c = 10; \
75 if (c != ' ' || (p > buf && p[-1] != 32)) { \
76 check_buf(p - buf + 1, (buf_size)); \
77 *p++ = c; \
78 } \
79 } while (0)
80
81 #define append_eol(p, buf, buf_size) do { \
82 check_buf(p - buf + 2, (buf_size)); \
83 if (p - buf > 1 && p[-1] != 10) \
84 *p++ = 10; \
85 if (p - buf > 2 && p[-2] == 32) { \
86 p[-2] = 10; \
87 p--; \
88 } \
89 *p = 0; \
90 } while (0)
91
92 #define remove_eol(p, buf) do { \
93 p = strend(buf) - 1; \
94 if (*p == 10) \
95 *p = 0; \
96 } while (0)
97
98 #define skip(p, c) if (*p == c) p++
99
100 #define alloc_array(T, n, s) do { \
101 if (T##_array == NULL) { \
102 T##_limit = (s); \
103 if ((n) > T##_limit) \
104 T##_limit = (n); \
105 T##_array = xtalloc(T##_limit, T##_entry); \
106 T##_ptr = T##_array; \
107 } \
108 else if (T##_ptr - T##_array + (n) > T##_limit) { \
109 last_ptr_index = T##_ptr - T##_array; \
110 T##_limit *= 2; \
111 if (T##_ptr - T##_array + (n) > T##_limit) \
112 T##_limit = T##_ptr - T##_array + (n); \
113 xretalloc(T##_array, T##_limit, T##_entry); \
114 T##_ptr = T##_array + last_ptr_index; \
115 } \
116 } while (0)
117
118 #define is_cfg_comment(c) \
119 (c == 10 || c == '*' || c == '#' || c == ';' || c == '%')
120
121 #define define_array(T) \
122 T##_entry *T##_ptr, *T##_array = NULL; \
123 size_t T##_limit
124
125 #define xfree(p) do { if (p != NULL) free(p); p = NULL; } while (0)
126 #define strend(s) strchr(s, 0)
127 #define xtalloc XTALLOC
128 #define xretalloc XRETALLOC
129
130 #define ASCENT_CODE 0
131 #define CAPHEIGHT_CODE 1
132 #define DESCENT_CODE 2
133 #define FONTNAME_CODE 3
134 #define ITALIC_ANGLE_CODE 4
135 #define STEMV_CODE 5
136 #define XHEIGHT_CODE 6
137 #define FONTBBOX1_CODE 7
138 #define FONTBBOX2_CODE 8
139 #define FONTBBOX3_CODE 9
140 #define FONTBBOX4_CODE 10
141 #define MAX_KEY_CODE (FONTBBOX1_CODE + 1)
142 #define FONT_KEYS_NUM (FONTBBOX4_CODE + 1)
143
144 #define F_INCLUDED 0x01
145 #define F_SUBSETTED 0x02
146 #define F_TRUETYPE 0x04
147 #define F_BASEFONT 0x08
148
149 #define set_included(fm) ((fm)->type |= F_INCLUDED)
150 #define set_subsetted(fm) ((fm)->type |= F_SUBSETTED)
151 #define set_truetype(fm) ((fm)->type |= F_TRUETYPE)
152 #define set_basefont(fm) ((fm)->type |= F_BASEFONT)
153
154 #define unset_included(fm) ((fm)->type &= ~F_INCLUDED)
155 #define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED)
156 #define unset_truetype(fm) ((fm)->type &= ~F_TRUETYPE)
157 #define unset_basefont(fm) ((fm)->type &= ~F_BASEFONT)
158
159 #define unset_fontfile(fm) xfree((fm)->ff_name)
160
161 #define is_included(fm) ((fm)->type & F_INCLUDED)
162 #define is_subsetted(fm) ((fm)->type & F_SUBSETTED)
163 #define is_truetype(fm) ((fm)->type & F_TRUETYPE)
164 #define is_basefont(fm) ((fm)->type & F_BASEFONT)
165 #define no_font_desc(fm) (is_basefont(fm) && !is_included(fm))
166
167 #define fm_slant(fm) (fm)->slant
168 #define fm_extend(fm) (fm)->extend
169 #define fm_fontfile(fm) (fm)->ff_name
170
171 #define is_reencoded(fm) ((fm)->encoding != NULL)
172 #define is_fontfile(fm) (fm_fontfile(fm) != NULL)
173 #define is_t1fontfile(fm) (is_fontfile(fm) && !is_truetype(fm))
174
175 #define LINK_TFM 0x01
176 #define LINK_PS 0x02
177 #define set_tfmlink(fm) ((fm)->links |= LINK_TFM)
178 #define set_pslink(fm) ((fm)->links |= LINK_PS)
179 #define unset_tfmlink(fm) ((fm)->links &= ~LINK_TFM)
180 #define unset_pslink(fm) ((fm)->links &= ~LINK_PS)
181 #define has_tfmlink(fm) ((fm)->links & LINK_TFM)
182 #define has_pslink(fm) ((fm)->links & LINK_PS)
183
184
185 #define set_cur_file_name(s) \
186 cur_file_name = s; \
187 packfilename(maketexstring(cur_file_name), getnullstr(), getnullstr())
188
189 #endif /* PDFTEXMAC */