计算机软件著作权登记-源代码范本_第1页
计算机软件著作权登记-源代码范本_第2页
计算机软件著作权登记-源代码范本_第3页
计算机软件著作权登记-源代码范本_第4页
计算机软件著作权登记-源代码范本_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、计算机软件着作权登记-源代码范本注意事项:常见的源代码包含:C语言,VB,C+,JAVA,.NET等。提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,着作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。格式要求:一、源代码应提交前、后各连续 30页,不足60页的,应当全部提交。、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行范例如下:#i nclude <tybs/comma ndli ne.h>#in elude <tybs/dir

2、.h>#i nclude <tybs/e ntropy.h>#in clude <tybs/file.h>#in clude <tybs/hash.h>#i nclude <tybs/os.h>#i nclude <tybs/platform.h>#i nclude <tybs/resource.h>#i nclude <tybs/stdio.h>#in clude <tybs/stri ng.h>#in clude <tybs/task.h>#in clude <tybs/

3、timer.h>#in clude <tybs/util.h>#in clude <tybscc/result.h>#in clude <dn s/dispatch.h>#in clude <dns/n ame.h>#in clude <dn s/result.h> #in clude <dn s/view.h>#in clude <dst/result.h> #defi ne NS_MAIN 1#i nclude <n amed/ns_smf_globals.h>#en dif#ifdef

4、DLZ#in clude <dlz/dlz_drivers.h>#en difstatic tybs_boolean_twan t_stats = TYBS_FALSE;static charstatic charstatic charstatic charstatic un sig ned int voidprogram_ nameTYBS_DIR_NAMEMAX = "n amed" absolute_co nffileTYBS_DIR_PATHMAX; saved_comma nd_li ne512;versio n512;maxsocks = 0;n s

5、_ma in _earlywar nin g(c onst 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_W ARNING, format, args); else fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprint

6、f(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_LOGCATEGO

7、RY_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 voidassertion_failed(const char *file, int

8、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_lc

9、tx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, "exiting (due to assertion failure)"); else fprintf(stderr, "%s:%d: %s(%s) failedn",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);if (ns_g_coreok)abort();exit(1);static voidlibrary_fatal_error(c

10、onst char *file, int line, const char *format, va_list args) TYBS_FORMA T_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, TYB

11、S_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)&qu

12、ot;); 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 voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3,

13、 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

14、_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 resolv

15、conffile " "-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|mctxn");static void usage(void) if (ns_g_lwresdonly) lwresd_usage(); return;fprintf(stderr,"

16、;usage: named -4|-6 -c conffile -d debuglevel ""-f|-g -n number_of_cpusn""-p port -s -t chrootdir -u usernamen""-m usage|trace|record|size|mctxn");static void save_command_line(int argc, char *argv) int i;char *src;char *dst;char *eob;const char truncated = ".

17、" 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 = argvi;while (*src != '0' && dst < eob) if (quoted | isalnum(*src & 0xff) |*s

18、rc = '-' | *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'st

19、atic 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&#

20、39; 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 , "mc

21、tx", TYBS_MEM_DEBUGCTX , NULL, 0 ;static voidset_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 != N

