version 1.1.2.4, 2007/01/12 00:34:38
|
version 1.1.2.5, 2007/01/12 23:09:06
|
|
|
| |
void Fatal(const char* file, size_t line, const char* format, ...) | void Fatal(const char* file, size_t line, const char* format, ...) |
{ | { |
char buffer[EXECUTOR_BUFFER_SIZE]; |
char prefixedFormat[EXECUTOR_BUFFER_SIZE]; |
char lineStr[32]; | char lineStr[32]; |
| |
/* Prepend "__FILE__(__LINE__): FATAL: " to format. */ | /* Prepend "__FILE__(__LINE__): FATAL: " to format. */ |
| |
Strlcpy(buffer, file, sizeof(buffer)); |
Strlcpy(prefixedFormat, file, sizeof(prefixedFormat)); |
Strlcat(buffer, "(", sizeof(buffer)); |
Strlcat(prefixedFormat, "(", sizeof(prefixedFormat)); |
sprintf(lineStr, "%u", (unsigned int)line); | sprintf(lineStr, "%u", (unsigned int)line); |
Strlcat(buffer, lineStr, sizeof(buffer)); |
Strlcat(prefixedFormat, lineStr, sizeof(prefixedFormat)); |
Strlcat(buffer, "): FATAL: ", sizeof(buffer)); |
Strlcat(prefixedFormat, "): FATAL: ", sizeof(prefixedFormat)); |
Strlcat(buffer, format, sizeof(buffer)); |
Strlcat(prefixedFormat, format, sizeof(prefixedFormat)); |
| |
/* Print to syslog. */ | /* Print to syslog. */ |
{ | { |
va_list ap; | va_list ap; |
|
char buffer[EXECUTOR_BUFFER_SIZE]; |
|
|
va_start(ap, format); | va_start(ap, format); |
vsyslog(LOG_CRIT, buffer, ap); |
vsprintf(buffer, prefixedFormat, ap); |
va_end(ap); | va_end(ap); |
|
|
|
vsyslog(LOG_CRIT, buffer, ap); |
} | } |
| |
/* Print to stderr. */ | /* Print to stderr. */ |
|
|
fprintf(stderr, "%s: ", globals.argv[0]); | fprintf(stderr, "%s: ", globals.argv[0]); |
va_start(ap, format); | va_start(ap, format); |
/* Flawfinder: ignore */ | /* Flawfinder: ignore */ |
vfprintf(stderr, buffer, ap); |
vfprintf(stderr, prefixedFormat, ap); |
va_end(ap); | va_end(ap); |
fputc('\n', stderr); | fputc('\n', stderr); |
} | } |