Skip to content

Commit

Permalink
nosip: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent d8ca55e commit 28049ec
Showing 1 changed file with 42 additions and 56 deletions.
98 changes: 42 additions & 56 deletions src/modules/nosip/nosip_mod.c
Expand Up @@ -42,46 +42,38 @@ MODULE_VERSION
static int nosip_rcv_msg(sr_event_param_t *evp);
static int mod_init(void);

static int pv_get_nosip(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);
static int pv_get_nosip(
struct sip_msg *msg, pv_param_t *param, pv_value_t *res);

static int nosip_route_no=-1;
static char* nosip_msg_match = NULL;
static int nosip_route_no = -1;
static char *nosip_msg_match = NULL;
static regex_t nosip_msg_match_regexp;
static char* nosip_msg_skip = NULL;
static char *nosip_msg_skip = NULL;
static regex_t nosip_msg_skip_regexp;


static cmd_export_t cmds[] = {
{0, 0, 0, 0, 0}
};
static cmd_export_t cmds[] = {{0, 0, 0, 0, 0}};

static pv_export_t mod_pvs[] = {
{{"nosip", (sizeof("nosip")-1)}, /* */
PVT_OTHER, pv_get_nosip, 0,
0, 0, 0, 0},
static pv_export_t mod_pvs[] = {{{"nosip", (sizeof("nosip") - 1)}, /* */
PVT_OTHER, pv_get_nosip, 0, 0, 0, 0, 0},

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

static param_export_t params[] = {
{"msg_match", STR_PARAM, &nosip_msg_match},
{"msg_skip", STR_PARAM, &nosip_msg_skip},
{0, 0, 0}
};
static param_export_t params[] = {{"msg_match", STR_PARAM, &nosip_msg_match},
{"msg_skip", STR_PARAM, &nosip_msg_skip}, {0, 0, 0}};

/** module exports */
struct module_exports exports = {
"nosip", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* cmd (cfg function) exports */
params, /* param exports */
0, /* RPC method exports */
mod_pvs, /* pseudo-variables exports */
0, /* response handling function */
mod_init, /* module init function */
0, /* per-child init function */
0 /* module destroy function */
"nosip", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* cmd (cfg function) exports */
params, /* param exports */
0, /* RPC method exports */
mod_pvs, /* pseudo-variables exports */
0, /* response handling function */
mod_init, /* module init function */
0, /* per-child init function */
0 /* module destroy function */
};

/**
Expand All @@ -91,34 +83,31 @@ static int mod_init(void)
{
int route_no;

route_no=route_get(&event_rt, "nosip:msg");
if (route_no==-1)
{
route_no = route_get(&event_rt, "nosip:msg");
if(route_no == -1) {
LM_ERR("failed to find event_route[nosip:msg]\n");
return -1;
}
if (event_rt.rlist[route_no]==0)
{
if(event_rt.rlist[route_no] == 0) {
LM_ERR("event_route[nosip:msg] is empty\n");
return -1;
}
nosip_route_no=route_no;
nosip_route_no = route_no;

/* register non-sip hooks */
sr_event_register_cb(SREV_RCV_NOSIP, nosip_rcv_msg);

if(nosip_msg_match!=NULL)
{
if(nosip_msg_match != NULL) {
memset(&nosip_msg_match_regexp, 0, sizeof(regex_t));
if (regcomp(&nosip_msg_match_regexp, nosip_msg_match, REG_EXTENDED)!=0) {
if(regcomp(&nosip_msg_match_regexp, nosip_msg_match, REG_EXTENDED)
!= 0) {
LM_ERR("bad match re %s\n", nosip_msg_match);
return E_BAD_RE;
}
}
if(nosip_msg_skip!=NULL)
{
if(nosip_msg_skip != NULL) {
memset(&nosip_msg_skip_regexp, 0, sizeof(regex_t));
if (regcomp(&nosip_msg_skip_regexp, nosip_msg_skip, REG_EXTENDED)!=0) {
if(regcomp(&nosip_msg_skip_regexp, nosip_msg_skip, REG_EXTENDED) != 0) {
LM_ERR("bad skip re %s\n", nosip_msg_skip);
return E_BAD_RE;
}
Expand All @@ -129,11 +118,10 @@ static int mod_init(void)
/**
*
*/
static int pv_get_nosip(sip_msg_t *msg, pv_param_t *param,
pv_value_t *res)
static int pv_get_nosip(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
{
str sb;
if(msg==NULL || res==NULL)
if(msg == NULL || res == NULL)
return -1;
sb.s = msg->buf;
sb.len = msg->len;
Expand All @@ -146,29 +134,27 @@ static int pv_get_nosip(sip_msg_t *msg, pv_param_t *param,
*/
static int nosip_rcv_msg(sr_event_param_t *evp)
{
sip_msg_t* msg;
sip_msg_t *msg;
regmatch_t pmatch;
char c;
struct run_act_ctx ra_ctx;

msg = (sip_msg_t*)evp->data;
msg = (sip_msg_t *)evp->data;

if(nosip_msg_skip!=NULL || nosip_msg_match!=NULL)
{
if(nosip_msg_skip != NULL || nosip_msg_match != NULL) {
c = msg->buf[msg->len];
msg->buf[msg->len] = '\0';
if (nosip_msg_skip!=NULL &&
regexec(&nosip_msg_skip_regexp, msg->buf,
1, &pmatch, 0)==0)
{
if(nosip_msg_skip != NULL
&& regexec(&nosip_msg_skip_regexp, msg->buf, 1, &pmatch, 0)
== 0) {
LM_DBG("matched skip re\n");
msg->buf[msg->len] = c;
return -1;
}
if (nosip_msg_match!=NULL &&
regexec(&nosip_msg_match_regexp, msg->first_line.u.request.uri.s,
1, &pmatch, 0)!=0)
{
if(nosip_msg_match != NULL
&& regexec(&nosip_msg_match_regexp,
msg->first_line.u.request.uri.s, 1, &pmatch, 0)
!= 0) {
LM_DBG("message not matched\n");
msg->buf[msg->len] = c;
return -1;
Expand Down

0 comments on commit 28049ec

Please sign in to comment.