当前位置:文档之家› 软件著作权-源代码范本

软件著作权-源代码范本

软件著作权-源代码范本注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。

提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。

格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。

、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。

范例如下:#i nclude <tybs/comma ndli ne.h>#in clude <tybs/dir.h>#in clude <tybs/e ntropy .h>#in clude <tybs/file.h>#in clude <tybs/hash.h>#i nclude <tybs/os.h>#i nclude <tybs/platform.h 〉#in clude <tybs/resource.h>#i nclude <tybs/stdio.h>#in clude <tybs/stri ng.h>#in clude <tybs/task.h>#in clude <tybs/timer.h>#in clude <tybs/util.h>#in clude <tybscc/result.h>#in clude <dn s/dis patch.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 DLZ#in clude <dlz/dlz_drivers.h>#en difstatic tybs_l static charstatic charstatic charstatic charstatic un signed intvoidn s_ma in _earlywar nin g(c onst char *format, ...) {va_list args; va_start(args, format); if (n s_g_lctx != NULL) {tybs_log_vwrite( ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_W ARNING, format, args);} else {fprin tf(stderr, "%s: ", p rogram_ name); vfprin tf(stderr, format, args);fprin tf(stderr, "\n"); fflush(stderr);}va_e nd(args);}Void n s_ma in _earlyfatal(c onst char *format, ...) { va_list args;va_start(args, format);if (n s_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_LOG_CRITICAL, "exit ing (due to early fatal error)"); } else {fprin tf(stderr, "%s: ", p rogram_ name);vfprin tf(stderr, format, args);fprin tf(stderr, "\n"); fflush(stderr);} boolean_t wan t_stats = TYBS_FALSE;p rogram_ name[TYBS_DIR_NAMEMAX] = "n amed"; absolute_co nffile[TYBS_DIR_ PATHMAX]; saved_comma nd_li ne[512]; version [512]; maxsocks = 0;va_e nd(args);exit(1);}static voidassert ion _failed(c onst char *file, in t li ne, tybs_assert iontype_t type, const char*cond){if (n s_g_lctx != NULL) {tybs_assert ion _setcallback(NULL); tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, "%s:%d: %s(%s) failed", file, li ne, tybs_assert ion_typ etotext(t yp e), con d); tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, "exit ing (due to asserti on failure)");} else {fprin tf(stderr, "%s:%d: %s(%s) failed\n", file, li ne, tybs_assert ion_typ etotext(t yp e), 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_FORMAT_ PRINTF(3, 0); static voidlibrary_fatal_error(c onst char *file, i nt li ne, const char *format, va_list args){if (n s_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_wnte( ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, "%s:%d: fatal error:", file, li ne);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, "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_ unexp ected_error(c onst char *file, i nt li ne, const char *format, va_list args) TYBS_FORMAT_ PRINTF(3, 0);static voidlibrary, unexp ected_error(c onst char *file, i nt li ne, const char *format, va_list args){if (n s_g_lctx != NULL) {tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, "%s:%d: unexp ected error:", file, li ne);tybs_log_vwrite( ns_g_lctx, 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(stderr,"usage: lwresd 卜4卜6] [-c con ffile | -C resolvco nffile]""[-d debuglevel]\n"" [-f|-g] [-n n umber_o1_c pus] [-p p ort]""[-P liste n-p ort] [-s]\n"" [-t chrootdir] [-u user name] [-i pi dfile]\n"[-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {if (n s_g_lwresdo niy) { lwresd_usage();return;}fprin tf(stderr,"usage: named [-4|-6] [-c con ffile] [-d debuglevel]""[-f|-g] [-n nu mber_of_c pus]\n"" [-p p ort] [-S] [-t chrootdir] [-u user name]' n"[-m {usage|trace|record|size|mctx}]\n");}static voidsave_comma nd_li ne(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 = saved_comma nd_li ne + sizeof(saved_comma nd_li ne); for (i = 1; i < argc && dst < eob; i++) { *dst++ ='';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isal nu m(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_comma nd_li ne) >= sizeof(tr un cated)); if (dst == eob)strc py (eob - sizeof(tr un cated), trun cated);else*dst = '\0';}static intp arse_ in t(char *arg, const char *desc) { char *endp;int tmp;long int Itmp;Itmp = strtol(arg, &endp, 10);tmp = (int) Itmp;if (*endp != '\0')n s_ma in _earlyfatal("%s '%s' must be nu meric", desc, arg); if (tmp < 0 II tmp != Itmp)n s_ma in _earlyfatal("%s '%s' out of ran ge", desc, arg);return (tm p);}static struct flag_def {const char *n ame;un sig ned 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 voidset_flags(c onst char *arg, struct flag_def *defs, un sig ned int *ret) { for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int argle n;if (end == NULL)end = arg + strle n( arg);argle n = end - arg;for (def = defs; def->n ame != NULL; def++) {if (argle n == (in t)strle n(def->n ame) && memcm p( arg, def->n ame, argle n) == 0) { *ret |= def->value;goto found;}}n s_ma in _earlyfatal(" un recog ni zed flag '%.*s'", argle n, arg); found:if (*e nd == '\0')break;arg = end + 1;}}static voidp arse_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_comma ndli ne_p arse(argc, argv,"46c:C:d:fgi:lm: n:N: p:P:" "sS:t:T:u:vVx:")) != -1) {switch (ch) {case 4:if (disabled n s_ma in _earlyfatal("ca nnot sp ecify -4 and -6");if (tybs_ net_p robei pv4() != TYBS_R_SUCCESS)n s_ma in _earlyfatal("I Pv4 not supp orted by OS");tybs_ net_disable ipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)n s_ma in _earlyfatal("ca nnot sp ecify -4 and -6");if (tybs_ net_p robei pv6() != TYBS_R_SUCCESS)n s_main_earlyfatal("I Pv6 not supp orted by OS");tybs_ net_disable ipv4();disable4 = TYBS_TRUE;break;case 'c':n s_g_c on ffile = tybs_comma ndli ne_argume nt; lwresd_g_c on ffile = tybs_comma ndli ne_argume nt; if (lwresd_g_useresolvc onf)n s_ma in _earlyfatal("ca nnot sp ecify -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 sp ecify -c and -C");lwresd_g_useresolvco nf = TYBS_TRUE; break;case 'd':n s_g_debuglevel = p arse_ in t(tybs_comma ndli ne_argume nt, "debug level");break;case f:n s_g_foregrou nd = 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_default pi dfile = tybs_comma ndli ne_argume nt; break;case 'l':n s_g_lwresdo niy = TYBS_TRUE;break;case 'm':set_flags(tybs_comma ndli ne_argume nt, mem_debug_flags, &tybs_mem_debuggi ng);break;case 'N': /* Dep recated. */case 'n':n s_g_c pus = p arse_ in t(tybs_comma ndli ne_argume nt, "nu mber of cpu s");if (n s_g_c pus == 0)n s_g_c pus = 1;break;case 'p':port = p arse_ in t(tybs_comma ndli ne_argume nt, "po rt"); if (port < 1 II port > 65535)n s_ma in _earlyfatal( "port '%s' out of ran ge", tybs_comma ndli ne_argume nt); ns_g_port = p ort;break;/* XXXBEW Should -P be removed? */case 'P':port = p arse_ in t(tybs_comma ndli ne_argume nt, "po rt"); if (port < 1 II port > 65535)n s_ma in _earlyfatal( "port '%s' out of ra nge", tybs_comma ndli ne_argume nt);lwresd_g_liste nport = p ort;break;case 's':wa nt_stats = TYBS_TRUE;break;case 'S':maxsocks = p arse_ in t(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 (strcm p( tybs_comma ndli ne_argume nt, "clie nttest") == 0) n s_g_clie nttest = TYBS_TRUE;elsefprin tf(stderr, "unknown -T flag '%s\n", 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 %s\n", ns_g_versio n);exit(0);case 'V':prin tf("BIND %s built with %s\n", n s_g_versio n, n s_g_c on figargs);exit(0);case '?':usage();if (tybs_comma ndli ne_op ti on == ?) exit(O);n s_main_earlyfatal("u nknown op ti on '-%c'", tybs_comma ndli ne_op ti on);default:n s_ma in _earlyfatal( "parsing op tio ns returned %d", ch); }}argc -= tybs_comma ndli ne_in dex;argv += tybs_comma ndli ne_in dex;if (argc > 0) {usage();n s_ma in _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 _P LATFORM_USETHREADSun sig ned int cpu s_detected;#en dif#ifdef TYBS _P LATFORM_USETHREADScpu s_detected = tybs_ os_ncp us();if (n s_g_c pus == 0)n s_g_c pus = cpu s_detected;tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "found %u CP U%s, using %u worker thread%s",cpu s_detected, cpu s_detected == 1 ? "" : "s",n s_g_c pus, n s_g_c pus == 1 ? "" : "s");#elsen s_g_c pus = 1;#e ndifresult = tybs_taskmgr_create( ns_g_mctx, n s_g_c pus, 0, &n s_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEX PECTED_ERROR(_FILE_, _LINE_, "tybs_taskmgr_create() failed: %s", tybs_result_totext(result));return (TYBS_R_UNEX PECTED);}result = tybs_timermgr_create( ns_g_mctx, &n s_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEX PECTED_ERROR(_FILE_, __LINE__, "tybs_timermgr_create() failed: %s", tybs_result_totext(result));return (TYBS_R_UNEX PECTED);}result = tybs_socketmgr_create2( ns_g_mctx, &n s_g_socketmgr, maxsocks); if (result != TYBS_R_SUCCESS) { UNEX PECTED_ERROR(_FILE_, __LINE__,"tybs_socketmgr_create() failed: %s", tybs_result_totext(result));return (TYBS_R_UNEX PECTED);}result = tybs_socketmgr_getmaxsockets (n s_g_socketmgr, &socks);if (result == TYBS_R_SUCCESS) {tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "usi ng up to %u sockets", socks);}result = tybs_e ntrop y_create( ns_g_mctx, &n s_g_e ntropy);if (result != TYBS_R_SUCCESS) {UNEX PECTED_ERROR(_FILE_, __LINE__,"tybs_e ntrop y_create() failed: %s", tybs_result_totext(result));return (TYBS_R_UNEX PECTED);}result = tybs_hash_create( ns_g_ mctx, ns_g_e ntro py, DNS_NAME_MAXWIRE); if (result != TYBS_R_SUCCESS) { UNEX PECTED_ERROR(_FILE_, __LINE__,"tybs_hash_create() failed: %s", tybs_result_totext(result));return (TYBS_R_UNEX PECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_ma nagers(void) {n s_lwresd_shutdow n();tybs_e ntrop y_detach(&n s_g_e ntropy);if (n s_g_fallbacke ntro py != NULL)tybs_e ntrop y_detach(&n s_g_fallbacke ntropy);tybs_taskmgr_destro y(&n s_g_taskmgr);tybs_timermgr_destro y(&n s_g_timermgr);tybs_socketmgr_destro y(&n s_g_socketmgr);tybs_hash_destroy();}static voidset up( void) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *in sta nee = NULL;#e ndifn s_os_ in ituseri nfo(n s_g_user name);n s_os_tzset();n s_os_ open dev 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_g ot_in sta nee = 0;if (in sta nee != NULL) tybs_mem_free( ns_g_mctx, in sta nee);#endif /* HA VE_LIBSCF */#ifdef P ATH_RANDOMDEVif (n s_g_chrootdir != NULL) {result = tybs_e ntrop y_create (n s_g_mctx, &n s_g_fallbacke ntropy); if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal("tybs_e ntrop y_create() failed: %s", tybs_result_totext(result));result = tybs_e ntrop y_createfilesource (n s_g_fallbacke ntropy, PATH _RANDOMDEV);if (result != TYBS_R_SUCCESS) {n s_ma in _earlywar nin g("could not open p re-chroot " "entropy source %s: %s", P ATH—RANDOMDEV ,tybs_result_totext(result));tybs_e ntrop y_detach(&n s_g_fallbacke ntropy);}}#en difnsos_chroot(n s_g_chrootdir);ns_os_ minp rivs();result = n s_log_i nit(TYBS_TF( ns_g_username != NULL));if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal(" ns_log_ in it() failed: %s", tybs_result_totext(result));if (!n s_g_foregro und)n s_os_daem oni ze();result = tybs_a pp_start();if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal("tybs_a pp_start() failed: %s", tybs_result_totext(result));tybs_log_write( ns_g_lctx, NS_LOGCATEGORY_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_g_lctx, 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 itstacksize);(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_ open files,&ns_g_in it open files);if (! tybs_file_isabsolute( ns_g_c on ffile)) {result = tybs_file_absolute path( ns_g_c on ffile,absolute_c on ffile,sizeof(absolute_c on file));if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal("could not con struct absolute p ath of " "con figurati on 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 (result != TYBS_R_SUCCESS)n s_ma in _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_builtin _in it();#ifdef DLZresult = dlz_drivers_i nit();if (result != TYBS_R_SUCCESS)n s_main_earlyfatal("dlz_drivers_i nit() failed: %s",tybs_result_totext(result));#en difn s_server_create (n s_g_mctx, &n s_g_server);}static voidclea nup( void) {destroy_ma nagers();n s_server_destroy(&n s_g_server);n s_builti n_dein it();#ifdef DLZdlz_drivers_clear();#e ndifdns_n ame_destroy();tybs_log_write( ns_g_lctx, 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(strle 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_VERSION)) == NULL) { if (debug)UNEX PECTED_ERROR(_FILE_, __LINE__, "scf_ha ndle_create() failed: %s", scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_ha ndle_bi nd(h) == -1) { if(debug)UNEX PECTED_ERROR(_FILE_, __LINE__,"scf_ha ndle_bi nd() failed: %s", scf_strerror(scf_error()));scf_ha ndle_destroy(h); return (TYBS_R_FAILURE);}if ((n amele n = scf_m yn ame(h, NULL, 0)) == -1) { if (debug)UNEX PECTED_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) { UNEX PECTED_ERROR(_FILE_, __LINE__,"n s_smf_get_ in sta nee memory ""allocatio n 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)UNEX PECTED_ERROR(_FILE_, __LINE__,"scf_m yn ame() failed: %s", scf_strerror(scf_error()));scf_ha ndle_destroy(h); tybs_mem_free(mctx, i nsta nee); return (TYBS_R_FAILURE);}scf_ha ndle_destroy(h);*ins_n ame = in sta nee;retur n (TYBS_R_SUCCESS);}#en difintmain (i nt argc, char *argv[]) { tybs_result_t result;#ifdef HA VE_LIBSCFchar *in sta nee = NULL;#e ndifstrlcat(vers ion,#ifdef __DATE__"n amed versio n: BIND " VERSION " (" __DA TE__ ")",#else"n amed versio n: BIND " VERSION,#e ndifsizeof(vers ion));result = tybs_file_ progn ame(*argv, p rogram_ name, sizeof( program, name)); if (result != TYBS_R_SUCCESS) n s_ma in _earlyfatal( "p rogram n ame too Ion g");if (strcm p(p rogram_ name, "lwresd") == 0)n s_g_lwresdo niy = TYBS_TRUE;tybs_assert ion _setcallback(assert ion _failed); tybs_error_setfatal(library_fatal_error);tybs_error_set unexp ected(library_ unexp ected_error);n s_os_ in it (p rogram_ name);dn s_result_register();dst_result_register();tybscc_result_register();p arse_comma nd_li ne(argc, argv);if (n s_g_chrootdir != NULL) {int len = strle n(n s_g_chrootdir);if (str ncmp(n s_g_chrootdir, n s_g_c on ffile, le n) == 0 &&(n s_g_c on ffile[le n] == '/' || n s_g_c on ffile[le n] == '\\'))n s_ma in _earlywar nin g("c onfig file name (-c %s) contains ""chroot path (-t %s)",n s_g_c on ffile, n s_g_chrootdir);}result = tybs_mem_create(O, 0, &n s_g_mctx);if (result != TYBS_R_SUCCESS)n s_ma in _earlyfatal("tybs_mem_create() failed: %s", tybs_result_totext(result));tybs_mem_set name( ns_g_mctx, "mai n", NULL);setu p();do {result = tybs_a pp_run();if (result == TYBS_R_RELOAD) {n s_server_reloadwa nted( ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEX PECTED_ERROR(_FILE_, _LINE_ "tybs_a pp_run (): %s", tybs_result_totext(result));result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HA VE_LIBSCFif (n s_smf_wa nt_disable == 1) {result = n s_smf_get_ in sta nce(&in sta nee, 1, n s_g_mctx); if (result == TYBS_R_SUCCESS && in sta nee != NULL) { if (smf_disable_ in sta nce(i nsta nee, 0) != 0)UNEX PECTED_ERROR(_FILE_, __LINE__ "smf_disable_ in sta nce()" "failed for %s : %s", in sta nee,scf_strerror(scf_error()));}if (in sta nee != NULL)tybs_mem_free( ns_g_mctx, in sta nee);}#endif /* HA VE_LIBSCF */clea nup();if (wa nt_stats) {tybs_mem_stats( ns_g_mctx, stdout); tybs_mutex_stats(stdout);}if (n s_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_ open( memstats, "w", &fp); if (result == TYBS_R_SUCCESS) { tybs_mem_stats (n s_g_mctx, fp); tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&n s_g_mctx); tybs_mem_checkdestroyed(stderr);n s_main_setmemstats(NULL);tybs_a pp_fini sh();n s_os_closedev nu 11();n s_os_shutdow n();return (0);}#defi ne ZEND_INCLUDE_FULL_WINDOWS_HEADERS#i nclude "php .h"#i nclude <stdio.h>#in clude <fcn tl.h>#ifdef PH P_WIN32#i nclude "wi n32/time.h"#i nclude "wi n32/sig nal.h"#i nclude "wi n32/php_wi n32_globals.h"#in clude <pro cess.h>#elif defined(NETW ARE)#i nclude <sys/timeval.h> #ifdef USE_WINSOCK #in clude <no vsoek2.h> #en dif #en dif #if HA VE_SYS_TIME_H #in clude <sys/time.h> #e ndif #if HA VE_UNISTD_H#in clude <uni std.h> #en dif #if HA VE_SIGNAL_H #in clude <sig nal.h> #e ndif #if HA VE_SETLOCALE#in clude <loeale.h> #en dif #in elude "ze nd.h" #in elude "zend extensions.h" #i nclude "php_in i.h"#in clude "php _globals.h"#i nclude "php_ mai n.h"#in clude "fopen_wrapp ers.h"#in clude "ext/sta ndard/php _sta ndard.h"#in clude "php _variables.h"#in clude "ext/sta ndard/credits.h" #ifdef PH P_WIN32#in clude <io.h> #in clude "win32/php _registry.h"#in clude "ext/sta ndard/flock_co mp at.h" #e ndif #in clude "php _syslog.h"#in clude "Ze nd/ze nd_exce pti on s.h"#if PHP SIGCHILD #in clude <sys/t yp es.h>#i nclude <sys/wait.h> #en dif #i nclude "ze nd_co mp ile.h" #include "zend execute.h" #in clude "ze nd_highlight.h"#include "zend indent.h" #inelude "zend extensions.h" #include "zend ini.h" #in clude "php_content_typ es.h"#i nclude "p hp_tieks.h"#in clude "php _logos.h"#in clude "php _streams.h"#in clude "php_open_tempo rary_file.h" #in clude "SAP I.h" #in elude "rfc1867.h"/* }}} */#ifndef ZTSphp _core_globals core_globals;#elsePHPAPI int core_globals_id;#en dif#defi ne SAFE_FILENAME(f) ((f)?(f):"-")/* {{{ PHP_INI_MH*/static PHP_INI_MH(On Set Precisi on){int i = ato i(n ew_value); if (i >= 0) {EG( precisi on) = i; return SUCCESS;} else {return FAILURE;} }static PH P_INI_MH(O nCha ngeMemoryLimit){if (n ew_value) {P G(memory_limit) = zen d_ato i(n ew_value, n ew_value_le ngth); } else {P G(memory_limit) = 1<<30;/* effectively, no limit */ }return zen d_set_memory_limit (P G(memory_limit));}static void php_disable_fu nctio ns(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_fu nctio ns"))) {return;}e = P G(disable_fu nctio ns) = strdu p(INI_STR("disable_fu nctio ns")); while (*e) {switch (*e) {case '':case ',':if (s) {*e = '\0';zen d_disable_fu nctio n(s, e-s TSRMLS_CC); s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zen d_disable_fu nctio n(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_classes"))) {return;}e = P G(disable_classes) = strdu p(INI_STR("disable_classes")); while (*e) {switch (*e) {case '':case ',':if (s) {*e = '\0';zen d_disable_class(s, e-s TSRMLS_CC); s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zen d_disable_class(s, e-s TSRMLS_CC);} }static PH P_INI_MH(O nUp dateTimeout){EG(timeout_sec on ds) = ato i(n ew_value);if (stage==PH P_INI_STAGE_START UP) {/* Don't set a timeout on start up, only p er-request */ return SUCCESS;}zen d_u nset_timeout(TSRMLS_C);zen d_set_timeout(EG(timeout_sec on ds)); retur n SUCCESS;}static int php _get_dis play_errors_mode(char *value, int value_le ngth) {int mode;if (!value) { return PH P_DIS PLAY_ERRORS_STDOUT;}if (value_le ngth == 2 && !strcasecm p(” on", value)) { mode = PH P_DIS PLAY_ERRORS_STDOUT;} else if (value_le ngth == 3 && !strcasecm p("yes", value)) { mode = PH P_DIS PLAY_ERRORS_STDOUT;} else if (value_le ngth == 4 && !strcasecm p("true", value)) { mode = PH P_DIS PLAY_ERRORS_STDOUT;} else if (value_le ngth == 6 && !strcasecm p( value, "stderr")) { mode = PH P_DIS PLAY_ERRORS_STDERR;} else if (value_le ngth == 6 && !strcasecm p( value, "stdout")) { mode = PH P_DIS PLAY_ERRORS_STDOUT;} else {mode = atoi(value);if (mode && mode != PH P_DIS PLAY_ERRORS_STDOUT&& mode !=PH P_DIS PLAY_ERRORS_STDERR) {mode = PH P_DIS PLAY_ERRORS_STDOUT;}} return mode;}static PH P_INI_MH(O nUp dateDis playErrors) {PG(dis play_errors) = (ze nd_bool) php _get_dis play_errors_mode( new_value, n ew_value_le ngth); retur n SUCCESS;}static PH P_INI_DIS P(dis play_errors_mode){int mode, tmp_value_le ngth, cgi_or_cli;char *tmp _value;TSRMLS_FETCH();if (type == ZEND_INI_DIS PLAY_ORIG && ini_en try->modified) { tmp_value = (ini_en try->orig_value ? ini_en try->orig_value : NULL );。

相关主题