1 /* $XConsortium: util.h,v 1.3 92/03/26 16:42:29 eswu Exp $ */
2 /* Copyright International Business Machines,Corp. 1991
5 * License to use, copy, modify, and distribute this software
6 * and its documentation for any purpose and without fee is
7 * hereby granted, provided that the above copyright notice
8 * appear in all copies and that both that copyright notice and
9 * this permission notice appear in supporting documentation,
10 * and that the name of IBM not be used in advertising or
11 * publicity pertaining to distribution of the software without
12 * specific, written prior permission.
14 * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
15 * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
16 * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
18 * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
19 * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20 * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
21 * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
22 * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
23 * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
25 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
26 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46 /***================================================================***/
47 /* Portable definitions for 2's complement machines.
48 * NOTE: These really should be based on PostScript types,
49 * for example, sizeof(ps_integer), or sizeof(ps_unsigned)
51 #define MAX_ULONG (~(unsigned long)(0))
52 /* This code is portable, assuming K&R C and 2's complement arithmetic */
54 ((long)((((unsigned long) 1)<<(sizeof(unsigned long)*8-1))-1))
55 #define MIN_INTEGER ((-MAX_INTEGER)-1)
57 #define MAX_ARRAY_CNT (65535)
58 #define MAX_DICT_CNT (65535)
59 #define MAX_STRING_LEN (65535)
60 #define MAX_NAME_LEN (128)
62 /* this is the size of memory allocated for reading fonts */
64 #define VM_SIZE (50*1024)
65 /***================================================================***/
68 #define MIN(a,b) (((a)<(b)) ? a : b )
71 /***================================================================***/
72 /* Routines for managing virtual memory */
73 /***================================================================***/
74 extern boolean vm_init();
78 extern char *vm_alloc();
79 /***================================================================***/
80 /* Macros for managing virtual memory */
81 /***================================================================***/
82 #define vm_next_byte() (vm_next)
83 #define vm_free_bytes() (vm_free)
84 #define vm_avail(B) (B <= vm_free)
88 /***================================================================***/
89 /* Types of PostScript objects */
90 /***================================================================***/
91 #define OBJ_INTEGER (0)
93 #define OBJ_BOOLEAN (2)
95 #define OBJ_STRING (4)
98 #define OBJ_ENCODING (7)
100 /***================================================================***/
101 /* Value of PostScript objects */
102 /***================================================================***/
103 typedef union ps_value {
104 char *valueP; /* value pointer for unspecified type */
105 int value; /* value for unspecified type */
106 int integer; /* when type is OBJ_INTEGER */
107 float real; /* when type is OBJ_REAL */
108 int boolean; /* when type is OBJ_BOOLEAN */
109 struct ps_obj *arrayP; /* when type is OBJ_ARRAY */
110 unsigned char *stringP; /* when type is OBJ_STRING */
111 char *nameP; /* when type is OBJ_NAME */
112 FILE *fileP; /* when type is OBJ_FILE */
115 /***================================================================***/
116 /* Definition of a PostScript object */
117 /***================================================================***/
118 typedef struct ps_obj {
125 /***================================================================***/
126 /* Definition of a PostScript Dictionary Entry */
127 /***================================================================***/
128 typedef struct ps_dict {
133 /***================================================================***/
134 /* Macros for testing type of PostScript objects */
135 /***================================================================***/
136 #define objIsInteger(o) ((o).type == OBJ_INTEGER)
137 #define objIsReal(o) ((o).type == OBJ_REAL)
138 #define objIsBoolean(o) ((o).type == OBJ_BOOLEAN)
139 #define objIsArray(o) ((o).type == OBJ_ARRAY)
140 #define objIsString(o) ((o).type == OBJ_STRING)
141 #define objIsName(o) ((o).type == OBJ_NAME)
142 #define objIsFile(o) ((o).type == OBJ_FILE)
144 /***================================================================***/
145 /* Macros for setting type of PostScript objects */
146 /***================================================================***/
147 #define objSetInteger(o) ((o).type = OBJ_INTEGER)
148 #define objSetReal(o) ((o).type = OBJ_REAL)
149 #define objSetBoolean(o) ((o).type = OBJ_BOOLEAN)
150 #define objSetArray(o) ((o).type = OBJ_ARRAY)
151 #define objSetString(o) ((o).type = OBJ_STRING)
152 #define objSetName(o) ((o).type = OBJ_NAME)
153 #define objSetFile(o) ((o).type = OBJ_FILE)
155 /***================================================================***/
156 /* Macros for testing type of PostScript objects (pointer access) */
157 /***================================================================***/
158 #define objPIsInteger(o) ((o)->type == OBJ_INTEGER)
159 #define objPIsReal(o) ((o)->type == OBJ_REAL)
160 #define objPIsBoolean(o) ((o)->type == OBJ_BOOLEAN)
161 #define objPIsArray(o) ((o)->type == OBJ_ARRAY)
162 #define objPIsString(o) ((o)->type == OBJ_STRING)
163 #define objPIsName(o) ((o)->type == OBJ_NAME)
164 #define objPIsFile(o) ((o)->type == OBJ_FILE)
166 /***================================================================***/
167 /* Macros for setting type of PostScript objects (pointer access) */
168 /***================================================================***/
169 #define objPSetInteger(o) ((o)->type = OBJ_INTEGER)
170 #define objPSetReal(o) ((o)->type = OBJ_REAL)
171 #define objPSetBoolean(o) ((o)->type = OBJ_BOOLEAN)
172 #define objPSetArray(o) ((o)->type = OBJ_ARRAY)
173 #define objPSetString(o) ((o)->type = OBJ_STRING)
174 #define objPSetName(o) ((o)->type = OBJ_NAME)
175 #define objPSetFile(o) ((o)->type = OBJ_FILE)
177 /***================================================================***/
178 /* Entry point for Type1Char to get entry from CharStrings */
179 /***================================================================***/
180 extern psobj *GetType1CharString();