5 * DIGITAL EQUIPMENT CORPORATION
6 * MAYNARD, MASSACHUSETTS
9 * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
10 * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
11 * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
12 * FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
15 * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
16 * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
17 * ADDITION TO THAT SET FORTH ABOVE.
19 * Permission to use, copy, modify, and distribute this software and its
20 * documentation for any purpose and without fee is hereby granted, provided
21 * that the above copyright notice appear in all copies and that both that
22 * copyright notice and this permission notice appear in supporting
23 * documentation, and that the name of Digital Equipment Corporation not be
24 * used in advertising or publicity pertaining to distribution of the
25 * software without specific, written prior permission.
28 #define DEBUG_VAR_LOCAL
33 unsigned int DEBUG_VAR;
35 /***====================================================================***/
40 return((Opaque)malloc(size));
43 /***====================================================================***/
46 uCalloc(unsigned n, unsigned size)
48 return((Opaque)calloc(n,size));
51 /***====================================================================***/
54 uRealloc(Opaque old, unsigned newSize)
57 return((Opaque)malloc(newSize));
58 else return((Opaque)realloc((char *)old,newSize));
61 /***====================================================================***/
64 uRecalloc(Opaque old, unsigned nOld, unsigned nNew, unsigned itemSize)
69 rtrn= (char *)calloc(nNew,itemSize);
71 rtrn= (char *)realloc((char *)old,nNew*itemSize);
72 if ((rtrn)&&(nNew>nOld)) {
73 bzero(&rtrn[nOld*itemSize],(nNew-nOld)*itemSize);
79 /***====================================================================***/
84 if (ptr!=(Opaque)NULL)
89 /***====================================================================***/
90 /*** FUNCTION ENTRY TRACKING ***/
91 /***====================================================================***/
93 static FILE *entryFile= NULL;
94 static int uEntryLevel;
97 uSetEntryFile(const char *name)
99 if ((entryFile!=NULL)&&(entryFile!=stderr)) {
100 fprintf(entryFile,"switching to %s\n",name?name:"stderr");
103 if (name!=NullString) entryFile= fopen(name,"w");
104 else entryFile= stderr;
105 if (entryFile==NULL) {
113 uEntry(int l, const char *s,...)
119 for (i=0;i<uEntryLevel;i++) {
122 vfprintf(entryFile,s,ap);
129 uExit(int l, const char *rtVal)
134 if (uEntryLevel<0) uEntryLevel= 0;
135 for (i=0;i<uEntryLevel;i++) {
138 fprintf(entryFile,"---> 0x%p\n",rtVal);
142 /***====================================================================***/
143 /*** PRINT FUNCTIONS ***/
144 /***====================================================================***/
146 FILE *uDebugFile= NULL;
147 int uDebugIndentLevel= 0;
148 int uDebugIndentSize= 4;
151 uSetDebugFile(const char *name)
153 if ((uDebugFile!=NULL)&&(uDebugFile!=stderr)) {
154 fprintf(uDebugFile,"switching to %s\n",name?name:"stderr");
157 if (name!=NullString) uDebugFile= fopen(name,"w");
158 else uDebugFile= stderr;
159 if (uDebugFile==NULL) {
167 uDebug(const char *s,...)
173 for (i=(uDebugIndentLevel*uDebugIndentSize);i>0;i--) {
174 putc(' ',uDebugFile);
176 vfprintf(uDebugFile,s,ap);
183 uDebugNOI(const char *s,...)
188 vfprintf(uDebugFile,s,ap);
194 /***====================================================================***/
196 static FILE *errorFile= NULL;
199 uSetErrorFile(const char *name)
201 if ((errorFile!=NULL)&&(errorFile!=stderr)) {
202 fprintf(errorFile,"switching to %s\n",name?name:"stderr");
205 if (name!=NullString) errorFile= fopen(name,"w");
206 else errorFile= stderr;
207 if (errorFile==NULL) {
215 uInformation(const char *s,...)
220 vfprintf(errorFile,s,ap);
226 /***====================================================================***/
229 uAction(const char *s,...)
234 fprintf(errorFile," ");
235 vfprintf(errorFile,s,ap);
241 /***====================================================================***/
244 uWarning(const char *s,...)
249 fprintf(errorFile,"Warning: ");
250 vfprintf(errorFile,s,ap);
256 /***====================================================================***/
259 uError(const char *s,...)
264 fprintf(errorFile,"Error: ");
265 vfprintf(errorFile,s,ap);
271 /***====================================================================***/
274 uFatalError(const char *s,...)
279 fprintf(errorFile,"Fatal Error: ");
280 vfprintf(errorFile,s,ap);
281 fprintf(errorFile," Exiting\n");
288 /***====================================================================***/
291 uInternalError(const char *s,...)
296 fprintf(errorFile,"Internal error: ");
297 vfprintf(errorFile,s,ap);
303 /***====================================================================***/
307 uStringDup(const char *str)
313 rtrn= (char *)uAlloc(strlen(str)+1);
319 #ifndef HAVE_STRCASECMP
321 uStrCaseCmp(const char *str1, const char *str2)
323 char buf1[512],buf2[512];
327 for (n=0, s = buf1; (c = *str1++); n++) {
335 for (n=0, s = buf2; (c = *str2++); n++) {
343 return (strcmp(buf1, buf2));
347 uStrCasePrefix(const char *prefix, const char *str)
351 while (((c1=*prefix)!='\0')&&((c2=*str)!='\0')) {
352 if (isupper(c1)) c1= tolower(c1);
353 if (isupper(c2)) c2= tolower(c2);