version 1.1.2.3, 2007/01/11 16:01:23
|
version 1.1.2.4, 2007/01/12 00:34:38
|
|
|
#include "Log.h" | #include "Log.h" |
#include "Exit.h" | #include "Exit.h" |
#include "Globals.h" | #include "Globals.h" |
|
#include "Strlcpy.h" |
|
#include "Strlcat.h" |
| |
/* | /* |
**============================================================================== | **============================================================================== |
|
|
| |
void Fatal(const char* file, size_t line, const char* format, ...) | void Fatal(const char* file, size_t line, const char* format, ...) |
{ | { |
Log(LL_FATAL, "%s(%d): Fatal() called", file, (int)line); |
char buffer[EXECUTOR_BUFFER_SIZE]; |
|
char lineStr[32]; |
|
|
|
/* Prepend "__FILE__(__LINE__): FATAL: " to format. */ |
|
|
|
Strlcpy(buffer, file, sizeof(buffer)); |
|
Strlcat(buffer, "(", sizeof(buffer)); |
|
sprintf(lineStr, "%u", (unsigned int)line); |
|
Strlcat(buffer, lineStr, sizeof(buffer)); |
|
Strlcat(buffer, "): FATAL: ", sizeof(buffer)); |
|
Strlcat(buffer, format, sizeof(buffer)); |
| |
/* Print to syslog. */ | /* Print to syslog. */ |
{ | { |
va_list ap; | va_list ap; |
va_start(ap, format); | va_start(ap, format); |
vsyslog(LOG_CRIT, format, ap); |
vsyslog(LOG_CRIT, buffer, ap); |
va_end(ap); | va_end(ap); |
} | } |
| |
|
|
{ | { |
va_list ap; | va_list ap; |
| |
fprintf(stderr, "%s: %s(%d): ", globals.argv[0], file, (int)line); |
fprintf(stderr, "%s: ", globals.argv[0]); |
va_start(ap, format); | va_start(ap, format); |
/* Flawfinder: ignore */ | /* Flawfinder: ignore */ |
vfprintf(stderr, format, ap); |
vfprintf(stderr, buffer, ap); |
va_end(ap); | va_end(ap); |
fputc('\n', stderr); | fputc('\n', stderr); |
} | } |