Пример #1
0
static PyObject *fs_root_is_file(FileSystemRootObject *self, PyObject *args)
{
	svn_boolean_t is_file;
	apr_pool_t *temp_pool;
	char *path;

	if (!PyArg_ParseTuple(args, "s", &path))
		return NULL;

	temp_pool = Pool(NULL);
	if (temp_pool == NULL)
		return NULL;
	RUN_SVN_WITH_POOL(temp_pool, svn_fs_is_file(&is_file, self->root,
											   path, temp_pool));
	apr_pool_destroy(temp_pool);
	return PyBool_FromLong(is_file);
}
Пример #2
0
static PyObject *fs_root_file_length(FileSystemRootObject *self, PyObject *args)
{
	svn_filesize_t filesize;
	apr_pool_t *temp_pool;
	char *path;

	if (!PyArg_ParseTuple(args, "s", &path))
		return NULL;

	temp_pool = Pool(NULL);
	if (temp_pool == NULL)
		return NULL;
	RUN_SVN_WITH_POOL(temp_pool, svn_fs_file_length(&filesize, self->root,
											   path, temp_pool));
	apr_pool_destroy(temp_pool);
	return PyLong_FromLong(filesize);
}
Пример #3
0
static PyObject *repos_delete(PyObject *self, PyObject *args)
{
	char *path;
	apr_pool_t *temp_pool;

	if (!PyArg_ParseTuple(args, "s", &path))
		return NULL;

	temp_pool = Pool(NULL);
	if (temp_pool == NULL)
		return NULL;
	RUN_SVN_WITH_POOL(temp_pool, svn_repos_delete(path, temp_pool));

	apr_pool_destroy(temp_pool);

	Py_RETURN_NONE;
}
Пример #4
0
/** Destroy ASR engine */
ASR_CLIENT_DECLARE(apt_bool_t) asr_engine_destroy(asr_engine_t *engine)
{
	if(engine->mrcp_client) {
		/* shutdown client stack */
		mrcp_client_shutdown(engine->mrcp_client);
		/* destroy client stack */
		mrcp_client_destroy(engine->mrcp_client);
		engine->mrcp_client = NULL;
		engine->mrcp_app = NULL;
	}

	/* destroy singleton logger */
	apt_log_instance_destroy();
	/* destroy APR pool */
	apr_pool_destroy(engine->pool);
	return TRUE;
}
Пример #5
0
int ltapi_globals_register( lua_State * L, lt_server_plugin_t * plugin,
        lt_var_set_t * varset )
{
    /* create new empty table and set it under the key "variables" into the
     * table of globals */
    lua_pushstring( L, "variables" );
    lua_newtable( L );

    /* for each variable in a varset, create light user data object and push
     * it under the key to the table at -3 in the stack */
    {
        apr_hash_t * h = NULL;
        apr_hash_index_t * hi = NULL;
        const char * key = NULL;
        lt_var_t * var = NULL;
        apr_pool_t * pool = NULL;
        apr_pool_create( &pool, NULL );

        h = lt_var_set_variables_get( varset );
        hi = apr_hash_first( pool, h );
        for( ; hi != NULL; hi = apr_hash_next( hi ) ) {
            apr_hash_this( hi, (const void**)&key, NULL, (void**)&var );

#if 0
            fprintf( stderr, "DEBUG: creating lightuserdata for variable %s"
                    " of lintouch type %d\n", key, lt_var_type_get( var ) );
#endif

            lua_pushstring( L, key );
            lua_pushlightuserdata( L, (void*) var );
            lua_settable( L, -3 );
        }

        apr_pool_destroy( pool );
    }

    lua_settable( L, LUA_GLOBALSINDEX );

    /* create new light user data and set it under the key "plugin" into the
     * table of globals */
    lua_pushstring( L, "plugin" );
    lua_pushlightuserdata( L, (void*) plugin );
    lua_settable( L, LUA_GLOBALSINDEX );

    return 0;
}
Пример #6
0
static apt_bool_t mrcp_server_agent_connection_accept(mrcp_connection_agent_t *agent)
{
	apr_socket_t *sock;
	apr_pool_t *pool;
	mrcp_connection_t *connection;

	if(!agent->null_connection) {
		apr_pool_create(&pool,NULL);
		if(apr_socket_accept(&sock,agent->listen_sock,pool) != APR_SUCCESS) {
			return FALSE;
		}
		apt_log(APT_PRIO_NOTICE,"Rejected TCP/MRCPv2 Connection");
		apr_socket_close(sock);
		apr_pool_destroy(pool);
		return FALSE;
	}

	pool = agent->null_connection->pool;
	if(apr_socket_accept(&sock,agent->listen_sock,pool) != APR_SUCCESS) {
		return FALSE;
	}

	connection = mrcp_connection_create();
	connection->sock = sock;
	connection->sock_pfd.desc_type = APR_POLL_SOCKET;
	connection->sock_pfd.reqevents = APR_POLLIN;
	connection->sock_pfd.desc.s = connection->sock;
	connection->sock_pfd.client_data = connection;
	if(apr_pollset_add(agent->pollset, &connection->sock_pfd) != APR_SUCCESS) {
		apt_log(APT_PRIO_WARNING,"Failed to Add to Pollset");
		apr_socket_close(sock);
		mrcp_connection_destroy(connection);
		return FALSE;
	}

	connection->it = apt_list_push_back(agent->connection_list,connection);

	apr_socket_addr_get(&connection->sockaddr,APR_REMOTE,sock);
	if(apr_sockaddr_ip_get(&connection->remote_ip.buf,connection->sockaddr) == APR_SUCCESS) {
		connection->remote_ip.length = strlen(connection->remote_ip.buf);
	}
	apt_log(APT_PRIO_NOTICE,"Accepted TCP/MRCPv2 Connection %s:%d",
			connection->remote_ip.buf,
			connection->sockaddr->port);
	return TRUE;
}
Пример #7
0
apr_status_t h2_session_stream_destroy(h2_session *session, h2_stream *stream)
{
    apr_pool_t *pool = h2_stream_detach_pool(stream);

    h2_mplx_stream_done(session->mplx, stream->id, stream->rst_error);
    h2_stream_set_remove(session->streams, stream->id);
    h2_stream_destroy(stream);
    
    if (pool) {
        apr_pool_clear(pool);
        if (session->spare) {
            apr_pool_destroy(session->spare);
        }
        session->spare = pool;
    }
    return APR_SUCCESS;
}
Пример #8
0
term_t bif_set_cwd1(term_t Dir, process_t *ctx)
{
	apr_status_t rs;
	apr_pool_t *p;
	const char *path;
	if (!is_string(Dir))
		return A_BADARG;
	apr_pool_create(&p, 0);
	path = ltoz(Dir, p);
	rs = apr_filepath_set(path, p);
	apr_pool_destroy(p);
	if (rs == 0)
		result(A_OK);
	else
		result(make_tuple2(A_ERROR, decipher_status(rs), proc_gc_pool(ctx)));
	return AI_OK;
}
Пример #9
0
SV *xml_to_hash( const char *xml_file )
{
  apr_pool_t *tmp_mp;
  apr_file_t *file;
  json_t *json;
  SV *hash = &PL_sv_undef;

  apr_pool_create( &tmp_mp, NULL );
  apr_file_open( &file, xml_file, APR_READ | APR_BUFFERED, 0, tmp_mp );
  xml_to_json( tmp_mp, file, 1, &json );
  if ( json ) {
    hash = json_to_perl_variable( json );
  }
  apr_pool_destroy( tmp_mp );

  return hash;
} 
Пример #10
0
term_t bif_delete1(term_t File, process_t *ctx)
{
	apr_pool_t *tmp;
	apr_status_t rs;
	const char *path;
	if (!is_string(File))
		return A_BADARG;
	apr_pool_create(&tmp, 0);
	path = ltoz(File, tmp);
	rs = apr_file_remove(path, tmp);
	if (rs == 0)
		result(A_OK);
	else
		result(make_tuple2(A_ERROR, decipher_status(rs), proc_gc_pool(ctx)));
	apr_pool_destroy(tmp);
	return AI_OK;
}
Пример #11
0
static void
test_add_last( CuTest* tc )
{
    apr_pool_t* pool;
    lcn_linked_list_t* l;
    unsigned int i;
    int vals[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 };

    int* p_vals = vals;

    LCN_TEST( apr_pool_create( &pool, main_pool ) );
    LCN_TEST( lcn_linked_list_create( &l, pool ) );

    CuAssertIntEquals( tc, 0, lcn_linked_list_size( l ) );
    for( i = 0; i < 10; i++ )
    {
        const lcn_linked_list_el_t* first, *last;

        LCN_TEST( lcn_linked_list_add_last( l, (p_vals + i ) ) );
        CuAssertIntEquals( tc, i+1, lcn_linked_list_size( l ) );

        first = lcn_linked_list_first( l );
        last  = lcn_linked_list_last( l );

        CuAssertIntEquals( tc,
                           vals[i],
                           *((int*)lcn_linked_list_content( last ) ) );
        CuAssertIntEquals( tc,
                           vals[0],
                           *((int*)lcn_linked_list_content( first ) ) );
    }

    i = 0;

    while( lcn_linked_list_size( l ) > 0 )
    {
        const lcn_linked_list_el_t* last;
        last = lcn_linked_list_last( l );

        CuAssertIntEquals( tc,
                           vals[9 - i++],
                           *((int*)lcn_linked_list_content( last ) ) );
        lcn_linked_list_remove_last( l );
    }
    apr_pool_destroy( pool );
}
Пример #12
0
void print(struct userRecord *user)
{
  apr_pool_t *p = NULL;
  char *timeReadable = NULL;
  apr_pool_create(&p, NULL);
  int i = 0;

  timeReadable = apr_palloc(p, APR_RFC822_DATE_LEN);
  apr_rfc822_date(timeReadable, user->creationDate);

  printf("Username:\t\t %s\n", user->username);
  printf("Password:\t\t %s\n", user->password);
  printf("CreationDate:\t\t %s\n", timeReadable);
 
  apr_pool_destroy(p);
  return;
}
Пример #13
0
static void
test_append_format( CuTest* tc )
{
    apr_pool_t* pool;
    lcn_string_buffer_t* sb;
    char* test_str;

    LCN_TEST( apr_pool_create( &pool, main_pool ) );
    LCN_TEST( lcn_string_buffer_create( &sb, pool ) );
    LCN_TEST( lcn_string_buffer_append_format( sb, "%d : %c : %s",
                                               10, 'b', "blah" ) );
    LCN_TEST( lcn_string_buffer_to_string( sb, &test_str, pool ) );

    CuAssertStrEquals( tc, test_str, "10 : b : blah" );
    CuAssertIntEquals( tc, strlen( test_str ), lcn_string_buffer_length( sb ) );
    apr_pool_destroy( pool );
}
Пример #14
0
apr_status_t
run_client_and_mock_servers_loops(test_baton_t *tb,
                                  int num_requests,
                                  handler_baton_t handler_ctx[],
                                  apr_pool_t *pool)
{
    apr_pool_t *iter_pool;
    int i, done = 0;
    MockHTTP *mh = tb->mh;
    apr_status_t status;
    apr_time_t finish_time = apr_time_now() + apr_time_from_sec(15);

    apr_pool_create(&iter_pool, pool);

    while (!done)
    {
        mhError_t err;
        apr_pool_clear(iter_pool);

        /* run server event loop */
        err = mhRunServerLoop(mh);

        /* Even if the mock server returned an error, it may have written 
           something to the client. So process that data first, handle the error
           later. */

        /* run client event loop */
        status = serf_context_run(tb->context, 0, iter_pool);
        if (!APR_STATUS_IS_TIMEUP(status) &&
            SERF_BUCKET_READ_ERROR(status))
            return status;

        done = 1;
        for (i = 0; i < num_requests; i++)
            done &= handler_ctx[i].done;

        if (!done && (apr_time_now() > finish_time))
            return APR_ETIMEDOUT;

        if (err == MOCKHTTP_TEST_FAILED)
            return SERF_ERROR_ISSUE_IN_TESTSUITE;
    }
    apr_pool_destroy(iter_pool);
    
    return APR_SUCCESS;
}
Пример #15
0
void switch_core_memory_stop(void)
{
#ifndef INSTANTLY_DESTROY_POOLS
	switch_status_t st;
	void *pop = NULL;

	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping memory pool queue.\n");

	memory_manager.pool_thread_running = 0;
	switch_thread_join(&st, pool_thread_p);
	
	
	while (switch_queue_trypop(memory_manager.pool_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
		apr_pool_destroy(pop);
	}
#endif
}
Пример #16
0
/** Destroy MRCP server */
MRCP_DECLARE(apt_bool_t) mrcp_server_destroy(mrcp_server_t *server)
{
	apt_task_t *task;
	if(!server || !server->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid Server");
		return FALSE;
	}

	mrcp_engine_factory_destroy(server->engine_factory);
	mrcp_engine_loader_destroy(server->engine_loader);

	task = apt_consumer_task_base_get(server->task);
	apt_task_destroy(task);

	apr_pool_destroy(server->pool);
	return TRUE;
}
Пример #17
0
		std::string makeRequest(
			const std::string& name,
			const std::string& httpRequest,
			bool timeout = false)
		{
			LLPipeStringInjector* injector = new LLPipeStringInjector(httpRequest);
			LLPipeStringExtractor* extractor = new LLPipeStringExtractor();
			
			apr_pool_t* pool;
			apr_pool_create(&pool, NULL);

			LLPumpIO* pump;
			pump = new LLPumpIO(pool);

			LLPumpIO::chain_t chain;
			LLSD context;

			chain.push_back(LLIOPipe::ptr_t(injector));
			LLIOHTTPServer::createPipe(chain, mRoot, LLSD());
			chain.push_back(LLIOPipe::ptr_t(extractor));

			pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);

			pumpPipe(pump, 10);
			if(mResponse.notNull() && (! timeout)) 
			{
				mResponse->result(mResult);
				mResponse = NULL;
			}
			pumpPipe(pump, 10);
			
			std::string httpResult = extractor->string();

			chain.clear();
			delete pump;
			apr_pool_destroy(pool);

			if(mResponse.notNull() && timeout)
			{
				mResponse->result(mResult);
				mResponse = NULL;
			}
			
			return httpResult;
		}
