Esempio n. 1
0
void UmcFramework::ProcessShowScenarios()
{
	UmcScenario* pScenario;
	void* pVal;
	printf("%d Scenario(s)\n", apr_hash_count(m_pScenarioTable));
	apr_hash_index_t* it = apr_hash_first(m_pPool,m_pScenarioTable);
	for(; it; it = apr_hash_next(it))
	{
		apr_hash_this(it,NULL,NULL,&pVal);
		pScenario = (UmcScenario*) pVal;
		if(pScenario)
		{
			printf("[%s]\n", pScenario->GetName());
		}
	}
}
Esempio n. 2
0
/** Close registered engines */
MRCP_DECLARE(apt_bool_t) mrcp_engine_factory_close(mrcp_engine_factory_t *factory)
{
	mrcp_engine_t *engine;
	apr_hash_index_t *it;
	void *val;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close MRCP Engines");
	it=apr_hash_first(factory->pool,factory->engines);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		engine = val;
		if(engine) {
			mrcp_engine_virtual_close(engine);
		}
	}
	return TRUE;
}
Esempio n. 3
0
static svn_error_t *
new_revision_record(void **revision_baton,
                    apr_hash_t *headers,
                    void *parse_baton,
                    apr_pool_t *pool)
{
  struct revision_baton *rb;
  struct parse_baton *pb;
  apr_hash_index_t *hi;
  svn_revnum_t head_rev;

  rb = apr_pcalloc(pool, sizeof(*rb));
  pb = parse_baton;
  rb->pool = svn_pool_create(pool);
  rb->pb = pb;
  rb->db = NULL;

  for (hi = apr_hash_first(pool, headers); hi; hi = apr_hash_next(hi))
    {
      const char *hname = svn__apr_hash_index_key(hi);
      const char *hval = svn__apr_hash_index_val(hi);

      if (strcmp(hname, SVN_REPOS_DUMPFILE_REVISION_NUMBER) == 0)
        rb->rev = atoi(hval);
    }

  SVN_ERR(svn_ra_get_latest_revnum(pb->session, &head_rev, pool));

  /* FIXME: This is a lame fallback loading multiple segments of dump in
     several separate operations. It is highly susceptible to race conditions.
     Calculate the revision 'offset' for finding copyfrom sources.
     It might be positive or negative. */
  rb->rev_offset = (apr_int32_t) ((rb->rev) - (head_rev + 1));

  /* Stash the oldest (non-zero) dumpstream revision seen. */
  if ((rb->rev > 0) && (!SVN_IS_VALID_REVNUM(pb->oldest_dumpstream_rev)))
    pb->oldest_dumpstream_rev = rb->rev;

  /* Set the commit_editor/ commit_edit_baton to NULL and wait for
     them to be created in new_node_record */
  rb->pb->commit_editor = NULL;
  rb->pb->commit_edit_baton = NULL;
  rb->revprop_table = apr_hash_make(rb->pool);

  *revision_baton = rb;
  return SVN_NO_ERROR;
}
Esempio n. 4
0
void
svn_ra_serf__merge_lock_token_list(apr_hash_t *lock_tokens,
                                   const char *parent,
                                   serf_bucket_t *body,
                                   serf_bucket_alloc_t *alloc,
                                   apr_pool_t *pool)
{
  apr_hash_index_t *hi;

  if (!lock_tokens || apr_hash_count(lock_tokens) == 0)
    return;

  svn_ra_serf__add_open_tag_buckets(body, alloc,
                                    "S:lock-token-list",
                                    "xmlns:S", SVN_XML_NAMESPACE,
                                    SVN_VA_NULL);

  for (hi = apr_hash_first(pool, lock_tokens);
       hi;
       hi = apr_hash_next(hi))
    {
      const void *key;
      apr_ssize_t klen;
      void *val;
      svn_string_t path;

      apr_hash_this(hi, &key, &klen, &val);

      path.data = key;
      path.len = klen;

      if (parent && !svn_relpath_skip_ancestor(parent, key))
        continue;

      svn_ra_serf__add_open_tag_buckets(body, alloc, "S:lock", SVN_VA_NULL);

      svn_ra_serf__add_open_tag_buckets(body, alloc, "lock-path", SVN_VA_NULL);
      svn_ra_serf__add_cdata_len_buckets(body, alloc, path.data, path.len);
      svn_ra_serf__add_close_tag_buckets(body, alloc, "lock-path");

      svn_ra_serf__add_tag_buckets(body, "lock-token", val, alloc);

      svn_ra_serf__add_close_tag_buckets(body, alloc, "S:lock");
    }

  svn_ra_serf__add_close_tag_buckets(body, alloc, "S:lock-token-list");
}
Esempio n. 5
0
Py::Object propsToObject( apr_hash_t *props, SvnPool &pool )
{
    Py::Dict py_prop_dict;

    for( apr_hash_index_t *hi = apr_hash_first( pool, props ); hi; hi = apr_hash_next( hi ) )
    {
        const void *key = NULL;
        void *val = NULL;

        apr_hash_this (hi, &key, NULL, &val);
        const svn_string_t *propval = (const svn_string_t *)val;
        
        py_prop_dict[ Py::String( (const char *)key ) ] = Py::String( propval->data, (int)propval->len );
    }

    return py_prop_dict;
}
Esempio n. 6
0
term_t proc_list_registered(xpool_t *xp)
{
	apr_hash_index_t *hi;

	term_t r = nil;
	term_t cons = nil;

	for (hi = apr_hash_first(0, registry); hi; hi = apr_hash_next(hi))
	{
		process_t *proc;
		apr_hash_this(hi, 0, 0, (void **)&proc);
		if (proc->registered_name != A_UNDEFINED)
		  lst_add(r, cons, proc->registered_name, xp);
	}

	return r;
}
apt_bool_t mrcp_connection_disconnect_raise(mrcp_connection_t *connection, const mrcp_connection_event_vtable_t *vtable)
{
	if(vtable && vtable->on_disconnect) {
		mrcp_control_channel_t *channel;
		void *val;
		apr_hash_index_t *it = apr_hash_first(connection->pool,connection->channel_table);
		/* walk through the list of channels and raise disconnect event for them */
		for(; it; it = apr_hash_next(it)) {
			apr_hash_this(it,NULL,NULL,&val);
			channel = val;
			if(channel) {
				vtable->on_disconnect(channel);
			}
		}
	}
	return TRUE;
}
Esempio n. 8
0
/** Unload loaded plugins */
MRCP_DECLARE(apt_bool_t) mrcp_engine_loader_plugins_unload(mrcp_engine_loader_t *loader)
{
	apr_hash_index_t *it;
	void *val;
	apr_dso_handle_t *plugin;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Unload Plugins");
	it=apr_hash_first(loader->pool,loader->plugins);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		plugin = val;
		if(plugin) {
			apr_dso_unload(plugin);
		}
	}
	apr_hash_clear(loader->plugins);
	return TRUE;
}
Esempio n. 9
0
static apr_status_t kill_dbi(void *p)
{
    apr_status_t rv = APR_SUCCESS;
    apr_hash_index_t *idx;
    char *key;
    ftpd_dbi_config *val;
    apr_ssize_t len;

    for (idx = apr_hash_first((apr_pool_t *) p, ftpd_dbi_config_hash); idx;
            idx = apr_hash_next(idx)) {
        apr_hash_this(idx, (void *) &key, &len, (void *) &val);
        apr_reslist_destroy(val->pool);
    }
    dbi_shutdown();

    return rv;
}
Esempio n. 10
0
Py::Object direntsToObject( apr_hash_t *dirents, SvnPool &pool )
{
    Py::Dict py_dirents_dict;

    for( apr_hash_index_t *hi = apr_hash_first( pool, dirents ); hi; hi = apr_hash_next( hi ) )
    {
        const void *key = NULL;
        void *val = NULL;

        apr_hash_this (hi, &key, NULL, &val);
        const svn_fs_dirent_t *dirent = (const svn_fs_dirent_t *)val;

        py_dirents_dict[ Py::String( (const char *)key ) ] = toEnumValue( dirent->kind );
    }

    return py_dirents_dict;
}
Esempio n. 11
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;
}
Esempio n. 12
0
File: util.c Progetto: demos/Motif
char * get_addhandler_extensions(request_rec *req)
{

    /* these typedefs are copied from mod_mime.c */

    typedef struct {
        apr_hash_t  *extension_mappings;  
        apr_array_header_t *remove_mappings; 
        char *default_language;
        int multimatch;
    } mime_dir_config;

    typedef struct extension_info {
        char *forced_type;                /* Additional AddTyped stuff */
        char *encoding_type;              /* Added with AddEncoding... */
        char *language_type;              /* Added with AddLanguage... */
        char *handler;                    /* Added with AddHandler... */
        char *charset_type;               /* Added with AddCharset... */
        char *input_filters;              /* Added with AddInputFilter... */
        char *output_filters;             /* Added with AddOutputFilter... */
    } extension_info;

    mime_dir_config *mconf;

    apr_hash_index_t *hi;
    void *val;
    void *key;
    extension_info *ei;
    char *result = NULL;

    module *mod_mime = find_module("mod_mime.c");
    mconf = (mime_dir_config *) ap_get_module_config(req->per_dir_config, mod_mime);

    if (mconf->extension_mappings) {

        for (hi = apr_hash_first(req->pool, mconf->extension_mappings); hi; hi = apr_hash_next(hi)) {
            apr_hash_this(hi, (const void **)&key, NULL, &val);
            ei = (extension_info *)val;
            if (ei->handler) 
                if (strcmp("python-program", ei->handler) == 0) 
                    result = apr_pstrcat(req->pool, (char *)key, " ", result, NULL);
        }
    }

    return result;
}
Esempio n. 13
0
void flite_voices_unload(flite_voices_t *voices)
{
	flite_voice_t *voice;
	apr_hash_index_t *it;
	void *val;

	/* unregister voices */
	it = apr_hash_first(voices->pool,voices->table);
	/* walk through the voices and register them */
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		voice = val;
		if(voice && voice->self) {
			voice->unregister_voice(voice->self);
		}
	}
}
Esempio n. 14
0
static void sum_hash(apr_pool_t *p, apr_hash_t *h, int *pcount, int *keySum, int *valSum)
{
    apr_hash_index_t *hi;
    void *val, *key;
    int count = 0;

    *keySum = 0;
    *valSum = 0;
    *pcount = 0;
    for (hi = apr_hash_first(p, h); hi; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, (void*)&key, NULL, &val);
        *valSum += *(int *)val;
        *keySum += *(int *)key;
        count++;
    }
    *pcount=count;
}
Esempio n. 15
0
void UmcFramework::ProcessStopRequest(const char* id)
{
	UmcSession* pSession;
	void* pVal;
	apr_hash_index_t* it = apr_hash_first(m_pPool,m_pSessionTable);
	for(; it; it = apr_hash_next(it)) 
	{
		apr_hash_this(it,NULL,NULL,&pVal);
		pSession = (UmcSession*) pVal;
		if(pSession && strcasecmp(pSession->GetId(),id) == 0)
		{
			/* stop in-progress request */
			pSession->Stop();
			return;
		}
	}
}
Esempio n. 16
0
static void dump_hash(apr_pool_t *p, apr_hash_t *h, char *str) 
{
    apr_hash_index_t *hi;
    char *val, *key;
    apr_ssize_t len;
    int i = 0;

    str[0] = '\0';

    for (hi = apr_hash_first(p, h); hi; hi = apr_hash_next(hi)) {
        apr_hash_this(hi,(void*) &key, &len, (void*) &val);
        apr_snprintf(str, 8196, "%sKey %s (%" APR_SSIZE_T_FMT ") Value %s\n", 
                     str, key, len, val);
        i++;
    }
    apr_snprintf(str, 8196, "%s#entries %d\n", str, i);
}
Esempio n. 17
0
void UmcFramework::DestroyScenarios()
{
	UmcScenario* pScenario;
	void* pVal;
	apr_hash_index_t* it = apr_hash_first(m_pPool,m_pScenarioTable);
	for(; it; it = apr_hash_next(it)) 
	{
		apr_hash_this(it,NULL,NULL,&pVal);
		pScenario = (UmcScenario*) pVal;
		if(pScenario)
		{
			pScenario->Destroy();
			delete pScenario;
		}
	}
	apr_hash_clear(m_pScenarioTable);
}
Esempio n. 18
0
void UmcFramework::ProcessKillRequest(const char* id)
{
	UmcSession* pSession;
	void* pVal;
	apr_hash_index_t* it = apr_hash_first(m_pPool,m_pSessionTable);
	for(; it; it = apr_hash_next(it)) 
	{
		apr_hash_this(it,NULL,NULL,&pVal);
		pSession = (UmcSession*) pVal;
		if(pSession && strcasecmp(pSession->GetId(),id) == 0)
		{
			/* first, terminate session */
			pSession->Terminate();
			return;
		}
	}
}
Esempio n. 19
0
  /**
   * lists properties in @a path no matter whether local or
   * repository
   *
   * @param path
   * @param revision
   * @param recurse
   * @return PropertiesList
   */
  PathPropertiesMapList
  Client::proplist(const Path & path,
                   const Revision & revision,
                   bool recurse)
  {
    Pool pool;
    apr_array_header_t * props;

    svn_error_t * error =
      svn_client_proplist(&props,
                          path.c_str(),
                          revision.revision(),
                          recurse,
                          *m_context,
                          pool);
    if (error != nullptr)
    {
      throw ClientException(error);
    }

    PathPropertiesMapList path_prop_map_list;
    for (int j = 0; j < props->nelts; ++j)
    {
      svn_client_proplist_item_t *item =
        ((svn_client_proplist_item_t **)props->elts)[j];

      PropertiesMap prop_map;

      apr_hash_index_t *hi;
      for (hi = apr_hash_first(pool, item->prop_hash); hi;
           hi = apr_hash_next(hi))
      {
        const void *key;
        void *val;

        apr_hash_this(hi, &key, nullptr, &val);

        prop_map [std::string((const char *)key)] =
          std::string(((const svn_string_t *)val)->data);
      }

      path_prop_map_list.push_back(PathPropertiesMapEntry(item->node_name->data, prop_map));
    }

    return path_prop_map_list;
  }
