&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_(ns_g_conffile)) { result = tybs_(ns_g_conffile, absolute_conffile, sizeof(absolute_conffile)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ \ 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_result_totext(result)); result = create_managers(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); ns_builtin_init(); #ifdef DLZ result = dlz_drivers_init(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ 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, \ ns_log_shutdown(); }
static char *memstats = NULL; void
ns_main_setmemstats(const char *) { if (memstats != NULL) { free(memstats); memstats = NULL; }
if ( == NULL) return; memstats = malloc(strlen() + 1); if (memstats) strcpy(memstats, ); }
#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_strerror(scf_error())); return (TYBS_R_FAILURE); } if (scf_handle_bind(h) == -1) { if (debug) UNEXPECTED_ERROR(__FILE__, __LINE__, \ 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_strerror(scf_error())); scf_handle_destroy(h); return (TYBS_R_FAILURE); } if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ \ 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_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__ \TE__ \#else \#endif sizeof(version)); result = tybs_(*argv, program_name, sizeof(program_name)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ if (strcmp(program_name, \ 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) { int len = strlen(ns_g_chrootdir); if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 && (ns_g_conf] == '/' || ns_g_conf] == '\\\\')) ns_main_earlywarning(\ (-c %s) contains \ \ ns_g_conffile, ns_g_chrootdir); } result = tybs_mem_create(0, 0, &ns_g_mctx); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); tybs_mem_setname(ns_g_mctx, \ 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_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 (smf_disable_instance(instance, 0) != 0) UNEXPECTED_ERROR(__FILE__, __LINE__, \ \ 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, \ 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 \#include
#if HAVE_SYS_TIME_H
#include
#if HAVE_UNISTD_H #include
#if HAVE_SIGNAL_H #include
#if HAVE_SETLOCALE #include
#include \
#include \#include \#include \#include \
#include \
#include \#include \
#include \#ifdef PHP_WIN32 #include
#include \
#include \#endif
#include \
#include \#if PHP_SIGCHILD #include
#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_(f) ((f)?(f):\/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnSetPrecision)
软件著作权-源代码范本
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)