Skip to content

Commit

Permalink
tsilo: exported functions to kemi framework
Browse files Browse the repository at this point in the history
(cherry picked from commit 19f7d56)
  • Loading branch information
miconda committed Nov 27, 2017
1 parent 75bb317 commit 5ae1d7e
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/modules/tsilo/tsilo.c
Expand Up @@ -32,6 +32,7 @@
#include "../../modules/registrar/api.h"
#include "../../core/dset.h"
#include "../../core/rpc_lookup.h"
#include "../../core/kemi.h"

#include "ts_hash.h"
#include "ts_handlers.h"
Expand Down Expand Up @@ -245,6 +246,7 @@ static int fixup_ts_append(void** param, int param_no)

return 0;
}

/**
*
*/
Expand All @@ -270,6 +272,28 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri)

return rc;
}

/**
*
*/
static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri)
{
str ruri = STR_NULL;
int rc;

if(ts_check_uri(_ruri)<0)
return -1;

if (pkg_str_dup(&ruri, _ruri) < 0)
return -1;

rc = ts_append(_msg, &ruri, _table->s);

pkg_free(ruri.s);

return rc;
}

/**
*
*/
Expand All @@ -291,6 +315,15 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table
return ts_append_to(msg, tindex, tlabel, table, 0);
}

/**
*
*/
static int ki_ts_append_to(sip_msg_t* _msg, int tindex, int tlabel, str *_table)
{
return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel,
_table->s, 0);
}

/**
*
*/
Expand Down Expand Up @@ -320,6 +353,16 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl
return ts_append_to(msg, tindex, tlabel, table, &suri);
}

/**
*
*/
static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel,
str *_table, str *_uri)
{
return ts_append_to(_msg, (unsigned int)tindex, (unsigned int)tlabel,
_table->s, _uri);
}

/**
*
*/
Expand All @@ -328,6 +371,13 @@ static int w_ts_store(struct sip_msg* msg, char *p1, char *p2)
return ts_store(msg, 0);
}

/**
*
*/
static int ki_ts_store(sip_msg_t* msg)
{
return ts_store(msg, 0);
}

/**
*
Expand All @@ -342,3 +392,44 @@ static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2)
}
return ts_store(msg, &suri);
}

/**
*
*/
/* clang-format off */
static sr_kemi_t sr_kemi_tsilo_exports[] = {
{ str_init("tsilo"), str_init("ts_store"),
SR_KEMIP_INT, ki_ts_store,
{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tsilo"), str_init("ts_store_uri"),
SR_KEMIP_INT, ts_store,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tsilo"), str_init("ts_append"),
SR_KEMIP_INT, ki_ts_append,
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tsilo"), str_init("ts_append_to"),
SR_KEMIP_INT, ki_ts_append_to,
{ SR_KEMIP_INT, SR_KEMIP_INT, SR_KEMIP_STR,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
{ str_init("tsilo"), str_init("ts_append_to_uri"),
SR_KEMIP_INT, ki_ts_append_to_uri,
{ SR_KEMIP_INT, SR_KEMIP_INT, SR_KEMIP_STR,
SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
},

{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};
/* clang-format on */

int mod_register(char *path, int *dlflags, void *p1, void *p2)
{
sr_kemi_modules_add(sr_kemi_tsilo_exports);
return 0;
}

0 comments on commit 5ae1d7e

Please sign in to comment.