Skip to content

Commit

Permalink
dialog: reworked kemi export for dlg_get_var()
Browse files Browse the repository at this point in the history
- return SR_KEMIP_XVAL type
  • Loading branch information
miconda committed May 20, 2022
1 parent 3efc0c1 commit 7c347e2
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ static int fixup_dlg_bridge(void** param, int param_no)
return 0;
}

static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
{
dlg_cell_t *dlg = NULL;
unsigned int dir = 0;
Expand All @@ -1538,6 +1538,30 @@ static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
return val;
}

/**
*
*/
static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};

static sr_kemi_xval_t *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
{
str *val = NULL;

memset(&_sr_kemi_dialog_xval, 0, sizeof(sr_kemi_xval_t));

val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
if(!val) {
sr_kemi_xval_null(&_sr_kemi_dialog_xval, SR_KEMI_XVAL_NULL_NONE);
return &_sr_kemi_dialog_xval;
}

_sr_kemi_dialog_xval.vtype = SR_KEMIP_STR;
_sr_kemi_dialog_xval.v.s = *pval;

return &_sr_kemi_dialog_xval;

}

static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key, char *pv)
{
str sc = STR_NULL;
Expand Down Expand Up @@ -1582,7 +1606,7 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
return -1;
}
dst_pv = (pv_spec_t *)pv;
val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
if(val) {
memset(&dst_val, 0, sizeof(pv_value_t));
dst_val.flags |= PV_VAL_STR;
Expand Down Expand Up @@ -2155,11 +2179,6 @@ static int ki_dlg_var_sets(sip_msg_t *msg, str *name, str *val)
return (ret==0)?1:ret;
}

/**
*
*/
static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};

/**
*
*/
Expand Down Expand Up @@ -2289,7 +2308,7 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("dialog"), str_init("dlg_get_var"),
SR_KEMIP_STR, ki_dlg_get_var,
SR_KEMIP_XVAL, ki_dlg_get_var,
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
Expand Down

0 comments on commit 7c347e2

Please sign in to comment.