7 * DIGITAL EQUIPMENT CORPORATION
8 * MAYNARD, MASSACHUSETTS
11 * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
12 * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
13 * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
14 * FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
17 * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
18 * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
19 * ADDITION TO THAT SET FORTH ABOVE.
21 * Permission to use, copy, modify, and distribute this software and its
22 * documentation for any purpose and without fee is hereby granted, provided
23 * that the above copyright notice appear in all copies and that both that
24 * copyright notice and this permission notice appear in supporting
25 * documentation, and that the name of Digital Equipment Corporation not be
26 * used in advertising or publicity pertaining to distribution of the
27 * software without specific, written prior permission.
30 /***====================================================================***/
34 #include <X11/Xfuncproto.h>
35 #include <X11/Xfuncs.h>
46 /***====================================================================***/
48 #ifndef OPAQUE_DEFINED
52 #define NullOpaque ((Opaque)NULL)
55 #ifndef BOOLEAN_DEFINED
60 #define True ((Boolean)1)
61 #define False ((Boolean)0)
62 #endif /* ndef True */
63 #define booleanText(b) ((b)?"True":"False")
65 #ifndef COMPARISON_DEFINED
66 typedef int Comparison;
68 #define Greater ((Comparison)1)
69 #define Equal ((Comparison)0)
70 #define Less ((Comparison)-1)
71 #define CannotCompare ((Comparison)-37)
72 #define comparisonText(c) ((c)?((c)<0?"Less":"Greater"):"Equal")
84 /***====================================================================***/
89 extern Opaque uCalloc(
93 extern Opaque uRealloc(
95 unsigned /* newSize */
97 extern Opaque uRecalloc(
101 unsigned /* newSize */
107 #define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t)))
108 #define uTypedCalloc(n,t) ((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
109 #define uTypedRealloc(pO,n,t) ((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
110 #define uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
111 #if (defined mdHasAlloca) && (mdHasAlloca)
112 #define uTmpAlloc(n) ((Opaque)alloca((unsigned)n))
115 #define uTmpAlloc(n) uAlloc(n)
116 #define uTmpFree(p) uFree(p)
119 /***====================================================================***/
121 extern Boolean uSetErrorFile ( const char *name );
122 extern void uInformation ( const char *s, ...) _X_ATTRIBUTE_PRINTF(1,2);
123 extern void uAction ( const char *s, ... ) _X_ATTRIBUTE_PRINTF(1,2);
124 extern void uWarning ( const char *s, ... ) _X_ATTRIBUTE_PRINTF(1,2);
125 extern void uError ( const char *s, ... ) _X_ATTRIBUTE_PRINTF(1,2);
126 extern void uFatalError( const char *s,...) _X_ATTRIBUTE_PRINTF(1,2);
127 extern void uInternalError ( const char *s, ... ) _X_ATTRIBUTE_PRINTF(1,2);
129 /***====================================================================***/
131 #define NullString ((char *)NULL)
133 #define uStringText(s) ((s)==NullString?"<NullString>":(s))
134 #define uStringEqual(s1,s2) (uStringCompare(s1,s2)==Equal)
135 #define uStringPrefix(p,s) (strncmp(p,s,strlen(p))==0)
136 #define uStringCompare(s1,s2) (strcmp(s1,s2))
137 #define uStrCaseEqual(s1,s2) (uStrCaseCmp(s1,s2)==0)
138 #ifdef HAVE_STRCASECMP
139 #define uStrCaseCmp(s1,s2) (strcasecmp(s1,s2))
140 #define uStrCasePrefix(p,s) (strncasecmp(p,s,strlen(p))==0)
142 extern int uStrCaseCmp(
143 const char * /* s1 */,
144 const char * /* s2 */
146 extern int uStrCasePrefix(
147 const char * /* p */,
148 const char * /* str */
152 #define uStringDup(s1) (strdup(s1))
154 extern char *uStringDup(
155 const char * /* s1 */
159 /***====================================================================***/
162 #define uASSERT(where,why) \
163 {if (!(why)) uFatalError("assertion botched in %s ( why )\n",where);}
165 #define uASSERT(where,why)
168 /***====================================================================***/
171 #define DEBUG_VAR debugFlags
175 unsigned int DEBUG_VAR;
177 extern void uDebug( const char *s, ... ) _X_ATTRIBUTE_PRINTF(1,2);
178 extern void uDebugNOI( const char *s, ... ) /* no indent */
179 _X_ATTRIBUTE_PRINTF(1,2);
180 extern Boolean uSetDebugFile(
183 extern FILE *uDebugFile;
184 extern int uDebugIndentLevel;
185 extern int uDebugIndentSize;
186 #define uDebugIndent(l) (uDebugIndentLevel+=(l))
187 #define uDebugOutdent(l) (uDebugIndentLevel-=(l))
189 #define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
190 #define uDEBUG1(f,s,a) { if (DEBUG_VAR&(f)) uDebug(s,a);}
191 #define uDEBUG2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebug(s,a,b);}
192 #define uDEBUG3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c);}
193 #define uDEBUG4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d);}
194 #define uDEBUG5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d,e);}
195 #define uDEBUG_NOI(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
196 #define uDEBUG_NOI1(f,s,a) { if (DEBUG_VAR&(f)) uDebugNOI(s,a);}
197 #define uDEBUG_NOI2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b);}
198 #define uDEBUG_NOI3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c);}
199 #define uDEBUG_NOI4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d);}
200 #define uDEBUG_NOI5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d,e);}
203 #define uDEBUG1(f,s,a)
204 #define uDEBUG2(f,s,a,b)
205 #define uDEBUG3(f,s,a,b,c)
206 #define uDEBUG4(f,s,a,b,c,d)
207 #define uDEBUG5(f,s,a,b,c,d,e)
208 #define uDEBUG_NOI(f,s)
209 #define uDEBUG_NOI1(f,s,a)
210 #define uDEBUG_NOI2(f,s,a,b)
211 #define uDEBUG_NOI3(f,s,a,b,c)
212 #define uDEBUG_NOI4(f,s,a,b,c,d)
213 #define uDEBUG_NOI5(f,s,a,b,c,d,e)
216 extern Boolean uSetEntryFile(
219 extern void uEntry(int l, const char *s, ... ) _X_ATTRIBUTE_PRINTF(2,3);
221 int l, const char *rtVal
223 #ifdef ENTRY_TRACKING_ON
224 #define ENTRY_BIT 0x10
225 #define LOW_ENTRY_BIT 0x1000
226 #define ENTER (DEBUG_VAR&ENTRY_BIT)
227 #define FLAG(fLag) (DEBUG_VAR&(fLag))
229 extern int uEntryLevel;
231 #define uENTRY(s) { if (ENTER) uEntry(1,s);}
232 #define uENTRY1(s,a) { if (ENTER) uEntry(1,s,a);}
233 #define uENTRY2(s,a,b) { if (ENTER) uEntry(1,s,a,b);}
234 #define uENTRY3(s,a,b,c) { if (ENTER) uEntry(1,s,a,b,c);}
235 #define uENTRY4(s,a,b,c,d) { if (ENTER) uEntry(1,s,a,b,c,d);}
236 #define uENTRY5(s,a,b,c,d,e) { if (ENTER) uEntry(1,s,a,b,c,d,e);}
237 #define uENTRY6(s,a,b,c,d,e,f) { if (ENTER) uEntry(1,s,a,b,c,d,e,f);}
238 #define uENTRY7(s,a,b,c,d,e,f,g) { if (ENTER) uEntry(1,s,a,b,c,d,e,f,g);}
239 #define uRETURN(v) { if (ENTER) uEntryLevel--; return(v); }
240 #define uVOIDRETURN { if (ENTER) uEntryLevel--; return; }
242 #define uFLAG_ENTRY(w,s) { if (FLAG(w)) uEntry(0,s);}
243 #define uFLAG_ENTRY1(w,s,a) { if (FLAG(w)) uEntry(0,s,a);}
244 #define uFLAG_ENTRY2(w,s,a,b) { if (FLAG(w)) uEntry(0,s,a,b);}
245 #define uFLAG_ENTRY3(w,s,a,b,c) { if (FLAG(w)) uEntry(0,s,a,b,c);}
246 #define uFLAG_ENTRY4(w,s,a,b,c,d) { if (FLAG(w)) uEntry(0,s,a,b,c,d);}
247 #define uFLAG_ENTRY5(w,s,a,b,c,d,e) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e);}
248 #define uFLAG_ENTRY6(w,s,a,b,c,d,e,f) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e,f);}
249 #define uFLAG_ENTRY7(w,s,a,b,c,d,e,f,g) { if(FLAG(w))uEntry(0,s,a,b,c,d,e,f,g);}
250 #define uFLAG_RETURN(v) { return(v);}
251 #define uFLAG_VOIDRETURN { return; }
255 #define uENTRY2(s,a1,a2)
256 #define uENTRY3(s,a1,a2,a3)
257 #define uENTRY4(s,a1,a2,a3,a4)
258 #define uENTRY5(s,a1,a2,a3,a4,a5)
259 #define uENTRY6(s,a1,a2,a3,a4,a5,a6)
260 #define uENTRY7(s,a1,a2,a3,a4,a5,a6,a7)
261 #define uRETURN(v) { return(v); }
262 #define uVOIDRETURN { return; }
264 #define uFLAG_ENTRY(f,s)
265 #define uFLAG_ENTRY1(f,s,a)
266 #define uFLAG_ENTRY2(f,s,a,b)
267 #define uFLAG_ENTRY3(f,s,a,b,c)
268 #define uFLAG_ENTRY4(f,s,a,b,c,d)
269 #define uFLAG_ENTRY5(f,s,a,b,c,d,e)
270 #define uFLAG_ENTRY6(f,s,a,b,c,d,e,g)
271 #define uFLAG_ENTRY7(f,s,a,b,c,d,e,g,h)
272 #define uFLAG_RETURN(v) { return(v);}
273 #define uFLAG_VOIDRETURN { return; }