22、ULL; 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 voidparse_command_line(int argc

23、, 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 (c

24、h) 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("c

25、annot 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

26、_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; bre

27、ak;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_d

28、efaultpidfile = 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_argume

29、nt, "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;

30、/* 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

31、 = 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

32、_TRUE;elsefprintf(stderr, "unknown -T flag '%sn", tybs_commandline_argument); break;case 'u': ns_g_username = tybs_commandline_argument; break;case 'v': printf("BIND %sn", ns_g_version); exit(0);case 'V': printf("BIND %s built with %sn", ns_g

33、_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

34、;argv += tybs_commandline_index;if (argc > 0) usage(); ns_main_earlyfatal("extra command line arguments");static tybs_result_tcreate_managers(void) tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus

35、_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 &

36、quot;" : "s");#elsens_g_cpus = 1;#endifresult = 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 = t

37、ybs_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

38、!= 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_

39、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);resu

40、lt = 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 voiddestroy_managers(void) ns_lwresd_shutdo

41、wn(); 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 voidsetup(void) t

42、ybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username); ns_os_tzset();ns_os_opendevnull();#ifdef HA VE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);if (result = TYBS_R_SUCCESS)ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (ins

43、tance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HA VE_LIBSCF */#ifdef PA TH_RANDOMDEVif (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_tot

44、ext(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_fallbackentr

45、opy);#endifns_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

46、!= 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_GE

47、NERAL, 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_

48、g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile) result = tybs_file_absolutepath(ns_g_conffile,absolute_conffile,sizeof(absolute_conffile);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct

49、absolute path of " "configuration file: %s", tybs_result_totext(result);ns_g_conffile = absolute_conffile; result = tybs_time_now(&ns_g_boottime); if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s", tybs_result_totext(result);result = create_man

50、agers();if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("create_managers() failed: %s",tybs_result_totext(result);ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("dlz_drivers_init() failed: %s", tybs_result_totext(result);

51、#endifns_server_create(ns_g_mctx, &ns_g_server);static voidcleanup(void) destroy_managers(); ns_server_destroy(& ns_builtin_deinit();#ifdef DLZ dlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "exiting&quo

52、t;);ns_log_shutdown();static char *memstats = NULL;void ns_main_setmemstats(const char *filename) if (memstats != NULL) free(memstats); memstats = NULL;if (filename = NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats) strcpy(memstats, filename);#ifdef HA VE_LIBSCF tybs_result_t ns_smf

53、_get_instance(char *ins_name, int debug, tybs_mem_t *mctx) scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name = NULL);if (h = scf_handle_create(SCF_VERSION) = NULL) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_, "scf_handle_create() failed: %s", scf

54、_strerror(scf_error();return (TYBS_R_FAILURE);if (scf_handle_bind(h) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_, "scf_handle_bind() failed: %s", scf_strerror(scf_error();scf_handle_destroy(h);return (TYBS_R_FAILURE);if (namelen = scf_myname(h, NULL, 0) = -1) if (debug)UNEXPECTED_ERROR

55、(_FILE_, _LINE_, "scf_myname() failed: %s", scf_strerror(scf_error(); scf_handle_destroy(h); return (TYBS_R_FAILURE);if (instance = tybs_mem_allocate(mctx, namelen + 1) = NULL) UNEXPECTED_ERROR(_FILE_, _LINE_, "ns_smf_get_instance memory " "allocation failed: %s", tybs_

56、result_totext(TYBS_R_NOMEMORY);scf_handle_destroy(h);return (TYBS_R_FAILURE);if (scf_myname(h, instance, namelen + 1) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_, "scf_myname() failed: %s", scf_strerror(scf_error(); scf_handle_destroy(h); tybs_mem_free(mctx, instance); return (TYBS_R_F

57、AILURE);scf_handle_destroy(h);*ins_name = instance;return (TYBS_R_SUCCESS);#endif intmain(int argc, char *argv) tybs_result_t result;#ifdef HA VE_LIBSCF char *instance = NULL;#endifstrlcat(version,#ifdef _DATE_"named version: BIND " VERSION " (" _DA TE_ ")", #else"

58、named version: BIND " VERSION,#endifsizeof(version);result = tybs_file_progname(*argv, program_name, sizeof(program_name); if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") = 0) ns_g_lwresdonly = TYBS_TRUE;tybs_assert

59、ion_setcallback(assertion_failed); tybs_error_setfatal(library_fatal_error); tybs_error_setunexpected(library_unexpected_error); ns_os_init(program_name);dns_result_register();dst_result_register(); tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) int len = strlen(

60、ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) = 0 && (ns_g_conffilelen = '/' | ns_g_conffilelen = '') ns_main_earlywarning("config filename (-c %s) contains " "chroot path (-t %s)", ns_g_conffile, ns_g_chrootdir);result = tybs_mem_create(

61、0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS) ns_main_earlyfatal("tybs_mem_create() failed: %s", tybs_result_totext(result);tybs_mem_setname(ns_g_mctx, "main", NULL);setup();do result = tybs_app_run();if (result = TYBS_R_RELOAD) ns_server_reloadwanted(ns_g_server); else if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_, "tybs_a

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论