2024年3月14日发(作者:)
1
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define NS_MAIN 1
#include
#endif
#ifdef DLZ
#include
#endif
static tybs_boolean_t want_stats = TYBS_FALSE;
static char program_name[TYBS_DIR_NAMEMAX] = "named";
static char absolute_conffile[TYBS_DIR_PATHMAX];
static char saved_command_line[512];
static char version[512];
static unsigned int maxsocks = 0;
void
ns_main_earlywarning(const char *format, ...) {
va_list args;
va_start(args, format);
if (ns_g_lctx != NULL) {
tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_WARNING,
format, args);
} else {
fprintf(stderr, "%s: ", program_name);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
}
va_end(args);
}
Void ns_main_earlyfatal(const char *format, ...) {
va_list args;
va_start(args, format);
if (ns_g_lctx != NULL) {
2
tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
format, args);
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"exiting (due to early fatal error)");
} else {
fprintf(stderr, "%s: ", program_name);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
}
va_end(args);
exit(1);
}
static void
assertion_failed(const char *file, int line, tybs_assertiontype_t type,
const char *cond)
{
if (ns_g_lctx != NULL) {
tybs_assertion_setcallback(NULL);
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"%s:%d: %s(%s) failed", file, line,
tybs_assertion_typetotext(type), cond);
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"exiting (due to assertion failure)");
} else {
fprintf(stderr, "%s:%d: %s(%s) failedn",
file, line, tybs_assertion_typetotext(type), cond);
fflush(stderr);
}
if (ns_g_coreok)
abort();
exit(1);
}
static void
library_fatal_error(const char *file, int line, const char *format,
va_list args) TYBS_FORMAT_PRINTF(3, 0);
static void
library_fatal_error(const char *file, int line, const char *format,
va_list args)
{
if (ns_g_lctx != NULL) {
tybs_error_setfatal(NULL);
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"%s:%d: fatal error:", file, line);
tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
format, args);
发布评论