Back to index

tetex-bin  3.0
util.h
Go to the documentation of this file.
00001 /* $XConsortium: util.h,v 1.3 92/03/26 16:42:29 eswu Exp $ */
00002 /* Copyright International Business Machines,Corp. 1991
00003  * All Rights Reserved
00004  *
00005  * License to use, copy, modify, and distribute this software
00006  * and its documentation for any purpose and without fee is
00007  * hereby granted, provided that the above copyright notice
00008  * appear in all copies and that both that copyright notice and
00009  * this permission notice appear in supporting documentation,
00010  * and that the name of IBM not be used in advertising or
00011  * publicity pertaining to distribution of the software without
00012  * specific, written prior permission.
00013  *
00014  * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
00015  * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
00016  * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
00018  * THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE QUALITY AND
00019  * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF
00021  * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
00022  * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN
00023  * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00024  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
00025  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
00026  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00027  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00028  * SOFTWARE.
00029  */
00030 #ifndef UTIL_H
00031 #define UTIL_H
00032 #include "types.h" 
00033  
00034 #ifndef KPATHSEA
00035 #ifndef boolean
00036 typedef int boolean;
00037 #endif
00038 #endif
00039  
00040 #ifndef TRUE
00041 #define TRUE (1)
00042 #endif
00043  
00044 #ifndef FALSE
00045 #define FALSE (0)
00046 #endif
00047  
00048 /***================================================================***/
00049 /* Portable definitions for 2's complement machines.
00050  * NOTE: These really should be based on PostScript types,
00051  * for example, sizeof(ps_integer), or sizeof(ps_unsigned)
00052  */
00053 #define MAX_ULONG             (~(ULONG)(0))
00054 /* This code is portable, assuming K&R C and 2's complement arithmetic */
00055 #define MAX_INTEGER      \
00056      ((LONG)((((ULONG) 1)<<(sizeof(ULONG)*8-1))-1))
00057 #define MIN_INTEGER           ((-MAX_INTEGER)-1)
00058  
00059 #define MAX_ARRAY_CNT         (65535)
00060 #define MAX_DICT_CNT          (65535)
00061 #define MAX_STRING_LEN        (65535)
00062 #define MAX_NAME_LEN          (128)
00063  
00064 /* this is the size of memory allocated for reading fonts */
00065  
00066 #define VM_SIZE               (50*1024)
00067 /***================================================================***/
00068  
00069 #ifndef MIN
00070 #define   MIN(a,b)   (((a)<(b)) ? a : b )
00071 #endif
00072  
00073 /***================================================================***/
00074 /*  Routines for managing virtual memory                              */
00075 /***================================================================***/
00076 extern boolean  vm_init();
00077 extern LONG     vm_free;
00078 extern LONG     vm_size;
00079 extern char    *vm_next;
00080 extern char    *vm_alloc();
00081 /***================================================================***/
00082 /*  Macros for managing virtual memory                                */
00083 /***================================================================***/
00084 #define vm_next_byte()  (vm_next)
00085 #define vm_free_bytes()  (vm_free)
00086 #define vm_avail(B)     (B <= vm_free)
00087  
00088  
00089  
00090 /***================================================================***/
00091 /* Types of PostScript objects */
00092 /***================================================================***/
00093 #define OBJ_INTEGER    (0)
00094 #define OBJ_REAL       (1)
00095 #define OBJ_BOOLEAN    (2)
00096 #define OBJ_ARRAY      (3)
00097 #define OBJ_STRING     (4)
00098 #define OBJ_NAME       (5)
00099 #define OBJ_FILE       (6)
00100 #define OBJ_ENCODING   (7)
00101  
00102 /***================================================================***/
00103 /* Value of PostScript objects */
00104 /***================================================================***/
00105 typedef union ps_value {
00106   char            *valueP;     /* value pointer for unspecified type */
00107   int              value;      /* value for unspecified type         */
00108   int              integer;    /* when type is OBJ_INTEGER           */
00109   float            real;       /* when type is OBJ_REAL              */
00110   int              boolean;    /* when type is OBJ_BOOLEAN           */
00111   struct ps_obj   *arrayP;     /* when type is OBJ_ARRAY             */
00112   unsigned char   *stringP;    /* when type is OBJ_STRING            */
00113   char            *nameP;      /* when type is OBJ_NAME              */
00114   FILE            *fileP;      /* when type is OBJ_FILE              */
00115 } psvalue;
00116  
00117 /***================================================================***/
00118 /* Definition of a PostScript object */
00119 /***================================================================***/
00120 typedef struct ps_obj {
00121   char type;
00122   char unused;
00123   unsigned short len;
00124   union ps_value data;
00125 } psobj;
00126  
00127 /***================================================================***/
00128 /*     Definition of a PostScript Dictionary Entry */
00129 /***================================================================***/
00130 typedef struct ps_dict {
00131   psobj   key;
00132   psobj   value;
00133 } psdict;
00134  
00135 /***================================================================***/
00136 /* Macros for testing type of PostScript objects */
00137 /***================================================================***/
00138 #define objIsInteger(o)          ((o).type == OBJ_INTEGER)
00139 #define objIsReal(o)             ((o).type == OBJ_REAL)
00140 #define objIsBoolean(o)          ((o).type == OBJ_BOOLEAN)
00141 #define objIsArray(o)            ((o).type == OBJ_ARRAY)
00142 #define objIsString(o)           ((o).type == OBJ_STRING)
00143 #define objIsName(o)             ((o).type == OBJ_NAME)
00144 #define objIsFile(o)             ((o).type == OBJ_FILE)
00145  
00146 /***================================================================***/
00147 /* Macros for setting type of PostScript objects */
00148 /***================================================================***/
00149 #define objSetInteger(o)         ((o).type = OBJ_INTEGER)
00150 #define objSetReal(o)            ((o).type = OBJ_REAL)
00151 #define objSetBoolean(o)         ((o).type = OBJ_BOOLEAN)
00152 #define objSetArray(o)           ((o).type = OBJ_ARRAY)
00153 #define objSetString(o)          ((o).type = OBJ_STRING)
00154 #define objSetName(o)            ((o).type = OBJ_NAME)
00155 #define objSetFile(o)            ((o).type = OBJ_FILE)
00156  
00157 /***================================================================***/
00158 /* Macros for testing type of PostScript objects (pointer access) */
00159 /***================================================================***/
00160 #define objPIsInteger(o)         ((o)->type == OBJ_INTEGER)
00161 #define objPIsReal(o)            ((o)->type == OBJ_REAL)
00162 #define objPIsBoolean(o)         ((o)->type == OBJ_BOOLEAN)
00163 #define objPIsArray(o)           ((o)->type == OBJ_ARRAY)
00164 #define objPIsString(o)          ((o)->type == OBJ_STRING)
00165 #define objPIsName(o)            ((o)->type == OBJ_NAME)
00166 #define objPIsFile(o)            ((o)->type == OBJ_FILE)
00167  
00168 /***================================================================***/
00169 /* Macros for setting type of PostScript objects (pointer access) */
00170 /***================================================================***/
00171 #define objPSetInteger(o)        ((o)->type = OBJ_INTEGER)
00172 #define objPSetReal(o)           ((o)->type = OBJ_REAL)
00173 #define objPSetBoolean(o)        ((o)->type = OBJ_BOOLEAN)
00174 #define objPSetArray(o)          ((o)->type = OBJ_ARRAY)
00175 #define objPSetString(o)         ((o)->type = OBJ_STRING)
00176 #define objPSetName(o)           ((o)->type = OBJ_NAME)
00177 #define objPSetFile(o)           ((o)->type = OBJ_FILE)
00178  
00179 /***================================================================***/
00180 /* Entry point for Type1Char to get entry from CharStrings            */
00181 /***================================================================***/
00182 extern psobj *GetType1CharString();
00183  
00184 #endif