Discussion:
[SR-Users] Comparing strings
Alex Balashov
2014-07-11 21:30:41 UTC
Permalink
Is there any compelling reason to use textops' cmp_str()/cmp_istr()
versus the 'eq' operator (or the implicit string comparison in "a" == "b")?
--
Alex Balashov - Principal
Evariste Systems LLC
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/

Please be kind to the English language:

http://www.entrepreneur.com/article/232906
AliReza Khoshgoftar Monfared
2014-07-11 21:50:28 UTC
Permalink
Here is the definition for cmp_str(), for example:

static int cmp_str_f(struct sip_msg *msg, char *str1, char *str2 )
{
str s1;
str s2;
int ret;
if(fixup_get_svalue(msg, (gparam_p)str1, &s1)!=0)
{
LM_ERR("cannot get first parameter\n");
return -8;
}
if(fixup_get_svalue(msg, (gparam_p)str2, &s2)!=0)
{
LM_ERR("cannot get second parameter\n");
return -8;
}
ret = cmp_str(&s1, &s2);
if(ret==0)
return 1;
if(ret>0)
return -1;
return -2;
}
i guess rather than the ability to use error codes, and the fact that one
function does case sensitive and the other case insensitive, there's no
tangible difference with ==
str
Loading...