当前位置: 首页>>代码示例>>C++>>正文


C++ usrloc_api_t::get_urecord方法代码示例

本文整理汇总了C++中usrloc_api_t::get_urecord方法的典型用法代码示例。如果您正苦于以下问题:C++ usrloc_api_t::get_urecord方法的具体用法?C++ usrloc_api_t::get_urecord怎么用?C++ usrloc_api_t::get_urecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在usrloc_api_t的用法示例。


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

示例1: get_first_child

/* UPDATED + CHECKED
 */
static inline char *run_lookup( struct cpl_interpreter *intr )
{
	unsigned short attr_name;
	unsigned short n;
	unsigned char  clear;
	char *p;
	char *kid;
	char *failure_kid = 0;
	char *success_kid = 0;
	char *notfound_kid = 0;
	int  i;
	time_t      tc;
	urecord_t*  r;
	ucontact_t* contact;

	clear = NO_VAL;

	/* check the params */
	for( i=NR_OF_ATTR(intr->ip),p=ATTR_PTR(intr->ip) ; i>0 ; i-- ) {
		get_basic_attr(p,attr_name,n,intr,script_error);
		switch (attr_name) {
			case CLEAR_ATTR:
				if (n!=YES_VAL && n!=NO_VAL)
					LOG(L_WARN,"WARNING:run_lookup: invalid value (%u) found"
						" for param. CLEAR in LOOKUP node -> using "
						"default (%u)!\n",n,clear);
				else
					clear = n;
				break;
			default:
				LOG(L_ERR,"ERROR:run_lookup: unknown attribute (%d) in "
					"LOOKUP node\n",attr_name);
				goto script_error;
		}
	}

	/* check the kids */
	for( i=0 ; i<NR_OF_KIDS(intr->ip) ; i++ ) {
		kid = intr->ip + KID_OFFSET(intr->ip,i);
		check_overflow_by_ptr( kid+SIMPLE_NODE_SIZE(kid), intr, script_error);
		switch ( NODE_TYPE(kid) ) {
			case SUCCESS_NODE :
				success_kid = kid;
				break;
			case NOTFOUND_NODE:
				notfound_kid = kid;
				break;
			case FAILURE_NODE:
				failure_kid = kid;
				break;
			default:
				LOG(L_ERR,"ERROR:run_lookup: unknown output node type"
					" (%d) for LOOKUP node\n",NODE_TYPE(kid));
				goto script_error;
		}
	}

	kid = failure_kid;

	if (cpl_domain) {
		/* fetch user's contacts via usrloc */
		tc = time(0);
		cpl_ulb.lock_udomain( cpl_domain );
		i = cpl_ulb.get_urecord( cpl_domain, &intr->user, &r);
		if (i < 0) {
			/* failure */
			LOG(L_ERR, "ERROR:run_lookup: Error while querying usrloc\n");
			cpl_ulb.unlock_udomain( cpl_domain );
		} else if (i > 0) {
			/* not found */
			DBG("DBG:cpl-c:run_lookup: '%.*s' Not found in usrloc\n",
				intr->user.len, intr->user.s);
			cpl_ulb.unlock_udomain( cpl_domain );
			kid = notfound_kid;
		} else {
			contact = r->contacts;
			/* skip expired contacts */
			while ((contact) && ((contact->expires <= tc) ||
			(contact->state >= CS_ZOMBIE_N)))
				contact = contact->next;
			/* any contacts left? */
			if (contact) {
				/* clear loc set if requested */
				if (clear)
					empty_location_set( &(intr->loc_set) );
				/* add first location to set */
				DBG("DBG:cpl-c:run_lookup: adding <%.*s>q=%d\n",
					contact->c.len,contact->c.s,(int)(10*contact->q));
				if (add_location( &(intr->loc_set), &contact->c,
				(int)(10*contact->q),
				CPL_LOC_DUPL|((contact->flags & FL_NAT)*CPL_LOC_NATED) )==-1) {
					LOG(L_ERR,"ERROR:cpl-c:run_lookup: unable to add "
						"location to set :-(\n");
					cpl_ulb.unlock_udomain( cpl_domain );
					goto runtime_error;
				}
				/* set the flag for modifing the location set */
				intr->flags |= CPL_LOC_SET_MODIFIED;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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