1、#ifdef DLZdlz/dlz_drivers.hstatic tybs_boolean_t want_stats = TYBS_FALSE;static char program_nameTYBS_DIR_NAMEMAX = named;static char absolute_conffileTYBS_DIR_PATHMAX;static char saved_command_line512;static char version512;static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *forma
2、t, .) 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);n); fflush(stderr); va_end(args);Void ns_main_earlyfatal(
3、const char *format, .) NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, exiting (due to early fatal error) exit(1);static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type, const char *cond) tybs_assertion_setcallback(NULL);%d: %s(%s) f
4、ailed, file, line, tybs_assertion_typetotext(type), cond);exiting (due to assertion failure) %s(%s) failedn, file, line, tybs_assertion_typetotext(type), cond); if (ns_g_coreok) abort();library_fatal_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0); va_lis
5、t args) tybs_error_setfatal(NULL); fatal error:, file, line);exiting (due to fatal error in library)library_unexpected_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0); va_list args) NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, unexpected error:lwresd_usage(void) fp
6、rintf(stderr, usage: lwresd -4|-6 -c conffile | -C resolvconffile -d debugleveln -f|-g -n number_of_cpus -p port -P listen-port -sn -t chrootdir -u username -i pidfilen -m usage|trace|record|size|mctxnusage(void) if (ns_g_lwresdonly) lwresd_usage(); return; named -4|-6 -c conffile -d debuglevel -f|-
7、g -n number_of_cpusn -p port -s -t chrootdir -u usernamensave_command_line(int argc, char *argv) int i; char *src; char *dst; char *eob; const char truncated = . tybs_boolean_t quoted = TYBS_FALSE; dst = saved_command_line; eob = saved_command_line + sizeof(saved_command_line); for (i = 1; i argc &
8、dst = sizeof(truncated); if (dst = eob) strcpy(eob - sizeof(truncated), truncated); else *dst = static intparse_int(char *arg, const char *desc) char *endp; int tmp; long int ltmp; ltmp = strtol(arg, &endp, 10); tmp = (int) ltmp; if (*endp !) ns_main_earlyfatal(%s %s must be numeric, desc, arg); if
9、(tmp name != NULL; def+) if (arglen = (int)strlen(def-name) & memcmp(arg, def-name, arglen) = 0) *ret |= def-value; goto found;unrecognized flag %.*s, arglen, arg); found: if (*end = break; arg = end + 1;parse_command_line(int argc, char *argv) int ch; int port; tybs_boolean_t disable6 = TYBS_FALSE;
10、 tybs_boolean_t disable4 = TYBS_FALSE; save_command_line(argc, argv); tybs_commandline_errprint = TYBS_FALSE; while (ch = tybs_commandline_parse(argc, argv, 46c:C:d:fgi:lm:n:N:p:P:sS:t:T:u:vVx:) != -1) switch (ch) case 4: if (disable4) ns_main_earlyfatal(cannot specify -4 and -6 if (tybs_net_probeip
11、v4() != TYBS_R_SUCCESS)IPv4 not supported by OS tybs_net_disableipv6(); disable6 = TYBS_TRUE;6 if (disable6) if (tybs_net_probeipv6() !IPv6 not supported by OS tybs_net_disableipv4(); disable4 = TYBS_TRUE;c ns_g_conffile = tybs_commandline_argument; lwresd_g_conffile = tybs_commandline_argument; if
12、(lwresd_g_useresolvconf)cannot specify -c and -C ns_g_conffileset = TYBS_TRUE;C lwresd_g_resolvconffile = tybs_commandline_argument; if (ns_g_conffileset) lwresd_g_useresolvconf = TYBS_TRUE;d ns_g_debuglevel = parse_int(tybs_commandline_argument, debug levelf ns_g_foreground = TYBS_TRUE;g ns_g_logst
13、derr = TYBS_TRUE; /* XXXBEW -i should be removed */i lwresd_g_defaultpidfile = tybs_commandline_argument;l ns_g_lwresdonly = TYBS_TRUE;m set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging);N /* Deprecated. */n ns_g_cpus = parse_int(tybs_commandline_argument,number of cpus if (
14、ns_g_cpus = 0) ns_g_cpus = 1;p port = parse_int(tybs_commandline_argument, port if (port 65535)port tybs_commandline_argument); ns_g_port = port; /* XXXBEW Should -P be removed? */P lwresd_g_listenport = port;s want_stats = TYBS_TRUE;S maxsocks = parse_int(tybs_commandline_argument,max number of soc
15、ketst ns_g_chrootdir = tybs_commandline_argument;T if (strcmp(tybs_commandline_argument, clienttest) = 0) ns_g_clienttest = TYBS_TRUE; else fprintf(stderr, unknown -T flag %sn tybs_commandline_argument);u ns_g_username = tybs_commandline_argument;v printf(BIND %sn, ns_g_version); exit(0);VBIND %s built with %sn, ns_g_version,
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2