Skip to content

Commit

Permalink
[avpops] removed the old is_avp_set() function
Browse files Browse the repository at this point in the history
it can be replaced with NULL testing in script
  • Loading branch information
bogdan-iancu committed Feb 17, 2024
1 parent e84eb59 commit 0972ad7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 195 deletions.
97 changes: 0 additions & 97 deletions modules/avpops/avpops.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ static int fixup_db_avp_dbparam(void** param);
static int fixup_db_url(void ** param);
static int fixup_avp_prefix(void **param);

static int fixup_is_avp_set_p1(void** param);
static int fixup_db_id_sync(void** param);
static int fixup_db_id_async(void** param);
static int fixup_pvname_list(void** param);
Expand All @@ -104,7 +103,6 @@ static int w_dbquery_avps(struct sip_msg* msg, str* query,
static int w_async_dbquery_avps(struct sip_msg* msg, async_ctx *ctx,
str* query, void* dest, void* url);
static int w_shuffle_avps(struct sip_msg* msg, void* param);
static int w_is_avp_set(struct sip_msg* msg, char* param, char *foo);

static const acmd_export_t acmds[] = {
{"avp_db_query", (acmd_function)w_async_dbquery_avps, {
Expand Down Expand Up @@ -153,11 +151,6 @@ static const cmd_export_t cmds[] = {
REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE|LOCAL_ROUTE|
STARTUP_ROUTE|TIMER_ROUTE|EVENT_ROUTE},

{"is_avp_set", (cmd_function)w_is_avp_set, {
{CMD_PARAM_STR|CMD_PARAM_NO_EXPAND, fixup_is_avp_set_p1, fixup_free_pkg}, {0, 0, 0}},
REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE|LOCAL_ROUTE|
STARTUP_ROUTE|TIMER_ROUTE|EVENT_ROUTE},

{0, 0, {{0, 0, 0}}, 0}
};

Expand Down Expand Up @@ -633,89 +626,6 @@ static int fixup_avp_shuffle_name(void** param)
return E_UNSPEC;
}

static int fixup_is_avp_set(void** param, int param_no)
{
struct fis_param *ap = NULL;
char *p;
char *s;
str cpy, *_param = (str *)*param;

if (pkg_nt_str_dup(&cpy, _param) < 0) {
LM_ERR("oom\n");
return -1;
}
s = cpy.s;

if (param_no==1) {
/* attribute name | alias / flags */
if ( (p=strchr(s,'/'))!=0 )
*(p++)=0;

ap = avpops_parse_pvar(s);
if (ap==0)
{
LM_ERR("unable to get pseudo-variable in param\n");
goto err_free;
}

if (ap->u.sval.type!=PVT_AVP)
{
LM_ERR("bad attribute name <%s>\n", (char*)*param);
goto err_free;
}
if(p==0 || *p=='\0')
ap->ops|=AVPOPS_FLAG_ALL;

/* flags */
for( ; p&&*p ; p++ )
{
switch (*p) {
case 'e':
case 'E':
ap->ops|=AVPOPS_FLAG_EMPTY;
break;
case 'n':
case 'N':
if(ap->ops&AVPOPS_FLAG_CASTS)
{
LM_ERR("invalid flag combination <%c> and 's|S'\n",*p);
return E_UNSPEC;
}
ap->ops|=AVPOPS_FLAG_CASTN;
break;
case 's':
case 'S':
if(ap->ops&AVPOPS_FLAG_CASTN)
{
LM_ERR("invalid flag combination <%c> and 'n|N'\n",*p);
goto err_free;
}
ap->ops|=AVPOPS_FLAG_CASTS;
break;
default:
LM_ERR("bad flag <%c>\n",*p);
goto err_free;
}
}

*param=(void*)ap;
}

pkg_free(cpy.s);
return 0;

err_free:
pkg_free(cpy.s);
pkg_free(ap);
return E_UNSPEC;
}

static int fixup_is_avp_set_p1(void** param)
{
return fixup_is_avp_set(param, 1);
}


static int w_dbload_avps(struct sip_msg* msg, void* source,
void* param, void *url, str *prefix)
{
Expand Down Expand Up @@ -773,10 +683,3 @@ static int w_shuffle_avps(struct sip_msg* msg, void* param)
{
return ops_shuffle_avp ( msg, (struct fis_param*)param);
}

static int w_is_avp_set(struct sip_msg* msg, char* param, char *op)
{
return ops_is_avp_set(msg, (struct fis_param*)param);
}


59 changes: 0 additions & 59 deletions modules/avpops/avpops_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,62 +1071,3 @@ int ops_subst(struct sip_msg* msg, struct fis_param** src,
error:
return -1;
}

int ops_is_avp_set(struct sip_msg* msg, struct fis_param *ap)
{
struct usr_avp *avp;
unsigned short name_type;
int avp_name;
int_str avp_value;
int index;
int findex;

/* get avp name */
if(avpops_get_aname(msg, ap, &avp_name, &name_type)!=0)
{
LM_ERR("failed to get AVP name\n");
return -1;
}

/* get avp index */
if(pv_get_spec_index(msg, &ap->u.sval.pvp, &index, &findex)!=0)
{
LM_ERR("failed to get AVP index\n");
return -1;
}

avp=search_first_avp(name_type, avp_name, &avp_value, 0);
if(avp==0)
return -1;

do {
/* last index [-1] or all [*] go here as well */
if(index<=0)
{
if(ap->ops&AVPOPS_FLAG_ALL)
return 1;
if((ap->ops&AVPOPS_FLAG_CASTS && !(avp->flags&AVP_VAL_STR))
||(ap->ops&AVPOPS_FLAG_CASTN && avp->flags&AVP_VAL_STR))
return -1;
if(ap->ops&AVPOPS_FLAG_EMPTY)
{
if(avp->flags&AVP_VAL_STR)
{
if(avp_value.s.s==0 || avp_value.s.len==0)
return 1;
else
return -1;
} else {
if(avp_value.n==0)
return 1;
else
return -1;
}
}
return 1;
}
index--;
} while ((avp=search_first_avp(name_type, avp_name, &avp_value, avp))!=0);

return -1;
}
39 changes: 0 additions & 39 deletions modules/avpops/doc/avpops_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -524,45 +524,6 @@ avp_db_query("DELETE FROM subscriber", , 2);

$avp(id) = 2;
avp_db_query("DELETE FROM subscriber", , $avp(id));
...
</programlisting>
</example>
</section>
<section id="func_is_avp_set" xreflabel="is_avp_set()">
<title>
<function moreinfo="none">is_avp_set(name)
</function>
</title>
<para>
Check if any AVP with <emphasis>name</emphasis> is set.
</para>
<para>Meaning of the parameters is as follows:</para>
<itemizedlist>
<listitem>
<para><emphasis>name (string, no expand)</emphasis> - name of AVP to look for.
Parameter syntax is:
<itemizedlist>
<listitem><para><emphasis>
name = avp_name|avp_alias [ '/' flags ])
</emphasis></para>
<para><emphasis>
flags = ('e'|'s'|'n') - e = empty value; s = value string;
n = value number (int)
</emphasis></para></listitem>
</itemizedlist>
</para>
</listitem>
</itemizedlist>
<para>
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
BRANCH_ROUTE, LOCAL_ROUTE and ONREPLY_ROUTE.
</para>
<example>
<title><function>is_avp_set</function> usage</title>
<programlisting format="linespecific">
...
if(is_avp_set("$avp(foo)"))
xlog("AVP with name 'foo' is set!\n");
...
</programlisting>
</example>
Expand Down

0 comments on commit 0972ad7

Please sign in to comment.