软件著作权源代码范本_第1页
软件著作权源代码范本_第2页
软件著作权源代码范本_第3页
软件著作权源代码范本_第4页
软件著作权源代码范本_第5页
已阅读5页,还剩126页未读 继续免费阅读

下载本文档

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

文档简介

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

2、;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/tim

3、er.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_smCgloba!s.h>#endif#ifdef DLZ#include <dlz/d

4、lz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE; static charprogram_nameTYBS_DIR_NAMEMAX ''named''static charabsolute_conffileTYBS_DIR_PATHMAX;static charsaved_command_line512;static charversion512;static unsigned int maxsocks = 0;voidns_main_earlywarning(const ch

5、ar "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, n%s: program_name);vfprintf(stderi; format, args);fprintf(stderr, nnn);fflush(stderr);)va_end(args);

6、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_Ictx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN,TYBS LOG CRITICAL,nexiting

7、(due to early fatal error)n); else fprintf(stderr, n%s: program_name);vfprintf(stderi; format, args);fprintf(stderr, nnn);fflush(stderr);va_end(args);exit(l);)static voidassertion_failed(const charint line,tybs_assertiontype_t type,const char *cond)if (ns_g_lctx != NULL) tybs_assertion_setcallback(N

8、ULL);tybs_log_write(ns_g_lctx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN,TYBS LOG CRITICAL,n%s:%d: %s(%s) failed”, file, line,tybs_assertion_typetotext(type)9 cond);tybs_log_write(ns_g_Ictx9 NS_LOGCATEGORY_GENERAL, NS LOGMODULE MAIN, TYBS LOG CRITICAL,nexiting (due to assertion failure)11); else fprin

9、tf(stderr, n%s:%d: %s(%s) failednffile, line, tybs_assertion_typetotext(type), cond);fflush(stderr);)if (ns_g_coreok)abort();exit(l);static voidlibrary_fatal_error(const char *行加,int line, const charformat,vajist args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_fatal_error(const charint line, const

10、 charformat,va_list args)(if (ns_g_lctx != NULL) tybs_error_setfatal(NULL);tybs_log_write(ns_g_Ictx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN,TYBS LOG CRITICAL,H%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_w

11、rite(ns_g_lctx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN,TYBS LOG CRITICAL,nexiting (due to fatal error in library)''); else fprintf(stderr, n%s:%d: fatal error: file, line);vfprintf(stderi; format, args);fprintf(stderr, nnn);fflush(stderr);)if (ns_g_coreok) abort();exit(l);)static voidlibrar

12、y_unexpected_error(const charint line,const char *format,vajist args) TYBS_FORMAT_PRINTF(3, 0); static voidlibrary_unexpected_error(const charint line,const char "format, vajist args)(if (ns_g_lctx != NULL) tybs_log_write(ns_g_lctx9NS_LOGCATEGORY_GENERAL, NS LOGMODULE MAIN, TYBS LOG ERROR, M%s:

13、%d: unexpected errorfile, line); tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS LOGMODULE MAIN, TYBS LOG ERROR, format, args); else fprintf(stderr, n%s:%d: fatal error: file, line);vfprintf(stderi; format, args);fprintf(stderr, nnn);fflush(stderr);)static voidlwresd_usage(void) fprintf(stderr

14、,''usage: Iwresd -41-6 -c conffile I -C resolvconffile ftn-d debuglevelnn''-fl-g -n number_of_cpus -pport nn-Plisten-port -snn''-t chrootdir -u username -ipidfilennn-musageltracelrecordlsizelmctxnn);static voidusage(void) if (ns_g_lwresdonly) lwresd_usage();return;)fprintf(st

15、derr,nusage: named -41-6 -c conffile -d debuglevel nn-fl-g -n number_of_cpusnf ,''-p port -s -t chrootdir -uusernamenMn-musageltracelrecordlsizelmctxnn);)static voidsave_command_line(int argc, char *argv口)int i;char *src;char *dst;char *eob;const char truncated = .'';tybs_boolean_t q

16、uoted = TYBS_FALSE;dst = saved_command_line;eob= saved_command_line +sizeof(sa ved_command_line);for (i = 1; i < argc && dst < eob; i+) *dst+ =,';src = argvi;while (*src != '0' && dst < eob) if (quoted II isalnum(src & Oxff) II*src II *src II*src = T II *src

