admin 管理员组文章数量: 887021
2024年2月24日发(作者:易语言加密防破解)
软件著作权源代码范本
Document number:BGCG-0857-BTDO-0089-2022
软件着作权-源代码范本
注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。
提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,着作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。
格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。
二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。
范例如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define NS_MAIN 1
#include
#endif
#ifdef DLZ
#include
#endif
static tybs_boolean_t want_stats = TYBS_FALSE;
static char
static char
static char
static char
program_name[TYBS_DIR_NAMEMAX] = "named";
absolute_conffile[TYBS_DIR_PATHMAX];
saved_command_line[512];
version[512];
maxsocks = 0;
static unsigned int
void
ns_main_earlywarning(const char *format, ...) {
}
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_WARNING,
format, args);
} else {
}
va_end(args);
fprintf(stderr, "%s: ", program_name);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
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_LOG_CRITICAL,
"exiting (due to early fatal error)");
} else {
}
va_end(args);
exit(1);
fprintf(stderr, "%s: ", program_name);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
static void
assertion_failed(const char *file, int line, tybs_assertiontype_t type,
{
const 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_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,
"exiting (due to assertion failure)");
} else {
}
if (ns_g_coreok)
abort();
fprintf(stderr, "%s:%d: %s(%s) failedn",
file, line, tybs_assertion_typetotext(type), cond);
fflush(stderr);
exit(1);
static void
library_fatal_error(const char *file, int line, const char *format,
va_list args) TYBS_FORMAT_PRINTF(3, 0);
static void
library_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 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 {
}
if (ns_g_coreok)
abort();
fprintf(stderr, "%s:%d: fatal error: ", file, line);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
exit(1);
static void
library_unexpected_error(const char *file, int line, const char *format,
va_list args) TYBS_FORMAT_PRINTF(3, 0);
static void
library_unexpected_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_LOG_ERROR,
format, args);
} else {
}
fprintf(stderr, "%s:%d: fatal error: ", file, line);
vfprintf(stderr, format, args);
fprintf(stderr, "n");
fflush(stderr);
static void
lwresd_usage(void) {
}
static void
usage(void) {
fprintf(stderr,
"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] "
"[-d debuglevel]n"
" [-f|-g] [-n number_of_cpus] [-p port] "
"[-P listen-port] [-s]n"
" [-t chrootdir] [-u username] [-i pidfile]n"
" [-m {usage|trace|record|size|mctx}]n");
if (ns_g_lwresdonly) {
}
}
lwresd_usage();
return;
fprintf(stderr,
"usage: named [-4|-6] [-c conffile] [-d debuglevel] "
"[-f|-g] [-n number_of_cpus]n"
" [-p port] [-s] [-t chrootdir] [-u username]n"
" [-m {usage|trace|record|size|mctx}]n");
static void
save_command_line(int argc, char *argv[]) {
int i;
char *src;
char *dst;
char *eob;
const char truncated[] = "...";
tybs_boolean_t quoted = 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';
}
static int
parse_int(char *arg, const char *desc) {
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 (tmp);
}
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 void
set_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->name) &&
}
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 void
parse_command_line(int argc, char *argv[]) {
int ch;
int port;
tybs_boolean_t disable6 = 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_earlyfatal("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() != 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 -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_commandline_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_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;
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_commandline_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_argument,
"max number of sockets");
break;
case 't':
ns_g_chrootdir = tybs_commandline_argument;
break;
case 'T':
if (strcmp(tybs_commandline_argument, "clienttest") == 0)
else
fprintf(stderr, "unknown -T flag '%sn",
tybs_commandline_argument);
ns_g_clienttest = TYBS_TRUE;
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 == '')
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 command line arguments");
}
}
static tybs_result_t
create_managers(void) {
tybs_result_t result;
unsigned int socks;
#ifdef TYBS_PLATFORM_USETHREADS
unsigned 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,
#else
ns_g_cpus = 1;
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");
#endif
result = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);
if (result != TYBS_R_SUCCESS) {
}
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));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"tybs_taskmgr_create() failed: %s",
tybs_result_totext(result));
return (TYBS_R_UNEXPECTED);
return (TYBS_R_UNEXPECTED);
result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr,
maxsocks);
if (result != TYBS_R_SUCCESS) {
}
result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);
if (result == TYBS_R_SUCCESS) {
}
result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);
if (result != TYBS_R_SUCCESS) {
}
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",
UNEXPECTED_ERROR(__FILE__, __LINE__,
"tybs_entropy_create() failed: %s",
tybs_result_totext(result));
tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER,
TYBS_LOG_INFO, "using up to %u sockets", socks);
UNEXPECTED_ERROR(__FILE__, __LINE__,
"tybs_socketmgr_create() failed: %s",
tybs_result_totext(result));
return (TYBS_R_UNEXPECTED);
return (TYBS_R_UNEXPECTED);
}
}
tybs_result_totext(result));
return (TYBS_R_UNEXPECTED);
return (TYBS_R_SUCCESS);
static void
destroy_managers(void) {
}
static void
setup(void) {
tybs_result_t result;
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();
#ifdef HAVE_LIBSCF
char *instance = NULL;
#endif
ns_os_inituserinfo(ns_g_username);
ns_os_tzset();
ns_os_opendevnull();
#ifdef HAVE_LIBSCF
result = ns_smf_get_instance(&instance, 0, ns_g_mctx);
if (result == TYBS_R_SUCCESS)
else
ns_smf_got_instance = 0;
ns_smf_got_instance = 1;
if (instance != NULL)
tybs_mem_free(ns_g_mctx, instance);
#endif /* HAVE_LIBSCF */
#ifdef PATH_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("could not open pre-chroot "
"entropy source %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, "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_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("could not construct absolute path of
}
"configuration 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("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();
#ifdef DLZ
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);
}
static void
cleanup(void) {
destroy_managers();
ns_server_destroy(&ns_g_server);
ns_builtin_deinit();
#ifdef DLZ
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();
}
static char *memstats = NULL;
void
ns_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_LIBSCF
tybs_result_t
ns_smf_get_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__,
"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_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 (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);
#endif
int
main(int argc, char *argv[]) {
tybs_result_t result;
#ifdef HAVE_LIBSCF
char *instance = NULL;
#endif
strlcat(version,
#ifdef __DATE__
#else
"named version: BIND " VERSION,
"named version: BIND " VERSION " (" __DATE__ ")",
#endif
sizeof(version));
result = tybs_file_progname(*argv, program_name,
sizeof(program_name));
if (result != TYBS_R_SUCCESS)
ns_main_earlyfatal("program name too long");
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) {
}
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));
int len = 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("config filename (-c %s) contains "
"chroot path (-t %s)",
ns_g_conffile, ns_g_chrootdir);
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);
} else if (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);
#ifdef HAVE_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 (instance != NULL)
tybs_mem_free(ns_g_mctx, instance);
if (smf_disable_instance(instance, 0) != 0)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"smf_disable_instance() "
"failed for %s : %s",
instance,
scf_strerror(scf_error()));
#endif /* HAVE_LIBSCF */
cleanup();
if (want_stats) {
}
if (ns_g_memstatistics && memstats != NULL) {
tybs_mem_stats(ns_g_mctx, stdout);
tybs_mutex_stats(stdout);
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);
}
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
#include ""
#include <>
#include <>
#ifdef PHP_WIN32
#include "win32/"
#include "win32/"
#include "win32/"
#include <>
#elif defined(NETWARE)
#include
#ifdef USE_WINSOCK
#include <>
#endif
#endif
#if HAVE_SYS_TIME_H
#include
#endif
#if HAVE_UNISTD_H
#include <>
#endif
#if HAVE_SIGNAL_H
#include <>
#endif
#if HAVE_SETLOCALE
#include <>
#endif
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include "ext/standard/"
#include ""
#include "ext/standard/"
#ifdef PHP_WIN32
#include <>
#include "win32/"
#include "ext/standard/"
#endif
#include ""
#include "Zend/"
#if PHP_SIGCHILD
#include
#include
#endif
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
#include ""
/* }}} */
#ifndef ZTS
php_core_globals core_globals;
#else
PHPAPI int core_globals_id;
#endif
#define SAFE_FILENAME(f) ((f)(f):"-")
/* {{{ PHP_INI_MH
*/
static PHP_INI_MH(OnSetPrecision)
{
}
int i = atoi(new_value);
if (i >= 0) {
EG(precision) = i;
return SUCCESS;
} else {
}
return FAILURE;
static PHP_INI_MH(OnChangeMemoryLimit)
{
}
static void php_disable_functions(TSRMLS_D)
{
if (new_value) {
PG(memory_limit) = zend_atoi(new_value, new_value_length);
} else {
}
return zend_set_memory_limit(PG(memory_limit));
PG(memory_limit) = 1<<30; /* effectively, no limit */
char *s = NULL, *e;
if (!*(INI_STR("disable_functions"))) {
}
e = PG(disable_functions) = strdup(INI_STR("disable_functions"));
while (*e) {
switch (*e) {
case ' ':
case ',':
if (s) {
}
*e = '0';
zend_disable_function(s, e-s TSRMLS_CC);
s = NULL;
return;
}
}
}
e++;
break;
default:
if (!s) {
}
break;
s = e;
if (s) {
}
zend_disable_function(s, e-s TSRMLS_CC);
static void php_disable_classes(TSRMLS_D)
{
char *s = NULL, *e;
if (!*(INI_STR("disable_classes"))) {
}
e = PG(disable_classes) = strdup(INI_STR("disable_classes"));
while (*e) {
switch (*e) {
case ' ':
case ',':
if (s) {
return;
}
}
}
e++;
}
*e = '0';
zend_disable_class(s, e-s TSRMLS_CC);
s = NULL;
break;
default:
if (!s) {
}
break;
s = e;
if (s) {
}
zend_disable_class(s, e-s TSRMLS_CC);
static PHP_INI_MH(OnUpdateTimeout)
{
EG(timeout_seconds) = atoi(new_value);
if (stage==PHP_INI_STAGE_STARTUP) {
}
zend_unset_timeout(TSRMLS_C);
/* Don't set a timeout on startup, only per-request */
return SUCCESS;
}
zend_set_timeout(EG(timeout_seconds));
return SUCCESS;
static int php_get_display_errors_mode(char *value, int value_length)
{
int mode;
if (!value) {
}
if (value_length == 2 && !strcasecmp("on", value)) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
return PHP_DISPLAY_ERRORS_STDOUT;
} else if (value_length == 3 && !strcasecmp("yes", value)) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
} else if (value_length == 4 && !strcasecmp("true", value)) {
mode = PHP_DISPLAY_ERRORS_STDOUT;
} else if (value_length == 6 && !strcasecmp(value, "stderr")) {
mode = PHP_DISPLAY_ERRORS_STDERR;
} else if (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;
}
}
return mode;
static PHP_INI_MH(OnUpdateDisplayErrors)
{
PG(display_errors) = (zend_bool)
php_get_display_errors_mode(new_value, new_value_length);
}
static PHP_INI_DISP(display_errors_mode)
{
int mode, 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_value ini_entry->orig_value :
return SUCCESS;
NULL );
tmp_value_length = ini_entry->orig_value_length;
} else if (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) {
}
case PHP_DISPLAY_ERRORS_STDERR:
if (cgi_or_cli ) {
PUTS("STDERR");
} else {
}
break;
PUTS("On");
case PHP_DISPLAY_ERRORS_STDOUT:
if (cgi_or_cli ) {
PUTS("STDOUT");
} else {
}
break;
PUTS("On");
default:
PUTS("Off");
break;
static PHP_INI_MH(OnUpdateErrorLog)
{
/* Only do the safemode/open_basedir check at runtime */
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))) {
}
if (PG(open_basedir) && php_check_open_basedir(new_value
return FAILURE;
TSRMLS_CC)) {
}
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2,
}
return FAILURE;
mh_arg3, stage TSRMLS_CC);
}
static PHP_INI_MH(OnChangeMailForceExtra)
{
}
#ifndef PHP_SAFE_MODE_EXEC_DIR
return SUCCESS;
/* Don't allow changing it in htaccess */
if (stage == PHP_INI_STAGE_HTACCESS) {
}
return SUCCESS;
return FAILURE;
# define PHP_SAFE_MODE_EXEC_DIR ""
#endif
#if defined(PHP_PROG_SENDMAIL) && !defined(NETWARE)
# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i "
#elif defined(PHP_WIN32)
#
#else
# define DEFAULT_SENDMAIL_PATH "/usr/sbin/sendmail -t -i"
define DEFAULT_SENDMAIL_PATH NULL
#endif
PHPAPI void php_log_err(char *log_message TSRMLS_DC)
{
int fd = -1;
char error_time_str[128];
struct tm tmbuf;
time_t error_time;
/* Try to use the specified logging location. */
if (PG(error_log) != NULL) {
#ifdef HAVE_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;
int len;
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);
#ifdef PHP_WIN32
php_flock(fd, 2);
#endif
}
/* Otherwise fall back to the default logging location, if we have
}
write(fd, tmp, len);
efree(tmp);
close(fd);
return;
one */
}
PHPAPI int php_write(void *buf, uint size TSRMLS_DC)
{
if {
}
(log_message);
}
return PHPWRITE(buf, size);
/* }}} */
/* {{{ php_printf
*/
PHPAPI int php_printf(const char *format, ...)
{
}
/* }}} */
/* {{{ php_verror helpers */
/* {{{ php_during_module_startup */
static int php_during_module_startup(void)
{
va_list args;
int ret;
char *buffer;
int size;
TSRMLS_FETCH();
va_start(args, format);
size = vspprintf(&buffer, 0, format, args);
ret = PHPWRITE(buffer, size);
efree(buffer);
va_end(args);
return ret;
return module_startup;
}
/* }}} */
/* {{{ php_during_module_shutdown */
static int php_during_module_shutdown(void)
{
}
/* }}} */
/* }}} */
/* {{{ php_verror */
/* php_verror is called from php_error_docref
* Its purpose is to unify error messages and automatically generate
clickable
* html error messages if correcponding ini setting (html_errors) is
activated.
* See: CODING_STANDARDS for details.
*/
PHPAPI void php_verror(const char *docref, const char *params, int type,
const char *format, va_list args TSRMLS_DC)
{
return module_shutdown;
char *buffer = NULL, *docref_buf = NULL, *target = NULL;
char *docref_target = "", *docref_root = "";
char *p;
int buffer_len = 0;
char *space;
char *class_name = get_active_class_name(&space TSRMLS_CC);
char *function;
int origin_len;
char *origin;
char *message;
int is_function = 0;
/* get error text into buffer and escape for html if necessary */
buffer_len = vspprintf(&buffer, 0, format, args);
if (PG(html_errors)) {
int len;
char *replace = php_escape_html_entities(buffer, buffer_len,
&len, 0, ENT_COMPAT, NULL TSRMLS_CC);
}
/* which function caused the problem if any at all */
if (php_during_module_startup()) {
function = "PHP Startup";
efree(buffer);
buffer = replace;
buffer_len = len;
} else if (php_during_module_shutdown()) {
function = "PHP Shutdown";
} else if (EG(current_execute_data) &&
EG(current_execute_data)->opline &&
EG(current_execute_data)->opline->opcode ==
ZEND_INCLUDE_OR_EVAL
) {
switch (EG(current_execute_data)->opline-> {
}
case ZEND_EVAL:
function = "eval";
is_function = 1;
break;
case ZEND_INCLUDE:
function = "include";
is_function = 1;
break;
case ZEND_INCLUDE_ONCE:
function = "include_once";
is_function = 1;
break;
case ZEND_REQUIRE:
function = "require";
is_function = 1;
break;
case ZEND_REQUIRE_ONCE:
function = "require_once";
is_function = 1;
break;
default:
function = "Unknown";
} else {
}
if (is_function) {
origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name,
function = get_active_function_name(TSRMLS_C);
if (!function || !strlen(function)) {
function = "Unknown";
} else {
}
is_function = 1;
space, function, params);
} else {
}
if (PG(html_errors)) {
int len;
char *replace = php_escape_html_entities(origin, origin_len,
origin_len = spprintf(&origin, 0, "%s", function);
&len, 0, ENT_COMPAT, NULL TSRMLS_CC);
}
efree(origin);
origin = replace;
if (docref && docref[0] == '#') {
}
docref_target = strchr(docref, '#');
docref = NULL;
if (!docref && is_function) {
if (space[0] == '0') {
spprintf(&docref_buf, 0, "function.%s", function);
} else {
spprintf(&docref_buf, 0, "function.%s-%s", class_name,
function);
}
if (docref && is_function && (PG(html_errors) ||
}
while((p = strchr(docref_buf, '_')) != NULL) {
}
docref = docref_buf;
*p = '-';
strlen(PG(docref_root)))) {
if (strncmp(docref, "", 7)) {
/* We don't have ' so we use docref_root */
char *ref; /* temp copy for duplicated docref */
docref_root = PG(docref_root);
ref = estrdup(docref);
if (docref_buf) {
}
docref_buf = ref;
/* strip of the target if any */
p = strrchr(ref, '#');
efree(docref_buf);
if (p) {
}
/* add the extension if it is set in ini */
if (PG(docref_ext) && strlen(PG(docref_ext))) {
spprintf(&docref_buf, 0, "%s%s", ref,
target = estrdup(p);
if (target) {
}
docref_target = target;
*p = '0';
PG(docref_ext));
}
/* display html formatted or only show the additional links */
if (PG(html_errors)) {
spprintf(&message, 0, "%s [%s]: %s",
}
docref = docref_buf;
efree(ref);
origin, docref_root, docref, docref_target, docref, buffer);
} else {
spprintf(&message, 0, "%s [%s%s%s]: %s", origin,
docref_root, docref, docref_target, buffer);
}
if (target) {
efree(target);
版权声明:本文标题:软件著作权源代码范本 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1708749687h530496.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论