Esempio n. 1
0
/* Iterate through CFG, passing BATON to CALLBACK for every (SECTION, OPTION)
   pair.  Stop if CALLBACK returns TRUE.  Allocate from POOL. */
static void
for_each_option(svn_config_t *cfg, void *baton, apr_pool_t *pool,
                svn_boolean_t callback(void *same_baton,
                                       cfg_section_t *section,
                                       cfg_option_t *option))
{
  apr_hash_index_t *sec_ndx;
  for (sec_ndx = apr_hash_first(pool, cfg->sections);
       sec_ndx != NULL;
       sec_ndx = apr_hash_next(sec_ndx))
    {
      void *sec_ptr;
      cfg_section_t *sec;
      apr_hash_index_t *opt_ndx;

      apr_hash_this(sec_ndx, NULL, NULL, &sec_ptr);
      sec = sec_ptr;

      for (opt_ndx = apr_hash_first(pool, sec->options);
           opt_ndx != NULL;
           opt_ndx = apr_hash_next(opt_ndx))
        {
          void *opt_ptr;
          cfg_option_t *opt;

          apr_hash_this(opt_ndx, NULL, NULL, &opt_ptr);
          opt = opt_ptr;

          if (callback(baton, sec, opt))
            return;
        }
    }
}
Esempio n. 2
0
static void mrcp_server_on_terminate_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_dso_handle_t *plugin;
	apr_hash_index_t *it;
	void *val;
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close 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_close(resource_engine);
		}
	}
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Unload Plugins");
	it=apr_hash_first(server->pool,server->plugin_table);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		plugin = val;
		if(plugin) {
			apr_dso_unload(plugin);
		}
	}
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"On Server Task Terminate");
}
Esempio n. 3
0
svn_error_t *
svn_config_dup(svn_config_t **cfgp,
               const svn_config_t *src,
               apr_pool_t *pool)
{
  apr_hash_index_t *sectidx;
  apr_hash_index_t *optidx;

  *cfgp = 0;
  SVN_ERR(svn_config_create2(cfgp, FALSE, FALSE, pool));

  (*cfgp)->x_values = src->x_values;
  (*cfgp)->section_names_case_sensitive = src->section_names_case_sensitive;
  (*cfgp)->option_names_case_sensitive = src->option_names_case_sensitive;

  for (sectidx = apr_hash_first(pool, src->sections);
       sectidx != NULL;
       sectidx = apr_hash_next(sectidx))
  {
    const void *sectkey;
    void *sectval;
    apr_ssize_t sectkeyLength;
    cfg_section_t * srcsect;
    cfg_section_t * destsec;

    apr_hash_this(sectidx, &sectkey, &sectkeyLength, &sectval);
    srcsect = sectval;

    destsec = svn_config_addsection(*cfgp, srcsect->name);

    for (optidx = apr_hash_first(pool, srcsect->options);
         optidx != NULL;
         optidx = apr_hash_next(optidx))
    {
      const void *optkey;
      void *optval;
      apr_ssize_t optkeyLength;
      cfg_option_t *srcopt;
      cfg_option_t *destopt;

      apr_hash_this(optidx, &optkey, &optkeyLength, &optval);
      srcopt = optval;

      svn_config_create_option(&destopt, srcopt->name, srcopt->value,
                               (*cfgp)->option_names_case_sensitive,
                               pool);

      destopt->value = apr_pstrdup(pool, srcopt->value);
      destopt->x_value = apr_pstrdup(pool, srcopt->x_value);
      destopt->expanded = srcopt->expanded;
      apr_hash_set(destsec->options,
                   apr_pstrdup(pool, (const char*)optkey),
                   optkeyLength, destopt);
    }
  }

  return SVN_NO_ERROR;
}
/**
 * Initialise the encryption as per the current config.
 *
 * Returns APR_SUCCESS if successful.
 */