17、= '/') *dst+ = *src+;quoted = TYBS_FALSE; else *dst+ = TV;quoted = TYBS_TRUE;)INSIST(sizeof(saved_command_line)>=sizeof(truncated);if (dst = eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '0')static intparse_int(char *arg, const char *desc) char *endp;int tmp;long int I

18、tmp;Itmp = strtol(arg9 &endp910);tmp = (int) Itmp;if (*endp !=、(),)ns_main_earlyfatal(n %s '%s' must be numeric desc, arg);if (tmp < 0 II tmp != Itmp)ns_main_earlyfatal(1 f %s 1 %s1 out of range* desc, arg);return (tmp);static struct flag_def const char *name;unsigned int value; mem_d

19、ebug_flags = ''trace'', TYBS_MEM_DEBUGTRACE , nrecordn, TYBS_MEM_DEBUGRECORD , ''usage'', TYBS_MEM_DEBUGUSAGE , ''size'', TYBS_MEM_DEBUGSIZE , nmctxn9 TYBS_MEM_DEBUGCTX , NULL, 0 );static voidset_flags(const char *arg, struct flag_def *defs, unsigned i

20、nt *ret) for (;) const struct flag_def *def;const char *end = strchr(arg, f);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(arg9 def->name9 arglen) = 0) *ret 1= def->valu

