软件著作权-源代码范本课件资料.pdf

上传人:白大夫 文档编号:5443998 上传时间:2020-05-12 格式:PDF 页数:60 大小:327.92KB
返回 下载 相关 举报
软件著作权-源代码范本课件资料.pdf_第1页
第1页 / 共60页
软件著作权-源代码范本课件资料.pdf_第2页
第2页 / 共60页
软件著作权-源代码范本课件资料.pdf_第3页
第3页 / 共60页
软件著作权-源代码范本课件资料.pdf_第4页
第4页 / 共60页
软件著作权-源代码范本课件资料.pdf_第5页
第5页 / 共60页
点击查看更多>>
资源描述

《软件著作权-源代码范本课件资料.pdf》由会员分享,可在线阅读,更多相关《软件著作权-源代码范本课件资料.pdf(60页珍藏版)》请在三一文库上搜索。

1、天一博胜企业管理软件V1.0 源代码1 软件著作权 -源代码范本 注意事项: 常见的源代码包含: C语言, VB,C+,JAVA,.NET等。 提交的代码必须是源代码的开头载入程序,第30 页必须断开,第60 页是软 件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软 件名字等,不能出现开源代码,不能出现任何版权纠纷。 格式要求 :一、源代码应提交前、后各连续30 页,不足 60 页的,应当全部提交。 二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页 眉右上应标注页码,源代码每页不少于50 行。 范例如下: #include #include #inclu

2、de 天一博胜企业管理软件V1.0 源代码2 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define NS_MAIN 1 #include #endif #ifdef DLZ #include #endif static tybs_boolean_t want_stats = TYBS_FALSE; static char program_nameT

3、YBS_DIR_NAMEMAX = “named“; static char absolute_conffileTYBS_DIR_PATHMAX; static char saved_command_line512; static char version512; 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_lc

4、tx, 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_

5、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, 天一博胜企业管理软件V1.0 源代码3 NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, “exiting (due to early fatal error)“); else fprintf(stderr, “%s: “, prog

6、ram_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_LOGCATEG

7、ORY_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) failedn“,

8、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 *forma

9、t, 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_

10、log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, “exiting (due to fatal error in library)“); else 天一博胜企业管理软件V1.0 源代码4 fprintf(stderr, “%s:%d: fatal error: “, file, line); vfprintf(stderr, format, args); fprintf(stderr, “n“); fflush(stderr); if (ns_g_coreok) abort();

11、 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_GE

12、NERAL, 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“); fflu

13、sh(stderr); static void lwresd_usage(void) fprintf(stderr, “usage: lwresd -4|-6 -c conffile | -C resolvconffile “ “-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_l

14、wresdonly) lwresd_usage(); return; fprintf(stderr, “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“); 天一博胜企业管理软件V1.0 源代码5 static void save_command_line(int argc, char *argv) int i; char *src; char *