static apr_status_t crypt_init(request_rec *r,
        const apr_crypto_t *f, apr_crypto_block_key_type_e **cipher,
        session_crypto_dir_conf * dconf)
{
    apr_status_t res;
    apr_hash_t *ciphers;

    res = apr_crypto_get_block_key_types(&ciphers, f);
    if (APR_SUCCESS != res) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, APLOGNO(01823)
                "no ciphers returned by APR. "
                "session encryption not possible");
        return res;
    }

    *cipher = apr_hash_get(ciphers, dconf->cipher, APR_HASH_KEY_STRING);
    if (!(*cipher)) {
        apr_hash_index_t *hi;
        const void *key;
        apr_ssize_t klen;
        int sum = 0;
        int offset = 0;
        char *options = NULL;

        for (hi = apr_hash_first(r->pool, ciphers); hi; hi = apr_hash_next(hi)) {
            apr_hash_this(hi, NULL, &klen, NULL);
            sum += klen + 2;
        }
        for (hi = apr_hash_first(r->pool, ciphers); hi; hi = apr_hash_next(hi)) {
            apr_hash_this(hi, &key, &klen, NULL);
            if (!options) {
                options = apr_palloc(r->pool, sum + 1);
            }
            else {
                options[offset++] = ',';
                options[offset++] = ' ';
            }
            strncpy(options + offset, key, klen);
            offset += klen;
        }
        options[offset] = 0;

        ap_log_rerror(APLOG_MARK, APLOG_ERR, res, r, APLOGNO(01824)
                "cipher '%s' not recognised by crypto driver. "
                "session encryption not possible, options: %s", dconf->cipher, options);

        return APR_EGENERAL;
    }

    return APR_SUCCESS;
}
Esempio n. 5
0
/** Get available profiles */
MRCP_DECLARE(apt_bool_t) mrcp_client_profiles_get(const mrcp_client_t *client, mrcp_profile_t *profiles[], apr_size_t *count, const char *tag)
{
	apr_hash_index_t *it;
	void *val;
	mrcp_profile_t *profile;
	apr_size_t i = 0;
	apt_bool_t status = TRUE;

	if(!profiles || !count) {
		return FALSE;
	}

	for(it = apr_hash_first(client->pool, client->profile_table); it; it = apr_hash_next(it)) {
		apr_hash_this(it, NULL, NULL, &val);
		if(!val) continue;

		if(i >= *count) {
			status = FALSE;
			break;
		}
		
		profile = val;
		if(!tag || (profile->tag && strcasecmp(tag,profile->tag) == 0)) {
			profiles[i] = profile;
			i++;
		}
	}
	*count = i;
	return status;
}
Esempio n. 6
0
/** Close connection */
static apt_bool_t rtsp_server_connection_close(rtsp_server_t *server, rtsp_server_connection_t *rtsp_connection)
{
	apr_size_t remaining_sessions = 0;
	if(!rtsp_connection || !rtsp_connection->sock) {
		return FALSE;
	}
	apt_log(RTSP_LOG_MARK,APT_PRIO_INFO,"Close RTSP Connection %s",rtsp_connection->id);
	apt_poller_task_descriptor_remove(server->task,&rtsp_connection->sock_pfd);
	apr_socket_close(rtsp_connection->sock);
	rtsp_connection->sock = NULL;

	APR_RING_REMOVE(rtsp_connection,link);

	remaining_sessions = apr_hash_count(rtsp_connection->session_table);
	if(remaining_sessions) {
		rtsp_server_session_t *session;
		void *val;
		apr_hash_index_t *it;
		apt_log(RTSP_LOG_MARK,APT_PRIO_NOTICE,"Terminate Remaining RTSP Sessions [%"APR_SIZE_T_FMT"]",
			remaining_sessions);
		it = apr_hash_first(rtsp_connection->pool,rtsp_connection->session_table);
		for(; it; it = apr_hash_next(it)) {
			apr_hash_this(it,NULL,NULL,&val);
			session = val;
			if(session && session->terminating == FALSE) {
				rtsp_server_session_terminate_request(server,session);
			}
		}
	}
	else {
		rtsp_server_connection_destroy(rtsp_connection);
	}
	return TRUE;
}
Esempio n. 7
0
apr_status_t lottery_stone_assembler(
    apr_hash_t * res_subhash,
    apr_pool_t * res_pool)
{
    apr_status_t rv = 0;
    apr_hash_index_t * hi = NULL;
    apr_hash_t * group_hash = NULL;
    apr_int32_t * group_id = NULL;
    apr_ssize_t group_id_len = 0;

    lottery_stone_prob_hash = apr_hash_make(res_pool);

    // 遍历整个哈希表,为每个抽奖组建立快速ROLL值表
    for (hi = apr_hash_first(NULL, res_subhash);
        hi != NULL;
        hi = apr_hash_next(hi)) {
        group_hash = NULL;
        apr_hash_this(hi, 
            (const void **)&group_id,
            &group_id_len,
            (void **)&group_hash);
        if (group_hash != NULL) {
            lottery_stone_group_assembler(
                *group_id,
                group_hash,
                lottery_stone_prob_hash,
                res_pool);
        }
    }

    return APR_SUCCESS;
}
Esempio n. 8
0
static int mapcache_hook_intercept(request_rec *r)
{
  mapcache_server_cfg *sconfig = ap_get_module_config(r->server->module_config, &mapcache_module);
  apr_hash_index_t *entry;

  if (!sconfig->aliases)
    return DECLINED;

  if (r->uri[0] != '/' && r->uri[0])
    return DECLINED;

  entry = apr_hash_first(r->pool,sconfig->aliases);

  /* loop through the entries to find one where the alias matches */
  while (entry) {
    int l = 0;
    const char *alias;
    apr_ssize_t aliaslen;
    mapcache_cfg *c;
    apr_hash_this(entry,(const void**)&alias,&aliaslen,(void**)&c);

    if((l=mapcache_alias_matches(r->uri, c->endpoint))>0) {
      r->handler = "mapcache";
      r->filename = c->configFile;
      r->path_info = &(r->uri[l]);
      return OK;
    }

    entry = apr_hash_next(entry);
  }

  return DECLINED;
}
Esempio n. 9
0
static void mrcp_client_on_start_complete(apt_task_t *task)
{
	apt_consumer_task_t *consumer_task = apt_task_object_get(task);
	mrcp_client_t *client = apt_consumer_task_object_get(consumer_task);
	void *val;
	mrcp_application_t *application;
	mrcp_app_message_t *app_message;
	apr_hash_index_t *it;
	apt_log(APT_PRIO_INFO,"On Client Task Start");
	it = apr_hash_first(client->pool,client->app_table);
	for(; it; it = apr_hash_next(it)) {
		apr_hash_this(it,NULL,NULL,&val);
		application = val;
		if(!application) continue;

		/* raise one-time ready event */			
		app_message = apr_palloc(client->pool,sizeof(mrcp_app_message_t));
		app_message->message_type = MRCP_APP_MESSAGE_TYPE_SIGNALING;
		app_message->sig_message.message_type = MRCP_SIG_MESSAGE_TYPE_EVENT;
		app_message->sig_message.event_id = MRCP_SIG_EVENT_READY;
		app_message->sig_message.status = MRCP_SIG_STATUS_CODE_SUCCESS;
		app_message->application = application;
		application->handler(app_message);
	}
}
	char* cfgm_serializeMessage(apr_pool_t* p, cfgm_wire_message* msg){
		apr_hash_index_t *hi;
		char* name=NULL,*value=NULL;
		char* ret=NULL;
		apr_pool_t* subp=NULL;
		

		if(msg==NULL) return NULL;
		if(apr_pool_create(&subp,p)!=APR_SUCCESS){
			return NULL;	
		}
		ret=apr_pstrcat(subp,"<message type=\"",msg->type,"\"",NULL);
		if(msg->header!=NULL){
			if(msg->header->nodeName!=NULL){
				ret=apr_pstrcat(subp,ret," node=\"",msg->header->nodeName,"\"",NULL);	
			}
			if(msg->header->componentId!=NULL){
				ret=apr_pstrcat(subp,ret," com=\"",msg->header->componentId,"\"",NULL);
			}
			if(msg->header->version!=NULL){
				ret=apr_pstrcat(subp,ret," ver=\"",msg->header->version,"\"",NULL);
			}
		}
		ret=apr_pstrcat(subp,ret,">\n",NULL);
		for (hi = apr_hash_first(subp, msg->params); hi; hi = apr_hash_next(hi)) {
        	apr_hash_this(hi,(const void**)&name, NULL, (void**)&value);
        	ret=apr_pstrcat(subp,ret,"\t<param name=\"",name,"\"><![CDATA[",value,"]]></param>\n",NULL);
        }
        
        //make last concat to non temporary memory pool
		ret=apr_pstrcat(p,ret,"</message>",NULL);
		//destroy temporary memeory pool
		apr_pool_destroy(subp);
		return ret;        		
	}
Esempio n. 11
0
int
svn_config_enumerate(svn_config_t *cfg, const char *section,
                     svn_config_enumerator_t callback, void *baton)
{
  cfg_section_t *sec;
  apr_hash_index_t *opt_ndx;
  int count;
  apr_pool_t *subpool;

  find_option(cfg, section, NULL, &sec);
  if (sec == NULL)
    return 0;

  subpool = svn_pool_create(cfg->pool);
  count = 0;
  for (opt_ndx = apr_hash_first(subpool, sec->options);
       opt_ndx != NULL;
       opt_ndx = apr_hash_next(opt_ndx))
    {
      void *opt_ptr;
      cfg_option_t *opt;
      const char *temp_value;

      apr_hash_this(opt_ndx, NULL, NULL, &opt_ptr);
      opt = opt_ptr;

      ++count;
      make_string_from_option(&temp_value, cfg, sec, opt, NULL);
      if (!callback(opt->name, temp_value, baton))
        break;
    }

  svn_pool_destroy(subpool);
  return count;
}
Esempio n. 12
0
cst_voice* flite_voices_best_match_get(flite_voices_t *voices, mrcp_message_t *message)
{
	cst_voice *voice = NULL;
	const char *voice_name = NULL;
	mrcp_synth_header_t *synth_header = mrcp_resource_header_get(message);
	if(synth_header) {
		if(mrcp_resource_header_property_check(message,SYNTHESIZER_HEADER_VOICE_NAME) == TRUE) {
			voice_name = synth_header->voice_param.name.buf;
		}
	}

	if(voice_name) {
		/* get voice by name */
		flite_voice_t *flite_voice;
		flite_voice = apr_hash_get(voices->table,voice_name,APR_HASH_KEY_STRING);
		if(flite_voice) {
			voice = flite_voice->self;
		}
	}

	if(!voice) {
		/* still no voice found, get the default one */
		flite_voice_t *flite_voice = NULL;
		void *val;
		apr_hash_index_t *it = apr_hash_first(voices->pool,voices->table);
		apr_hash_this(it,NULL,NULL,&val);
		if(val) {
			flite_voice = val;
			voice = flite_voice->self;
		}
	}
	return voice;
}
Esempio n. 13
0
void *svn__apr_hash_index_val(const apr_hash_index_t *hi)
{
  void *val;

  apr_hash_this((apr_hash_index_t *)hi, NULL, NULL, &val);
  return val;
}
Esempio n. 14
0
apr_ssize_t svn__apr_hash_index_klen(const apr_hash_index_t *hi)
{
  apr_ssize_t klen;

  apr_hash_this((apr_hash_index_t *)hi, NULL, &klen, NULL);
  return klen;
}
Esempio n. 15
0
const void *svn__apr_hash_index_key(const apr_hash_index_t *hi)
{
  const void *key;

  apr_hash_this((apr_hash_index_t *)hi, &key, NULL, NULL);
  return key;
}
Esempio n. 16
0
/* Return all rev (and packed rev) files sorted by revision number.
 * Allocate the result in POOL.
 */