Esempio n. 20
0
static void mrcp_server_on_start_complete(apt_task_t *task)
{
	apt_consumer_task_t *consumer_task = apt_task_object_get(task);
	mrcp_server_t *server = apt_consumer_task_object_get(consumer_task);
	mrcp_resource_engine_t *resource_engine;
	apr_hash_index_t *it;
	void *val;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Open Resource Engines");
	it = apr_hash_first(server->pool,server->resource_engine_table);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		resource_engine = val;
		if(resource_engine) {
			mrcp_resource_engine_open(resource_engine);
		}
	}
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"On Server Task Start");
}
Esempio n. 21
0
/**
 * 哈希表统计
 */
static int count_hash(apr_hash_t *h)
{
    apr_hash_index_t *hi;
    char *key;
    apr_ssize_t klen;
    void *val;
    int cnt;

    for (cnt = 0, hi = apr_hash_first(NULL, h); hi; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, (void *)&key, &klen, &val);
        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_main_server,
                     "hash: key[%s] klen[%u]",
                     key, (apr_uint32_t)klen);
        cnt++;
    }

    return cnt;
}
Esempio n. 22
0
static mrcp_profile_t* mrcp_server_profile_get_by_agent(mrcp_server_t *server, mrcp_server_session_t *session, mrcp_sig_agent_t *signaling_agent)
{
	mrcp_profile_t *profile;
	apr_hash_index_t *it;
	void *val;
	char *name;
	it = apr_hash_first(session->base.pool,server->profile_table);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,(void*)&name,NULL,&val);
		profile = val;
		if(profile && profile->signaling_agent == signaling_agent) {
			apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Found Profile [%s]",name);
			return profile;
		}
	}
	apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Cannot Find Profile by Agent <%s>",session->base.id.buf);
	return NULL;
}
Esempio n. 23
0
svn_error_t *
svn_hash__clear(apr_hash_t *hash, apr_pool_t *pool)
{
#if APR_VERSION_AT_LEAST(1, 3, 0)
  apr_hash_clear(hash);
#else
  apr_hash_index_t *hi;
  const void *key;
  apr_ssize_t klen;

  for (hi = apr_hash_first(pool, hash); hi; hi = apr_hash_next(hi))
    {
      apr_hash_this(hi, &key, &klen, NULL);
      apr_hash_set(hash, key, klen, NULL);
    }
#endif
  return SVN_NO_ERROR;
}
Esempio n. 24
0
/* Write a summary of the I/O ops to stdout.
 * Use POOL for temporaries.
 */