Пример #18
0
static PyObject *fs_root_file_checksum(FileSystemRootObject *self, PyObject *args)
{
	apr_pool_t *temp_pool;
	bool force = false;
	char *path;
#if ONLY_SINCE_SVN(1, 6)
	svn_checksum_kind_t kind;
	const char *cstr;
	svn_checksum_t *checksum;
#else
	int kind;
	unsigned char checksum[APR_MD5_DIGESTSIZE];
#endif
	PyObject *ret;

	if (!PyArg_ParseTuple(args, "s|ib", &path, &kind, &force))
		return NULL;

	temp_pool = Pool(NULL);
	if (temp_pool == NULL)
		return NULL;
#if ONLY_SINCE_SVN(1, 6)
	RUN_SVN_WITH_POOL(temp_pool, svn_fs_file_checksum(
		&checksum, kind, self->root, path, force?TRUE:FALSE, temp_pool));
	cstr = svn_checksum_to_cstring(checksum, temp_pool);
	if (cstr == NULL) {
		ret = Py_None;
		Py_INCREF(ret);
	} else {
		ret = PyUnicode_FromString(cstr);
	}
#else
	if (kind > 0)  {
		PyErr_SetString(PyExc_ValueError, "Only MD5 checksums allowed with subversion < 1.6");
		return NULL;
	}

	RUN_SVN_WITH_POOL(temp_pool, svn_fs_file_md5_checksum(checksum,
													  self->root,
											   path, temp_pool));
	ret = PyBytes_FromStringAndSize((char *)checksum, APR_MD5_DIGESTSIZE);
#endif
	apr_pool_destroy(temp_pool);
	return ret;
}
void nx_expr_proc__xm_fileop_dir_remove(nx_expr_eval_ctx_t *eval_ctx,
					nx_module_t *module,
					nx_expr_arg_list_t *args)
{
    nx_expr_arg_t *arg;
    nx_value_t path;
    apr_status_t rv;
    apr_pool_t *pool;

    ASSERT(module != NULL);

    ASSERT(args != NULL);
    arg = NX_DLIST_FIRST(args);
    ASSERT(arg != NULL);
    ASSERT(arg->expr != NULL);

    nx_expr_evaluate(eval_ctx, &path, arg->expr);

    if ( path.defined != TRUE )
    {
	throw_msg("'path' is undef");
    }
    if ( path.type != NX_VALUE_TYPE_STRING )
    {
	nx_value_kill(&path);
	throw_msg("string type required for 'path'");
    }

    // TODO: remove contents before

    pool = nx_pool_create_core();
    rv = apr_dir_remove(path.string->buf, pool);
    if ( APR_STATUS_IS_ENOENT(rv) )
    {
    }
    else if ( rv == APR_SUCCESS )
    {
    }
    else
    {
	    log_aprerror(rv, "failed to remove directory '%s'", path.string->buf);
    }
    apr_pool_destroy(pool);
    nx_value_kill(&path);
}
Пример #20
0
term_t bif_rename2(term_t Src, term_t Dst, process_t *ctx)
{
	apr_status_t rs;
	apr_pool_t *tmp;
	const char *from_path, *to_path;
	if (!is_string(Src) || !is_string(Dst))
		return A_BADARG;
	apr_pool_create(&tmp, 0);
	from_path = ltoz(Src, tmp);
	to_path = ltoz(Dst, tmp);
	rs = apr_file_rename(from_path, to_path, tmp);
	if (rs == 0)
		result(A_OK);
	else
		result(make_tuple2(A_ERROR, decipher_status(rs), proc_gc_pool(ctx)));
	apr_pool_destroy(tmp);
	return AI_OK;
}
Пример #21
0
static void table_getm(abts_case *tc, void *data)
{
    const char *orig, *val;
    apr_pool_t *subp;

    apr_pool_create(&subp, p);

    orig = "bar";
    apr_table_setn(t1, "foo", orig);
    val = apr_table_getm(subp, t1, "foo");
    ABTS_PTR_EQUAL(tc, orig, val);
    ABTS_STR_EQUAL(tc, "bar", val);
    apr_table_add(t1, "foo", "baz");
    val = apr_table_getm(subp, t1, "foo");
    ABTS_STR_EQUAL(tc, "bar,baz", val);

    apr_pool_destroy(subp);
}
Пример #22
0
/* Helper function, runs the client and server context loops and validates
 that no errors were encountered, and all messages were sent and received. */