static apr_array_header_t *
get_rev_files(apr_pool_t *pool)
{
  apr_hash_index_t *hi;
  apr_array_header_t *result = apr_array_make(pool,
                                              apr_hash_count(files),
                                              sizeof(file_stats_t *));

  /* select all files that have a rev number */
  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);
      if (file->rev_num >= 0)
        APR_ARRAY_PUSH(result, file_stats_t *) = file;
    }

  /* sort them */
  qsort(result->elts, result->nelts, result->elt_size,
        (int (*)(const void *, const void *))compare_files);

  /* return the result */
  return result;
}
Esempio n. 17
0
void nx_config_cache_free()
{
    nx_ctx_t *ctx;
    nx_cc_item_t *item = NULL;
    apr_hash_index_t *idx;
    const char *key;
    apr_ssize_t keylen;

    ctx = nx_ctx_get();

    CHECKERR(apr_thread_mutex_lock(ctx->config_cache_mutex));
    for ( idx = apr_hash_first(NULL, ctx->config_cache);
	  idx != NULL;
	  idx = apr_hash_next(idx) )
    {
	apr_hash_this(idx, (const void **) &key, &keylen, (void **) &item);
	apr_hash_set(ctx->config_cache, item->key, APR_HASH_KEY_STRING, NULL);
	_free_item(item);
    }
    if ( ctx->ccfile != NULL )
    {
	apr_file_close(ctx->ccfile);
	ctx->ccfile = NULL;
    }
    CHECKERR(apr_thread_mutex_unlock(ctx->config_cache_mutex));
}
Esempio n. 18
0
int
svn_config_enumerate_sections(svn_config_t *cfg,
                              svn_config_section_enumerator_t callback,
                              void *baton)
{
  apr_hash_index_t *sec_ndx;
  int count = 0;
  apr_pool_t *subpool = svn_pool_create(cfg->x_pool);

  for (sec_ndx = apr_hash_first(subpool, cfg->sections);
       sec_ndx != NULL;
       sec_ndx = apr_hash_next(sec_ndx))
    {
      void *sec_ptr;
      cfg_section_t *sec;

      apr_hash_this(sec_ndx, NULL, NULL, &sec_ptr);
      sec = sec_ptr;
      ++count;
      if (!callback(sec->name, baton))
        break;
    }

  svn_pool_destroy(subpool);
  return count;
}
Esempio n. 19
0
int
svn_config_enumerate_sections2(svn_config_t *cfg,
                               svn_config_section_enumerator2_t callback,
                               void *baton, apr_pool_t *pool)
{
  apr_hash_index_t *sec_ndx;
  apr_pool_t *iteration_pool;
  int count = 0;

  iteration_pool = svn_pool_create(pool);
  for (sec_ndx = apr_hash_first(pool, cfg->sections);
       sec_ndx != NULL;
       sec_ndx = apr_hash_next(sec_ndx))
    {
      void *sec_ptr;
      cfg_section_t *sec;

      apr_hash_this(sec_ndx, NULL, NULL, &sec_ptr);
      sec = sec_ptr;
      ++count;
      svn_pool_clear(iteration_pool);
      if (!callback(sec->name, baton, iteration_pool))
        break;
    }
  svn_pool_destroy(iteration_pool);

  return count;
}
Esempio n. 20
0
flite_voices_t* flite_voices_load(apr_pool_t *pool)
{
	flite_voice_t *voice;
	apr_hash_index_t *it;
	void *val;

	flite_voices_t *voices = apr_palloc(pool,sizeof(flite_voices_t));
	voices->pool = pool;
	voices->table = apr_hash_make(pool);

	/* init voices */
	flite_voices_init(voices,pool);

	/* register voices */
	it = apr_hash_first(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->register_voice();
		}
	}

	return voices;
}
Esempio n. 21
0
/**
 * Flushes the cache.
 * The cache can still be used as normal after a flush.
 */
