软件著作权源代码.doc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件 著作权 源代码
- 资源描述:
-
60 #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; } fprintf(stderr, "usage: named [-4|-6] [-c conffile] [-d debuglevel] " "[-f|-g] [-n number_of_cpus]\n" " [-p port] [-s] [-t chrootdir] [-u username]\n" " [-m {usage|trace|record|size|mctx}]\n"); } static void save_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 && dst < eob; i++) { *dst++ = ' '; src = argv[i]; while (*src != '\0' && dst < eob) { 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'; } static int parse_int(char *arg, const char *desc) { char *endp; int tmp; long int ltmp; ltmp = strtol(arg, &endp, 10); tmp = (int) ltmp; if (*endp != '\0') ns_main_earlyfatal("%s '%s' must be numeric", desc, arg); if (tmp < 0 || tmp != ltmp) ns_main_earlyfatal("%s '%s' out of range", desc, arg); return (tmp); } static struct flag_def { const char *name; unsigned int value; } mem_debug_flags[] = { { "trace", TYBS_MEM_DEBUGTRACE }, { "record", TYBS_MEM_DEBUGRECORD }, { "usage", TYBS_MEM_DEBUGUSAGE }, { "size", TYBS_MEM_DEBUGSIZE }, { "mctx", TYBS_MEM_DEBUGCTX }, { NULL, 0 } }; static void set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { for (;;) { const struct flag_def *def; const char *end = strchr(arg, ','); int arglen; if (end == NULL) end = arg + strlen(arg); arglen = end - arg; for (def = defs; def->name != NULL; def++) { if (arglen == (int)strlen(def->name) && memcmp(arg, def->name, arglen) == 0) { *ret |= def->value; goto found; } } ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg); found: if (*end == '\0') break; arg = end + 1; } } static void parse_command_line(int argc, char *argv[]) { int ch; int port; tybs_boolean_t disable6 = TYBS_FALSE; 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_probeipv4() != TYBS_R_SUCCESS) ns_main_earlyfatal("IPv4 not supported by OS"); tybs_net_disableipv6(); disable6 = TYBS_TRUE; break; case '6': if (disable6) ns_main_earlyfatal("cannot specify -4 and -6"); if (tybs_net_probeipv6() != TYBS_R_SUCCESS) ns_main_earlyfatal("IPv6 not supported by OS"); tybs_net_disableipv4(); disable4 = TYBS_TRUE; break; case 'c': ns_g_conffile = tybs_commandline_argument; lwresd_g_conffile = tybs_commandline_argument; if (lwresd_g_useresolvconf) ns_main_earlyfatal("cannot specify -c and -C"); ns_g_conffileset = TYBS_TRUE; break; case 'C': lwresd_g_resolvconffile = tybs_commandline_argument; if (ns_g_conffileset) ns_main_earlyfatal("cannot specify -c and -C"); lwresd_g_useresolvconf = TYBS_TRUE; break; case 'd': ns_g_debuglevel = parse_int(tybs_commandline_argument, "debug level"); break; case 'f': ns_g_foreground = TYBS_TRUE; break; case 'g': ns_g_foreground = TYBS_TRUE; ns_g_logstderr = TYBS_TRUE; break; /* XXXBEW -i should be removed */ case 'i': lwresd_g_defaultpidfile = tybs_commandline_argument; break; case 'l': ns_g_lwresdonly = TYBS_TRUE; break; case 'm': set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging); break; case 'N': /* Deprecated. */ case 'n': ns_g_cpus = parse_int(tybs_commandline_argument, "number of cpus"); if (ns_g_cpus == 0) ns_g_cpus = 1; break; case 'p': port = parse_int(tybs_commandline_argument, "port"); if (port < 1 || port > 65535) ns_main_earlyfatal("port '%s' out of range", tybs_commandline_argument); ns_g_port = port; break; /* XXXBEW Should -P be removed? */ case 'P': port = parse_int(tybs_commandline_argument, "port"); if (port < 1 || port > 65535) ns_main_earlyfatal("port '%s' out of range", tybs_commandline_argument); lwresd_g_listenport = port; break; case 's': want_stats = TYBS_TRUE; break; case 'S': maxsocks = parse_int(tybs_commandline_argument, "max number of sockets"); break; case 't': ns_g_chrootdir = tybs_commandline_argument; break; case 'T': if (strcmp(tybs_commandline_argument, "clienttest") == 0) ns_g_clienttest = TYBS_TRUE; else fprintf(stderr, "unknown -T flag '%s\n", tybs_commandline_argument); break; case 'u': ns_g_username = tybs_commandline_argument; break; case 'v': printf("BIND %s\n", ns_g_version); exit(0); case 'V': printf("BIND %s built with %s\n", ns_g_version, ns_g_configargs); exit(0); case '?': usage(); if (tybs_commandline_option == '?') exit(0); ns_main_earlyfatal("unknown option '-%c'", tybs_commandline_option); default: ns_main_earlyfatal("parsing options returned %d", ch); } } argc -= tybs_commandline_index; argv += tybs_commandline_index; if (argc > 0) { usage(); ns_main_earlyfatal("extra command line arguments"); } } static tybs_result_t create_managers(void) { tybs_result_t result; unsigned int socks; #ifdef TYBS_PLATFORM_USETHREADS unsigned int cpus_detected; #endif #ifdef TYBS_PLATFORM_USETHREADS cpus_detected = tybs_os_ncpus(); if (ns_g_cpus == 0) ns_g_cpus = cpus_detected; tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s", cpus_detected, cpus_detected == 1 ? "" : "s", ns_g_cpus, ns_g_cpus == 1 ? "" : "s"); #else ns_g_cpus = 1; #endif result = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_taskmgr_create() failed: %s", tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_timermgr_create() failed: %s", tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_socketmgr_create() failed: %s", tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks); if (result == TYBS_R_SUCCESS) { tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, "using up to %u sockets", socks); } result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_entropy_create() failed: %s", tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_hash_create() failed: %s", tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } return (TYBS_R_SUCCESS); } static void destroy_managers(void) { ns_lwresd_shutdown(); tybs_entropy_detach(&ns_g_entropy); if (ns_g_fallbackentropy != NULL) tybs_entropy_detach(&ns_g_fallbackentropy); tybs_taskmgr_destroy(&ns_g_taskmgr); tybs_timermgr_destroy(&ns_g_timermgr); tybs_socketmgr_destroy(&ns_g_socketmgr); tybs_hash_destroy(); } static void setup(void) { tybs_result_t result; #ifdef HAVE_LIBSCF char *instance = NULL; #endif ns_os_inituserinfo(ns_g_username); ns_os_tzset(); ns_os_opendevnull(); #ifdef HAVE_LIBSCF result = ns_smf_get_instance(&instance, 0, ns_g_mctx); if (result == TYBS_R_SUCCESS) ns_smf_got_instance = 1; else ns_smf_got_instance = 0; if (instance != NULL) tybs_mem_free(ns_g_mctx, instance); #endif /* HAVE_LIBSCF */ #ifdef PATH_RANDOMDEV if (ns_g_chrootdir != NULL) { result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("tybs_entropy_create() failed: %s", tybs_result_totext(result)); result = tybs_entropy_createfilesource(ns_g_fallbackentropy, PATH_RANDOMDEV); if (result != TYBS_R_SUCCESS) { ns_main_earlywarning("could not open pre-chroot " "entropy source %s: %s", PATH_RANDOMDEV, tybs_result_totext(result)); tybs_entropy_detach(&ns_g_fallbackentropy); } } #endif ns_os_chroot(ns_g_chrootdir); ns_os_minprivs(); result = ns_log_init(TYBS_TF(ns_g_username != NULL)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("ns_log_init() failed: %s", tybs_result_totext(result)); if (!ns_g_foreground) ns_os_daemonize(); result = tybs_app_start(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("tybs_app_start() failed: %s", tybs_result_totext(result)); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version, saved_command_line); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "built with %s", ns_g_configargs); (void)tybs_resource_getlimit(tybs_resource_stacksize, &ns_g_initstacksize); (void)tybs_resource_getlimit(tybs_resource_datasize, &ns_g_initdatasize); (void)tybs_resource_getlimit(tybs_resource_coresize, &ns_g_initcoresize); (void)tybs_resource_getlimit(tybs_resource_openfiles, &ns_g_initopenfiles); if (! tybs_file_isabsolute(ns_展开阅读全文
咨信网温馨提示:1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。




软件著作权源代码.doc



实名认证













自信AI助手
















微信客服
客服QQ
发送邮件
意见反馈



链接地址:https://www.zixin.com.cn/doc/7605612.html