• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ core_hash函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中core_hash函数的典型用法代码示例。如果您正苦于以下问题:C++ core_hash函数的具体用法?C++ core_hash怎么用?C++ core_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了core_hash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: update_subscriber

int update_subscriber(impurecord_t* urec, reg_subscriber** _reg_subscriber, int *expires, int *local_cseq, int *version) {

    subs_t subs;
    unsigned int hash_code = 0;
    reg_subscriber *rs = *_reg_subscriber;
    if (expires) {
        rs->expires = *expires;
    } else {
        LM_DBG("No expires so will not update subscriber expires.\n");
    }
    if (local_cseq) {
        rs->local_cseq = *local_cseq;
    } else {
        LM_DBG("No local cseq so will not update subscriber local cseq.\n");
    }
    if (version) {
        rs->version = *version;
    } else {
        LM_DBG("No version so will not update subscriber version.\n");
    }
    
    /*This lets us get presentity URI info for subsequent SUBSCRIBEs that don't have presentity URI as req URI*/
    get_act_time();
    
    subs.pres_uri = rs->presentity_uri;
    subs.from_tag = rs->from_tag;
    subs.to_tag = rs->to_tag;
    subs.callid = rs->call_id;
    subs.expires = rs->expires - act_time;
    subs.contact = rs->watcher_contact;
    
    hash_code = core_hash(&subs.callid, &subs.to_tag, sub_dialog_hash_size);
    
    LM_DBG("Updating sub dialog hash info with call_id: <%.*s> and ttag <%.*s> amd ftag <%.*s> and hash code <%d>", subs.callid.len, subs.callid.s, subs.to_tag.len, subs.to_tag.s, subs.from_tag.len,  subs.from_tag.s, hash_code);
    
    if (pres_update_shtable(sub_dialog_table, hash_code, &subs, REMOTE_TYPE))
    {
	LM_ERR("while updating new subscription\n");
	return 0;
    }
        
    /*DB?*/
    if (db_mode == WRITE_THROUGH && db_insert_subscriber(urec, rs) != 0) {
	    LM_ERR("Failed to insert subscriber into DB subscriber [%.*s] to IMPU [%.*s]...continuing but db will be out of sync!\n", 
		    rs->presentity_uri.len, rs->presentity_uri.s, urec->public_identity.len, urec->public_identity.s);
    }

    return 1;
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:49,代码来源:subscribe.c


示例2: get_hash_index_and_shared_line

int get_hash_index_and_shared_line(struct sip_msg* msg, unsigned int *hash_index, str **shared_line)
{
	if(shared_line_spec_param.s)
	{
		memset(&shared_line_tok, 0, sizeof(pv_value_t));
		if(pv_get_spec_value(msg, &shared_line_spec, &shared_line_tok) < 0)
		{
			LM_ERR("Failed to get shared_line value\n");
			return -1;
		}
		//LM_DBG("got shared_line_spec_param flags [%d]\n", shared_line_tok.flags);
		if(!(shared_line_tok.flags&PV_VAL_INT) && (shared_line_tok.flags&PV_VAL_STR))
		{
			*shared_line = &shared_line_tok.rs;
			*hash_index = core_hash(&shared_line_tok.rs, NULL, b2b_sca_hsize);
			//LM_DBG("got hash_index=[%d] for PV_SPEC user [%.*s]\n", *hash_index,
			//	shared_line_tok.rs.len, shared_line_tok.rs.s);
			return 0;
		}
		else
		{
			LM_ERR("No shared line PV [%.*s] defined\n",
				shared_line_spec_param.len, shared_line_spec_param.s);
			return -1;
		}
	}
	else
	{
		LM_ERR("No shared line PV defined\n");
		return -1;
	}

	/* If the shared_line_spec_param is not set, use the username from original RURI */
	/*
	parse_orig_ruri(msg);
	if (msg->parsed_orig_ruri_ok &&
		msg->parsed_orig_ruri.user.s && msg->parsed_orig_ruri.user.len) {
		*shared_line = &msg->parsed_orig_ruri.user;
		*hash_index = core_hash(&msg->parsed_orig_ruri.user, NULL, b2b_sca_hsize);
		//LM_DBG("got hash_index=[%d] for RURI user [%.*s]\n", *hash_index,
		//		msg->parsed_orig_ruri.user.len, msg->parsed_orig_ruri.user.s);
		return 0;
	} else {
		LM_ERR("msg->parsed_orig_ruri_ok is NULL\n");
	}
	*/

	return -1;
}
开发者ID:NoamRom89,项目名称:opensips,代码行数:49,代码来源:b2b_sca.c


示例3: dbt_release_table

int dbt_release_table(dbt_cache_p _dc, const str *_s)
{
	int hash;
	int hashidx;

	if(!_dbt_cachetbl || !_dc || !_s || !_s->s || _s->len<=0)
		return -1;

	hash = core_hash(&_dc->name, _s, DBT_CACHETBL_SIZE);
	hashidx = hash % DBT_CACHETBL_SIZE;

	lock_release(&_dbt_cachetbl[hashidx].sem);

	return 0;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:15,代码来源:dbt_lib.c


示例4: insert_phtable

pres_entry_t* insert_phtable(str* pres_uri, int event, str* etag, char* sphere, int init_turn)
{
	unsigned int hash_code;
	pres_entry_t* p= NULL;
	int size;

	size= sizeof(pres_entry_t)+ pres_uri->len;
	p= (pres_entry_t*)shm_malloc(size);
	if(p== NULL)
	{
		ERR_MEM(SHARE_MEM);
	}
	memset(p, 0, size);

	size= sizeof(pres_entry_t);
	p->pres_uri.s= (char*)p+ size;
	memcpy(p->pres_uri.s, pres_uri->s, pres_uri->len);
	p->pres_uri.len= pres_uri->len;

	if(sphere)
	{
		p->sphere= (char*)shm_malloc(strlen(sphere)+ 1);
		if(p->sphere== NULL)
		{
			ERR_MEM(SHARE_MEM);
		}
		strcpy(p->sphere, sphere);
	}
	p->event= event;
	update_pres_etag(p, etag);

	hash_code= core_hash(pres_uri, NULL, phtable_size);
	lock_get(&pres_htable[hash_code].lock);

	p->next= pres_htable[hash_code].entries->next;
	pres_htable[hash_code].entries->next= p;

	p->last_turn = init_turn;

	lock_release(&pres_htable[hash_code].lock);

	return p;

error:
	if(p)
		shm_free(p);
	return NULL;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:48,代码来源:hash.c


示例5: release_dynamic_lock

int release_dynamic_lock(struct sip_msg *msg, char *string)
{
	str ret;
	int hash;

	if (fixup_get_svalue(msg, (gparam_p)string, &ret) != 0) {
		LM_ERR("Get string from fixup param failed!\n");
		return -1;
	}

	hash = (int)core_hash(&ret, NULL, lock_pool_size);

	lock_set_release(dynamic_locks, hash);
	LM_DBG("Released dynamic lock----- %d\n", hash);

	return 1;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:17,代码来源:script_locks.c


示例6: lcache_htable_insert

int lcache_htable_insert(cachedb_con *con,str* attr, str* value, int expires)
{
	lcache_entry_t* me, *it;
	int hash_code;
	int size;
	struct timeval start;

	size= sizeof(lcache_entry_t) + attr->len + value->len;

	me = (lcache_entry_t*)shm_malloc(size);
	if(me == NULL)
	{
		LM_ERR("no more shared memory\n");
		return -1;
	}
	memset(me, 0, size);

	start_expire_timer(start,local_exec_threshold);

	me->attr.s = (char*)me + (sizeof(lcache_entry_t));
	memcpy(me->attr.s, attr->s, attr->len);
	me->attr.len = attr->len;

	me->value.s = (char*)me + (sizeof(lcache_entry_t)) + attr->len;
	memcpy(me->value.s, value->s, value->len);
	me->value.len = value->len;
	if( expires != 0)
		me->expires = get_ticks() + expires;

	hash_code= core_hash( attr, 0, cache_htable_size);
	lock_get(&cache_htable[hash_code].lock);

	it = cache_htable[hash_code].entries;

	/* if a previous record for the same attr delete it */
	lcache_htable_remove_safe( *attr, &it);

	me->next = it;
	cache_htable[hash_code].entries = me;

	lock_release(&cache_htable[hash_code].lock);

	stop_expire_timer(start,local_exec_threshold,
	"cachedb_local insert",attr->s,attr->len,0);
	return 1;
}
开发者ID:leedm777,项目名称:opensips,代码行数:46,代码来源:hash.c


示例7: delete_phtable_query

int delete_phtable_query(str *pres_uri, int event, str* etag)
{
	pres_entry_t* p;
	unsigned int hash_code;

	hash_code = core_hash(pres_uri, 0, phtable_size);
	lock_get(&pres_htable[hash_code].lock);
	p = search_phtable_etag(pres_uri, event, etag, hash_code);
	if(p == NULL)
	{
		LM_ERR("Record not found [%.*s]\n", etag->len, etag->s);
		lock_release(&pres_htable[hash_code].lock);
		return -1;
	}
	delete_phtable(p, hash_code);
	lock_release(&pres_htable[hash_code].lock);
	return 0;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:18,代码来源:hash.c


示例8: internal_rpc_print_single_dlg

/*!
 * \brief Helper function that outputs a dialog via the RPC interface
 * \see rpc_print_dlgs
 * \param rpc RPC node that should be filled
 * \param c RPC void pointer
 * \param with_context if 1 then the dialog context will be also printed
 */
static void internal_rpc_print_single_dlg(rpc_t *rpc, void *c, int with_context) {
	str callid, from_tag;
	dlg_entry_t *d_entry;
	dlg_cell_t *dlg;
	unsigned int h_entry;

	if (rpc->scan(c, ".S.S", &callid, &from_tag) < 2) return;

	h_entry = core_hash( &callid, 0, d_table->size);
	d_entry = &(d_table->entries[h_entry]);
	dlg_lock( d_table, d_entry);
	for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
		if (match_downstream_dialog( dlg, &callid, &from_tag)==1) {
			internal_rpc_print_dlg(rpc, c, dlg, with_context);
		}
	}
	dlg_unlock( d_table, d_entry);
}
开发者ID:kingsumos,项目名称:kamailio,代码行数:25,代码来源:dialog.c


示例9: delete_phtable

int delete_phtable(str* pres_uri, int event)
{
	unsigned int hash_code;
	pres_entry_t* p= NULL, *prev_p= NULL;

	hash_code= core_hash(pres_uri, NULL, phtable_size);

	lock_get(&pres_htable[hash_code].lock);
	
	p= search_phtable(pres_uri, event, hash_code);
	if(p== NULL)
	{
		LM_DBG("record not found\n");
		lock_release(&pres_htable[hash_code].lock);
		return 0;
	}
	
	p->publ_count--;
	if(p->publ_count== 0)
	{
		/* delete record */	
		prev_p= pres_htable[hash_code].entries;
		while(prev_p->next)
		{
			if(prev_p->next== p)
				break;
			prev_p= prev_p->next;
		}
		if(prev_p->next== NULL)
		{
			LM_ERR("record not found\n");
			lock_release(&pres_htable[hash_code].lock);
			return -1;
		}
		prev_p->next= p->next;
		if(p->sphere)
			shm_free(p->sphere);

		shm_free(p);
	}
	lock_release(&pres_htable[hash_code].lock);

	return 0;	
}
开发者ID:AndreyRybkin,项目名称:kamailio,代码行数:44,代码来源:hash.c


示例10: lcache_htable_remove

int lcache_htable_remove(cachedb_con *con,str* attr)
{
	int hash_code;
	struct timeval start;

	start_expire_timer(start,local_exec_threshold);

	hash_code= core_hash( attr, 0, cache_htable_size);
	lock_get(&cache_htable[hash_code].lock);

	lcache_htable_remove_safe( *attr, &cache_htable[hash_code].entries);

	lock_release(&cache_htable[hash_code].lock);

	stop_expire_timer(start,local_exec_threshold,
	"cachedb_local remove",attr->s,attr->len,0);

	return 0;
}
开发者ID:leedm777,项目名称:opensips,代码行数:19,代码来源:hash.c


示例11: insert_htable

unsigned long insert_htable(ua_pres_t* presentity)
{
	unsigned int hash_code;
	str* s1;
	unsigned long pres_id;
	ua_pres_t* p;

	if(presentity->to_uri.s)
		s1 = &presentity->to_uri;
	else
		s1 = presentity->pres_uri;

	LM_DBG("to_uri= %.*s, watcher_uri= %.*s\n", s1->len, s1->s,
		(presentity->watcher_uri?presentity->watcher_uri->len:0),
		(presentity->watcher_uri?presentity->watcher_uri->s:0));

	hash_code= core_hash(s1, presentity->watcher_uri, 
			HASH_SIZE);
	presentity->hash_index = hash_code;
	LM_DBG("hash_code = %d\n", hash_code);

	lock_get(&HashT->p_records[hash_code].lock);

	p= HashT->p_records[hash_code].entity;

	presentity->db_flag= INSERTDB_FLAG;
	presentity->next= p->next;
	if(p->next)
	{
		presentity->local_index = p->next->local_index + 1;
	}
	else
		presentity->local_index = 0;

	p->next= presentity;

	pres_id = PRES_HASH_ID(presentity);

	lock_release(&HashT->p_records[hash_code].lock);

	return pres_id;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:42,代码来源:hash.c


示例12: dbt_db_del_table

int dbt_db_del_table(dbt_cache_p _dc, const str *_s, int sync)
{
	dbt_table_p _tbc = NULL;
	int hash;
	int hashidx;
	if(!_dbt_cachetbl || !_dc || !_s || !_s->s || _s->len<=0)
		return -1;

	hash = core_hash(&_dc->name, _s, DBT_CACHETBL_SIZE);
	hashidx = hash % DBT_CACHETBL_SIZE;

	if(sync)
		lock_get(&_dbt_cachetbl[hashidx].sem);

	_tbc = _dbt_cachetbl[hashidx].dtp;

	while(_tbc)
	{
		if(_tbc->hash==hash && _tbc->dbname.len == _dc->name.len
				&& _tbc->name.len == _s->len
				&& !strncasecmp(_tbc->dbname.s, _dc->name.s, _dc->name.len)
				&& !strncasecmp(_tbc->name.s, _s->s, _s->len))
		{
			if(_tbc->prev)
				(_tbc->prev)->next = _tbc->next;
			else
				_dbt_cachetbl[hashidx].dtp = _tbc->next;

			if(_tbc->next)
				(_tbc->next)->prev = _tbc->prev;
			break;
		}
		_tbc = _tbc->next;
	}

	if(sync)
		lock_release(&_dbt_cachetbl[hashidx].sem);

	dbt_table_free(_tbc);

	return 0;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:42,代码来源:dbt_lib.c


示例13: get_ts_urecord

/*
 * Obtain a urecord pointer if the urecord exists in the table
 */
int get_ts_urecord(str* ruri, struct ts_urecord** _r)
{
	int sl, i, rurihash;
	ts_urecord_t* r;

	rurihash = core_hash(ruri, 0, 0);
	sl = rurihash&(t_table->size-1);
	r = t_table->entries[sl].first;

	for(i = 0; r!=NULL && i < t_table->entries[sl].n; i++) {
		if((r->rurihash==rurihash) && (r->ruri.len==ruri->len)
				&& !memcmp(r->ruri.s,ruri->s,ruri->len)){
			*_r = r;
			return 0;
		}
		r = r->next;
	}

	return 1;   /* Nothing found */
}
开发者ID:DileepNunna,项目名称:kamailio,代码行数:23,代码来源:ts_hash.c


示例14: get_pcontact

int get_pcontact(udomain_t* _d, str* _contact, struct pcontact** _c) {
	unsigned int sl, i, aorhash;
	struct pcontact* c;

	/* search in cache */
	aorhash = core_hash(_contact, 0, 0);
	sl = aorhash & (_d->size - 1);
	c = _d->table[sl].first;

	for (i = 0; i < _d->table[sl].n; i++) {
		if ((c->aorhash == aorhash) && (c->aor.len == _contact->len)
				&& !memcmp(c->aor.s, _contact->s, _contact->len)) {
			*_c = c;
			return 0;
		}

		c = c->next;
	}
	return 1; /* Nothing found */
}
开发者ID:aallamaa,项目名称:kamailio,代码行数:20,代码来源:udomain.c


示例15: get_impurecord

/*!
 * \brief Obtain a impurecord pointer if the impurecord exists in domain
 * \param _d domain to search the record
 * \param _aor address of record
 * \param _r new created record
 * \return 0 if a record was found, 1 if nothing could be found
 */
int get_impurecord(udomain_t* _d, str* public_identity, struct impurecord** _r) {
    unsigned int sl, i, aorhash;
    impurecord_t* r;

    /* search in cache */
    aorhash = core_hash(public_identity, 0, 0);
    sl = aorhash & (_d->size - 1);
    r = _d->table[sl].first;

    for (i = 0; i < _d->table[sl].n; i++) {
	if ((r->aorhash == aorhash) && (r->public_identity.len == public_identity->len)
		&& !memcmp(r->public_identity.s, public_identity->s, public_identity->len)) {
	    *_r = r;
	    return 0;
	}

	r = r->next;
    }
    return 1; /* Nothing found */
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:27,代码来源:udomain.c


示例16: convert_temporary_dialog

int convert_temporary_dialog(ua_pres_t *dialog)
{
	ua_pres_t *temp_dialog;
	unsigned int hash_code;

	hash_code= core_hash(dialog->pres_uri,dialog->watcher_uri, HASH_SIZE); 
	lock_get(&HashT->p_records[hash_code].lock);

	temp_dialog = get_temporary_dialog(dialog, hash_code);
	if (temp_dialog)
		delete_htable(temp_dialog, hash_code);
	else
		return -1;

	insert_htable(dialog, hash_code);

	lock_release(&HashT->p_records[hash_code].lock);

	return 1;
}
开发者ID:mattvv,项目名称:kamailio,代码行数:20,代码来源:hash.c


示例17: notif_cback_func

/* Treat Notify reply callback */
void notif_cback_func(struct cell *t, int cb_type, struct tmcb_params *params){
	int code = params->code;
	struct sm_subscriber* params_notify = (struct sm_subscriber*)(*params->param);
	unsigned int hash_code;

	LM_DBG("TREAT NOTIFY REPLY \n");
	LM_DBG("CODE: %d \n ", code);

	// verify if response is OK
	if (code >= 200 && code < 300){
		// response OK(2XX)
		if (params_notify->expires > 0){
			LM_DBG("REPLY OK timeout %d \n", params_notify->timeout);
			LM_DBG("REPLY OK expires %d \n", params_notify->expires);
			time_t rawtime;

			time(&rawtime);
			int time_now = (int)rawtime;
			LM_DBG("TIME : %d \n", (int)rawtime );

			// update timeout
			params_notify->timeout =  params_notify->expires + time_now;
			LM_DBG("TIMEOUT_NOTIFY: %d \n ", params_notify->timeout);
			return;
		}
		if (params_notify->dlg_id->status == TERMINATED){

			// delete subs_htable
			hash_code= core_hash(&params_notify->call_dlg_id->callid, 0, subst_size);
			LM_DBG("********************************************HASH_CODE%d\n", hash_code);
			LM_DBG("********************************************CALLID_STR%.*s\n", params_notify->call_dlg_id->callid.len, params_notify->call_dlg_id->callid.s);

			delete_shtable(subs_htable, hash_code, params_notify);
		}

	}else{
		// Response NOK
		LM_ERR("reply to NOTIFY NOK\n");
	}
	return;
}
开发者ID:OpenSIPS,项目名称:opensips,代码行数:42,代码来源:notifier_emergency.c


示例18: new_ts_urecord

/*!
 * \brief Create and initialize new record structure
 * \param ruri request uri
 * \param _r pointer to the new record
 * \return 0 on success, negative on failure
 */
int new_ts_urecord(str* ruri, ts_urecord_t** _r)
{
	*_r = (ts_urecord_t*)shm_malloc(sizeof(ts_urecord_t));
	if (*_r == 0) {
		LM_ERR("no more share memory\n");
		return -1;
	}
	memset(*_r, 0, sizeof(ts_urecord_t));

	(*_r)->ruri.s = (char*)shm_malloc(ruri->len);
	if ((*_r)->ruri.s == 0) {
		LM_ERR("no more share memory\n");
		shm_free(*_r);
		*_r = 0;
		return -2;
	}
	memcpy((*_r)->ruri.s, ruri->s, ruri->len);
	(*_r)->ruri.len = ruri->len;
	(*_r)->rurihash = core_hash(ruri, 0, 0);
	return 0;
}
开发者ID:DileepNunna,项目名称:kamailio,代码行数:27,代码来源:ts_hash.c


示例19: get_dynamic_lock

int get_dynamic_lock(struct sip_msg *msg, char *string)
{
	str ret;
	int hash;

	if (((gparam_p)string)->type == GPARAM_TYPE_STR) {
		LM_INFO("Static string given! get_static_lock() function is better!\n");
	}

	if (fixup_get_svalue(msg, (gparam_p)string, &ret) != 0) {
		LM_ERR("Get string from fixup param failed!\n");
		return -1;
	}

	hash = (int)core_hash(&ret, NULL, lock_pool_size);

	LM_DBG("Getting dynamic lock----- %d\n", hash);
	lock_set_get(dynamic_locks, hash);
	LM_DBG("Got dynamic lock----- %d\n", hash);

	return 1;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:22,代码来源:script_locks.c


示例20: is_dialog

int is_dialog(ua_pres_t* dialog)
{
	int ret_code= 0;
	unsigned int hash_code;
	str* s1;

	if(dialog->to_uri.s)
		s1 = &dialog->to_uri;
	else
		s1 = dialog->pres_uri;

	hash_code= core_hash(s1, dialog->watcher_uri, HASH_SIZE);
	lock_get(&HashT->p_records[hash_code].lock);

	if(get_dialog(dialog, hash_code)== NULL)
		ret_code= -1;
	else
		ret_code= 0;
	lock_release(&HashT->p_records[hash_code].lock);
	
	return ret_code;

}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:23,代码来源:hash.c



注:本文中的core_hash函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ core_readl函数代码示例发布时间:2022-05-30
下一篇:
C++ core_get函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap