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.
34 recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
39 rtrn = calloc(nNew, itemSize);
42 rtrn = realloc(old, nNew * itemSize);
43 if ((rtrn) && (nNew > nOld))
45 memset(&rtrn[nOld * itemSize], 0, (nNew - nOld) * itemSize);
51 static FILE *errorFile = NULL;
52 static int outCount = 0;
53 static char *preMsg = NULL;
54 static char *prefix = NULL;
57 uSetErrorFile(char *name)
59 if ((errorFile != NULL) && (errorFile != stderr))
61 fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
64 if (name != NullString)
65 errorFile = fopen(name, "w");
68 if (errorFile == NULL)
77 uInformation(const char *s, ...)
85 vfprintf(errorFile, s, args);
90 /***====================================================================***/
93 uAction(const char *s, ...)
101 fprintf(errorFile, "%s", prefix);
102 fprintf(errorFile, " ");
104 vfprintf(errorFile, s, args);
109 /***====================================================================***/
112 uWarning(const char *s, ...)
119 if ((outCount == 0) && (preMsg != NULL))
120 fprintf(errorFile, "%s\n", preMsg);
122 fprintf(errorFile, "%s", prefix);
123 fprintf(errorFile, "Warning: ");
125 vfprintf(errorFile, s, args);
131 /***====================================================================***/
134 uError(const char *s, ...)
141 if ((outCount == 0) && (preMsg != NULL))
142 fprintf(errorFile, "%s\n", preMsg);
144 fprintf(errorFile, "%s", prefix);
145 fprintf(errorFile, "Error: ");
147 vfprintf(errorFile, s, args);
153 /***====================================================================***/
156 uFatalError(const char *s, ...)
163 if ((outCount == 0) && (preMsg != NULL))
164 fprintf(errorFile, "%s\n", preMsg);
166 fprintf(errorFile, "%s", prefix);
167 fprintf(errorFile, "Fatal Error: ");
169 vfprintf(errorFile, s, args);
171 fprintf(errorFile, " Exiting\n");
178 /***====================================================================***/
181 uInternalError(const char *s, ...)
188 if ((outCount == 0) && (preMsg != NULL))
189 fprintf(errorFile, "%s\n", preMsg);
191 fprintf(errorFile, "%s", prefix);
192 fprintf(errorFile, "Internal error: ");
194 vfprintf(errorFile, s, args);
200 /***====================================================================***/
202 #ifndef HAVE_STRCASECMP
204 uStrCaseCmp(const char *str1, const char *str2)
206 char buf1[512], buf2[512];
210 for (n = 0, s = buf1; (c = *str1++); n++)
219 for (n = 0, s = buf2; (c = *str2++); n++)
228 return (strcmp(buf1, buf2));
232 uStrCasePrefix(const char *my_prefix, char *str)
236 while (((c1 = *my_prefix) != '\0') && ((c2 = *str) != '\0'))