/* New RTSP connection accepted */ static apt_bool_t rtsp_server_on_connect(apt_net_server_task_t *task, apt_net_server_connection_t *connection) { rtsp_server_t *server = apt_net_server_task_object_get(task); rtsp_server_connection_t *rtsp_connection = apr_palloc(connection->pool,sizeof(rtsp_server_connection_t)); rtsp_connection->session_table = apr_hash_make(connection->pool); apt_text_stream_init(&rtsp_connection->rx_stream,rtsp_connection->rx_buffer,sizeof(rtsp_connection->rx_buffer)-1); apt_text_stream_init(&rtsp_connection->tx_stream,rtsp_connection->tx_buffer,sizeof(rtsp_connection->tx_buffer)-1); rtsp_connection->parser = rtsp_parser_create(connection->pool); rtsp_connection->generator = rtsp_generator_create(connection->pool); rtsp_connection->base = connection; connection->obj = rtsp_connection; if(!server->connection_list) { server->connection_list = apt_list_create(server->sub_pool); } rtsp_connection->server = server; rtsp_connection->it = apt_list_push_back(server->connection_list,rtsp_connection,connection->pool); return TRUE; }
static cfg_section_t * svn_config_addsection(svn_config_t *cfg, const char *section) { cfg_section_t *s; const char *hash_key; s = apr_palloc(cfg->pool, sizeof(cfg_section_t)); s->name = apr_pstrdup(cfg->pool, section); if(cfg->section_names_case_sensitive) hash_key = s->name; else hash_key = make_hash_key(apr_pstrdup(cfg->pool, section)); s->options = apr_hash_make(cfg->pool); svn_hash_sets(cfg->sections, hash_key, s); return s; }
svn_error_t * svn_config_get_config(apr_hash_t **cfg_hash, const char *config_dir, apr_pool_t *pool) { svn_config_t *cfg; *cfg_hash = apr_hash_make(pool); SVN_ERR(get_category_config(&cfg, config_dir, SVN_CONFIG_CATEGORY_SERVERS, pool)); svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_SERVERS, cfg); SVN_ERR(get_category_config(&cfg, config_dir, SVN_CONFIG_CATEGORY_CONFIG, pool)); svn_hash_sets(*cfg_hash, SVN_CONFIG_CATEGORY_CONFIG, cfg); return SVN_NO_ERROR; }
svn_error_t * svn_repos_fs_begin_txn_for_commit(svn_fs_txn_t **txn_p, svn_repos_t *repos, svn_revnum_t rev, const char *author, const char *log_msg, apr_pool_t *pool) { apr_hash_t *revprop_table = apr_hash_make(pool); if (author) svn_hash_sets(revprop_table, SVN_PROP_REVISION_AUTHOR, svn_string_create(author, pool)); if (log_msg) svn_hash_sets(revprop_table, SVN_PROP_REVISION_LOG, svn_string_create(log_msg, pool)); return svn_repos_fs_begin_txn_for_commit2(txn_p, repos, rev, revprop_table, pool); }
static const char* mapcache_add_alias(cmd_parms *cmd, void *cfg, const char *alias, const char* configfile) { mapcache_server_cfg *sconfig = ap_get_module_config(cmd->server->module_config, &mapcache_module); mapcache_cfg *config = mapcache_configuration_create(cmd->pool); mapcache_context *ctx = (mapcache_context*)apache_server_context_create(cmd->server,cmd->pool); char *msg = NULL; config->configFile = apr_pstrdup(cmd->pool,configfile); config->endpoint = alias; mapcache_configuration_parse(ctx,configfile,config,0); if(GC_HAS_ERROR(ctx)) { return ctx->get_error_message(ctx); } ap_log_error(APLOG_MARK, APLOG_INFO, 0, cmd->server, "loaded mapcache configuration file from %s on alias %s", config->configFile, alias); if(!sconfig->aliases) { sconfig->aliases = apr_hash_make(cmd->pool); } apr_hash_set(sconfig->aliases,configfile,APR_HASH_KEY_STRING,config); return msg; }
/** Create MRCP client instance */ MRCP_DECLARE(mrcp_client_t*) mrcp_client_create(apt_dir_layout_t *dir_layout) { mrcp_client_t *client; apr_pool_t *pool; apt_task_vtable_t vtable; apt_task_msg_pool_t *msg_pool; if(apr_pool_create(&pool,NULL) != APR_SUCCESS) { return NULL; } apt_log(APT_PRIO_NOTICE,"Create MRCP Client"); client = apr_palloc(pool,sizeof(mrcp_client_t)); client->pool = pool; client->dir_layout = dir_layout; client->resource_factory = NULL; client->media_engine_table = NULL; client->rtp_factory_table = NULL; client->sig_agent_table = NULL; client->cnt_agent_table = NULL; client->profile_table = NULL; client->app_table = NULL; client->session_table = NULL; client->cnt_msg_pool = NULL; apt_task_vtable_reset(&vtable); vtable.process_msg = mrcp_client_msg_process; vtable.on_start_complete = mrcp_client_on_start_complete; vtable.on_terminate_complete = mrcp_client_on_terminate_complete; msg_pool = apt_task_msg_pool_create_dynamic(0,pool); client->task = apt_consumer_task_create(client, &vtable, msg_pool, pool); if(!client->task) { apt_log(APT_PRIO_WARNING,"Failed to Create Client Task"); return NULL; } client->media_engine_table = apr_hash_make(client->pool); client->rtp_factory_table = apr_hash_make(client->pool); client->sig_agent_table = apr_hash_make(client->pool); client->cnt_agent_table = apr_hash_make(client->pool); client->profile_table = apr_hash_make(client->pool); client->app_table = apr_hash_make(client->pool); client->session_table = apr_hash_make(client->pool); return client; }
static void register_hooks(apr_pool_t *p) { ap_hook_pre_config(log_pre_config,NULL,NULL,APR_HOOK_REALLY_FIRST); ap_hook_child_init(init_child,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_open_logs(init_config_log,NULL,NULL,APR_HOOK_MIDDLE); ap_hook_log_transaction(multi_log_transaction,NULL,NULL,APR_HOOK_MIDDLE); /* Init log_hash before we register the optional function. It is * possible for the optional function, ap_register_log_handler, * to be called before any other mod_log_config hooks are called. * As a policy, we should init everything required by an optional function * before calling APR_REGISTER_OPTIONAL_FN. */ log_hash = apr_hash_make(p); APR_REGISTER_OPTIONAL_FN(ap_register_log_handler); APR_REGISTER_OPTIONAL_FN(ap_log_set_writer_init); APR_REGISTER_OPTIONAL_FN(ap_log_set_writer); }
static char *test_plaintext_decrypt(apr_pool_t *pool) { // from http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-30 // A.2. Example JWE using RSAES-PKCS1-V1_5 and AES_128_CBC_HMAC_SHA_256 char *s = apr_pstrdup(pool, "eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0" ".UGhIOguC7IuEvf_NPVaXsGMoLOmwvc1GyqlIKOK1nN94nHPoltGRhWhw7Zx0-kFm1NJn8LE9XShH59_i8J0PH5ZZyNfGy2xGdULU7sHNF6Gp2vPLgNZ__deLKxGHZ7PcHALUzoOegEI-8E66jX2E4zyJKx-YxzZIItRzC5hlRirb6Y5Cl_p-ko3YvkkysZIFNPccxRU7qve1WYPxqbb2Yw8kZqa2rMWI5ng8OtvzlV7elprCbuPhcCdZ6XDP0_F8rkXds2vE4X-ncOIM8hAYHHi29NX0mcKiRaD0-D-ljQTP-cFPgwCp6X-nZZd9OHBv-B3oWh2TbqmScqXMR4gp_A" ".AxY8DCtDaGlsbGljb3RoZQ" ".KDlTtXchhZTGufMYmOYGS4HffxPSUrfmqCHXaI9wOGY" ".9hH0vgRfYgPnAHOd8stkvw"); char * k = "{\"kty\":\"RSA\"," "\"n\":\"sXchDaQebHnPiGvyDOAT4saGEUetSyo9MKLOoWFsueri23bOdgWp4Dy1WlUzewbgBHod5pcM9H95GQRV3JDXboIRROSBigeC5yjU1hGzHHyXss8UDprecbAYxknTcQkhslANGRUZmdTOQ5qTRsLAt6BTYuyvVRdhS8exSZEy_c4gs_7svlJJQ4H9_NxsiIoLwAEk7-Q3UXERGYw_75IDrGA84-lA_-Ct4eTlXHBIY2EaV7t7LjJaynVJCpkv4LKjTTAumiGUIuQhrNhZLuF_RJLqHpM2kgWFLU7-VTdL1VbC2tejvcI2BlMkEpk1BzBZI0KQB0GaDWFLN-aEAw3vRw\"," "\"e\":\"AQAB\"," "\"d\":\"VFCWOqXr8nvZNyaaJLXdnNPXZKRaWCjkU5Q2egQQpTBMwhprMzWzpR8Sxq1OPThh_J6MUD8Z35wky9b8eEO0pwNS8xlh1lOFRRBoNqDIKVOku0aZb-rynq8cxjDTLZQ6Fz7jSjR1Klop-YKaUHc9GsEofQqYruPhzSA-QgajZGPbE_0ZaVDJHfyd7UUBUKunFMScbflYAAOYJqVIVwaYR5zWEEceUjNnTNo_CVSj-VvXLO5VZfCUAVLgW4dpf1SrtZjSt34YLsRarSb127reG_DUwg9Ch-KyvjT1SkHgUWRVGcyly7uvVGRSDwsXypdrNinPA4jlhoNdizK2zF2CWQ\"" "}"; apr_jwt_error_t err; apr_hash_t *keys = apr_hash_make(pool); apr_jwk_t *jwk = NULL; TST_ASSERT_ERR("apr_jwk_parse_json", _jwk_parse(pool, k, &jwk, &err) == 0, pool, err); apr_hash_set(keys, "dummy", APR_HASH_KEY_STRING, jwk); apr_array_header_t *unpacked = NULL; apr_jwt_header_t header; memset(&header, 0, sizeof(header)); TST_ASSERT_ERR("apr_jwt_header_parse", apr_jwt_header_parse(pool, s, &unpacked, &header, &err), pool, err); char *decrypted = NULL; TST_ASSERT_ERR("apr_jwe_decrypt_jwt", apr_jwe_decrypt_jwt(pool, &header, unpacked, keys, &decrypted, &err), pool, err); TST_ASSERT_STR("decrypted", decrypted, "Live long and prosper."); json_decref(header.value.json); return 0; }
/* Find the operation associated with PATH, which is a single-path component representing a child of the path represented by OPERATION. If no such child operation exists, create a new one of type OP_OPEN. */ static struct operation * get_operation(const char *path, struct operation *operation, apr_pool_t *pool) { struct operation *child = apr_hash_get(operation->children, path, APR_HASH_KEY_STRING); if (! child) { child = apr_pcalloc(pool, sizeof(*child)); child->children = apr_hash_make(pool); child->operation = OP_OPEN; child->rev = SVN_INVALID_REVNUM; child->kind = svn_node_dir; child->props = apr_table_make(pool, 0); apr_hash_set(operation->children, path, APR_HASH_KEY_STRING, child); } return child; }
/* Sets up a delta editor for dumping a revision */ void delta_setup_editor(session_t *session, dump_options_t *options, list_t *logs, log_revision_t *log_revision, svn_revnum_t local_revnum, svn_delta_editor_t **editor, void **editor_baton, apr_pool_t *pool) { de_baton_t *baton; *editor = svn_delta_default_editor(pool); (*editor)->set_target_revision = de_set_target_revision; (*editor)->open_root = de_open_root; (*editor)->delete_entry = de_delete_entry; (*editor)->add_directory = de_add_directory; (*editor)->open_directory = de_open_directory; (*editor)->add_file = de_add_file; (*editor)->open_file = de_open_file; (*editor)->apply_textdelta = de_apply_textdelta; (*editor)->close_file = de_close_file; (*editor)->close_directory = de_close_directory; (*editor)->change_file_prop = de_change_file_prop; (*editor)->change_dir_prop = de_change_dir_prop; (*editor)->close_edit = de_close_edit; (*editor)->absent_directory = de_absent_directory; (*editor)->absent_file = de_absent_file; (*editor)->abort_edit = de_abort_edit; baton = apr_palloc(pool, sizeof(de_baton_t)); baton->session = session; baton->opts = options; baton->logs = logs; baton->log_revision = log_revision; baton->local_revnum = local_revnum; baton->revision_pool = svn_pool_create(pool); baton->dumped_entries = apr_hash_make(baton->revision_pool); *editor_baton = baton; /* Create global hashes if needed */ if (!hashes_created) { apr_pool_t *hash_pool = svn_pool_create(session->pool); md5_hash = rhash_make(hash_pool); delta_hash = rhash_make(hash_pool); prop_hash = rhash_make(hash_pool); hashes_created = 1; } }
static const char *set_links (cmd_parms * cmd, void *CFG, const char *elt, const char *att) { apr_array_header_t *attrs; tattr *attr; cdn_conf *cfg = CFG; if (cfg->links == NULL) cfg->links = apr_hash_make(cmd->pool); attrs = apr_hash_get(cfg->links, elt, APR_HASH_KEY_STRING); if (!attrs) { attrs = apr_array_make(cmd->pool, 2, sizeof(tattr *)); apr_hash_set(cfg->links, elt, APR_HASH_KEY_STRING, attrs); } attr = apr_array_push(attrs); attr->val = att; return NULL; }
/*** Public API to SSL file providers. ***/ void svn_auth_get_ssl_client_cert_pw_file_provider2 (svn_auth_provider_object_t **provider, svn_auth_plaintext_passphrase_prompt_func_t plaintext_passphrase_prompt_func, void *prompt_baton, apr_pool_t *pool) { svn_auth_provider_object_t *po = apr_pcalloc(pool, sizeof(*po)); ssl_client_cert_pw_file_provider_baton_t *pb = apr_pcalloc(pool, sizeof(*pb)); pb->plaintext_passphrase_prompt_func = plaintext_passphrase_prompt_func; pb->prompt_baton = prompt_baton; pb->plaintext_answers = apr_hash_make(pool); po->vtable = &ssl_client_cert_pw_file_provider; po->provider_baton = pb; *provider = po; }
static svn_error_t * dir_change_prop(void *dir_baton, const char *name, const svn_string_t *value, apr_pool_t *scratch_pool) { struct dir_baton_t *db = dir_baton; struct edit_baton_t *eb = db->eb; svn_prop_kind_t prop_kind; prop_kind = svn_property_kind2(name); if (prop_kind != svn_prop_regular_kind || ! strcmp(name, SVN_PROP_MERGEINFO)) { /* We can't handle DAV, ENTRY and merge specific props here */ return SVN_NO_ERROR; } if (! db->created) { /* We can still store them in the hash for immediate addition with the svn_wc_add_from_disk3() call */ if (! db->properties) db->properties = apr_hash_make(db->pool); if (value != NULL) svn_hash_sets(db->properties, apr_pstrdup(db->pool, name), svn_string_dup(value, db->pool)); } else { /* We have already notified for this directory, so don't do that again */ SVN_ERR(svn_wc_prop_set4(eb->wc_ctx, db->local_abspath, name, value, svn_depth_empty, FALSE, NULL, NULL, NULL, /* Cancellation */ NULL, NULL, /* Notification */ scratch_pool)); } return SVN_NO_ERROR; }
svn_error_t * svn_config_read_auth_data(apr_hash_t **hash, const char *cred_kind, const char *realmstring, const char *config_dir, apr_pool_t *pool) { svn_node_kind_t kind; const char *auth_path; *hash = NULL; SVN_ERR(svn_auth__file_path(&auth_path, cred_kind, realmstring, config_dir, pool)); if (! auth_path) return SVN_NO_ERROR; SVN_ERR(svn_io_check_path(auth_path, &kind, pool)); if (kind == svn_node_file) { svn_stream_t *stream; svn_string_t *stored_realm; SVN_ERR_W(svn_stream_open_readonly(&stream, auth_path, pool, pool), _("Unable to open auth file for reading")); *hash = apr_hash_make(pool); SVN_ERR_W(svn_hash_read2(*hash, stream, SVN_HASH_TERMINATOR, pool), apr_psprintf(pool, _("Error parsing '%s'"), svn_dirent_local_style(auth_path, pool))); stored_realm = svn_hash_gets(*hash, SVN_CONFIG_REALMSTRING_KEY); if (!stored_realm || strcmp(stored_realm->data, realmstring) != 0) *hash = NULL; /* Hash collision, or somebody tampering with storage */ SVN_ERR(svn_stream_close(stream)); } return SVN_NO_ERROR; }
static apr_status_t lcn_document_writer_init_posting_table( lcn_document_writer_t *document_writer, unsigned int field_infos_size, float boost ) { apr_status_t s; do { unsigned int i; apr_pool_clear( document_writer->posting_table_pool ); LCNPV( document_writer->posting_table = apr_hash_make( document_writer->posting_table_pool ), APR_ENOMEM ); LCNPV( document_writer->field_lengths = (unsigned int*) apr_pcalloc( document_writer->posting_table_pool, sizeof(unsigned int) * field_infos_size ), APR_ENOMEM ); LCNPV( document_writer->field_positions = (unsigned int*) apr_pcalloc( document_writer->posting_table_pool, sizeof(unsigned int) * field_infos_size ), APR_ENOMEM ); LCNPV( document_writer->field_offsets = (unsigned int*) apr_pcalloc( document_writer->posting_table_pool, sizeof(unsigned int) * field_infos_size ), APR_ENOMEM ); LCNPV( document_writer->field_boosts = (float*) apr_palloc( document_writer->posting_table_pool, sizeof(float) * field_infos_size ), APR_ENOMEM ); for( i = 0; i < field_infos_size; i++ ) { (document_writer->field_boosts)[i] = boost; } } while(0); return s; }
apr_hash_t * svn_prop_hash_dup(const apr_hash_t *hash, apr_pool_t *pool) { apr_hash_index_t *hi; apr_hash_t *new_hash = apr_hash_make(pool); for (hi = apr_hash_first(pool, (apr_hash_t *)hash); hi; hi = apr_hash_next(hi)) { const void *key; apr_ssize_t klen; void *prop; apr_hash_this(hi, &key, &klen, &prop); apr_hash_set(new_hash, apr_pstrmemdup(pool, key, klen), klen, svn_string_dup(prop, pool)); } return new_hash; }
int proc_register(process_t *self, term_t name) { if (self->registered_name != A_UNDEFINED) return 0; if (registry == 0) { apr_pool_t *pool; apr_pool_create(&pool, 0); registry = apr_hash_make(pool); } else { process_t *proc = apr_hash_get(registry, &name, sizeof(name)); if (proc) return 0; } self->registered_name = name; apr_hash_set(registry, &self->registered_name, sizeof(self->registered_name), self); return 1; }
/* Conforms to svn_ra_serf__xml_opened_t */ static svn_error_t * iprops_opened(svn_ra_serf__xml_estate_t *xes, void *baton, int entered_state, const svn_ra_serf__dav_props_t *tag, apr_pool_t *scratch_pool) { iprops_context_t *iprops_ctx = baton; if (entered_state == IPROPS_ITEM) { svn_stringbuf_setempty(iprops_ctx->curr_propname); iprops_ctx->curr_iprop = apr_pcalloc(iprops_ctx->pool, sizeof(*iprops_ctx->curr_iprop)); iprops_ctx->curr_iprop->prop_hash = apr_hash_make(iprops_ctx->pool); } return SVN_NO_ERROR; }
/* An implementation of svn_config_enumerator2_t. * Set environment variable NAME to value VALUE in the environment for * all hooks (in case the current section is the default section), * or the hook with the name corresponding to the current section's name. */ static svn_boolean_t parse_hooks_env_option(const char *name, const char *value, void *baton, apr_pool_t *pool) { struct parse_hooks_env_option_baton *bo = baton; apr_pool_t *result_pool = apr_hash_pool_get(bo->hooks_env); apr_hash_t *hook_env; hook_env = svn_hash_gets(bo->hooks_env, bo->section); if (hook_env == NULL) { hook_env = apr_hash_make(result_pool); svn_hash_sets(bo->hooks_env, apr_pstrdup(result_pool, bo->section), hook_env); } svn_hash_sets(hook_env, apr_pstrdup(result_pool, name), apr_pstrdup(result_pool, value)); return TRUE; }
svn_error_t * svn_delta_from_editor(const svn_delta_editor_t **deditor, void **dedit_baton, svn_editor_t *editor, svn_delta_fetch_props_func_t fetch_props_func, void *fetch_props_baton, apr_pool_t *pool) { /* Static 'cause we don't want it to be on the stack. */ static svn_delta_editor_t delta_editor = { ev2_set_target_revision, ev2_open_root, ev2_delete_entry, ev2_add_directory, ev2_open_directory, ev2_change_dir_prop, ev2_close_directory, ev2_absent_directory, ev2_add_file, ev2_open_file, ev2_apply_textdelta, ev2_change_file_prop, ev2_close_file, ev2_absent_file, ev2_close_edit, ev2_abort_edit }; struct ev2_edit_baton *eb = apr_palloc(pool, sizeof(*eb)); eb->editor = editor; eb->paths = apr_hash_make(pool); eb->target_revision = SVN_INVALID_REVNUM; eb->edit_pool = pool; eb->fetch_props_func = fetch_props_func; eb->fetch_props_baton = fetch_props_baton; *dedit_baton = eb; *deditor = &delta_editor; return SVN_NO_ERROR; }
static svn_error_t * commit_tree(svn_ra_session_t *session, apr_pool_t *pool) { apr_hash_t *revprop_table = apr_hash_make(pool); const svn_delta_editor_t *editor; void *edit_baton; const char *repos_root_url; void *root_baton, *A_baton, *B_baton, *file_baton; SVN_ERR(svn_ra_get_commit_editor3(session, &editor, &edit_baton, revprop_table, NULL, NULL, NULL, TRUE, pool)); SVN_ERR(svn_ra_get_repos_root(session, &repos_root_url, pool)); SVN_ERR(editor->open_root(edit_baton, SVN_INVALID_REVNUM, pool, &root_baton)); SVN_ERR(editor->add_directory("A", root_baton, NULL, SVN_INVALID_REVNUM, pool, &A_baton)); SVN_ERR(editor->add_directory("A/B", A_baton, NULL, SVN_INVALID_REVNUM, pool, &B_baton)); SVN_ERR(editor->add_file("A/B/f", B_baton, NULL, SVN_INVALID_REVNUM, pool, &file_baton)); SVN_ERR(editor->close_file(file_baton, NULL, pool)); SVN_ERR(editor->add_file("A/B/g", B_baton, NULL, SVN_INVALID_REVNUM, pool, &file_baton)); SVN_ERR(editor->close_file(file_baton, NULL, pool)); SVN_ERR(editor->close_directory(B_baton, pool)); SVN_ERR(editor->add_directory("A/BB", A_baton, NULL, SVN_INVALID_REVNUM, pool, &B_baton)); SVN_ERR(editor->add_file("A/BB/f", B_baton, NULL, SVN_INVALID_REVNUM, pool, &file_baton)); SVN_ERR(editor->close_file(file_baton, NULL, pool)); SVN_ERR(editor->add_file("A/BB/g", B_baton, NULL, SVN_INVALID_REVNUM, pool, &file_baton)); SVN_ERR(editor->close_file(file_baton, NULL, pool)); SVN_ERR(editor->close_directory(B_baton, pool)); SVN_ERR(editor->close_directory(A_baton, pool)); SVN_ERR(editor->close_edit(edit_baton, pool)); return SVN_NO_ERROR; }
apr_hash_t *get_active_queries(apr_pool_t *pool) { PGresult *result = NULL; apr_hash_t *active_query_tab = NULL; PGconn *conn = PQconnectdb(GPDB_CONNECTION_STRING); if (PQstatus(conn) != CONNECTION_OK) { gpmon_warning( FLINE, "error creating GPDB client connection to dynamically " "check/create gpperfmon partitions: %s", PQerrorMessage(conn)); PQfinish(conn); return NULL; } const char *qry= "SELECT sess_id, current_query FROM pg_stat_activity;"; const char *errmsg = gpdb_exec_only(conn, &result, qry); if (errmsg) { gpmon_warning(FLINE, "check query status failed : %s", errmsg); } else { active_query_tab = apr_hash_make(pool); if (! active_query_tab) { gpmon_warning(FLINE, "Out of memory"); } else { convert_tuples_to_hash(result, active_query_tab, pool); } } PQclear(result); PQfinish(conn); return active_query_tab; }
static svn_error_t * fetch_props_func(apr_hash_t **props, void *baton, const char *path, svn_revnum_t base_revision, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { struct revision_baton *rb = baton; svn_node_kind_t node_kind; if (! SVN_IS_VALID_REVNUM(base_revision)) base_revision = rb->rev - 1; SVN_ERR(svn_ra_check_path(rb->pb->aux_session, path, base_revision, &node_kind, scratch_pool)); if (node_kind == svn_node_file) { SVN_ERR(svn_ra_get_file(rb->pb->aux_session, path, base_revision, NULL, NULL, props, result_pool)); } else if (node_kind == svn_node_dir) { apr_array_header_t *tmp_props; SVN_ERR(svn_ra_get_dir2(rb->pb->aux_session, NULL, NULL, props, path, base_revision, 0 /* Dirent fields */, result_pool)); tmp_props = svn_prop_hash_to_array(*props, result_pool); SVN_ERR(svn_categorize_props(tmp_props, NULL, NULL, &tmp_props, result_pool)); *props = svn_prop_array_to_hash(tmp_props, result_pool); } else { *props = apr_hash_make(result_pool); } return SVN_NO_ERROR; }
svn_error_t * svn_config_create2(svn_config_t **cfgp, svn_boolean_t section_names_case_sensitive, svn_boolean_t option_names_case_sensitive, apr_pool_t *result_pool) { svn_config_t *cfg = apr_palloc(result_pool, sizeof(*cfg)); cfg->sections = apr_hash_make(result_pool); cfg->pool = result_pool; cfg->x_pool = svn_pool_create(result_pool); cfg->x_values = FALSE; cfg->tmp_key = svn_stringbuf_create_empty(result_pool); cfg->tmp_value = svn_stringbuf_create_empty(result_pool); cfg->section_names_case_sensitive = section_names_case_sensitive; cfg->option_names_case_sensitive = option_names_case_sensitive; cfg->read_only = FALSE; *cfgp = cfg; return SVN_NO_ERROR; }
int main(void) { apr_initialize(); apr_pool_t *pool; apr_pool_create(&pool, NULL); apr_hash_t *hash = apr_hash_make(pool); apr_hash_set(hash, "php", APR_HASH_KEY_STRING, "Hello, PHP"); apr_hash_set(hash, "apache", APR_HASH_KEY_STRING, "Hello, Apache"); apr_hash_set(hash, "mysql", APR_HASH_KEY_STRING, "hello, mysql"); apr_hash_do(print_hash_item, "first_print", hash); printf("apr_hash_count(hash) = %d\n", apr_hash_count(hash)); printf("apr_hash_get(hash, \"apache\", APR_HASH_KEY_STRING) = %s\n", apr_hash_get(hash, "apache", APR_HASH_KEY_STRING)); apr_pool_destroy(pool); apr_terminate(); return 0; }
/* Create RTSP session */ static rtsp_server_session_t* rtsp_server_session_create(rtsp_server_t *server) { rtsp_server_session_t *session; apr_pool_t *pool = apt_pool_create(); session = apr_palloc(pool,sizeof(rtsp_server_session_t)); session->pool = pool; session->obj = NULL; session->last_cseq = 0; session->active_request = NULL; session->request_queue = apt_list_create(pool); session->resource_table = apr_hash_make(pool); session->terminating = FALSE; apt_unique_id_generate(&session->id,RTSP_SESSION_ID_HEX_STRING_LENGTH,pool); apt_log(RTSP_LOG_MARK,APT_PRIO_NOTICE,"Create RTSP Session " APT_SID_FMT,session->id.buf); if(server->vtable->create_session(server,session) != TRUE) { apr_pool_destroy(pool); return NULL; } return session; }
/* Conforms to svn_ra_serf__xml_opened_t */ static svn_error_t * propfind_opened(svn_ra_serf__xml_estate_t *xes, void *baton, int entered_state, const svn_ra_serf__dav_props_t *tag, apr_pool_t *scratch_pool) { propfind_context_t *ctx = baton; if (entered_state == PROPVAL) { svn_ra_serf__xml_note(xes, PROPVAL, "ns", tag->xmlns); svn_ra_serf__xml_note(xes, PROPVAL, "name", tag->name); } else if (entered_state == PROPSTAT) { ctx->ps_props = apr_hash_make(svn_ra_serf__xml_state_pool(xes)); } return SVN_NO_ERROR; }
/* Parse application options. */ static int mrcpsynth_options_parse(char *str, mrcpsynth_options_t *options, apr_pool_t *pool) { char *s; char *name, *value; if (!str) return 0; if ((options->synth_hfs = apr_hash_make(pool)) == NULL) { return -1; } while ((s = strsep(&str, "&"))) { value = s; if ((name = strsep(&value, "=")) && value) { ast_log(LOG_DEBUG, "Apply option %s: %s\n", name, value); mrcpsynth_option_apply(options, name, value); } } return 0; }
static svn_error_t * construct_config(apr_hash_t **config_p, const char *http_library, apr_pool_t *pool) { apr_hash_t *config; svn_config_t *servers; /* Populate SERVERS. */ SVN_ERR(svn_config_create(&servers, FALSE, pool)); svn_config_set(servers, SVN_CONFIG_SECTION_GLOBAL, SVN_CONFIG_OPTION_HTTP_LIBRARY, http_library); /* Populate CONFIG. */ config = apr_hash_make(pool); apr_hash_set(config, SVN_CONFIG_CATEGORY_SERVERS, APR_HASH_KEY_STRING, servers); *config_p = config; return SVN_NO_ERROR; }
apr_status_t _kahanaIOInit( Kahana_t *kahana ) { apr_status_t rc; apr_pool_t *p; kIOCache_t *iocache; kahana->iocache = NULL; if( ( rc = kahanaMalloc( kahana->p, sizeof( kIOCache_t ), (void**)&iocache, &p ) ) ){ kahanaLogPut( NULL, NULL, "failed to kahanaMalloc(): %s", STRERROR_APR( rc ) ); } else { iocache->p = p; iocache->store = FALSE; iocache->size = 0; iocache->hash = apr_hash_make( p ); kahana->iocache = iocache; } return rc; }