Back to index

tetex-bin  3.0
ptexmac.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 1996-2004 Han The Thanh, <thanh@pdftex.org>
00003 
00004 This file is part of pdfTeX.
00005 
00006 pdfTeX is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 pdfTeX is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with pdfTeX; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 $Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/ptexmac.h#14 $
00021 */
00022 
00023 #ifndef PDFTEXMAC
00024 #define PDFTEXMAC
00025 
00026 /* Not all systems define it. */
00027 #ifndef M_PI
00028 #define M_PI           3.14159265358979323846   /* pi */
00029 #define M_PI_2         1.5707963267948966192E0  /*Hex  2^ 0 * 1.921FB54442D18 */
00030 #define M_PI_4         7.8539816339744830962E-1 /*Hex  2^-1 * 1.921FB54442D18 */
00031 #endif
00032 
00033 #ifdef WIN32
00034 // Why relying on gmalloc() ???
00035 #define gmalloc(n) xmalloc(n)
00036 #define gfree(p) free(p)
00037 #define inline __inline
00038 #define srandom(n) srand(n)
00039 #define random() rand()
00040 #endif
00041 
00042 /* Pascal WEB macros */
00043 #define maxinteger 0x7FFFFFFF
00044 #define maxdimen   0x3FFFFFFF
00045 
00046 #define objinfo(n) objtab[n].int0
00047 
00048 #define pdfroom(n) do {                                 \
00049     if (pdfbufsize < n)                                 \
00050         pdftex_fail("PDF output buffer overflowed");    \
00051     if (pdfptr + n > pdfbufsize)                        \
00052         pdfflush();                                     \
00053 } while (0)
00054 
00055 #define pdfout(c)  do {             \
00056     if (pdfptr > pdfbufsize)        \
00057         pdfflush();                 \
00058     pdfbuf[pdfptr++] = c;           \
00059 } while (0)
00060 
00061 #define pdfoffset()     (pdfgone + pdfptr)
00062 #define pdfinitfont(f)  {tmpf = f; pdfcreatefontobj();}
00063 
00064 #define pdfmovechars        getintpar(cfgmovecharscode)
00065 
00066 #define MAX_CHAR_CODE       255
00067 #define MOVE_CHARS_OFFSET   160
00068 
00069 #define PRINTF_BUF_SIZE     1024
00070 #define MAX_CSTRING_LEN     1024
00071 #define MAX_PSTRING_LEN     1024
00072 #define SMALL_BUF_SIZE      256
00073 #define SMALL_ARRAY_SIZE    256
00074 #define FONTNAME_BUF_SIZE   128 /* a PDF name can be maximum 127 chars long */
00075 
00076 #define check_buf(size, buf_size)                          \
00077     if ((size) > (buf_size))                               \
00078         pdftex_fail("buffer overflow", (buf_size))
00079 
00080 #define append_char_to_buf(c, p, buf, buf_size) do {       \
00081     if (c == 9)                                            \
00082         c = 32;                                            \
00083     if (c == 13 || c == EOF)                               \
00084         c = 10;                                            \
00085     if (c != ' ' || (p > buf && p[-1] != 32)) {            \
00086         check_buf(p - buf + 1, (buf_size));                \
00087         *p++ = c;                                          \
00088     }                                                      \
00089 } while (0)
00090 
00091 #define append_eol(p, buf, buf_size) do {                  \
00092     check_buf(p - buf + 2, (buf_size));                    \
00093     if (p - buf > 1 && p[-1] != 10)                        \
00094         *p++ = 10;                                         \
00095     if (p - buf > 2 && p[-2] == 32) {                      \
00096         p[-2] = 10;                                        \
00097         p--;                                               \
00098     }                                                      \
00099     *p = 0;                                                \
00100 } while (0)
00101 
00102 #define remove_eol(p, buf) do {                            \
00103     p = strend(buf) - 1;                                   \
00104     if (*p == 10)                                          \
00105         *p = 0;                                            \
00106 } while (0)
00107 
00108 #define skip(p, c)   if (*p == c)  p++
00109 
00110 #define alloc_array(T, n, s) do {                           \
00111     if (T##_array == NULL) {                                   \
00112         T##_limit = (s);                                    \
00113         if ((n) > T##_limit)                                \
00114             T##_limit = (n);                                \
00115         T##_array = xtalloc(T##_limit, T##_entry);          \
00116         T##_ptr = T##_array;                                \
00117     }                                                       \
00118     else if (T##_ptr - T##_array + (n) > T##_limit) {       \
00119         last_ptr_index = T##_ptr - T##_array;               \
00120         T##_limit *= 2;                                     \
00121         if (T##_ptr - T##_array + (n) > T##_limit)          \
00122             T##_limit = T##_ptr - T##_array + (n);          \
00123         T##_array = xretalloc(T##_array, T##_limit, T##_entry); \
00124         T##_ptr = T##_array + last_ptr_index;               \
00125     }                                                       \
00126 } while (0)
00127 
00128 #define is_cfg_comment(c) \
00129     (c == 10 || c == '*' || c == '#' || c == ';' || c == '%')
00130 
00131 #define define_array(T)                     \
00132 T##_entry      *T##_ptr, *T##_array = NULL;    \
00133 size_t          T##_limit
00134 
00135 #define xfree(p)            do { if (p != NULL) free(p); p = NULL; } while (0)
00136 #define strend(s)           strchr(s, 0)
00137 #define xtalloc             XTALLOC
00138 #define xretalloc           XRETALLOC
00139 
00140 #define ASCENT_CODE         0
00141 #define CAPHEIGHT_CODE      1
00142 #define DESCENT_CODE        2
00143 #define FONTNAME_CODE       3
00144 #define ITALIC_ANGLE_CODE   4
00145 #define STEMV_CODE          5
00146 #define XHEIGHT_CODE        6
00147 #define FONTBBOX1_CODE      7
00148 #define FONTBBOX2_CODE      8
00149 #define FONTBBOX3_CODE      9
00150 #define FONTBBOX4_CODE      10
00151 #define MAX_KEY_CODE        (FONTBBOX1_CODE + 1)
00152 #define FONT_KEYS_NUM       (FONTBBOX4_CODE + 1)
00153 
00154 #define F_INCLUDED          0x01
00155 #define F_SUBSETTED         0x02
00156 #define F_TRUETYPE          0x04
00157 #define F_BASEFONT          0x08
00158 
00159 #define set_included(fm)    ((fm)->type |= F_INCLUDED)
00160 #define set_subsetted(fm)   ((fm)->type |= F_SUBSETTED)
00161 #define set_truetype(fm)    ((fm)->type |= F_TRUETYPE)
00162 #define set_basefont(fm)    ((fm)->type |= F_BASEFONT)
00163 
00164 #define unset_included(fm)  ((fm)->type &= ~F_INCLUDED)
00165 #define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED)
00166 #define unset_truetype(fm)  ((fm)->type &= ~F_TRUETYPE)
00167 #define unset_basefont(fm)  ((fm)->type &= ~F_BASEFONT)
00168 
00169 #define unset_fontfile(fm)  xfree((fm)->ff_name)
00170 
00171 #define is_included(fm)     ((fm)->type & F_INCLUDED)
00172 #define is_subsetted(fm)    ((fm)->type & F_SUBSETTED)
00173 #define is_truetype(fm)     ((fm)->type & F_TRUETYPE)
00174 #define is_basefont(fm)     ((fm)->type & F_BASEFONT)
00175 
00176 #define fm_slant(fm)        (fm)->slant
00177 #define fm_extend(fm)       (fm)->extend
00178 #define fm_fontfile(fm)     (fm)->ff_name
00179 
00180 #define is_reencoded(fm)    ((fm)->encoding != NULL)
00181 #define is_fontfile(fm)     (fm_fontfile(fm) != NULL)
00182 #define is_t1fontfile(fm)   (is_fontfile(fm) && !is_truetype(fm))
00183 
00184 #define LINK_TFM            0x01
00185 #define LINK_PS             0x02
00186 #define set_tfmlink(fm)     ((fm)->links |= LINK_TFM)
00187 #define set_pslink(fm)      ((fm)->links |= LINK_PS)
00188 #define unset_tfmlink(fm)   ((fm)->links &= ~LINK_TFM)
00189 #define unset_pslink(fm)    ((fm)->links &= ~LINK_PS)
00190 #define has_tfmlink(fm)     ((fm)->links & LINK_TFM)
00191 #define has_pslink(fm)      ((fm)->links & LINK_PS)
00192 
00193 
00194 #define set_cur_file_name(s)      \
00195     cur_file_name = s;      \
00196     packfilename(maketexstring(cur_file_name), getnullstr(), getnullstr())
00197 
00198 #endif  /* PDFTEXMAC */