软件著作权源代码.docx
《软件著作权源代码.docx》由会员分享,可在线阅读,更多相关《软件著作权源代码.docx(101页珍藏版)》请在冰豆网上搜索。
软件著作权源代码
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#defineNS_MAIN1
#include
#endif
#ifdefDLZ
#include
#endif
statictybs_boolean_twant_stats=TYBS_FALSE;
staticcharprogram_name[TYBS_DIR_NAMEMAX]="named";
staticcharabsolute_conf];
staticcharsaved_command_line[512];
staticcharversion[512];
staticunsignedintmaxsocks=0;
void
ns_main_earlywarning(constchar*format,...){
va_listargs;
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);
}
Voidns_main_earlyfatal(constchar*format,...){
va_listargs;
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(duetoearlyfatalerror)");
}else{
fprintf(stderr,"%s:
",program_name);
vfprintf(stderr,format,args);
fprintf(stderr,"\n");
fflush(stderr);
}
va_end(args);
exit
(1);
}
staticvoid
assertion_failed(constchar*file,intline,tybs_assertiontype_ttype,
constchar*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(duetoassertionfailure)");
}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);
}
staticvoid
library_fatal_error(constchar*file,intline,constchar*format,
va_listargs)TYBS_FORMAT_PRINTF(3,0);
staticvoid
library_fatal_error(constchar*file,intline,constchar*format,
va_listargs)
{
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:
fatalerror:
",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(duetofatalerrorinlibrary)");
}else{
fprintf(stderr,"%s:
%d:
fatalerror:
",file,line);
vfprintf(stderr,format,args);
fprintf(stderr,"\n");
fflush(stderr);
}
if(ns_g_coreok)
abort();
exit
(1);
}
staticvoid
library_unexpected_error(constchar*file,intline,constchar*format,
va_listargs)TYBS_FORMAT_PRINTF(3,0);
staticvoid
library_unexpected_error(constchar*file,intline,constchar*format,
va_listargs)
{
if(ns_g_lctx!
=NULL){
tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN,TYBS_LOG_ERROR,
"%s:
%d:
unexpectederror:
",file,line);
tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_MAIN,TYBS_LOG_ERROR,
format,args);
}else{
fprintf(stderr,"%s:
%d:
fatalerror:
",file,line);
vfprintf(stderr,format,args);
fprintf(stderr,"\n");
fflush(stderr);
}
}
staticvoid
lwresd_usage(void){
fprintf(stderr,
"usage:
lwresd[-4|-6][-cconffile|-Cresolvconffile]"
"[-ddebuglevel]\n"
"[-f|-g][-nnumber_of_cpus][-pport]"
"[-Plisten-port][-s]\n"
"[-tchrootdir][-uusername][-ipidfile]\n"
"[-m{usage|trace|record|size|mctx}]\n");
}
staticvoid
usage(void){
if(ns_g_lwresdonly){
lwresd_usage();
return;
}
fprintf(stderr,
"usage:
named[-4|-6][-cconffile][-ddebuglevel]"
"[-f|-g][-nnumber_of_cpus]\n"
"[-pport][-s][-tchrootdir][-uusername]\n"
"[-m{usage|trace|record|size|mctx}]\n");
}
staticvoid
save_command_line(intargc,char*argv[]){
inti;
char*src;
char*dst;
char*eob;
constchartruncated[]="...";
tybs_boolean_tquoted=TYBS_FALSE;
dst=saved_command_line;
eob=saved_command_line+sizeof(saved_command_line);
for(i=1;i*dst++='';
src=argv[i];
while(*src!
='\0'&&dstif(quoted||is