rem: DBG("XJAB:xj_address_translation:%d: - checking aliases\n", _xj_pid);
context: int xj_address_translation(str *src, str *dst, xj_jalias als, int flag){	char *p, *p0;	int i;		if(!src || !dst || !src->s || !dst->s )		return -1; 		if(!als || !als->jdm || !als->jdm->s || als->jdm->len <= 0)		goto done;		dst->len = 0;	DBG("XJAB:xj_address_translation:%d: - checking aliases\n", 			_xj_pid);	p = src->s;	while(p<(src->s + src->len)	&& *p != '@') 		p++;	if(*p != '@')		goto done;	p++;		/*** checking aliases */	if(als->size > 0)	{		for(i=0; i<als->size; i++)			if(!strncasecmp(p, als->a[i].s, als->a[i].len))			{				if(als->d[i])				{					if(flag & XJ_ADDRTR_A2B)					{						strncpy(dst->s, src->s, src->len);						p0 = dst->s;						while(p0 < dst->s + (p-src->s)) 						{							if(*p0 == als->dlm)								*p0 = als->d[i];							p0++;						}						return 0;					}					if(flag & XJ_ADDRTR_B2A)					{						strncpy(dst->s, src->s, src->len);						p0 = dst->s;						while(p0 < dst->s + (p-src->s)) 						{							if(*p0 == als->d[i])								*p0 = als->dlm;							p0++;						}												return 0;					}				}				goto done;			}	}	DBG("XJAB:xj_address_translation:%d: - doing address corection\n", 			_xj_pid);		if(flag & XJ_ADDRTR_A2B)	{		if(strncasecmp(p, als->jdm->s, als->jdm->len))		{			DBG("XJA:xj_address_translation:%d: - wrong Jabber"				" destination!\n", _xj_pid);			return -1;		}		if(flag & XJ_ADDRTR_CON)		{			DBG("XJAB:xj_address_translation:%d: - that is for"				" Jabber conference\n", _xj_pid);			p0 = p-1;			while(p0 > src->s && *p0 != als->dlm)				p0--;			if(p0 <= src->s)				return -1;			p0--;			while(p0 > src->s && *p0 != als->dlm)				p0--;			if(*p0 != als->dlm)				return -1;			dst->len = p - p0 - 2;			strncpy(dst->s, p0+1, dst->len);			dst->s[dst->len]=0;			p = dst->s;			while(p < (dst->s + dst->len) && *p!=als->dlm)				p++;			if(*p==als->dlm)				*p = '@';			return 0;		}				DBG("XJAB:xj_address_translation:%d: - that is for"			" Jabber network\n", _xj_pid);		dst->len = p - src->s - 1;		strncpy(dst->s, src->s, dst->len);		dst->s[dst->len]=0;		if((p = strchr(dst->s, als->dlm)) != NULL)			*p = '@';		else		{			DBG("XJAB:xj_address_translation:%d: - wrong Jabber"			" destination\n", _xj_pid);			return -1;		}		return 0;	}	if(flag & XJ_ADDRTR_B2A)	{		*(p-1) = als->dlm;		p0 = src->s + src->len;		while(p0 > p)		{			if(*p0 == '/')			{				src->len = p0 - src->s;				*p0 = 0;			}			p0--;		}		strncpy(dst->s, src->s, src->len);		dst->s[src->len] = '@';		dst->s[src->len+1] = 0;		strncat(dst->s, als->jdm->s, als->jdm->len);		dst->len = strlen(dst->s);		return 0;	}done:	dst->s = src->s;	dst->len = src->len;	return 0;	}