^defineNS_MAIN1
^includevnamcd/ns_smf_globals.h>#endif
#ifdefDLZ
#include
#endif
statictybs_boolean_twant^stats=TYBS_FALSE;
staticchar
staticchar
staticchar
staticchar
staticunsignedintvoid
program_name|TYBS_DIR_NAMEMAX]="named";absolutc_conffilc[TYBS_DIR_PATHMAX];saved_commandjine[512];
version[512];
maxsocks=0;
ns_main_earlywarning(constchar*format.・・・){
vajistargs;
va_start(args,format);
if(ns_gjctx!
=NULL){tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL.
NS_LOGMODULE_MAIN.TYBS_LOG_WARNING,format,args);
}else{
fprintf(stderr,H%s:
”,program_name);
vfprintf(stderr,format,args);
fprintf(stderr,n\nH);fflush(stderr);
}
va_end(args);
}
Voidns_main_earlyfatal(constchar^format,・・・){
vajistargs;
va_start(args,format);
if(ns_gJctx!
=NULL){
tybs_log_vwrite(ns_g_lctx,NS丄OGCATEGORY_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(duetoearlyfatalerror)11);
}else{
fprintf(stderr,H%s:
”,program_name);
vfprintf(stderr,format,args);
fprintf(stderr,n\nH);
fflush(stderr);
}
va_end(args);
exit(l);
}
staticvoid
assertion_failed(constchar*file,intline,tybs_assertiontype_ttype,
constchar*cond)
{
if(ns_g」ctx!
=NULL){
tybs_assertion_setcallback(NULL);tybs_log^write(ns_g_lctx,NS_LOGCATEGORY_GENERAL.NS_LOGMODULE_MAIN.TYBS_LOG_CRITICAL.M%s:
%d:
%s(%s)failed”,file,line,tybs_assertion_typetotext(type),cond);
tybs_log^write(ns_g_lctx,NS丄OGCATEGORY_GENERAL・NS_LOGMODULE_MAIN・TYBS_LOG_CRITICAL.”exiting(duetoassertionfailure)11);
}else{
fprintf(stderr,H%s:
%d:
%s(%s)failed\nM,
file,line,tybs_assertion_typetotext(type),cond);
fflush(stderr);
}
if(ns_g_coreok)
abort();
exit(l);
}
staticvoid
library_fataLerror(constchar*file,intline,constchar^format.
va.listargs)TYBS_FORMAT_PRINTF(3,0);
staticvoidlibrary_fatal_error(constchar*file,intline,constchar^format.
va_listargs)
{-
if(ns_g」ctx!
=NULL){
tybs_error_setfatal(NULL);tybs_log^write(ns_g_lctx,NS_LOGCATEGORY_GENERAL.NS_LOGMODULE_MAIN.TYBS_LOG_CRITICAL.fatalerror:
file,line);
tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL.
・・word.
NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL.format,args);
tybs_log^write(ns.g_lctx,NS_LOGCATEGORY_GENERAL.
ns_l6gmodule_main.tybs_log_critical.
Hexiting(duetofatalerrorinlibrary)”);
}else{
fprintf(stderr,n%s:
%d:
fatalerror:
file,line);
vfprintf(stderr.format,args);
fprintf(stderr.H\nH);
fflush(stderr);
}
if(ns_g_coreok)
abort();
exit(l);
}
staticvoidlibrary_unexpected_error(constchar*file,intline,constchar^format,vajistargs)TYBS_FORMAT_PRINTF(3,0);
staticvoid
library_unexpected_error(constchar*file,intline・constchar*format,va_listargs)
{
if(ns_gjctx!
=NULL){tybsjog^write(ns_g_lctx,NS_LOGCATEGORY_GENERAL.
NS_LOGMODULE_MAIN・TYBS_LOG_ERROR.
N%s:
%d:
unexpectederror:
”,file,line);tybsjog_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL・〜ns_l6gmodule_main.tybs_log_error.format,args);
}else{
fprintf(stderr,H%s:
%d:
fatalerror:
file,line);
vfprintf(stderr,format,args);
fprintf(stderr.H\nH);
ftlush(stdcrr);
}
}
staticvoid
lwresd_usage(void){
fprintf(stden\
Musage:
Iwresd[-41-6][-cconffileI-Cresolvconffile]H
M[-ddebuglevel]\n"
[-fl-g][-nnumber_of_cpus][-pport]N
M[-Plisten-port][-s]\nM
[-tchrootdir][-uusername][-ipidfile]\nH
[-m{usageltracelrecordlsizelmctx}]\nN);
}
staticvoid
usage(void){
if(ns_gJwresdonly){
Iwresd_usage();
return;
fprintf(stden\
Musage:
named[-41-6][-cconffile][-ddebuglevel]"
[-nnumber_oLcpus]\nn
[-pport][-s][4chrootdir][-uusername]\nH[-m{usageltracelrecordlsizelmctx)]\n,r);
}
staticvoid
save_command_line(intargc,char*argv[]){
inti;
char*src;
char*dst;
char*eob;
constchartruncated!
]=
tybs_booleanJquoted=TYBS_FALSE;
dst=saved_command_Iine;
eob=saved^commandjine+sizeof(saved_commandjine);
for(i=1;i*dst++=1:
src=argv[i];
while(*src!
='O'&&dstif(quotedIIisalnum(*src&Oxff)II
*src=tI