static void
print_stats(apr_pool_t *pool)
{
  apr_int64_t open_count = 0;
  apr_int64_t seek_count = 0;
  apr_int64_t read_count = 0;
  apr_int64_t read_size = 0;
  apr_int64_t clusters_read = 0;
  apr_int64_t unique_clusters_read = 0;
  apr_int64_t uncached_seek_count = 0;
  apr_int64_t unnecessary_seek_count = 0;
  apr_int64_t empty_read_count = 0;

  apr_hash_index_t *hi;
  for (hi = apr_hash_first(pool, files); hi; hi = apr_hash_next(hi))
    {
      const char *name = NULL;
      apr_ssize_t len = 0;
      file_stats_t *file = NULL;

      apr_hash_this(hi, (const void **)&name, &len, (void**)&file);

      open_count += file->open_count;
      seek_count += file->seek_count;
      read_count += file->read_count;
      read_size += file->read_size;
      clusters_read += file->clusters_read;
      unique_clusters_read += file->unique_clusters_read;
      uncached_seek_count += file->uncached_seek_count;
      unnecessary_seek_count += file->unnecessary_seeks;
      empty_read_count += file->empty_reads;
    }

  printf("%20s files\n", svn__i64toa_sep(apr_hash_count(files), ',', pool));
  printf("%20s files opened\n", svn__i64toa_sep(open_count, ',', pool));
  printf("%20s seeks\n", svn__i64toa_sep(seek_count, ',', pool));
  printf("%20s unnecessary seeks\n", svn__i64toa_sep(unnecessary_seek_count, ',', pool));
  printf("%20s uncached seeks\n", svn__i64toa_sep(uncached_seek_count, ',', pool));
  printf("%20s reads\n", svn__i64toa_sep(read_count, ',', pool));
  printf("%20s empty reads\n", svn__i64toa_sep(empty_read_count, ',', pool));
  printf("%20s unique clusters read\n", svn__i64toa_sep(unique_clusters_read, ',', pool));
  printf("%20s clusters read\n", svn__i64toa_sep(clusters_read, ',', pool));
  printf("%20s bytes read\n", svn__i64toa_sep(read_size, ',', pool));
}
svn_error_t *svn_ra_unlock(svn_ra_session_t *session,
                           apr_hash_t *path_tokens,
                           svn_boolean_t break_lock,
                           svn_ra_lock_callback_t lock_func,
                           void *lock_baton,
                           apr_pool_t *pool)
{
  apr_hash_index_t *hi;

  for (hi = apr_hash_first(pool, path_tokens); hi; hi = apr_hash_next(hi))
    {
      const char *path = svn__apr_hash_index_key(hi);

      SVN_ERR_ASSERT(*path != '/');
    }

  return session->vtable->unlock(session, path_tokens, break_lock,
                                 lock_func, lock_baton, pool);
}
Esempio n. 26
0
static void mrcp_server_on_terminate_request(apt_task_t *task)
{
	apt_consumer_task_t *consumer_task = apt_task_object_get(task);
	mrcp_server_t *server = apt_consumer_task_object_get(consumer_task);

	mrcp_engine_t *engine;
	apr_hash_index_t *it;
	void *val;
	it = mrcp_engine_factory_engine_first(server->engine_factory);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		engine = val;
		if(engine) {
			if(mrcp_engine_virtual_close(engine) == TRUE) {
				apt_task_terminate_request_add(task);
			}
		}
	}
}
Esempio n. 27
0
void _rss_clear_check_table(data_service_fn_t *ds, apr_hash_t *table, apr_pool_t *mpool)
{
    apr_hash_index_t *hi;
    rss_check_entry_t *entry;
    const void *rid;
    apr_ssize_t klen;

    for (hi = apr_hash_first(NULL, table); hi != NULL; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, &rid, &klen, (void **)&entry);
        apr_hash_set(table, rid, klen, NULL);

        ds_inquire_destroy(ds, entry->space);
        free(entry->ds_key);
        free(entry->rid_key);
        free(entry);
    }

    apr_hash_clear(table);
}
Esempio n. 28
0
static apr_status_t stat_cache_cleanup(void *data)
{
    apr_pool_t *p = (apr_pool_t *)getGlobalPool();
    apr_hash_index_t *hi;
    apr_hash_t *statCache = (apr_hash_t*)data;
	char *key;
    apr_ssize_t keylen;
    NXPathCtx_t pathctx;

    for (hi = apr_hash_first(p, statCache); hi; hi = apr_hash_next(hi)) {
        apr_hash_this(hi, (const void**)&key, &keylen, (void**)&pathctx);

        if (pathctx) {
            NXFreePathContext(pathctx);
        }
    }

    return APR_SUCCESS;
}
Esempio n. 29
0
  PathPropertiesMapList
  Client::propget(const char *propName,
                  const Path &path,
                  const Revision &revision,
                  bool recurse)
  {
    Pool pool;

    apr_hash_t *props;
    svn_error_t * error =
      svn_client_propget(&props,
                         propName,
                         path.c_str(),
                         revision.revision(),
                         recurse,
                         *m_context,
                         pool);
    if (error != nullptr)
    {
      throw ClientException(error);
    }

    PathPropertiesMapList path_prop_map_list;


    apr_hash_index_t *hi;
    for (hi = apr_hash_first(pool, props); hi;
         hi = apr_hash_next(hi))
    {
      PropertiesMap prop_map;

      const void *key;
      void *val;

      apr_hash_this(hi, &key, nullptr, &val);

      prop_map [std::string(propName)] = std::string(((const svn_string_t *)val)->data);

      path_prop_map_list.push_back(PathPropertiesMapEntry((const char *)key, prop_map));
    }

    return path_prop_map_list;
  }
Esempio n. 30
0
// select
void int_int_hash_select(int key, int select_all)
{
    if(select_all){
        apr_hash_index_t *hi;
        void *key;
        apr_ssize_t key_len;// 使用int类型出错
        void *val;
        for (hi = apr_hash_first(data_mng.pool, data_mng.int_int_hash); hi; hi = apr_hash_next(hi)) {
            apr_hash_this(hi, &key, (apr_ssize_t *)&key_len, &val);
            fprintf(stderr, "%d --> %d\n", *(int*)key, *(int*)val);
        }
    }else{
        int *val = (int *)apr_hash_get(data_mng.int_int_hash, &key, sizeof(int));
        if(val)
            fprintf(stderr, "%d --> %d\n", key, *(int *)val);
        else
            fprintf(stderr, "can`t find key %d \n", key);
    }
}