21、e;goto found;)ns_main_early fatal(11 unrecognized flag ' arglen, arg);found:if (*end =、(),) break;arg = end + 1;)static voidparse_command_line(int argc9 char *argv) int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc9 argv);tybs_comman

22、dline_errprint = TYBS_FALSE;while (ch = tybs_commandline_parse(argc9 argv, n46c:C:d:fgi:lm:n:N:p:P:H HsS:t:T:u:vVx:H) != -1) switch (ch) case '4':if (disabledns_main_earlyfatal(1 f cannot specify -4 and6);if (tybs_net_probeipv4() != TYBS_R_SUCCESS) ns_main_earlyfatal(f 1 IPv4 not supported b

23、yOS'');tybs_net_disableipv6();disable6 = TYBS TRUE;break;case '6':if (disable6)ns_main_earlyfatal(1 * cannot specify -4 and 6);if (tybs_net_probeipv6() != TYBS_R_SUCCESS) ns_main_earlyfatal(f 1 IPv6 not supported by os”);tybs_net_disableipv4();disable4 = TYBS TRUE;break;case 'c&#

24、39;:ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile=tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal(f 1 cannot specify -c and-cn);ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile=tybs_commandline_argument;if (ns_g_conffileset)ns_main_ear

25、lyfatal(1 f cannot specify -c andlwresd_g_useresolvconf = TYBS_TRUE; break;case'd':ns_g_debuglevelparse_int(tybs_commandline_argument9H debug leveln);break;casens_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should

26、be removed */case T:lwresd_g_defaultpidfile tybs_commandline_argument;break;case T: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_comman

27、dline_argument, Mnumber of cpusn); if (ns_g_cpus = 0) ns_g_cpus = 1; break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 II port > 65535) ns_main_earlyfatal(f 1 port '%s' out of range1 tybs_commandline_argument);ns_g_port = port;break;/* XX

28、XBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 II port > 65535)ns_main_earlyfatal(11 port '%s' out of range! tybs_commandline_argument);lwresd_g_listenport = port;break;case s :want stats = TYBS TRUE;break;case &

29、#39;S':maxsocks=parse_int(tybs_commandline_argument9“max number of sockets11);break;case 't':ns_g_chrootdir = tybs_commandline_ar gument;break;case T:if (strcmp(tybs_commandline_argument9Hclienttestn) = 0)ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, nunknown -T flag tybs_commandline_a

30、rgument);break;case 'u':ns_g_username = ty bs_commandline_ar gument;break;case 'v':printf(HBIND %sn' ns_g_version);exit(0);case 'V':printf(HBIND %s built with %sn”,ns_g_version,ns_g_configargs);exit(O);caseusage();if (tybs_commandline_option ='?')exit(O);ns_main_e

31、arlyfatal(*funknown option !-%cn tybs_commandline_option);default:ns_main_early fatal(1 f parsingoptionsreturned %d' ch);)argc -= tybs_commandline_index;argv += ty bs_commandline_index;if (argc > 0) usage();ns_main_early fatal(11 extracommand linearguments'');)static tybs_result_tcrea

32、te_managers(void) tybs_result_t result;unsigned int socks;#ifdef TYBS PLATFORM USETHREADSunsigned 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,TY

33、BS_LOG_INFO, "found %u CPU%s, using %u worker thread%sn,cpus_detected9 cpus_detected = 1 ? nn :ns_g_cpus9 ns_g_cpus = 1 ? nn : ''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(

34、_FILE_, _LINE, M 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, fftybs_timermgr_create() failed: %s' tybs_result_totext(

35、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, 1 ftybs_socketmgr_create() failed: %s' tybs_result_totext(result);return (TYBS_R_UNEXPECTED);)result=tybs_socketmgr_getmaxso

36、ckets(ns_g_socketmgr, &socks);if (result = TYBS_R_SUCCESS) tybs_log_write(ns_g_Ictx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE SERVER,TYBS_LOG_INFO, "using up to %u socketssocks);)result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LIN

37、E, 1 ftybs_entropy_create() failed: %sn, 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, ntybs_hash_create() failed: %s”, tybs_result_totext(result);return (TYBS_

38、R_UNEXPECTED);return (TYBS_R_SUCCESS);)static voiddestroy_managers(void) ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)ty bs_entropy_detach( &ns_g_fallbackentropy);tybs_taskmgr_destroy(&ns_g_taskmgr); tybs_timermgr_destroy(&ns_g_timermgr); t

39、ybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();static voidsetup(void) tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HAVE_LIBSCFresult =ns_smf_get_instance( &instance90,ns_g_mctx);if (r

40、esult = TYBS_R_SUCCESS) ns_smCgot_instance = X;elsens_smCgot_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx9 instance);#endif/* HAVE_LIBSCF */#ifdef PATH_RANDOMDEVif (ns_g_chrootdir != NULL) result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS) n

41、s_main_earlyfatal(1 * tybs_entropy_create() failed: %s",tybs_result_totext(result);resulttybs_entropy_createfilesource(ns_g_fallbackentropy, PATH_RANDOMDEV);if (result != TYBS_R_SUCCESS) ns_main_early warning(11 couldnot openpre-chroot''nentropy source %s: %s'1PATH RANDOMDEV, tybs_r

42、esult_totext(result); tybs_entropy_detach(&ns_g_fallbackentropy);)#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(1 fns_log_init() failed: %s' tybs_result_totext(result);if (! ns_g_foregro

43、und) ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal(1 ftybs_app_start() failed: %s' tybs_result_totext (result);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN, TYBS_LOG_NOTICE9n startingBIND %s%sf ns_g_version, saved_command_line);

44、tybs_log_write(ns_g_lctx9NS_LOGCATEGORY_GENERAL,NS LOGMODULE MAIN,TYBS LOG NOTICE, nbuilt with %s”, ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize, &ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize9 &ns_g_initdatasize);(void)tybs_resource_getlimi

45、t(tybs_resource_coresize, &ns_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_

46、earlyfatal(11 could not construct absolute path of HHconfiguration 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(11 tybs_time_now() failed: %s' ty bs_result_totext(result);re

47、sult = create_managers();if (result != TYBS_R_SUCCESS)ns_main_early fatal(1 f create_managers()failed: %s", tybs_result_totext(result);ns_builtin_init();#ifdef DLZresult = dlz_dri vers_init();if (result != TYBS_R_SUCCESS)ns_main_early fatal(11 dlz_dri vers_init () failed: % s'', tybs_re

48、sult_totext (result);#endifns_server_create(ns_g_mctx, &ns_g_server);static voidcleanup(void) destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS LOGMODULE MAIN,TYBS

49、_LOG_NOTICE, Exiting1);ns_log_shutdown();)static char *memstats = NULL;voidns_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 HAVE_LIBSCFt

50、ybs_result_tns_smCget_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, f*scf_handle_create() failed: %s&

51、#39; scf_strerror(scf_error();return (TYBS_R_FAILURE);)if (scf_handle_bind(h) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE, f*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(_F

52、ILE, _LINE, nscf_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 一 nns_smf_get_instance memoryHallocation failed: %s'tybs_result_totext(TYBS_R_NOMEMORY);scf_handl

53、e_destroy(h);return (TYBS_R_FAILURE);)if (scjmyname(h, instance, namelen + 1) = -1) if (debug)UNEXPECTED_ERROR(_FILE, _LINE, nscf_myname() failed: %s scf_strerror(scf_error();scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);scf_handle_destroy(h);*ins_name = instance;return

54、 (TYBS_R_SUCCESS);)#endifintmain(int argc, char *argv) tybs_result_t result;#ifdef HAVE LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef _DATE“named version: BIND '' VERSION ''('' DATE#else"named version: BIND n VERSION,#endifsizeof(version);result = tybs_file_pr

55、ogname(*argv, program_name, sizeof(program_name);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal(1 fprogram name too long'');if (strcmp(program_name91 f 1 wresd *f) = 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);tybs_erro

56、r_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(ns_g_chrootdir);if (strncmp(ns_g_chrootdir; ns_g_conffile, len) = 0 &&(ns_g_conff

57、ilelen = II ns_g_conffilelen='、')ns_main_earlywarning(11 config filename (-c %s) contains ''nchroot path (-t %s)f ns_g_conffile, ns_g_chrootdir);)result = tybs_mem_create(O, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_early fatal(f 1 tybs_mem_create()failed: %s”, tybs_result_totext(result);tybs_mem_setname(ns_g_mctx9 fTmain11, NULL);setup();do result = tybs_app_run();if (result = TYBS_R_RELOAD) ns_server_reloadwanted(ns_g_s

温馨提示

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

评论

0/150

提交评论