From e5d7688f99046a4b3022e13701fd346f5328d6d4 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 25 May 2000 16:24:31 +0000 Subject: Dump com_err, it's a stinking crock of shit. --- lib/libfetch/common.c | 56 ++++++++++----------------------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) (limited to 'lib/libfetch/common.c') diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 789cad5..9ec6825 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -33,9 +33,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -58,31 +58,18 @@ static struct fetcherr _netdb_errlist[] = { { -1, FETCH_UNKNOWN, "Unknown resolver error" } }; -static int com_err_initialized; /*** Error-reporting functions ***********************************************/ /* - * Initialize the common error library - */ -static void -_fetch_init_com_err(void) -{ - initialize_ftch_error_table(); - com_err_initialized = 1; -} - -/* * Map error code to string */ -static int +static struct fetcherr * _fetch_finderr(struct fetcherr *p, int e) { - int i; - for (i = 0; p[i].num != -1; i++) - if (p[i].num == e) - break; - return i; + while (p->num != -1 && p->num != e) + p++; + return p; } /* @@ -91,14 +78,9 @@ _fetch_finderr(struct fetcherr *p, int e) void _fetch_seterr(struct fetcherr *p, int e) { - int n; - - if (!com_err_initialized) - _fetch_init_com_err(); - - n = _fetch_finderr(p, e); - fetchLastErrCode = p[n].cat; - com_err("libfetch", fetchLastErrCode, "(%03d %s)", e, p[n].string); + p = _fetch_finderr(p, e); + fetchLastErrCode = p->cat; + snprintf(fetchLastErrString, MAXERRSTRING, "%s", p->string); } /* @@ -110,9 +92,6 @@ _fetch_syserr(void) int e; e = errno; - if (!com_err_initialized) - _fetch_init_com_err(); - switch (errno) { case 0: fetchLastErrCode = FETCH_OK; @@ -163,34 +142,21 @@ _fetch_syserr(void) default: fetchLastErrCode = FETCH_UNKNOWN; } - com_err("libfetch", fetchLastErrCode, "(%03d %s)", e, strerror(e)); + snprintf(fetchLastErrString, MAXERRSTRING, "%s", strerror(e)); } /* * Emit status message */ -int +void _fetch_info(char *fmt, ...) { va_list ap; - char *s; - if (!com_err_initialized) - _fetch_init_com_err(); - va_start(ap, fmt); - vasprintf(&s, fmt, ap); + vfprintf(stderr, fmt, ap); va_end(ap); - - if (s == NULL) { - com_err("libfetch", FETCH_MEMORY, ""); - return -1; - } else { - com_err("libfetch", FETCH_VERBOSE, "%s", s); - free(s); - return 0; - } } -- cgit v1.1