#include <tybs/commandline.h>
#include <tybs/dir.h>
#include <tybs/entropy.h>
#include <tybs/file.h>
#include <tybs/hash.h>
#include <tybs/os.h>
#include <tybs/platform.h>
#include <tybs/resource.h>
#include <tybs/stdio.h>
#include <tybs/string.h>
#include <tybs/task.h>
#include <tybs/timer.h>
#include <tybs/util.h>
#include <tybscc/result.h>
#include <dns/dispatch.h>
#include <dns/name.h>
#include <dns/result.h>
#include <dns/view.h>
#include <dst/result.h>
#define NS_MAIN 1
#include <named/ns_smf_globals.h>
#endif
#ifdef DLZ
#include <dlz/dlz_drivers.h>
#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) {
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) failed\n",
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);
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"exiting (due to fatal error in library)");
} else {
fprintf(stderr, "%s:%d: fatal error: ", file, line);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
}
if (ns_g_coreok)
abort();
exit(1);
}
static void
library_unexpected_error(const char *file, int line, const char *format,
va_list args) TYBS_FORMAT_PRINTF(3, 0);
static void
library_unexpected_error(const char *file, int line, const char *format,
va_list args)
{
if (ns_g_lctx != NULL) {
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,
"%s:%d: unexpected error:", file, line);
tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,
format, args);
} else {
fprintf(stderr, "%s:%d: fatal error: ", file, line);
vfprintf(stderr, format, args);
fprintf(stderr, "\n");
fflush(stderr);
}
}
static void
lwresd_usage(void) {
fprintf(stderr,
"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] "
"[-d debuglevel]\n"
" [-f|-g] [-n number_of_cpus] [-p port] "
"[-P listen-port] [-s]\n"
" [-t chrootdir] [-u username] [-i pidfile]\n"
" [-m {usage|trace|record|size|mctx}]\n");
}
static void
usage(void) {
if (ns_g_lwresdonly) {
lwresd_usage();
return;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论