Пример #1
0
/* {{{ axis2_environment create function */
axutil_env_t *
wsf_env_create_svr (
    axis2_char_t * path_tolog, int loglevel)
{
    axutil_allocator_t *allocator = NULL;
    axutil_error_t *error = NULL;
    axutil_log_t *log = NULL;
    axis2_char_t log_path[1024];
    axutil_env_t *env = NULL;
    axutil_thread_pool_t *thread_pool = NULL;
    const axis2_char_t *LOG_NAME = "wsf_ruby_server.log";
    allocator = malloc (sizeof (axutil_allocator_t));

    allocator->free_fn = wsf_free_wrapper;
    allocator->malloc_fn = wsf_malloc_wrapper;
    allocator->realloc = wsf_realloc_warpper;

    error = axutil_error_create (allocator);
    if (path_tolog && (
                (0 == strcmp (path_tolog, "")) ||
                (0 == strcmp (path_tolog, ".")) ||
                (0 == strcmp (path_tolog, "./")))) {
        snprintf (log_path, sizeof(log_path), "%s", LOG_NAME);
    } else {
        snprintf (log_path, sizeof(log_path), "%s/%s", path_tolog, LOG_NAME);
    }

    thread_pool = axutil_thread_pool_init (allocator);
    log = axutil_log_create (allocator, NULL, log_path);
    env = axutil_env_create_with_error_log_thread_pool (allocator, error, log,
            thread_pool);

    env->log->level = loglevel;
    return env;
}
Пример #2
0
const axutil_env_t *
test_init(
    )
{
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = axutil_error_create(allocator);
    const axutil_env_t *env = axutil_env_create_with_error(allocator, error);
    return env;
}
Пример #3
0
AXIS2_EXTERN axutil_env_t *AXIS2_CALL
axutil_init_thread_env(
    const axutil_env_t *system_env)
{
    axutil_allocator_t * allocator = NULL;
    axutil_error_t *error = NULL;
    allocator = axutil_allocator_clone(system_env->allocator);
    error = axutil_error_create(allocator);
    return axutil_env_create_with_error_log_thread_pool(allocator, error, system_env->log,
        system_env-> thread_pool);
}
static int
ngx_squ_xml_parse(squ_State *l)
{
    char                  *name;
    ngx_str_t              xml;
    axiom_node_t          *node;
    axutil_env_t          *env;
    axutil_log_t          *log;
    axutil_error_t        *error;
    axiom_element_t       *elem;
    axiom_document_t      *doc;
    ngx_squ_thread_t      *thr;
    axutil_allocator_t    *a;
    axiom_xml_reader_t    *reader;
    axiom_stax_builder_t  *builder;

    thr = ngx_squ_thread(l);

    ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml parse");

    xml.data = (u_char *) squL_checklstring(l, -1, &xml.len);

    squ_createtable(l, 2, 2);

    a = ngx_squ_axis2c_allocator_create(thr);
    log = ngx_squ_axis2c_log_create(thr);
    error = axutil_error_create(a);
    env = axutil_env_create_with_error_log(a, error, log);

    reader = axiom_xml_reader_create_for_memory(env, xml.data, xml.len, NULL,
                                                AXIS2_XML_PARSER_TYPE_BUFFER);
    builder = axiom_stax_builder_create(env, reader);
    doc = axiom_stax_builder_get_document(builder, env);

    node = axiom_document_get_root_element(doc, env);

    if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) {
        return 1;
    }

    elem = axiom_node_get_data_element(node, env);
    name = axiom_element_get_localname(elem, env);

    squ_newtable(l);

    ngx_squ_xml_parse_children(l, env, node, elem);

    squ_setfield(l, -2, name);

    return 1;
}
Пример #5
0
/***************************** End of function headers ************************/
axutil_env_t *
init_syetem_env(
    axutil_allocator_t * allocator,
    const axis2_char_t * log_file)
{
    axutil_error_t *error = axutil_error_create(allocator);
    axutil_log_t *log = axutil_log_create(allocator, NULL, log_file);
    axutil_thread_pool_t *thread_pool = axutil_thread_pool_init(allocator);
    /* We need to init the parser in main thread before spawning child
     * threads
     */
    axiom_xml_reader_init();
    return axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool);
}
Пример #6
0
int
main(
    int argc,
    char **argv)
{
    axis2_status_t status = AXIS2_FAILURE;
    int i = 0;
    axutil_array_list_t *policy_list = NULL;
    axutil_array_list_t *policy_node_list = NULL;
    neethi_policy_t *resultant = NULL;
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = axutil_error_create(allocator);
    const axutil_env_t *env = axutil_env_create_with_error(allocator, error);

    policy_list = axutil_array_list_create(env, 0);
    policy_node_list = axutil_array_list_create(env, 0);

    get_all_policy(argv[1], env, policy_node_list, argv[2]);

    for (i = 0; i < axutil_array_list_size(policy_node_list, env); i++)
    {
        axiom_node_t *node = NULL;
        node = (axiom_node_t *) axutil_array_list_get(policy_node_list, env, i);
        status = load_policy_array(policy_list, node, env);
    }

    resultant = merge_policylist(policy_list, env);
    if (!resultant)
    {
        printf("Error Merging\n");
        return 0;
    }
    else
    {
        axiom_node_t *s_node = NULL;
        axis2_char_t *buff = NULL;
        s_node = neethi_engine_serialize(resultant, env);
        if (!s_node)
        {
            printf("Serializing failed\n");
            return 0;
        }
        buff = axiom_node_to_string(s_node, env);
        printf("\n%s", buff);
    }
    printf("Successful\n");
    return 0;

}
Пример #7
0
AXIS2_EXTERN axutil_env_t *AXIS2_CALL
axutil_env_create_all(
    const axis2_char_t *log_file,
    const axutil_log_levels_t log_level)
{
    axutil_env_t *env = NULL;
    axutil_error_t *error = NULL;
    axutil_log_t *log = NULL;
    axutil_allocator_t *allocator = NULL;
    axutil_thread_pool_t *thread_pool = NULL;

    allocator = axutil_allocator_init(NULL);
    error = axutil_error_create(allocator);

    if(log_file)
    {
        log = axutil_log_create(allocator, NULL, log_file);
    }

    /* if log file name was not given or the log could not be create with 
     given name, create default log */
    if(!log)
    {
        log = axutil_log_create_default(allocator);
    }

    thread_pool = axutil_thread_pool_init(allocator);

    env = axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool);
    if(env->log)
    {
        /*if(AXIS2_LOG_LEVEL_CRITICAL <= log_level && log_level <= AXIS2_LOG_LEVEL_TRACE)*/
	if (log_level <= AXIS2_LOG_LEVEL_TRACE)
        {
            env->log->level = log_level;
        }
        else
        {
            env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug */
        }
    }

    env->ref = 1;
    env->get_session_fn = NULL;
    env->set_session_fn = NULL;

    return env;
}
Пример #8
0
void
test_log_write(
    )
{
    char msg[20];
    printf("start of test_log_write\n\n");
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    if (!allocator)
    {
        printf("allocator is NULL\n");
        return;
    }
    axutil_error_t *error = axutil_error_create(allocator);
    if (!error)
    {
        printf("cannot create error\n");
        return;
    }
    axutil_log_t *log22 = axutil_log_create(allocator, NULL, NULL);
    if (!log22)
    {
        printf("cannot create log\n");
        return;
    }
    log22->level = AXIS2_LOG_LEVEL_DEBUG;

    const axutil_env_t *env =
        axutil_env_create_with_error_log(allocator, error, log22);
    if (!env)
    {
        printf("cannot create env with error and log\n");
        return;
    }
    strcpy(msg, "abcd test123");

    AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1");
    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2);
    AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3");
    AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2");
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5);
    printf("end of test_log_write \n\n");

}
Пример #9
0
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;
}
Пример #10
0
void
test_axutil_dir_handler_list_service_or_module_dirs(
    )
{
    int i,
     isize;
    axutil_file_t *file = NULL;
    axis2_char_t *filename = NULL;
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = axutil_error_create(allocator);
    axutil_log_t *log = axutil_log_create(allocator, NULL, NULL);
    const axutil_env_t *env =
        axutil_env_create_with_error_log(allocator, error, log);

    axis2_char_t *pathname = axutil_strdup(env, "/tmp/test/");

    axutil_array_list_t *arr_folders =
        axutil_dir_handler_list_service_or_module_dirs(env, pathname);
    if (arr_folders == NULL)
    {
        printf("List of folders is NULL\n");
        return;
    }

    isize = axutil_array_list_size(arr_folders, env);
    printf("Folder array size = %d \n", isize);

    for (i = 0; i < isize; ++i)
    {
        file = (axutil_file_t *) axutil_array_list_get(arr_folders, env, i);
        filename = axutil_file_get_name(file, env);
        printf("filename = %s \n", filename);
    }
    printf
        ("----end of test_axutil_dir_handler_list_service_or_module_dirs----\n");

}
static int
ngx_squ_xml_serialize(squ_State *l)
{
    int                     top;
    char                   *uri, *prefix;
    axiom_node_t           *node;
    axutil_env_t           *env;
    axutil_log_t           *log;
    axutil_error_t         *error;
    axiom_output_t         *output;
    ngx_squ_thread_t       *thr;
    axiom_namespace_t      *ns;
    axiom_soap_body_t      *body;
    axutil_allocator_t     *a;
    axiom_xml_writer_t     *writer;
    axiom_soap_header_t    *header;
    axiom_soap_envelope_t  *envelope;

    thr = ngx_squ_thread(l);

    ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml serialize");

    top = squ_gettop(l);

    if (!squ_istable(l, top)) {
        return squL_error(l, "invalid argument, must be a table");
    }

    a = ngx_squ_axis2c_allocator_create(thr);
    log = ngx_squ_axis2c_log_create(thr);
    error = axutil_error_create(a);
    env = axutil_env_create_with_error_log(a, error, log);

    squ_getfield(l, top, "uri");
    uri = (char *) squL_optstring(l, -1,
                                  "http://www.w3.org/2003/05/soap-envelope");

    squ_getfield(l, top, "prefix");
    prefix = (char *) squL_optstring(l, -1, "soap");

    ns = axiom_namespace_create(env, uri, prefix);
    envelope = axiom_soap_envelope_create(env, ns);

    squ_getfield(l, top, "header");
    if (!squ_isnil(l, -1)) {
        if (!squ_istable(l, -1)) {
            return squL_error(l, "the value of \"header\" must be a table");
        }

        header = axiom_soap_header_create_with_parent(env, envelope);
        node = axiom_soap_header_get_base_node(header, env);

        ngx_squ_xml_serialize_tables(l, env, node);
    }

    squ_getfield(l, top, "body");
    if (!squ_isnil(l, -1)) {
        if (!squ_istable(l, -1)) {
            return squL_error(l, "the value of \"body\" must be a table");
        }

        body = axiom_soap_body_create_with_parent(env, envelope);
        node = axiom_soap_body_get_base_node(body, env);

        ngx_squ_xml_serialize_tables(l, env, node);
    }

    squ_settop(l, top);

    writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE,
                                                AXIS2_FALSE,
                                                AXIS2_XML_PARSER_TYPE_BUFFER);
    output = axiom_output_create(env, writer);
    axiom_soap_envelope_serialize(envelope, env, output, AXIS2_FALSE);

    squ_pushstring(l, axiom_xml_writer_get_xml(writer, env));

    return 1;
}