/** * This method initializes the axis2 engine. All the required variables are set to * their initial values in this method. */ axis2_status_t AXIS2_CALL init_axis2() { /* * These are the varibles required to initialize axis. */ axis2_status_t status = FALSE; /* We need to init xml readers before we go into threaded env */ if (!is_inited) { axiom_xml_reader_init(); status = read_registery_init_data(); if (status == AXIS2_FAILURE) { return AXIS2_FAILURE; } axutil_error_init(); /* Initialize the environement */ axutil_env = axutil_env_create_all(log_file, log_level); if (!axutil_env) { return AXIS2_FAILURE; } axis2_worker = axis2_iis_worker_create(axutil_env, repo_path); if (!axis2_worker) { return AXIS2_FAILURE; } is_inited = AXIS2_TRUE; return AXIS2_SUCCESS; } return AXIS2_FAILURE; }
static ngx_int_t ngx_squ_xml_module_init(ngx_cycle_t *cycle) { int n; ngx_squ_conf_t *scf; ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, "squ xml module init"); scf = (ngx_squ_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_squ_module); squ_getglobal(scf->l, NGX_SQU_TABLE); n = sizeof(ngx_squ_xml_consts) / sizeof(ngx_squ_const_t) - 1; n += sizeof(ngx_squ_xml_methods) / sizeof(squL_Reg) - 1; squ_createtable(scf->l, 0, n); for (n = 0; ngx_squ_xml_consts[n].name != NULL; n++) { squ_pushinteger(scf->l, ngx_squ_xml_consts[n].value); squ_setfield(scf->l, -2, ngx_squ_xml_consts[n].name); } for (n = 0; ngx_squ_xml_methods[n].name != NULL; n++) { squ_pushcfunction(scf->l, ngx_squ_xml_methods[n].func); squ_setfield(scf->l, -2, ngx_squ_xml_methods[n].name); } squ_setfield(scf->l, -2, "xml"); squ_pop(scf->l, 1); axutil_error_init(); return NGX_OK; }
AXIS2_EXTERN axutil_env_t *AXIS2_CALL axutil_env_create_with_error_log( axutil_allocator_t *allocator, axutil_error_t *error, axutil_log_t *log) { axutil_env_t *env; if(!allocator || !error) return NULL; env = (axutil_env_t *)AXIS2_MALLOC(allocator, sizeof(axutil_env_t)); if(!env) return NULL; memset(env, 0, sizeof(axutil_env_t)); env->allocator = allocator; env->error = error; env->log = log; axutil_error_init(); env->ref = 1; env->get_session_fn = NULL; env->set_session_fn = NULL; return env; }
static ngx_int_t ngx_lua_xml_module_init(ngx_cycle_t *cycle) { int n; ngx_lua_conf_t *lcf; ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, "lua xml module init"); lcf = (ngx_lua_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_lua_module); lua_getglobal(lcf->l, NGX_LUA_TABLE); n = sizeof(ngx_lua_xml_consts) / sizeof(ngx_lua_const_t) - 1; n += sizeof(ngx_lua_xml_methods) / sizeof(luaL_Reg) - 1; lua_createtable(lcf->l, 0, n); for (n = 0; ngx_lua_xml_consts[n].name != NULL; n++) { lua_pushinteger(lcf->l, ngx_lua_xml_consts[n].value); lua_setfield(lcf->l, -2, ngx_lua_xml_consts[n].name); } for (n = 0; ngx_lua_xml_methods[n].name != NULL; n++) { lua_pushcfunction(lcf->l, ngx_lua_xml_methods[n].func); lua_setfield(lcf->l, -2, ngx_lua_xml_methods[n].name); } lua_setfield(lcf->l, -2, "xml"); lua_pop(lcf->l, 1); axutil_error_init(); return NGX_OK; }
AXIS2_EXTERN axutil_env_t *AXIS2_CALL axutil_env_create( axutil_allocator_t *allocator) { axutil_env_t *env; if(!allocator) return NULL; env = (axutil_env_t *)AXIS2_MALLOC(allocator, sizeof(axutil_env_t)); if(!env) return NULL; memset(env, 0, sizeof(axutil_env_t)); env->allocator = allocator; env->log = axutil_log_create_default(allocator); env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug */ env->log->enabled = AXIS2_TRUE; /* Create default error struct */ env->error = axutil_error_create(allocator); if(!env->error) { AXIS2_FREE(allocator, env); return NULL; } /* Call error init to fill in the axutil_error_messages array. This array holds the error messages with respect to error codes */ axutil_error_init(); env->ref = 1; env->get_session_fn = NULL; env->set_session_fn = NULL; return env; }
int main( int argc, char *argv[]) { axutil_allocator_t *allocator = NULL; axutil_env_t *env = NULL; extern char *optarg; extern int optopt; int c; int log_file_size = AXUTIL_LOG_FILE_SIZE; axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG; const axis2_char_t *log_file = AXIS2_TCP_SERVER_LOG_FILE_NAME; int port = AXIS2_TCP_SERVER_PORT; const axis2_char_t *repo_path = AXIS2_TCP_SERVER_REPO_PATH; while((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1) { switch(c) { case 'p': port = AXIS2_ATOI(optarg); break; case 'r': repo_path = optarg; break; case 't': axis2_tcp_socket_read_timeout = AXIS2_ATOI(optarg) * 1000; break; case 'l': log_level = AXIS2_ATOI(optarg); if(log_level < AXIS2_LOG_LEVEL_CRITICAL) log_level = AXIS2_LOG_LEVEL_CRITICAL; if(log_level > AXIS2_LOG_LEVEL_TRACE) log_level = AXIS2_LOG_LEVEL_TRACE; break; case 's': log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg); break; case 'f': log_file = optarg; break; case 'h': usage(argv[0]); return 0; case ':': fprintf(stderr, "\nOption -%c requires an operand\n", optopt); usage(argv[0]); return -1; case '?': if(isprint(optopt)) fprintf(stderr, "\nUnknown option `-%c'.\n", optopt); usage(argv[0]); return -1; } } allocator = axutil_allocator_init(NULL); if(!allocator) { system_exit(NULL, -1); } env = init_syetem_env(allocator, log_file); env->log->level = log_level; env->log->size = log_file_size; axutil_error_init(); system_env = env; #ifndef WIN32 signal(SIGINT, sig_handler); signal(SIGPIPE, sig_handler); #endif AXIS2_LOG_INFO(env->log, "Starting Axis2 TCP server...."); AXIS2_LOG_INFO(env->log, "Server port : %d", port); AXIS2_LOG_INFO(env->log, "Repo location : %s", repo_path); AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms", axis2_tcp_socket_read_timeout); server = axis2_tcp_server_create(env, repo_path, port); if(!server) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server creation failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } printf("Started Simple Axis2 TCP Server ...\n"); if(axis2_transport_receiver_start(server, env) == AXIS2_FAILURE) { AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:" " %d :: %s", env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error)); system_exit(env, -1); } return 0; }