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

下载本文档

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

文档简介

软件著作权-源代码范本软件著作权-源代码范本软件著作权-源代码范本软件著作权-源代码范本编制仅供参考审核批准生效日期地址:电话:传真:邮编:软件著作权-源代码范本注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。范例如下:#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybs/>#include<tybscc/>#include<dns/>#include<dns/>#include<dns/>#include<dns/>#include<dst/>#defineNS_MAIN1#include<named/>#endif#ifdefDLZ#include<dlz/>#endifstatictybs_boolean_t want_stats=TYBS_FALSE;staticchar program_name[TYBS_DIR_NAMEMAX]="named";staticchar absolute_conffile[TYBS_DIR_PATHMAX];staticchar saved_command_line[512];staticchar version[512];staticunsignedint maxsocks=0;voidns_main_earlywarning(constchar*format,...){ va_listargs; 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(stderr); } va_end(args);}Voidns_main_earlyfatal(constchar*format,...){ va_listargs; 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_LOG_CRITICAL, "exiting(duetoearlyfatalerror)"); }else{ fprintf(stderr,"%s:",program_name); vfprintf(stderr,format,args); fprintf(stderr,"\n"); fflush(stderr); } va_end(args); exit(1);}staticvoidassertion_failed(constchar*file,intline,tybs_assertiontype_ttype, constchar*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_LOGMODULE_MAIN,TYBS_LOG_CRITICAL, "exiting(duetoassertionfailure)"); }else{ fprintf(stderr,"%s:%d:%s(%s)failed\n", file,line,tybs_assertion_typetotext(type),cond); fflush(stderr); } if(ns_g_coreok) abort(); exit(1);}staticvoidlibrary_fatal_error(constchar*file,intline,constchar*format, va_listargs)TYBS_FORMAT_PRINTF(3,0);staticvoidlibrary_fatal_error(constchar*file,intline,constchar*format, va_listargs){ 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:fatalerror:",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(duetofatalerrorinlibrary)"); }else{ fprintf(stderr,"%s:%d:fatalerror:",file,line); vfprintf(stderr,format,args); fprintf(stderr,"\n"); fflush(stderr); } if(ns_g_coreok) abort(); exit(1);}staticvoidlibrary_unexpected_error(constchar*file,intline,constchar*format, va_listargs)TYBS_FORMAT_PRINTF(3,0);staticvoidlibrary_unexpected_error(constchar*file,intline,constchar*format, va_listargs){ if(ns_g_lctx!=NULL){ tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,TYBS_LOG_ERROR, "%s:%d:unexpectederror:",file,line); tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,TYBS_LOG_ERROR, format,args); }else{ fprintf(stderr,"%s:%d:fatalerror:",file,line); vfprintf(stderr,format,args); fprintf(stderr,"\n"); fflush(stderr); }}staticvoidlwresd_usage(void){ fprintf(stderr, "usage:lwresd[-4|-6][-cconffile|-Cresolvconffile]" "[-ddebuglevel]\n" "[-f|-g][-nnumber_of_cpus][-pport]" "[-Plisten-port][-s]\n" "[-tchrootdir][-uusername][-ipidfile]\n" "[-m{usage|trace|record|size|mctx}]\n");}staticvoidusage(void){ if(ns_g_lwresdonly){ lwresd_usage(); return; } fprintf(stderr, "usage:named[-4|-6][-cconffile][-ddebuglevel]" "[-f|-g][-nnumber_of_cpus]\n" "[-pport][-s][-tchrootdir][-uusername]\n" "[-m{usage|trace|record|size|mctx}]\n");}staticvoidsave_command_line(intargc,char*argv[]){ inti; char*src; char*dst; char*eob; constchartruncated[]="..."; tybs_boolean_tquoted=TYBS_FALSE; dst=saved_command_line; eob=saved_command_line+sizeof(saved_command_line); for(i=1;i<argc&&dst<eob;i++){ *dst++=''; src=argv[i]; while(*src!='\0'&&dst<eob){ if(quoted||isalnum(*src&0xff)|| *src=='-'||*src=='_'|| *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';}staticintparse_int(char*arg,constchar*desc){ char*endp; inttmp; longintltmp; ltmp=strtol(arg,&endp,10); tmp=(int)ltmp; if(*endp!='\0') ns_main_earlyfatal("%s'%s'mustbenumeric",desc,arg); if(tmp<0||tmp!=ltmp) ns_main_earlyfatal("%s'%s'outofrange",desc,arg); return(tmp);}staticstructflag_def{ constchar*name; unsignedintvalue;}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}};staticvoidset_flags(constchar*arg,structflag_def*defs,unsignedint*ret){ for(;;){ conststructflag_def*def; constchar*end=strchr(arg,','); intarglen; if(end==NULL) end=arg+strlen(arg); arglen=end-arg; for(def=defs;def->name!=NULL;def++){ if(arglen==(int)strlen(def->name)&& memcmp(arg,def->name,arglen)==0){ *ret|=def->value; gotofound; } } ns_main_earlyfatal("unrecognizedflag'%.*s'",arglen,arg); found: if(*end=='\0') break; arg=end+1; }}staticvoidparse_command_line(intargc,char*argv[]){ intch; intport; tybs_boolean_tdisable6=TYBS_FALSE; tybs_boolean_tdisable4=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_earlyfatal("cannotspecify-4and-6"); if(tybs_net_probeipv4()!=TYBS_R_SUCCESS) ns_main_earlyfatal("IPv4notsupportedbyOS"); tybs_net_disableipv6(); disable6=TYBS_TRUE; break; case'6': if(disable6) ns_main_earlyfatal("cannotspecify-4and-6"); if(tybs_net_probeipv6()!=TYBS_R_SUCCESS) ns_main_earlyfatal("IPv6notsupportedbyOS"); 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("cannotspecify-cand-C"); ns_g_conffileset=TYBS_TRUE; break; case'C': lwresd_g_resolvconffile=tybs_commandline_argument; if(ns_g_conffileset) ns_main_earlyfatal("cannotspecify-cand-C"); lwresd_g_useresolvconf=TYBS_TRUE; break; case'd': ns_g_debuglevel=parse_int(tybs_commandline_argument, "debuglevel"); break; case'f': ns_g_foreground=TYBS_TRUE; break; case'g': ns_g_foreground=TYBS_TRUE; ns_g_logstderr=TYBS_TRUE; break; /*XXXBEW-ishouldberemoved*/ case'i': lwresd_g_defaultpidfile=tybs_commandline_argument; break; case'l': 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_commandline_argument, "numberofcpus"); if(ns_g_cpus==0) ns_g_cpus=1; break; case'p': port=parse_int(tybs_commandline_argument,"port"); if(port<1||port>65535) ns_main_earlyfatal("port'%s'outofrange", tybs_commandline_argument); ns_g_port=port; break; /*XXXBEWShould-Pberemoved*/ case'P': port=parse_int(tybs_commandline_argument,"port"); if(port<1||port>65535) ns_main_earlyfatal("port'%s'outofrange", tybs_commandline_argument); lwresd_g_listenport=port; break; case's': want_stats=TYBS_TRUE; break; case'S': maxsocks=parse_int(tybs_commandline_argument, "maxnumberofsockets"); break; case't': ns_g_chrootdir=tybs_commandline_argument; break; case'T': if(strcmp(tybs_commandline_argument,"clienttest")==0) ns_g_clienttest=TYBS_TRUE; else fprintf(stderr,"unknown-Tflag'%s\n", tybs_commandline_argument); break; case'u': ns_g_username=tybs_commandline_argument; break; case'v': printf("BIND%s\n",ns_g_version); exit(0); case'V': printf("BIND%sbuiltwith%s\n",ns_g_version, ns_g_configargs); exit(0); case'': usage(); if(tybs_commandline_option=='') exit(0); ns_main_earlyfatal("unknownoption'-%c'", tybs_commandline_option); default: ns_main_earlyfatal("parsingoptionsreturned%d",ch); } } argc-=tybs_commandline_index; argv+=tybs_commandline_index; if(argc>0){ usage(); ns_main_earlyfatal("extracommandlinearguments"); }}statictybs_result_tcreate_managers(void){ tybs_result_tresult; unsignedintsocks;#ifdefTYBS_PLATFORM_USETHREADS unsignedintcpus_detected;#endif#ifdefTYBS_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, TYBS_LOG_INFO,"found%uCPU%s,using%uworkerthread%s", cpus_detected,cpus_detected==1"":"s", ns_g_cpus,ns_g_cpus==1"":"s");#else ns_g_cpus=1;#endif result=tybs_taskmgr_create(ns_g_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){ UNEXPECTED_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()failed:%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,"usingupto%usockets",socks); } result=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_R_SUCCESS){ UNEXPECTED_ERROR(__FILE__,__LINE__, "tybs_hash_create()failed:%s", tybs_result_totext(result)); return(TYBS_R_UNEXPECTED); } return(TYBS_R_SUCCESS);}staticvoiddestroy_managers(void){ ns_lwresd_shutdown(); tybs_entropy_detach(&ns_g_entropy); if(ns_g_fallbackentropy!=NULL) tybs_entropy_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();}staticvoidsetup(void){ tybs_result_tresult;#ifdefHAVE_LIBSCF char*instance=NULL;#endif ns_os_inituserinfo(ns_g_username); ns_os_tzset(); ns_os_opendevnull();#ifdefHAVE_LIBSCF result=ns_smf_get_instance(&instance,0,ns_g_mctx); if(result==TYBS_R_SUCCESS) ns_smf_got_instance=1; else ns_smf_got_instance=0; if(instance!=NULL) tybs_mem_free(ns_g_mctx,instance);#endif/*HAVE_LIBSCF*/#ifdefPATH_RANDOMDEV if(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(result!=TYBS_R_SUCCESS){ ns_main_earlywarning("couldnotopenpre-chroot" "entropysource%s:%s", PATH_RANDOMDEV, tybs_result_totext(result)); tybs_entropy_detach(&ns_g_fallbackentropy); } }#endif ns_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("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(result)); tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE,"startingBIND%s%s",ns_g_version, saved_command_line); tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE,"builtwith%s",ns_g_configargs); (void)tybs_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); 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("couldnotconstructabsolutepathof" "configurationfile:%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("tybs_time_now()failed:%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();#ifdefDLZ result=dlz_drivers_init(); if(result!=TYBS_R_SUCCESS) ns_main_earlyfatal("dlz_drivers_init()failed:%s", tybs_result_totext(result));#endif ns_server_create(ns_g_mctx,&ns_g_server);}staticvoidcleanup(void){ destroy_managers(); ns_server_destroy(&ns_g_server); ns_builtin_deinit();#ifdefDLZ dlz_drivers_clear();#endif dns_name_destroy(); tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE,"exiting"); ns_log_shutdown();}staticchar*memstats=NULL;voidns_main_setmemstats(constchar*filename){ if(memstats!=NULL){ free(memstats); memstats=NULL; } if(filename==NULL) return; memstats=malloc(strlen(filename)+1); if(memstats) strcpy(memstats,filename);}#ifdefHAVE_LIBSCFtybs_result_tns_smf_get_instance(char**ins_name,intdebug,tybs_mem_t*mctx){ scf_handle_t*h=NULL; intnamelen; 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) 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) 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_instancememory" "allocationfailed:%s", tybs_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); } scf_handle_destroy(h); *ins_name=instance; return(TYBS_R_SUCCESS);}#endifintmain(intargc,char*argv[]){ tybs_result_tresult;#ifdefHAVE_LIBSCF char*instance=NULL;#endif strlcat(version,#ifdef__DATE__ "namedversion:BIND"VERSION"("__DATE__")",#else "namedversion:BIND"VERSION,#endif sizeof(version)); result=tybs_file_progname(*argv,program_name,sizeof(program_name)); if(result!=TYBS_R_SUCCESS) ns_main_earlyfatal("programnametoolong"); if(strcmp(program_name,"lwresd")==0) ns_g_lwresdonly=TYBS_TRUE; tybs_assertion_setcallback(assertion_failed); tybs_error_setfatal(library_fatal_error); tybs_error_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){ intlen=strlen(ns_g_chrootdir); if(strncmp(ns_g_chrootdir,ns_g_conffile,len)==0&& (ns_g_conffile[len]=='/'||ns_g_conffile[len]=='\\')) ns_main_earlywarning("configfilename(-c%s)contains" "chrootpath(-t%s)", ns_g_conffile,ns_g_chrootdir); } result=tybs_mem_create(0,0,&ns_g_mctx); if(result!=TYBS_R_SUCCESS) ns_main_earlyfatal("tybs_mem_create()failed:%s", tybs_result_totext(result)); tybs_mem_setname(ns_g_mctx,"main",NULL); setup(); do{ result=tybs_app_run(); if(result==TYBS_R_RELOAD){ ns_server_reloadwanted(ns_g_server); }elseif(result!=TYBS_R_SUCCESS){ UNEXPECTED_ERROR(__FILE__,__LINE__, "tybs_app_run():%s", tybs_result_totext(result)); result=TYBS_R_SUCCESS; } }while(result!=TYBS_R_SUCCESS);#ifdefHAVE_LIBSCF if(ns_smf_want_disable==1){ result=ns_smf_get_instance(&instance,1,ns_g_mctx); if(result==TYBS_R_SUCCESS&&instance!=NULL){ if(smf_disable_instance(instance,0)!=0) UNEXPECTED_ERROR(__FILE__,__LINE__, "smf_disable_instance()" "failedfor%s:%s", instance, scf_strerror(scf_error())); } if(instance!=NULL) tybs_mem_free(ns_g_mctx,instance); }#endif/*HAVE_LIBSCF*/ cleanup(); if(want_stats){ tybs_mem_stats(ns_g_mctx,stdout); tybs_mutex_stats(stdout); } if(ns_g_memstatistics&&memstats!=NULL){ FILE*fp=NULL; result=tybs_stdio_open(memstats,"w",&fp); if(result==TYBS_R_SUCCESS){ tybs_mem_stats(ns_g_mctx,fp); tybs_mutex_stats(fp); tybs_stdio_close(fp); } } tybs_mem_destroy(&ns_g_mctx); tybs_mem_checkdestroyed(stderr); ns_main_setmemstats(NULL); tybs_app_finish(); ns_os_closedevnull(); ns_os_shutdown(); return(0);}#defineZEND_INCLUDE_FULL_WINDOWS_HEADERS#include""#include<>#include<>#ifdefPHP_WIN32#include"win32/"#include"win32/"#include"win32/"#include<>#elifdefined(NETWARE)#include<sys/>#ifdefUSE_WINSOCK#include<>#endif#endif#ifHAVE_SYS_TIME_H#include<sys/>#endif#ifHAVE_UNISTD_H#include<>#endif#ifHAVE_SIGNAL_H#include<>#endif#ifHAVE_SETLOCALE#include<>#endif#include""#include""#include""#include""#include""#include""#include"ext/standard/"#include""#include"ext/standard/"#ifdefPHP_WIN32#include<>#include"win32/"#include"ext/standard/"#endif#include""#include"Zend/"#ifPHP_SIGCHILD#include<sys/>#include<sys/>#endif#include""#include""#include""#include""#include""#include""#include""#include""#include""#include""#include""#include""#include""/*}}}*/#ifndefZTSphp_core_globalscore_globals;#elsePHPAPIintcore_globals_id;#endif#defineSAFE_FILENAME(f)((f)(f):"-")/*{{{PHP_INI_MH*/staticPHP_INI_MH(OnSetPrecision){ inti=atoi(new_value); if(i>=0){ EG(precision)=i; returnSUCCESS; }else{ returnFAILURE; }}staticPHP_INI_MH(OnChangeMemoryLimit){ if(new_value){ PG(memory_limit)=zend_atoi(new_value,new_value_length); }else{ PG(memory_limit)=1<<30; /*effectively,nolimit*/ } returnzend_set_memory_limit(PG(memory_limit));}staticvoidphp_disable_functions(TSRMLS_D){ char*s=NULL,*e; if(!*(INI_STR("disable_functions"))){ return; } e=PG(disable_functions)=strdup(INI_STR("disable_functions")); while(*e){ switch(*e){ case'': case',': if(s){ *e='\0'; zend_disable_function(s,e-sTSRMLS_CC); s=NULL; } break; default: if(!s){ s=e; } break; } e++; } if(s){ zend_disable_function(s,e-sTSRMLS_CC); }}staticvoidphp_disable_classes(TSRMLS_D){ char*s=NULL,*e; if(!*(INI_STR("disable_classes"))){ return; } e=PG(disable_classes)=strdup(INI_STR("disable_classes")); while(*e){ switch(*e){ case'': case',': if(s){ *e='\0'; zend_disable_class(s,e-sTSRMLS_CC); s=NULL; } break; default: if(!s){ s=e; } break; } e++; } if(s){ zend_disable_class(s,e-sTSRMLS_CC); }}staticPHP_INI_MH(OnUpdateTimeout){ EG(timeout_seconds)=atoi(new_value); if(stage==PHP_INI_STAGE_STARTUP){ /*Don'tsetatimeoutonstartup,onlyper-request*/ returnSUCCESS; } zend_unset_timeout(TSRMLS_C); zend_set_timeout(EG(timeout_seconds)); returnSUCCESS;}staticintphp_get_display_errors_mode(char*value,intvalue_length){ intmode; if(!value){ returnPHP_DISPLAY_ERRORS_STDOUT; } if(value_length==2&&!strcasecmp("on",value)){ mode=PHP_DISPLAY_ERRORS_STDOUT; }elseif(value_length==3&&!strcasecmp("yes",value)){ mode=PHP_DISPLAY_ERRORS_STDOUT; }elseif(value_length==4&&!strcasecmp("true",value)){ mode=PHP_DISPLAY_ERRORS_STDOUT; }elseif(value_length==6&&!strcasecmp(value,"stderr")){ mode=PHP_DISPLAY_ERRORS_STDERR; }elseif(value_length==6&&!strcasecmp(value,"stdout")){ mode=PHP_DISPLAY_ERRORS_STDOUT; }else{ mode=atoi(value); if(mode&&mode!=PHP_DISPLAY_ERRORS_STDOUT&&mode!=PHP_DISPLAY_ERRORS_STDERR){ mode=PHP_DISPLAY_ERRORS_STDOUT; } } returnmode;}staticPHP_INI_MH(OnUpdateDisplayErrors){ PG(display_errors)=(zend_bool)php_get_display_errors_mode(new_value,new_value_length); returnSUCCESS;}staticPHP_INI_DISP(display_errors_mode){ intmode,tmp_value_length,cgi_or_cli; char*tmp_value; TSRMLS_FETCH(); if(type==ZEND_INI_DISPLAY_ORIG&&ini_entry->modified){ tmp_value=(ini_entry->orig_valueini_entry->orig_value:NULL); tmp_value_length=ini_entry->orig_value_length; }elseif(ini_entry->value){ tmp_value=ini_entry->value; tmp_value_length=ini_entry->value_length; }else{ tmp_value=NULL; tmp_value_length=0; } mode=php_get_display_errors_mode(tmp_value,tmp_value_length); cgi_or_cli=(!strcmp,"cli")||!strcmp,"cgi")); switch(mode){ casePHP_DISPLAY_ERRORS_STDERR: if(cgi_or_cli){ PUTS("STDERR"); }else{ PUTS("On"); } break; casePHP_DISPLAY_ERRORS_STDOUT: if(cgi_or_cli){ PUTS("STDOUT"); }else{ PUTS("On"); } break; default: PUTS("Off"); break; }}staticPHP_INI_MH(OnUpdateErrorLog){ /*Onlydothesafemode/open_basedircheckatruntime*/ if((stage==PHP_INI_STAGE_RUNTIME||stage==PHP_INI_STAGE_HTACCESS)&& strcmp(new_value,"syslog")){ if(PG(safe_mode)&&(!php_checkuid(new_value,NULL,CHECKUID_CHECK_FILE_AND_DIR))){ returnFAILURE; } if(PG(open_basedir)&&php_check_open_basedir(new_valueTSRMLS_CC)){ returnFAILURE; } } OnUpdateString(entry,new_value,new_value_length,mh_arg1,mh_arg2,mh_arg3,stageTSRMLS_CC); returnSUCCESS;}staticPHP_INI_MH(OnChangeMailForceExtra){ /*Don'tallowchangingitinhtaccess*/ if(stage==PHP_INI_STAGE_HTACCESS){ returnFAILURE; } returnSUCCESS;}#ifndefPHP_SAFE_MODE_EXEC_DIR# definePHP_SAFE_MODE_EXEC_DIR""#endif#ifdefined(PHP_PROG_SENDMAIL)&&!defined(NETWARE)# defineDEFAULT_SENDMAIL_PATHPHP_PROG_SENDMAIL"-t-i"#elifdefined(PHP_WIN32)# defineDEFAULT_SENDMAIL_PATHNULL#else# defineDEFAULT_SENDMAIL_PATH"/usr/sbin/sendmail-t-i"#endifPHPAPIvoidphp_log_err(char*log_messageTSRMLS_DC){ intfd=-1; charerror_time_str[128]; structtmtmbuf; time_terror_time; /*Trytousethespecifiedlogginglocation.*/ if(PG(error_log)!=NULL){#ifdefHAVE_SYSLOG_H if(!strcmp(PG(error_log),"syslog")){ php_syslog(LOG_NOTICE,"%.500s",log_message); return; }#endif fd=VCWD_OPEN_MODE(PG(error_log),O_CREAT|O_APPEND|O_WRONLY,0644); if(fd!=-1){ char*tmp; intlen; time(&error_time); strftime(error_time_str,sizeof(error_time_str),"%d-%b-%Y%H:%M:%S",php_localtime_r(&error_time,&tmbuf)); len=spprintf(&tmp,0,"[%s]%s%s",error_time_str,log_message,PHP_EOL);#ifdefPHP_WIN32 php_flock(fd,2);#endif write(fd,tmp,len); efree(tmp); close(fd); return; } } /*Otherwisefallbacktothedefaultlogginglocation,ifwehaveone*/ if{ (log_message); }}PHPAPIintphp_write(void*buf,uintsizeTSRMLS_DC){ returnPHPWRITE(buf,size);}/*}}}*//*{{{php_printf*/PHPAPIintphp_printf(constchar*format,...){ va_listargs; intret; char*buffer; intsize; TSRMLS_FETCH(); va_start(args,format); size=vspprintf(&buffer,0,format,args); ret=PHPWRITE(buffer,size); efree(buffer); va_end(args); returnret;}/*}}}*//*{{{php_verrorhelpers*//*{{{php_during_module_startup*/staticintphp_during_module_startup(void){ returnmodule_startup;}/*}}}*//*{{{php_during_module_shutdown*/staticintphp_during_module_shutdown(void){ returnmodule_shutdown;}/*}}}*//*}}}*//*{{{php_verror*//*php_verroriscalledfromphp_error_docref<n>functions.*Itspurposeistounifyerrormessagesandautomaticallygenerateclickable*htmlerrormessagesifcorrecpondinginisetting(html_errors)isactivated.*See:CODING_STANDARDSfordetails.*/PHPAPIvoidphp_verror(constchar*docref,constchar*params,inttype,constchar*format,va_listargsTSRMLS_DC){ char*buffer=NULL,*docref_buf=NULL,*target=NULL; char*docref_target="",*docref_root=""; char*p; intbuffer_len=0; char*space; char*class_name=get_active_class_name(&spaceTSRMLS_CC); char*function; intorigin_len; char*origin; char*message; intis_function=0; /*geterrortextintobufferandescapeforhtmlifnecessary*/ buffer_len=v

温馨提示

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

评论

0/150

提交评论