15、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 = sizeof(truncated); if (dst = eob) strcpy(eob - sizeof(truncated), truncated); else *dst = 0; static int parse_int(char *arg

16、, const char *desc) char *endp; int tmp; long int ltmp; ltmp = strtol(arg, tmp = (int) ltmp; if (*endp != 0) ns_main_earlyfatal(“%s %s must be numeric“, desc, arg); if (tmp name != NULL; def+) if (arglen = (int)strlen(def-name) goto found; ns_main_earlyfatal(“unrecognized flag %.*s“, arglen, arg); f

17、ound: 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,

18、 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 (disa

19、ble6) 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(); 天一博胜企业管理软件V1.0 源代码7 disable4 = TYBS_TRUE; break; case c: ns_g_conffile = tybs_commandline_argument; lwresd_g_conffile = tybs_comma

20、ndline_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; bre

21、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_defaultpidfile = tybs_commandline_argument;

22、 break; case l: ns_g_lwresdonly = TYBS_TRUE; break; case m: set_flags(tybs_commandline_argument, mem_debug_flags, 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_comman

23、dline_argument, “port“); if (port 65535) ns_main_earlyfatal(“port %s out of range“, tybs_commandline_argument); ns_g_port = port; break; /* XXXBEW Should -P be removed? */ 天一博胜企业管理软件V1.0 源代码8 case P: port = parse_int(tybs_commandline_argument, “port“); if (port 65535) ns_main_earlyfatal(“port %s out

24、 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_ar

25、gument, “clienttest“) = 0) ns_g_clienttest = TYBS_TRUE; else fprintf(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_version, n

26、s_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();

27、 ns_main_earlyfatal(“extra command line arguments“); static tybs_result_t 天一博胜企业管理软件V1.0 源代码9 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_c

28、pus = 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_cre

29、ate(ns_g_mctx, ns_g_cpus, 0, 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, if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_, “tybs_timerm

30、gr_create() failed: %s“, tybs_result_totext(result); return (TYBS_R_UNEXPECTED); result = tybs_socketmgr_create2(ns_g_mctx, if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_, “tybs_socketmgr_create() failed: %s“, tybs_result_totext(result); return (TYBS_R_UNEXPECTED); result = tybs_socke

31、tmgr_getmaxsockets(ns_g_socketmgr, 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, if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_, “tybs_entropy

32、_create() failed: %s“, tybs_result_totext(result); return (TYBS_R_UNEXPECTED); result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE); 天一博胜企业管理软件V1.0 源代码10 if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_, “tybs_hash_create() failed: %s“, tybs_result_totext(result); return

33、 (TYBS_R_UNEXPECTED); return (TYBS_R_SUCCESS); static void destroy_managers(void) ns_lwresd_shutdown(); tybs_entropy_detach( if (ns_g_fallbackentropy != NULL) tybs_entropy_detach( tybs_taskmgr_destroy( tybs_timermgr_destroy( tybs_socketmgr_destroy( tybs_hash_destroy(); static void setup(void) tybs_r

34、esult_t result; #ifdef HA VE_LIBSCF char *instance = NULL; #endif ns_os_inituserinfo(ns_g_username); ns_os_tzset(); ns_os_opendevnull(); #ifdef HA VE_LIBSCF result = ns_smf_get_instance( if (result = TYBS_R_SUCCESS) ns_smf_got_instance = 1; else ns_smf_got_instance = 0; if (instance != NULL) tybs_me

35、m_free(ns_g_mctx, instance); #endif /* HA VE_LIBSCF */ #ifdef PATH_RANDOMDEV if (ns_g_chrootdir != NULL) result = tybs_entropy_create(ns_g_mctx, if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(“tybs_entropy_create() failed: %s“, tybs_result_totext(result); result = tybs_entropy_createfilesource(ns_

36、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( 天一博胜企业管理软件V1.0 源代码11 #endif ns_os_chroot(ns_g_chrootdir); ns_os_minprivs(); result = ns_log_in

37、it(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_

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

39、getlimit(tybs_resource_stacksize, (void)tybs_resource_getlimit(tybs_resource_datasize, (void)tybs_resource_getlimit(tybs_resource_coresize, (void)tybs_resource_getlimit(tybs_resource_openfiles, if (! tybs_file_isabsolute(ns_g_conffile) result = tybs_file_absolutepath(ns_g_conffile, absolute_conffile

40、, sizeof(absolute_conffile); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(“could not construct absolute path of “ “configuration file: %s“, tybs_result_totext(result); ns_g_conffile = absolute_conffile; result = tybs_time_now( if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(“tybs_time_now() fai

41、led: %s“, tybs_result_totext(result); result = create_managers(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(“create_managers() failed: %s“, tybs_result_totext(result); ns_builtin_init(); #ifdef DLZ result = dlz_drivers_init(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(“dlz_drivers_init

42、() failed: %s“, tybs_result_totext(result); #endif 天一博胜企业管理软件V1.0 源代码12 ns_server_create(ns_g_mctx, static void cleanup(void) destroy_managers(); ns_server_destroy( ns_builtin_deinit(); #ifdef DLZ dlz_drivers_clear(); #endif dns_name_destroy(); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LO

43、GMODULE_MAIN, TYBS_LOG_NOTICE, “exiting“); 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, filen

44、ame); #ifdef HA VE_LIBSCF tybs_result_t ns_smf_get_instance(char *ins_name, int debug, tybs_mem_t *mctx) scf_handle_t *h = NULL; int namelen; char *instance; REQUIRE(ins_name != NULL if (h = scf_handle_create(SCF_VERSION) = NULL) if (debug) UNEXPECTED_ERROR(_FILE_, _LINE_, “scf_handle_create() faile

45、d: %s“, scf_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) 天一博胜企业管理

46、软件V1.0 源代码13 UNEXPECTED_ERROR(_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_

47、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_FAILURE

48、); scf_handle_destroy(h); *ins_name = instance; return (TYBS_R_SUCCESS); #endif int main(int argc, char *argv) tybs_result_t result; #ifdef HA VE_LIBSCF char *instance = NULL; #endif strlcat(version, #ifdef _DATE_ “named version: BIND “ VERSION “ (“ _DATE_ “)“, #else “named version: BIND “ VERSION, #endif sizeof(version); result = tybs_file_progname(*argv, program_name, sizeof(program_name); if (result != TYBS_R_SUCCESS) ns_main

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1