apr_status_t
test_helper_run_requests_no_check(CuTest *tc, test_baton_t *tb,
                                  int num_requests,
                                  handler_baton_t handler_ctx[],
                                  apr_pool_t *pool)
{
    apr_pool_t *iter_pool;
    int i, done = 0;
    apr_status_t status;

    apr_pool_create(&iter_pool, pool);

    while (!done)
    {
        apr_pool_clear(iter_pool);

        /* run server event loop */
        status = run_test_server(tb->serv_ctx, 0, iter_pool);
        if (!APR_STATUS_IS_TIMEUP(status) &&
            SERF_BUCKET_READ_ERROR(status))
            return status;

        /* run proxy event loop */
        if (tb->proxy_ctx) {
            status = run_test_server(tb->proxy_ctx, 0, iter_pool);
            if (!APR_STATUS_IS_TIMEUP(status) &&
                SERF_BUCKET_READ_ERROR(status))
                return status;
        }

        /* run client event loop */
        status = serf_context_run(tb->context, 0, iter_pool);
        if (!APR_STATUS_IS_TIMEUP(status) &&
            SERF_BUCKET_READ_ERROR(status))
            return status;

        done = 1;
        for (i = 0; i < num_requests; i++)
            done &= handler_ctx[i].done;
    }
    apr_pool_destroy(iter_pool);

    return APR_SUCCESS;
}
Пример #23
0
term_t bif_list_dir2_1(term_t Dir, process_t *ctx)
{
	apr_status_t rs;
	apr_pool_t *p;
	const char *path;
	apr_dir_t *dir;
	term_t r = nil;
	if (!is_string(Dir))
		return A_BADARG;
	apr_pool_create(&p, 0);
	path = ltoz(Dir, p);
	rs = apr_dir_open(&dir, path, p);
	if (rs == 0)
	{
		term_t cons = nil;
		apr_finfo_t fi;
		for (;;)
		{
			term_t v;
			term_t name;
			rs = apr_dir_read(&fi, APR_FINFO_NAME | APR_FINFO_SIZE, dir);
			if (rs != 0)
				break;
			name = ztol(fi.name, proc_gc_pool(ctx));
			if (fi.filetype == APR_DIR)
				v = make_tuple2(A_DIR, name, proc_gc_pool(ctx));
			else if (fi.filetype == APR_REG)
				v = make_tuple3(A_FILE, name, intnum(fi.size), proc_gc_pool(ctx));	//TODO: large size
			else
				v = make_tuple2(A_UNKNOWN, name, proc_gc_pool(ctx));
			lst_add(r, cons, v, proc_gc_pool(ctx));
		}

		apr_dir_close(dir);
	}

	if (rs != 0 && !APR_STATUS_IS_ENOENT(rs))
		result(make_tuple2(A_ERROR, decipher_status(rs), proc_gc_pool(ctx)));
	else
		result(make_tuple2(A_OK, r, proc_gc_pool(ctx)));

	apr_pool_destroy(p);
	return AI_OK;
}
Пример #24
0
/** Process MPF response  */
static apt_bool_t mpf_suite_response_process(mpf_suite_engine_t *suite_engine, const mpf_message_t *mpf_message)
{
	mpf_task_msg_t *task_msg = NULL;
	apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process MPF Response");
	if(mpf_message->command_id == MPF_ADD_TERMINATION) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"On Add Termination");
		if(mpf_message->termination) {
			mpf_suite_session_t *session;
			session = mpf_termination_object_get(mpf_message->termination);
			if(session->termination2 == mpf_message->termination && session->rtp_mode == TRUE) {
				void *descriptor = mpf_rtp_remote_descriptor_create(session);
				mpf_engine_termination_message_add(
					suite_engine->engine,
					MPF_MODIFY_TERMINATION,session->context,session->termination2,descriptor,
					&task_msg);
			}
		}
	}
	else if(mpf_message->command_id == MPF_SUBTRACT_TERMINATION) {
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"On Subtract Termination");
		if(mpf_message->termination) {
			mpf_suite_session_t *session;
			session = mpf_termination_object_get(mpf_message->termination);
			if(session->termination1 == mpf_message->termination) {
				session->termination1 = NULL;
			}
			if(session->termination2 == mpf_message->termination) {
				session->termination2 = NULL;
			}
			mpf_termination_destroy(mpf_message->termination);

			if(!session->termination1 && !session->termination2) {
				mpf_engine_context_destroy(session->context);
				session->context = NULL;
				apr_pool_destroy(session->pool);

				apr_thread_mutex_lock(suite_engine->wait_object_mutex);
				apr_thread_cond_signal(suite_engine->wait_object);
				apr_thread_mutex_unlock(suite_engine->wait_object_mutex);
			}
		}
	}
	return mpf_engine_message_send(suite_engine->engine,&task_msg);
}
Пример #25
0
term_t bif_sendto4(term_t Sock, term_t RemIP, term_t RemPort, term_t Bin, process_t *ctx)
{
	apr_status_t rs;
	port_t *port;
	apr_socket_t *sock;
	const char *host;
	int udp_port;
	apr_sockaddr_t *sa;
	apr_pool_t *p;

	if (!is_port(Sock))
		return A_BADARG;
	if (!is_binary(RemIP) || !is_int(RemPort))
		return A_BADARG;
	if (!is_binary(Bin))
		return A_BADARG;

	port = port_lookup(prp_serial(Sock));
	if (port == 0)
		return A_CLOSED;
	if (!port->is_socket(port))
		return A_BADARG;
	sock = port->get_socket(port);

	host = (const char *)bin_data(RemIP);
	udp_port = (apr_port_t)int_value(RemPort);

	apr_pool_create(&p, 0);
	rs = apr_sockaddr_info_get(&sa, host, APR_INET, udp_port, 0, p);
	if (rs == 0)
	{
		apr_size_t len = (apr_size_t)int_value(bin_size(Bin));
		rs = apr_socket_sendto(sock, sa, 0, (const char *)bin_data(Bin), &len);
	}

	if (rs != 0)
	{
		apr_pool_destroy(p);
		return decipher_status(rs);
	}

	result(A_OK);
	return AI_OK;
}
Пример #26
0
/* gets the current encoding of the system */
MVMString * MVM_proc_getencoding(MVMThreadContext *tc) {
    MVMString *result;
    apr_status_t rv;
    apr_pool_t *tmp_pool;
    char *encoding;

    /* need a temporary pool */
    if ((rv = apr_pool_create(&tmp_pool, POOL(tc))) != APR_SUCCESS) {
        MVM_exception_throw_apr_error(tc, rv, "Failed to get encoding: ");
    }

    encoding = (char *)apr_os_locale_encoding(tmp_pool);

    result = MVM_string_utf8_decode(tc, tc->instance->VMString, encoding, strlen(encoding));

    apr_pool_destroy(tmp_pool);

    return result;
}
Пример #27
0
SV *json_to_hash( const char *json_file )
{
  apr_pool_t *tmp_mp;
  apr_file_t *in_file;
  json_t *json;
  SV *hash = &PL_sv_undef;
  parser_t *json_parser;

  apr_pool_create( &tmp_mp, NULL );
  json_parser = json_parser_create( tmp_mp );
  if ( open_apr_input_file( tmp_mp, json_file, &in_file ) &&
       json_parser_parse_file_to_obj( tmp_mp, json_parser, in_file,
                                      &json ) ) {
    hash = json_to_perl_variable( json );
  }
  apr_pool_destroy( tmp_mp );

  return hash;
}
Пример #28
0
void ll_cleanup_apr()
{
	LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL;

	if (gLogMutexp)
	{
		// Clean up the logging mutex

		// All other threads NEED to be done before we clean up APR, so this is okay.
		apr_thread_mutex_destroy(gLogMutexp);
		gLogMutexp = NULL;
	}
	if (gAPRPoolp)
	{
		apr_pool_destroy(gAPRPoolp);
		gAPRPoolp = NULL;
	}
	apr_terminate();
}
Пример #29
0
static void cleanup_cache_object(cache_object_t *obj)
{
    mem_cache_object_t *mobj = obj->vobj;

    /* Cleanup the mem_cache_object_t */
    if (mobj) {
        if (mobj->m) {
            free(mobj->m);
        }
        if (mobj->type == CACHE_TYPE_FILE && mobj->fd) {
#ifdef WIN32
            CloseHandle(mobj->fd);
#else
            close(mobj->fd);
#endif
        }
        apr_pool_destroy(mobj->pool);
    }
}
Пример #30
0
int main(int argc, const char* const argv[]) {
    apr_pool_t* pool = NULL;
    apr_status_t status = APR_SUCCESS;

#ifdef WIN32
#ifndef _DEBUG // only Release configuration dump generating
    SetUnhandledExceptionFilter(dbg_top_level_filter);
#endif
#endif

    setlocale(LC_ALL, ".ACP");
    setlocale(LC_NUMERIC, "C");

#ifdef USE_GETTEXT
    bindtextdomain("hc", LOCALEDIR); /* set the text message domain */
    textdomain("hc");
#endif /* USE_GETTEXT */

    status = apr_app_initialize(&argc, &argv, NULL);
    if(status != APR_SUCCESS) {
        lib_printf(_("Couldn't initialize APR"));
        lib_new_line();
        out_print_error(status);
        return EXIT_FAILURE;
    }
    atexit(apr_terminate);
    apr_pool_create(&pool, NULL);
    hsh_initialize_hashes(pool);

    configuration_ctx_t* configuration_ctx = apr_pcalloc(pool, sizeof(configuration_ctx_t));
    configuration_ctx->pool = pool;
    configuration_ctx->argc = argc;
    configuration_ctx->argv = argv;
    configuration_ctx->pfn_on_string = &prhc_on_string;
    configuration_ctx->pfn_on_hash = &prhc_on_hash;
    configuration_ctx->pfn_on_file = &prhc_on_file;
    configuration_ctx->pfn_on_dir = &prhc_on_dir;

    conf_run_app(configuration_ctx);

    apr_pool_destroy(pool);
    return EXIT_SUCCESS;
}