replace unexpect.[ch] and fatal.[ch] with error.[ch]
This commit is contained in:
63
lib/isc/error.c
Normal file
63
lib/isc/error.c
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <isc/error.h>
|
||||
|
||||
static void default_unexpected_callback(char *, int, char *, va_list);
|
||||
static void default_fatal_callback(char *, int, char *, va_list);
|
||||
|
||||
static isc_errorcallback_t unexpected_callback = default_unexpected_callback;
|
||||
static isc_errorcallback_t fatal_callback = default_fatal_callback;
|
||||
|
||||
void
|
||||
isc_error_setunexpected(isc_errorcallback_t cb) {
|
||||
if (cb == NULL)
|
||||
unexpected_callback = default_unexpected_callback;
|
||||
else
|
||||
unexpected_callback = cb;
|
||||
}
|
||||
|
||||
void
|
||||
isc_error_setfatal(isc_errorcallback_t cb) {
|
||||
if (cb == NULL)
|
||||
fatal_callback = default_fatal_callback;
|
||||
else
|
||||
fatal_callback = cb;
|
||||
}
|
||||
|
||||
void
|
||||
isc_error_unexpected(char *file, int line, char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
(unexpected_callback)(file, line, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
isc_error_fatal(char *file, int line, char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
(fatal_callback)(file, line, format, args);
|
||||
va_end(args);
|
||||
abort();
|
||||
}
|
||||
|
||||
static void
|
||||
default_unexpected_callback(char *file, int line, char *format, va_list args) {
|
||||
fprintf(stderr, "%s:%d: ", file, line);
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
static void
|
||||
default_fatal_callback(char *file, int line, char *format, va_list args) {
|
||||
fprintf(stderr, "%s:%d: fatal error: ", file, line);
|
||||
vfprintf(stderr, format, args);
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
17
lib/isc/include/isc/error.h
Normal file
17
lib/isc/include/isc/error.h
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#ifndef ISC_ERROR_H
|
||||
#define ISC_ERROR_H 1
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef void (*isc_errorcallback_t)(char *, int, char *, va_list);
|
||||
|
||||
void isc_error_setunexpected(isc_errorcallback_t);
|
||||
void isc_error_setfatal(isc_errorcallback_t);
|
||||
void isc_error_unexpected(char *, int, char *, ...);
|
||||
void isc_error_fatal(char *, int, char *, ...);
|
||||
|
||||
#define UNEXPECTED_ERROR isc_error_unexpected
|
||||
#define FATAL_ERROR isc_error_fatal
|
||||
|
||||
#endif /* ISC_ERROR_H */
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "attribute.h"
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
#if !defined(LINT) && !defined(CODECENTER)
|
||||
static char rcsid[] __attribute__((unused)) = "$Id: mem.c,v 1.8 1998/11/11 19:02:24 halley Exp $";
|
||||
static char rcsid[] __attribute__((unused)) = "$Id: mem.c,v 1.9 1998/12/04 20:00:13 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/condition.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
|
||||
isc_result_t
|
||||
isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t t)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/rwlock.h>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <isc/thread.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/condition.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/task.h>
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/condition.h>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Id: socket.c,v 1.15 1998/12/04 11:21:10 explorer Exp $ */
|
||||
/* $Id: socket.c,v 1.16 1998/12/04 20:00:16 halley Exp $ */
|
||||
|
||||
#include "attribute.h"
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/fatal.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/thread.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/condition.h>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/error.h>
|
||||
#include <isc/time.h>
|
||||
|
||||
/***
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/unexpect.h>
|
||||
#include <isc/time.h>
|
||||
|
||||
/***
|
||||
|
||||
Reference in New Issue
Block a user