void
auth_vas_cache_flush(auth_vas_cache *cache)
{
    apr_hash_index_t *index;

    for (index = apr_hash_first(cache->pool, cache->table);
	    index;
	    index = apr_hash_next(index))
    {
	const void *key;
	apr_ssize_t keylength;
	auth_vas_cache_item *item;

	/* We know the key is a string, but we might as well just keep this
	 * generic and use whatever the hash table says the key length is. */
	apr_hash_this(index, &key, &keylength, (void**)&item);

	/* Remove item from cache */
	apr_hash_set(cache->table, key, keylength, NULL);

	/* Remove the cache's reference to the item */
	if (cache->unref_item_cb)
	    cache->unref_item_cb(item->item);

	free(item);
    }

    cache->youngest = NULL;
    cache->oldest = NULL;

    /* APR 1.2 doesn't allow us to destroy cache->pool.
     * If we do, it tries to destroy it again later and crashes. */
}
Esempio n. 22
0
static void get_name(dav_db *db, dav_prop_name *pname)
{
  if (db->hi == NULL)
    {
      pname->ns = pname->name = NULL;
    }
  else
    {
      const void *name;

      apr_hash_this(db->hi, &name, NULL, NULL);

#define PREFIX_LEN (sizeof(SVN_PROP_PREFIX) - 1)
      if (strncmp(name, SVN_PROP_PREFIX, PREFIX_LEN) == 0)
#undef PREFIX_LEN
        {
          pname->ns = SVN_DAV_PROP_NS_SVN;
          pname->name = (const char *)name + 4;
        }
      else
        {
          pname->ns = SVN_DAV_PROP_NS_CUSTOM;
          pname->name = name;
        }
    }
}
CContentInstance* CContentFieldSvnPresentProps::getInstance(const char* pchPath)
{
	CSvnPool oPool;
	apr_hash_t* pProps = getParent().getPropsForPath(pchPath, oPool);

	if (!pProps)
	{
		return new CContentInstanceEmpty(*this, pchPath);
	}

	svn_stringbuf_t* pBuf = svn_stringbuf_create("", oPool);
	svn_stringbuf_ensure(pBuf, apr_hash_count(pProps) * 16);

	for (apr_hash_index_t* pIdx = apr_hash_first(oPool, pProps); pIdx; pIdx = apr_hash_next(pIdx))
	{
		const char* pchPropName;
		int iSize = 0;

		apr_hash_this(pIdx, reinterpret_cast<const void**>(&pchPropName), &iSize, NULL);
		svn_stringbuf_appendcstr(pBuf, pchPropName);
		svn_stringbuf_appendcstr(pBuf, " ");
	}

	svn_stringbuf_chop(pBuf, 1);
	return new CContentInstanceString(*this, pchPath, pBuf->data, pBuf->len);
}
Esempio n. 24
0
  std::string
  Property::getValue(const char * name)
  {
    Pool pool;
    Revision revision;

    apr_hash_t *props;
    svn_client_propget(&props,
                       name,
                       m_path.c_str(),
                       revision,
                       false, // recurse
                       *m_context,
                       pool);

    apr_hash_index_t *hi;
    hi = apr_hash_first(pool, props);
    if (!hi)
    {
      return "";
    }

    const void *key;
    void *val;
    const svn_string_t *propval;
    apr_hash_this(hi, &key, NULL, &val);
    propval = (const svn_string_t *)val;

    return propval->data;
  }
