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>
44 /***====================================================================***/
46 #ifndef OPAQUE_DEFINED
50 #define NullOpaque ((Opaque)NULL)
53 #ifndef BOOLEAN_DEFINED
58 #define True ((Boolean)1)
59 #define False ((Boolean)0)
60 #endif /* ndef True */
61 #define booleanText(b) ((b)?"True":"False")
63 #ifndef COMPARISON_DEFINED
64 typedef int Comparison;
66 #define Greater ((Comparison)1)
67 #define Equal ((Comparison)0)
68 #define Less ((Comparison)-1)
69 #define CannotCompare ((Comparison)-37)
70 #define comparisonText(c) ((c)?((c)<0?"Less":"Greater"):"Equal")
73 /***====================================================================***/
75 extern Opaque uAlloc(unsigned /* size */
77 extern Opaque uCalloc(unsigned /* n */ ,
80 extern Opaque uRealloc(Opaque /* old */ ,
81 unsigned /* newSize */
83 extern Opaque uRecalloc(Opaque /* old */ ,
86 unsigned /* newSize */
88 extern void uFree(Opaque /* ptr */
91 #define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t)))
92 #define uTypedCalloc(n,t) ((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
93 #define uTypedRealloc(pO,n,t) ((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
94 #define uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
95 #if (defined mdHasAlloca) && (mdHasAlloca)
96 #define uTmpAlloc(n) ((Opaque)alloca((unsigned)n))
99 #define uTmpAlloc(n) uAlloc(n)
100 #define uTmpFree(p) uFree(p)
103 /***====================================================================***/
105 extern Boolean uSetErrorFile(char * /* name */
108 #define INFO uInformation
111 uInformation(const char * /* s */ , ...
113 #if defined(__GNUC__) && \
114 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
115 __attribute__ ((format(printf, 1, 2)))
119 #define ACTION uAction
121 extern void uAction(const char * /* s */ , ...
123 #if defined(__GNUC__) && \
124 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
125 __attribute__ ((format(printf, 1, 2)))
129 #define WARN uWarning
131 extern void uWarning(const char * /* s */ , ...
133 #if defined(__GNUC__) && \
134 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
135 __attribute__ ((format(printf, 1, 2)))
141 extern void uError(const char * /* s */ , ...
143 #if defined(__GNUC__) && \
144 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
145 __attribute__ ((format(printf, 1, 2)))
149 #define FATAL uFatalError
151 extern void uFatalError(const char * /* s */ , ...
153 #if defined(__GNUC__) && \
154 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
155 __attribute__ ((format(printf, 1, 2)))
159 /* WSGO stands for "Weird Stuff Going On" (wtf???) */
160 #define WSGO uInternalError
162 extern void uInternalError(const char * /* s */ , ...
164 #if defined(__GNUC__) && \
165 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
166 __attribute__ ((format(printf, 1, 2)))
170 extern void uSetPreErrorMessage(char * /* msg */
173 extern void uSetPostErrorMessage(char * /* msg */
176 extern void uSetErrorPrefix(char * /* void */
179 extern void uFinishUp(void);
182 /***====================================================================***/
184 #define NullString ((char *)NULL)
186 #define uStringText(s) ((s)==NullString?"<NullString>":(s))
187 #define uStringEqual(s1,s2) (uStringCompare(s1,s2)==Equal)
188 #define uStringPrefix(p,s) (strncmp(p,s,strlen(p))==0)
189 #define uStringCompare(s1,s2) (((s1)==NullString||(s2)==NullString)?\
190 (s1)!=(s2):strcmp(s1,s2))
191 #define uStrCaseEqual(s1,s2) (uStrCaseCmp(s1,s2)==0)
192 #ifdef HAVE_STRCASECMP
193 #define uStrCaseCmp(s1,s2) (strcasecmp(s1,s2))
194 #define uStrCasePrefix(p,s) (strncasecmp(p,s,strlen(p))==0)
196 extern int uStrCaseCmp(const char * /* s1 */ ,
197 const char * /* s2 */
199 extern int uStrCasePrefix(const char * /* p */ ,
204 #define uStringDup(s1) (strdup(s1))
206 extern char *uStringDup(const char * /* s1 */
210 /***====================================================================***/
213 #define uASSERT(where,why) \
214 {if (!(why)) uFatalError("assertion botched in %s ( why )\n",where);}
216 #define uASSERT(where,why)
219 /***====================================================================***/
222 #define DEBUG_VAR debugFlags
226 unsigned int DEBUG_VAR;
228 extern void uDebug(char * /* s */ , ...
230 #if defined(__GNUC__) && \
231 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
232 __attribute__ ((format(printf, 1, 2)))
236 extern void uDebugNOI( /* no indent */
239 #if defined(__GNUC__) && \
240 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
241 __attribute__ ((format(printf, 1, 2)))
245 extern Boolean uSetDebugFile(char *name);
247 extern FILE *uDebugFile;
248 extern int uDebugIndentLevel;
249 extern int uDebugIndentSize;
250 #define uDebugIndent(l) (uDebugIndentLevel+=(l))
251 #define uDebugOutdent(l) (uDebugIndentLevel-=(l))
253 #define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
254 #define uDEBUG1(f,s,a) { if (DEBUG_VAR&(f)) uDebug(s,a);}
255 #define uDEBUG2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebug(s,a,b);}
256 #define uDEBUG3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c);}
257 #define uDEBUG4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d);}
258 #define uDEBUG5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d,e);}
259 #define uDEBUG_NOI(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
260 #define uDEBUG_NOI1(f,s,a) { if (DEBUG_VAR&(f)) uDebugNOI(s,a);}
261 #define uDEBUG_NOI2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b);}
262 #define uDEBUG_NOI3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c);}
263 #define uDEBUG_NOI4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d);}
264 #define uDEBUG_NOI5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d,e);}
267 #define uDEBUG1(f,s,a)
268 #define uDEBUG2(f,s,a,b)
269 #define uDEBUG3(f,s,a,b,c)
270 #define uDEBUG4(f,s,a,b,c,d)
271 #define uDEBUG5(f,s,a,b,c,d,e)
272 #define uDEBUG_NOI(f,s)
273 #define uDEBUG_NOI1(f,s,a)
274 #define uDEBUG_NOI2(f,s,a,b)
275 #define uDEBUG_NOI3(f,s,a,b,c)
276 #define uDEBUG_NOI4(f,s,a,b,c,d)
277 #define uDEBUG_NOI5(f,s,a,b,c,d,e)
280 extern Boolean uSetEntryFile(char *name);
281 extern void uEntry(int /* l */ ,
284 #if defined(__GNUC__) && \
285 ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 6)))
286 __attribute__ ((format(printf, 2, 3)))
290 extern void uExit(int l, char *rtVal);
291 #ifdef ENTRY_TRACKING_ON
292 #define ENTRY_BIT 0x10
293 #define LOW_ENTRY_BIT 0x1000
294 #define ENTER (DEBUG_VAR&ENTRY_BIT)
295 #define FLAG(fLag) (DEBUG_VAR&(fLag))
297 extern int uEntryLevel;
299 #define uENTRY(s) { if (ENTER) uEntry(1,s);}
300 #define uENTRY1(s,a) { if (ENTER) uEntry(1,s,a);}
301 #define uENTRY2(s,a,b) { if (ENTER) uEntry(1,s,a,b);}
302 #define uENTRY3(s,a,b,c) { if (ENTER) uEntry(1,s,a,b,c);}
303 #define uENTRY4(s,a,b,c,d) { if (ENTER) uEntry(1,s,a,b,c,d);}
304 #define uENTRY5(s,a,b,c,d,e) { if (ENTER) uEntry(1,s,a,b,c,d,e);}
305 #define uENTRY6(s,a,b,c,d,e,f) { if (ENTER) uEntry(1,s,a,b,c,d,e,f);}
306 #define uENTRY7(s,a,b,c,d,e,f,g) { if (ENTER) uEntry(1,s,a,b,c,d,e,f,g);}
307 #define uRETURN(v) { if (ENTER) uEntryLevel--; return(v); }
308 #define uVOIDRETURN { if (ENTER) uEntryLevel--; return; }
310 #define uFLAG_ENTRY(w,s) { if (FLAG(w)) uEntry(0,s);}
311 #define uFLAG_ENTRY1(w,s,a) { if (FLAG(w)) uEntry(0,s,a);}
312 #define uFLAG_ENTRY2(w,s,a,b) { if (FLAG(w)) uEntry(0,s,a,b);}
313 #define uFLAG_ENTRY3(w,s,a,b,c) { if (FLAG(w)) uEntry(0,s,a,b,c);}
314 #define uFLAG_ENTRY4(w,s,a,b,c,d) { if (FLAG(w)) uEntry(0,s,a,b,c,d);}
315 #define uFLAG_ENTRY5(w,s,a,b,c,d,e) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e);}
316 #define uFLAG_ENTRY6(w,s,a,b,c,d,e,f) { if (FLAG(w)) uEntry(0,s,a,b,c,d,e,f);}
317 #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);}
318 #define uFLAG_RETURN(v) { return(v);}
319 #define uFLAG_VOIDRETURN { return; }
323 #define uENTRY2(s,a1,a2)
324 #define uENTRY3(s,a1,a2,a3)
325 #define uENTRY4(s,a1,a2,a3,a4)
326 #define uENTRY5(s,a1,a2,a3,a4,a5)
327 #define uENTRY6(s,a1,a2,a3,a4,a5,a6)
328 #define uENTRY7(s,a1,a2,a3,a4,a5,a6,a7)
329 #define uRETURN(v) { return(v); }
330 #define uVOIDRETURN { return; }
332 #define uFLAG_ENTRY(f,s)
333 #define uFLAG_ENTRY1(f,s,a)
334 #define uFLAG_ENTRY2(f,s,a,b)
335 #define uFLAG_ENTRY3(f,s,a,b,c)
336 #define uFLAG_ENTRY4(f,s,a,b,c,d)
337 #define uFLAG_ENTRY5(f,s,a,b,c,d,e)
338 #define uFLAG_ENTRY6(f,s,a,b,c,d,e,g)
339 #define uFLAG_ENTRY7(f,s,a,b,c,d,e,g,h)
340 #define uFLAG_RETURN(v) { return(v);}
341 #define uFLAG_VOIDRETURN { return; }