版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、天一博胜企业管理软件V1.0 源代码1计算机软件著作权登记-源代码范本注意事项:常见的源代码包含:C语言,VB,C+,JAVA,.NET等。提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。格式要求:一、源代码应提交前、后各连续 30页,不足60页的,应当全部提交。二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于 50行。范例如下:#i nclude #in elude #i nclude #in elud
2、e #in elude #i nclude #i nclude #i nclude #i nclude #in clude #in clude 天一博胜企业管理软件V1.0 源代码3#in elude #in elude #in elude #in elude #in elude #in elude #in elude #in elude #defi ne NS_MAIN 1#i nclude #en dif#ifdef DLZ#in elude #en difstatie tybs_boolean_twan t_stats = TYBS_FALSE;statie eharstatie eha
3、rstatie eharstatie eharstatie un sig ned int voidprogram_ nameTYBS_DIR_NAMEMAX = n amed; absolute_eo nffileTYBS_DIR_PATHMAX; saved_eomma nd_li ne512;versio n512;maxsoeks = 0;n s_ma in _earlywar nin g(e onst ehar *format, .) va_list args;va_start(args, format);if (ns_gctx != NULL) tybs_log_vwrite( ns
4、_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_W ARNING, format, args); else fprin tf(stderr, %s: , program_ name);vfprin tf(stderr, format, args);fprin tf(stderr, n);fflush(stderr);va_e nd(args);Void n s_ma in _earlyfatal(e onst ehar *format, .) va_list args;va_start(args, format);if (n
5、s_gctx != NULL) tybs_log_vwrite( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, format, args);tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, exit ing (due to early fatal error); else fprin tf(stderr, %s: , program_ name);vfprin tf(stder
6、r, format, args);fprin tf(stderr, n);fflush(stderr);天一博胜企业管理软件V1.0 源代码9va_e nd(args);exit(1);static voidassert ion _failed(c onst char *file, in t li ne, tybs_assert ion type_t type,const char *cond)if (ns_gctx != NULL) tybs_assert ion _setcallback(NULL); tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENE
7、RAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, %s:%d: %s(%s) failed, file, line, tybs_assert ion _typetotext(type), con d); tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, exit ing (due to asserti on failure); else fprin tf(stderr, %s:%d: %s(%s) failedn,file, li ne,
8、tybs_assert ion _typetotext(type), con d); fflush(stderr);if (n s_g_coreok)abort();exit(1);static voidlibrary_fatal_error(c onst char *file, i nt li ne, const char *format,va_list args) TYBS_FORMA T_PRINTF(3, 0); static voidlibrary_fatal_error(c onst char *file, i nt li ne, const char *format,va_lis
9、t args)if (ns_gctx != NULL) tybs_error_setfatal(NULL); tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, %s:%d: fatal error:, file, li ne);tybs_log_vwrite( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, format, args);tybs_log_write( ns_gctx
10、, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, exit ing (due to fatal error in library); else fprin tf(stderr, %s:%d: fatal error: , file, li ne);vfprin tf(stderr, format, args);fprin tf(stderr, n); fflush(stderr);if (n s_g_coreok)abort();exit(1);static voidlibrary, un expected_error
11、(c onst char *file, i nt li ne, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_ un expected_error(c onst char *file, i nt li ne, const char *format, va_list args)if (ns_gctx != NULL) tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, %s
12、:%d: unexpected error:, file, line);tybs_log_vwrite( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, format, args); else fprin tf(stderr, %s:%d: fatal error: , file, li ne);vfprin tf(stderr, format, args);fprin tf(stderr, n);fflush(stderr);static voidlwresd_usage(void) fprin tf(s
13、tderr,usage: lwresd 卜4卜6 -c con ffile | -C resolvco nffile-d debugleveln-f|-g _n n umber_of_cpus _p port-P liste n-port -sn-t chrootdir -u user name -i pidfilen-m usage|trace|record|size|mctxn);static voidusage(void) if (n s_g_lwresdo nly) lwresd_usage();return;fprin tf(stderr,usage: named -4|-6 -c
14、con ffile -d debuglevel-f|-g -n nu mber_of_cpusn-p port -s -t chrootdir -u user name n-m usage|trace|record|size|mctxn);static voidsave_comma ndin e(i nt argc, char *argv) int i;char *src;char *dst;char *eob;const char trun cated=.;tybs_boolean_t quoted = TYBS_FALSE;dst = saved_comma nd_li ne;eob =
15、saved_comma nd_li ne + sizeof(saved_comma nd_li ne); for (i = 1; i argc & dst eob; i+) *dst+ =;src = argvi;while (*src != 0 & dst = sizeof(tr un cated);if (dst = eob)strcpy(eob - sizeof(tr un cated), trun cated);else*dst = 0;static intparse_ in t(char *arg, const char *desc) char *en dp;int tmp;long
16、 int ltmp;ltmp = strtol(arg, &en dp, 10);tmp = (int) ltmp;if (*en dp != 0)n s_ma in _earlyfatal(%s %s must be nu meric, desc, arg);if (tmp n ame != NULL; def+) if (argle n = (in t)strle n(def-n ame) & memcmp(arg, def-n ame, argle n) = 0) *ret |= def-value;goto found;ns_main_earlyfatal(unrecognized f
17、lag %.*s, arglen, arg); found:if (*e nd = 0)break;arg = end + 1;static voidparse_comma nd_li ne(i nt argc, char *argv) int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE; save_comma nd_li ne(argc, argv);tybs_comma ndli ne_errpri nt = TYBS_FALSE;while (ch = tybs
18、_comma ndli ne_parse(argc, argv, 46c:C:d:fgi:lm: n:N:p:P: sS:t:T:u:vVx:) != -1) switch (ch) case 4:if (disable4)n s_ma in _earlyfatal(ca nnot specify -4 and -6);if (tybs_ net_probeipv4() != TYBS_R_SUCCESS) n s_ma in _earlyfatal(IPv4 not supported by OS); tybs_ net_disableipv6();disable6 = TYBS_TRUE;
19、break;case 6:if (disable6)n s_ma in _earlyfatal(ca nnot specify -4 and -6);if (tybs_ net_probeipv6() != TYBS_R_SUCCESS) n s_main_earlyfatal(IPv6 not supported by OS);tybs_ net_disableipv4();disable4 = TYBS_TRUE;break;case c:n s_g_c on ffile = tybs_comma ndli ne_argume nt; lwresd_g_c on ffile = tybs_
20、comma ndli ne_argume nt; if (lwresd_g_useresolvc onf)n s_ma in _earlyfatal(ca nnot specify -c and -C);n s_g_c on ffileset = TYBS_TRUE;break;case C:lwresd_g_resolvc on ffile = tybs_comma ndli ne_argume nt;if (n s_g_c on ffileset)n s_ma in _earlyfatal(ca nnot specify -c and -C); lwresd_g_useresolvco n
21、f = TYBS_TRUE;break;case d:n s_g_debuglevel = parsen t(tybs_comma ndli ne_argume nt,debug level);break;case f:n s_g_foregro und = TYBS_TRUE;break;case g:n s_g_foregro und = TYBS_TRUE;n s_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case i:lwresd_g_defaultpidfile = tybs_comma ndli n
22、e_argume nt; break;case T:ns_gwresdo nly = TYBS_TRUE;break;case m:set_flags(tybs_comma ndli ne_argume nt, mem_debug_flags, &tybs_mem_debuggi ng);break;case N: /* Deprecated. */case n:n s_g_cpus = parse_ in t(tybs_comma ndli ne_argume nt,nu mber of cpus);if (n s_g_cpus = 0)n s_g_cpus = 1;break;case p
23、:port = parse_ in t(tybs_comma ndli ne_argume nt, port);if (port 65535)n s_ma in _earlyfatal(port %s out of ran ge, tybs_comma ndli ne_argume nt);n s_g_port = port;break;/* XXXBEW Should -P be removed? */case P:port = parse_ in t(tybs_comma ndli ne_argume nt, port);if (port 65535)n s_ma in _earlyfat
24、al(port %s out of ran ge, tybs_comma ndli ne_argume nt); lwresd_g_liste nport = port;break;case s: wan t_stats = TYBS_TRUE; break;case S:maxsocks = parsent(tybs_comma ndli ne_argume nt,max nu mber of sockets);break;case t:n s_g_chrootdir = tybs_comma ndli ne_argume nt; break;case T:if (strcmp(tybs_c
25、omma ndli ne_argume nt, clie nttest) = 0) n s_g_clie nttest = TYBS_TRUE;elsefprin tf(stderr, unknown -T flag %sn, tybs_comma ndli ne_argume nt); break;case u:n s_g_user name = tybs_comma ndli ne_argume nt; break;case v:prin tf(BIND %sn, ns_g_versio n);exit(0);case V:prin tf(BIND %s built with %sn, n
26、 s_g_versio n, n s_g_c on figargs);exit(0);case ?:usage();if (tybs_comma ndli ne_opti on = ?)exit(0);n s_ma in _earlyfatal( unknown opti on -%c, tybs_comma ndli ne_opti on);default:n s_ma in _earlyfatal(pars ing optio ns returned %d, ch);argc -= tybs_comma ndli ne_in dex;argv += tybs_comma ndli ne_i
27、n dex;if (argc 0) usage();n s_main_earlyfatal(extra comma nd line argume nts);static tybs_result_tcreate_ma nagers(void) tybs_result_t result;un sig ned int socks;#ifdef TYBS_PLATFORM_USETHREADSun sig ned int cpus_detected;#en dif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_ os_n cpus();天一博胜企
28、业管理软件V1.0 源代码#if (n s_g_cpus = 0) n s_g_cpus = cpus_detected;tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,TYBS_LOGNFO, found %u CPU%s, using %u worker thread%s, cpus_detected, cpus_detected = 1 ? : s, n s_g_cpus, n s_g_cpus = 1 ? : s);#elsen s_g_cpus = 1;#en difresult = tybs_
29、taskmgr_create( ns_g_mctx, n s_g_cpus, 0, &n s_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, &n s_g_timermgr);if (result != TYBS_R_SUCCESS) UNE
30、XPECTED_ERROR(_FILE_, _LINE_,tybs_timermgr_create() failed: %s, tybs_result_totext(result);return (TYBS_R_UNEXPECTED);result = tybs_socketmgr_create2( ns_g_mctx, &n s_g_socketmgr, maxsocks);if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_,tybs_socketmgr_create() failed: %s, tybs_result_
31、totext(result);return (TYBS_R_UNEXPECTED);result = tybs_socketmgr_getmaxsockets (n s_g_socketmgr, &socks);if (result = TYBS_R_SUCCESS) tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,TYBS_LOG_INFO, us ing up to %u sockets, socks);result = tybs_e ntropy_create( ns_g_mctx, &n s_g_
32、e ntropy);if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_,tybs_e ntropy_create() failed: %s, tybs_result_totext(result);return (TYBS_R_UNEXPECTED);result = tybs_hash_create( ns_g_ mctx, ns_g_e ntropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) UNEXPECTED_ERROR(_FILE_, _LINE_,tybs_
33、hash_create() failed: %s, tybs_result_totext(result);return (TYBS_R_UNEXPECTED);retur n (TYBS_R_SUCCESS);天一博胜企业管理软件V1.0 源代码19static voiddestroy_ma nagers(void) n s_lwresd_shutdow n();tybs_e ntropy_detach(&n s_g_e ntropy);if (n s_g_fallbacke ntropy != NULL)tybs_e ntropy_detach(&n s_g_fallbacke ntropy
34、); tybs_taskmgr_destro y(&n s_g_taskmgr); tybs_timermgr_destroy(&n s_g_timermgr); tybs_socketmgr_destro y(&n s_g_socketmgr);tybs_hash_destroy();static voidsetup(void) tybs_result_t result;#ifdef HA VE_LIBSCFchar *in sta nee = NULL;#en difn s_os_ in ituseri nfo(n s_g_user name);n s_os_tzset();n s_os_
35、ope ndev nu 11();#ifdef HA VE_LIBSCFresult = n s_smf_get_ in sta nce(&in sta nee, 0, n s_g_mctx);if (result = TYBS_R_SUCCESS)n s_smf_g ot_in sta nee = 1;elsen s_smf_got_i nsta nee = 0;if (in sta nee != NULL)tybs_mem_free( ns_g_mctx, i nsta nee);#endif /* HA VE_LIBSCF */#ifdef PATH_RANDOMDEVif (n s_g
36、_chrootdir != NULL) result = tybs_e ntropy_create (n s_g_mctx, &n s_g_fallbacke ntropy); if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(tybs_e ntropy_create() failed: %s, tybs_result_totext(result);result = tybs_e ntropy_createfilesource (n s_g_fallbacke ntropy, PATH_RANDOMDEV);if (result != TYB
37、S_R_SUCCESS) ns_main_earlywarning(could not open pre-chroot en tropy source %s: %s, PATH_RANDOMDEV , tybs_result_totext(result);tybs_e ntropy_detach(&n s_g_fallbacke ntropy);#en difn s_os_chroot (n s_g_chrootdir);n s_os_ min privs();result = n s_log_i nit(TYBS_TF( ns_g_username != NULL); if (result
38、!= TYBS_R_SUCCESS)n s_main_earlyfatal( nso g_i nit() failed: %s, tybs_result_totext(result);if (!n s_g_foregro und)n s_os_daem oni ze();result = tybs_app_start();if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(tybs_app_start() failed: %s,tybs_result_totext(result);tybs_log_write( ns_gctx, NS_LOGC
39、ATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, starti ng BIND %s%s, ns_g_versio n, saved_comma nd_li ne);tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, built with %s, ns_g_con figargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_in itstacksi
40、ze);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_in itdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize, &ns_g_in itcoresize);(void)tybs_resource_getlimit(tybs_resource_ope nfiles, &ns_g_in itope nfiles);if (! tybs_file_isabsolute( ns_g_c on ffile) result = tybs_file_absolut
41、epath( ns_g_c on ffile, absolute_c on ffile,sizeof(absolute_c on ffile);if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(could not con struct absolute path of configuration file: %s, tybs_result_totext(result);n s_g_c on ffile = absolute_c on ffile;result = tybs_time_ now(&n s_g_boottime);if (resu
42、lt != TYBS_R_SUCCESS)n s_main_earlyfatal(tybs_time _no w() failed: %s, tybs_result_totext(result);result = create_ma nagers();if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(create_ma nagers() failed: %s, tybs_result_totext(result);n s_built inn it();#ifdef DLZresult = dlz_drivers_i nit();if (res
43、ult != TYBS_R_SUCCESS)n s_main_earlyfatal(dlz_drivers_i nit() failed: %s, tybs_result_totext(result);#en difn s_server_create( ns_g_mctx, &n s_g_server);static voidclea nup(void) destroy_ma nagers(); n s_server_destroy( & n s_builti n_dein it();#ifdef DLZdlz_drivers_clear();#en difdns_n ame_destroy(
44、);tybs_log_write( ns_gctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, exit in g);n s_log_shutdow n();static char *memstats = NULL;voidn s_main_setmemstats(c on st char *file name) if (memstats != NULL) free(memstats); memstats = NULL;if (file name = NULL)return;memstats = malloc(str
45、le n(file name) + 1);if (memstats)strcpy(memstats, file name);#ifdef HA VE_LIBSCFtybs_result_tn s_smf_get_i nsta nce(char *ins_n ame, int debug, tybs_mem_t *mctx) scf_ha ndle_t *h = NULL;int n amele n;char *in sta nee;REQUIRE(i ns_n ame != NULL & *i ns_n ame = NULL);if (h = scf_ha ndle_create(SCF_VE
46、RSION) = NULL) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_,scf_handle_create() failed: %s, scf_strerror(scf_error();return (TYBS_R_FAILURE);if (scf_ha ndle_b in d(h) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_,scf_handle_bind() failed: %s, scf_strerror(scf_error();scf_ha ndle_destroy(h);return (TY
47、BS_R_FAILURE);if (n amele n = scf_m yn ame(h, NULL, 0) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_,scf_m yn ame() failed: %s, scf_strerror(scf_error();scf_ha ndle_destroy(h);return (TYBS_R_FAILURE);if (i nsta nee = tybs_mem_allocate(mctx, n amele n + 1) = NULL) UNEXPECTED_ERROR(_FILE_, _LINE_,n
48、s_smf_get_i nsta nee memory allocation failed: %s, tybs_result_totext(TYBS_R_NOMEMORY);scf_ha ndle_destroy(h);return (TYBS_R_FAILURE);if (scf_ myn ame(h, in sta nee, n amele n + 1) = -1) if (debug)UNEXPECTED_ERROR(_FILE_, _LINE_,scf_m yn ame() failed: %s, scf_strerror(scf_error();scf_ha ndle_destroy
49、(h);tybs_mem_free(mctx, i nsta nee);return (TYBS_R_FAILURE);scf_ha ndle_destroy(h);*i ns_n ame = in sta nee;return (TYBS_R_SUCCESS);#en difintmain (i nt argc, char *argv) tybs_result_t result;#ifdef HA VE_LIBSCFchar *in sta nee = NULL;#en difstrlcat(vers ion,#ifdef _DATE_n amed versio n: BIND VERSIO
50、N ( _DA TE_ ),#elsenamed version: BIND VERSION,#en difsizeof(vers ion);result = tybs_file_prog name(*argv, program_ name, sizeof(program_ name); if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(program n ame too Ion g);if (strcmp(program_ name, lwresd) = 0)ns_gwresdo nly = TYBS_TRUE;tybs_assert ion _setcallback(assert ion _failed); tybs_error_setfatal(library_fatal_error);tybs_error_set un expected(library_ un expected_error);n s_os_i nit(program _n ame);dn s_result_register();dst_result_register();tybscc_result_register();parse_comma nd_li ne(argc, arg
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024届广东省广州市仲元中学高三第三次(4月)联考数学试题文试题
- 小红书推广协议合同范本
- 景区观光车运营合同范本
- 2024年专业车辆运送协议格式样本
- 房产交易授权委托协议2024年
- 2024年义齿行业政策分析:义齿行业标准进一步提高患者就医体验
- 2024现代化办公建筑物业管理协议
- 家庭施工图纸设计合同范本
- 投资管理公司合同范本
- 乐器培训合同范本
- 化妆品市场微观环境分析
- MOOC 金羽飞扬-世界冠军的羽毛球课堂-哈尔滨工业大学 中国大学慕课答案
- (正式版)SHT 3075-2024 石油化工钢制压力容器材料选用规范
- 大学生的自己的职业生涯规划
- 教育科学规划课题申请书《基于生活化的幼儿数学教学活动研究》
- 小班数学《认识数字4》课件
- (高清版)DZT 0270-2014 地下水监测井建设规范
- 脑梗死合并高血压患者个案护理
- 2024年中国能源建设集团国际工程有限公司招聘笔试参考题库含答案解析
- 高职专业人才培养方案-会计专业人才培养方案
- 趸船总体建造方案 投标方案(技术方案)
评论
0/150
提交评论