Simplifications and use standard functions.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5521 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
1999-03-11 17:45:10 +00:00
parent 8a516cfec7
commit 848ac697e8

View File

@@ -59,7 +59,7 @@ error_message (long code)
if(p != NULL && *p != '\0') if(p != NULL && *p != '\0')
strcpy_truncate(msg, p, sizeof(msg)); strcpy_truncate(msg, p, sizeof(msg));
else else
snprintf(msg, sizeof(msg), "Unknown error %ld", code); sprintf(msg, "Unknown error %ld", code);
return msg; return msg;
} }
@@ -73,27 +73,13 @@ init_error_table(const char **msgs, long base, int count)
static void static void
default_proc (const char *whoami, long code, const char *fmt, va_list args) default_proc (const char *whoami, long code, const char *fmt, va_list args)
{ {
char f[sizeof("%s: %s %s\r\n")] = ""; if (whoami)
char *x; fprintf(stderr, "%s: ", whoami);
const void *arg[3], **ap = arg; if (code)
fprintf(stderr, "%s ", error_message(code));
if(whoami) { if (fmt)
strcat_truncate(f, "%s: ", sizeof(f)); vfprintf(stderr, fmt, args);
*ap++ = whoami; fprintf(stderr, "\r\n"); /* ??? */
}
if(code) {
strcat_truncate(f, "%s ", sizeof(f));
*ap++ = error_message(code);
}
if(fmt) {
strcat_truncate(f, "%s", sizeof(f));
*ap++ = fmt;
}
strcat_truncate(f, "\r\n", sizeof(f));
asprintf(&x, f, arg[0], arg[1], arg[2]);
vfprintf(stderr, x, args);
free(x);
fflush(stderr);
} }
static errf com_err_hook = default_proc; static errf com_err_hook = default_proc;