軟件著作權(quán)-源代碼范本課件_第1頁
軟件著作權(quán)-源代碼范本課件_第2頁
軟件著作權(quán)-源代碼范本課件_第3頁
軟件著作權(quán)-源代碼范本課件_第4頁
軟件著作權(quán)-源代碼范本課件_第5頁
已閱讀5頁,還剩55頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、60天一博勝企業(yè)管理軟件V1.0 源代碼 軟件著作權(quán)-源代碼范本 注意事項(xiàng):常見的源代碼包含:C語言,VB,C+,JAVA,.NET等。 提交的代碼必須是源代碼的開頭載入程序,第30頁必須斷開,第60頁是軟件的程序結(jié)尾,代碼中不得出現(xiàn)與申請表內(nèi)容不符合的日期,著作權(quán)人,軟件名字等,不能出現(xiàn)開源代碼,不能出現(xiàn)任何版權(quán)糾紛。格式要求:一、源代碼應(yīng)提交前、后各連續(xù)30頁,不足60頁的,應(yīng)當(dāng)全部提交。二、源代碼頁眉應(yīng)標(biāo)注軟件的名稱和版本號,應(yīng)當(dāng)與申請表中名稱完全一致,頁眉右上應(yīng)標(biāo)注頁碼,源代碼每頁不少于50行。范例如下:#include <tybs/commandline.h>#inclu

2、de <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 <ty

3、bs/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 &l

4、t;dlz/dlz_drivers.h>#endifstatic tybs_boolean_twant_stats = TYBS_FALSE;static charprogram_nameTYBS_DIR_NAMEMAX = "named"static charabsolute_conffileTYBS_DIR_PATHMAX;static charsaved_command_line512;static charversion512;static unsigned intmaxsocks = 0;voidns_main_earlywarning(const char

5、 *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(std

6、err);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

7、_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 line, tybs_assertiontype_t type, co

8、nst 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_LOG

9、MODULE_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(const char *file, int line, const c

10、har *format, va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_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

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

12、:%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, 0);static voidlibrary_unexpected_

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

14、LOG_ERROR, format, args); else fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "n");fflush(stderr);static voidlwresd_usage(void) fprintf(stderr,"usage: lwresd -4|-6 -c conffile | -C resolvconffile ""-d debugleveln&

15、quot;" -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 voidusage(void) if (ns_g_lwresdonly) lwresd_usage();return;fprintf(stderr,"usage: named -4|-6 -c conffile -d deb

16、uglevel ""-f|-g -n number_of_cpusn"" -p port -s -t chrootdir -u usernamen"" -m usage|trace|record|size|mctxn");static voidsave_command_line(int argc, char *argv) int i;char *src;char *dst;char *eob;const char truncated = "."tybs_boolean_t quoted = TYBS_FA

17、LSE;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) | *src = '-' | *src = '_' |

18、 *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 intparse_int(char *arg, const char *d

19、esc) 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 (tm

20、p);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 v

21、oidset_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->nam

22、e) && 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, char *argv) int ch;int port;tybs_boolean_t dis

23、able6 = 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_earlyfat

24、al("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

25、() != 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

26、-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_commandlin

27、e_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_

28、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;

29、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_c

30、ommandline_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_arg

31、ument, "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;elsefprintf(stderr, "unknown -T flag '%sn",tybs_commandline_a

32、rgument);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,ns_g_configargs);exit(0);case '?':usage();if (tybs_commandline_option =

33、 '?')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 com

34、mand 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_detected = tybs_os_ncpus();if (ns_g_cpus = 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_

35、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");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g

36、_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) UNEXPE

37、CTED_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() faile

38、d: %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 =

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

40、_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_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_en

41、tropy_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) tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_

42、username);ns_os_tzset();ns_os_opendevnull();#ifdef HAVE_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 (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HAVE_LIBSCF */#ifdef PATH_RANDOMDE

43、Vif (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 (re

44、sult != 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);#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_usern

45、ame != 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(r

46、esult);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_

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

48、;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 absolute path of " "configuration file: %s", tybs_result_totext(result);ns_g

49、_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_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers() failed: %s&qu

50、ot;, 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);#endifns_server_create(ns_g_mctx, &ns_g_server);static voidcleanup(void) destroy_managers(

51、);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_LOG_NOTICE, "exiting");ns_log_shutdown();static char *memstats = NULL;voidns_main_setmemstats(const cha

52、r *filename) if (memstats != NULL) free(memstats);memstats = NULL;if (filename = NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)strcpy(memstats, filename);#ifdef HAVE_LIBSCFtybs_result_tns_smf_get_instance(char *ins_name, int debug, tybs_mem_t *mctx) scf_handle_t *h = NULL;int name

53、len;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_strerror(scf_error();return (TYBS_R_FAILURE);if (scf_handle_bind(h) = -1) if (debug)UNEXP

54、ECTED_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(_FILE_, _LINE_, "scf_myname() failed: %s", scf_strerror(scf_error();scf_handle_

55、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_result_totext(TYBS_R_NOMEMORY);scf_handle_destroy(h);return (TYBS_R_FAILURE);if (scf_myname(h, instance, namelen + 1) = -1) if (

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論