您好,欢迎访问三七文档
1#includetybs/commandline.h#includetybs/dir.h#includetybs/entropy.h#includetybs/file.h#includetybs/hash.h#includetybs/os.h#includetybs/platform.h#includetybs/resource.h#includetybs/stdio.h#includetybs/string.h#includetybs/task.h#includetybs/timer.h#includetybs/util.h#includetybscc/result.h#includedns/dispatch.h#includedns/name.h#includedns/result.h#includedns/view.h#includedst/result.h#defineNS_MAIN1#includenamed/ns_smf_globals.h#endif#ifdefDLZ#includedlz/dlz_drivers.h#endifstatictybs_boolean_twant_stats=TYBS_FALSE;staticcharprogram_name[TYBS_DIR_NAMEMAX]=named;staticcharabsolute_conffile[TYBS_DIR_PATHMAX];staticcharsaved_command_line[512];staticcharversion[512];staticunsignedintmaxsocks=0;voidns_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){2tybs_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);}staticvoidassertion_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);}staticvoidlibrary_fatal_error(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_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);3tybs_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);}staticvoidlibrary_unexpected_error(constchar*file,intline,constchar*format,va_listargs)TYBS_FORMAT_PRINTF(3,0);staticvoidlibrary_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);}}staticvoidlwresd_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);}staticvoidusage(void){if(ns_g_lwresdonly){lwresd_usage();return;}fprintf(stderr,usage:named[-4|-6][-cconffile][-ddebuglevel]4[-f|-g][-nnumber_of_cpus]\n[-pport][-s][-tchrootdir][-uusername]\n[-m{usage|trace|record|size|mctx}]\n);}staticvoidsave_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;iargc&&dsteob;i++){*dst++='';src=argv[i];while(*src!='\0'&&dsteob){if(quoted||isalnum(*src&0xff)||*src=='-'||*src=='_'||*src=='.'||*src=='/'){*dst++=*src++;quoted=TYBS_FALSE;}else{*dst++='\\';quoted=TYBS_TRUE;}}}INSIST(sizeof(saved_command_line)=sizeof(truncated));if(dst==eob)strcpy(eob-sizeof(truncated),truncated);else*dst='\0';}staticintparse_int(char*arg,constchar*desc){char*endp;inttmp;longintltmp;ltmp=strtol(arg,&endp,10);tmp=(int)ltmp;if(*endp!='\0')ns_main_earlyfatal(%s'%s'mustbenumeric,desc,arg);if(tmp0||tmp!=ltmp)ns_main_earlyfatal(%s'%s'outofrange,desc,arg);return(tmp);}staticstructflag_def{constchar*name;unsignedintvalue;}mem_debug_flags[]={5{trace,TYBS_MEM_DEBUGTRACE},{record,TYBS_MEM_DEBUGRECORD},{usage,TYBS_MEM_DEBUGUSAGE},{size,TYBS_MEM_DEBUGSIZE},{mctx,TYBS_MEM_DEBUGCTX},{NULL,0}};staticvoidset_flags(constchar*arg,structflag_def*defs,unsignedint*ret){for(;;){conststructflag_def*def;constchar*end=strchr(arg,',');intarglen;if(end==NULL)end=arg+strlen(arg);arglen=end-arg;for(def=d
本文标题:软件著作权源代码
链接地址:https://www.777doc.com/doc-2132199 .html