Esempio n. 25
0
/* ### FIXME:  Consider somehow sharing code with
   ### libsvn_repos/load-fs-vtable.c:prefix_mergeinfo_paths() */
static svn_error_t *
prefix_mergeinfo_paths(svn_string_t **mergeinfo_val,
                       const svn_string_t *mergeinfo_orig,
                       const char *parent_dir,
                       apr_pool_t *pool)
{
  apr_hash_t *prefixed_mergeinfo, *mergeinfo;
  apr_hash_index_t *hi;
  void *rangelist;

  SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_orig->data, pool));
  prefixed_mergeinfo = apr_hash_make(pool);
  for (hi = apr_hash_first(pool, mergeinfo); hi; hi = apr_hash_next(hi))
    {
      const void *key;
      const char *path, *merge_source;

      apr_hash_this(hi, &key, NULL, &rangelist);
      merge_source = svn_relpath_canonicalize(key, pool);

      /* The svn:mergeinfo property syntax demands a repos abspath */
      path = svn_fspath__canonicalize(svn_relpath_join(parent_dir,
                                                       merge_source, pool),
                                      pool);
      svn_hash_sets(prefixed_mergeinfo, path, rangelist);
    }
  return svn_mergeinfo_to_string(mergeinfo_val, prefixed_mergeinfo, pool);
}
Esempio n. 26
0
/* Set *HANDLE to an open filehandle for a temporary file (i.e.,
   automatically deleted when closed), into which the LOCK_TOKENS have
   been written out in the format described in the pre-commit hook
   template.

   LOCK_TOKENS is as returned by svn_fs__access_get_lock_tokens().

   Allocate *HANDLE in POOL, and use POOL for temporary allocations. */
static svn_error_t *
lock_token_content(apr_file_t **handle, apr_hash_t *lock_tokens,
                   apr_pool_t *pool)
{
  svn_stringbuf_t *lock_str = svn_stringbuf_create("LOCK-TOKENS:\n", pool);
  apr_hash_index_t *hi;

  for (hi = apr_hash_first(pool, lock_tokens); hi;
       hi = apr_hash_next(hi))
    {
      void *val;
      const char *path, *token;

      apr_hash_this(hi, (void *)&token, NULL, &val);
      path = val;
      svn_stringbuf_appendstr(lock_str,
        svn_stringbuf_createf(pool, "%s|%s\n",
                              svn_path_uri_autoescape(path, pool),
                              token));
    }

  svn_stringbuf_appendcstr(lock_str, "\n");
  return create_temp_file(handle,
                          svn_stringbuf__morph_into_string(lock_str), pool);
}
Esempio n. 27
0
/**
 * \private \memberof mapcache_cache_sqlite
 */
static void _mapcache_cache_mbtiles_configuration_post_config(mapcache_context *ctx,
    mapcache_cache *cache, mapcache_cfg *cfg)
{
  /* check that only one tileset/grid references this cache, as mbtiles does
   not support multiple tilesets/grids per cache */
  int nrefs = 0;
  apr_hash_index_t *tileseti = apr_hash_first(ctx->pool,cfg->tilesets);
  while(tileseti) {
    mapcache_tileset *tileset;
    const void *key;
    apr_ssize_t keylen;
    apr_hash_this(tileseti,&key,&keylen,(void**)&tileset);
    if(tileset->cache == cache) {
      nrefs++;
      if(nrefs>1) {
        ctx->set_error(ctx,500,"mbtiles cache %s is referenced by more than 1 tileset, which is not supported",cache->name);
        return;
      }
      if(tileset->grid_links->nelts > 1) {
        ctx->set_error(ctx,500,"mbtiles cache %s is referenced by tileset %s which has more than 1 grid, which is not supported",cache->name,tileset->name);
        return;
      }
    }
    tileseti = apr_hash_next(tileseti);
  }

}
Esempio n. 28
0
static svn_error_t *
close_directory(void *dir_baton,
                apr_pool_t *pool)
{
  struct dir_baton *db = dir_baton;
  struct edit_baton *eb = db->edit_baton;
  apr_hash_index_t *hi;
  apr_pool_t *subpool = svn_pool_create(pool);

  for (hi = apr_hash_first(pool, db->deleted_entries);
       hi;
       hi = apr_hash_next(hi))
    {
      const void *key;
      const char *path;
      apr_hash_this(hi, &key, NULL, NULL);
      path = key;

      svn_pool_clear(subpool);

      /* By sending 'svn_node_unknown', the Node-kind: header simply won't
         be written out.  No big deal at all, really.  The loader
         shouldn't care.  */
      SVN_ERR(dump_node(eb, path,
                        svn_node_unknown, svn_node_action_delete,
                        FALSE, NULL, SVN_INVALID_REVNUM, subpool));
    }

  svn_pool_destroy(subpool);
  return SVN_NO_ERROR;
}
Esempio n. 29
0
svn_error_t *
svn_config_copy_config(apr_hash_t **cfg_hash,
                       apr_hash_t *src_hash,
                       apr_pool_t *pool)
{
  apr_hash_index_t *cidx;

  *cfg_hash = apr_hash_make(pool);
  for (cidx = apr_hash_first(pool, src_hash);
       cidx != NULL;
       cidx = apr_hash_next(cidx))
  {
    const void *ckey;
    void *cval;
    apr_ssize_t ckeyLength;
    svn_config_t * srcconfig;
    svn_config_t * destconfig;

    apr_hash_this(cidx, &ckey, &ckeyLength, &cval);
    srcconfig = cval;

    SVN_ERR(svn_config_dup(&destconfig, srcconfig, pool));

    apr_hash_set(*cfg_hash,
                 apr_pstrdup(pool, (const char*)ckey),
                 ckeyLength, destconfig);
  }

  return SVN_NO_ERROR;
}
Esempio n. 30
0
/* RTSP connection disconnected */
static apt_bool_t rtsp_server_on_disconnect(apt_net_server_task_t *task, apt_net_server_connection_t *connection)
{
	apr_size_t remaining_sessions = 0;
	rtsp_server_t *server = apt_net_server_task_object_get(task);
	rtsp_server_connection_t *rtsp_connection = connection->obj;
	apt_list_elem_remove(server->connection_list,rtsp_connection->it);
	rtsp_connection->it = NULL;
	if(apt_list_is_empty(server->connection_list) == TRUE) {
		apr_pool_clear(server->sub_pool);
		server->connection_list = NULL;
	}

	remaining_sessions = apr_hash_count(rtsp_connection->session_table);
	if(remaining_sessions) {
		rtsp_server_session_t *session;
		void *val;
		apr_hash_index_t *it;
		apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Terminate Remaining RTSP Sessions [%d]",remaining_sessions);
		it = apr_hash_first(connection->pool,rtsp_connection->session_table);
		for(; it; it = apr_hash_next(it)) {
			apr_hash_this(it,NULL,NULL,&val);
			session = val;
			if(session && session->terminating == FALSE) {
				rtsp_server_session_terminate_request(server,session);
			}
		}
	}
	else {
		apt_net_server_connection_destroy(connection);
	}
	return TRUE;
}