Skip to content

Commit

Permalink
pua_reginfo: clang format code files
Browse files Browse the repository at this point in the history
  • Loading branch information
miconda committed Apr 21, 2022
1 parent 27a98c5 commit e2df1d9
Show file tree
Hide file tree
Showing 8 changed files with 410 additions and 323 deletions.
375 changes: 210 additions & 165 deletions src/modules/pua_reginfo/notify.c

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/modules/pua_reginfo/notify.h
Expand Up @@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -26,6 +26,6 @@

#include "../../core/parser/msg_parser.h"

int reginfo_handle_notify(struct sip_msg*, char*, char*);
int reginfo_handle_notify(struct sip_msg *, char *, char *);

#endif
98 changes: 50 additions & 48 deletions src/modules/pua_reginfo/pua_reginfo.c
Expand Up @@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -35,7 +35,7 @@
MODULE_VERSION

usrloc_api_t ul; /*!< Structure containing pointers to usrloc functions*/
pua_api_t pua; /*!< Structure containing pointers to PUA functions*/
pua_api_t pua; /*!< Structure containing pointers to PUA functions*/

/* Default domain to be added, if none provided. */
str default_domain = {NULL, 0};
Expand All @@ -49,38 +49,41 @@ sruid_t _reginfo_sruid;
int reginfo_use_domain = 0;

/** Fixup functions */
static int domain_fixup(void** param, int param_no);
static int domain_fixup(void **param, int param_no);

/** module functions */
static int mod_init(void);

/* Commands */
static cmd_export_t cmds[] = {
{"reginfo_subscribe", (cmd_function)reginfo_subscribe, 1, fixup_subscribe, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"reginfo_subscribe", (cmd_function)reginfo_subscribe2, 2, fixup_subscribe, 0, REQUEST_ROUTE|ONREPLY_ROUTE},
{"reginfo_handle_notify", (cmd_function)reginfo_handle_notify, 1, domain_fixup, 0, REQUEST_ROUTE},
{0, 0, 0, 0, 0, 0}
{"reginfo_subscribe", (cmd_function)reginfo_subscribe, 1,
fixup_subscribe, 0, REQUEST_ROUTE | ONREPLY_ROUTE},
{"reginfo_subscribe", (cmd_function)reginfo_subscribe2, 2,
fixup_subscribe, 0, REQUEST_ROUTE | ONREPLY_ROUTE},
{"reginfo_handle_notify", (cmd_function)reginfo_handle_notify, 1,
domain_fixup, 0, REQUEST_ROUTE},
{0, 0, 0, 0, 0, 0}
};

static param_export_t params[]={
{"default_domain", PARAM_STR, &default_domain},
static param_export_t params[] = {
{"default_domain", PARAM_STR, &default_domain},
{"outbound_proxy", PARAM_STR, &outbound_proxy},
{"server_address", PARAM_STR, &server_address},
{"publish_reginfo", INT_PARAM, &publish_reginfo},
{0, 0, 0}
};

struct module_exports exports= {
"pua_reginfo", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* exported functions */
params, /* exported parameters */
0, /* RPC method exports */
0, /* exported pseudo-variables */
0, /* response handling function */
mod_init, /* module initialization function */
0, /* per-child init function */
0 /* module destroy function */
struct module_exports exports = {
"pua_reginfo", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* exported functions */
params, /* exported parameters */
0, /* RPC method exports */
0, /* exported pseudo-variables */
0, /* response handling function */
mod_init, /* module initialization function */
0, /* per-child init function */
0 /* module destroy function */
};

/**
Expand All @@ -91,29 +94,29 @@ static int mod_init(void)
bind_pua_t bind_pua;
bind_usrloc_t bind_usrloc;

if (publish_reginfo == 1) {
/* Verify the default domain: */
if(!default_domain.s || default_domain.len<=0) {
LM_ERR("default domain parameter not set\n");
return -1;
}
if(publish_reginfo == 1) {
/* Verify the default domain: */
if(!default_domain.s || default_domain.len <= 0) {
LM_ERR("default domain parameter not set\n");
return -1;
}
}

if(!server_address.s || server_address.len<=0) {
if(!server_address.s || server_address.len <= 0) {
LM_ERR("server_address parameter not set\n");
return -1;
}

if(!outbound_proxy.s || outbound_proxy.len<=0)
if(!outbound_proxy.s || outbound_proxy.len <= 0)
LM_DBG("No outbound proxy set\n");

/* Bind to PUA: */
bind_pua= (bind_pua_t)find_export("bind_pua", 1,0);
if (!bind_pua) {
bind_pua = (bind_pua_t)find_export("bind_pua", 1, 0);
if(!bind_pua) {
LM_ERR("Can't bind pua\n");
return -1;
}
if (bind_pua(&pua) < 0) {
}
if(bind_pua(&pua) < 0) {
LM_ERR("Can't bind pua\n");
return -1;
}
Expand All @@ -129,38 +132,38 @@ static int mod_init(void)

/* Bind to URSLOC: */
bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
if (!bind_usrloc) {
if(!bind_usrloc) {
LM_ERR("Can't bind usrloc\n");
return -1;
}
if (bind_usrloc(&ul) < 0) {
if(bind_usrloc(&ul) < 0) {
LM_ERR("Can't bind usrloc\n");
return -1;
}
if (publish_reginfo == 1) {
if(publish_reginfo == 1) {
if(ul.register_ulcb == NULL) {
LM_ERR("Could not import ul_register_ulcb\n");
return -1;
}
if(ul.register_ulcb(UL_CONTACT_INSERT, reginfo_usrloc_cb , 0)< 0) {
if(ul.register_ulcb(UL_CONTACT_INSERT, reginfo_usrloc_cb, 0) < 0) {
LM_ERR("can not register callback for insert\n");
return -1;
}
if(ul.register_ulcb(UL_CONTACT_EXPIRE, reginfo_usrloc_cb, 0)< 0) {
if(ul.register_ulcb(UL_CONTACT_EXPIRE, reginfo_usrloc_cb, 0) < 0) {
LM_ERR("can not register callback for expire\n");
return -1;
}
if(ul.register_ulcb(UL_CONTACT_UPDATE, reginfo_usrloc_cb, 0)< 0) {
if(ul.register_ulcb(UL_CONTACT_UPDATE, reginfo_usrloc_cb, 0) < 0) {
LM_ERR("can not register callback for update\n");
return -1;
}
if(ul.register_ulcb(UL_CONTACT_DELETE, reginfo_usrloc_cb, 0)< 0) {
if(ul.register_ulcb(UL_CONTACT_DELETE, reginfo_usrloc_cb, 0) < 0) {
LM_ERR("can not register callback for delete\n");
return -1;
}
}

if(sruid_init(&_reginfo_sruid, (char)'-', "regi", SRUID_INC)<0)
if(sruid_init(&_reginfo_sruid, (char)'-', "regi", SRUID_INC) < 0)
return -1;

/*
Expand All @@ -174,18 +177,17 @@ static int mod_init(void)
/*! \brief
* Convert char* parameter to udomain_t* pointer
*/
static int domain_fixup(void** param, int param_no)
static int domain_fixup(void **param, int param_no)
{
udomain_t* d;
udomain_t *d;

if (param_no == 1) {
if (ul.register_udomain((char*)*param, &d) < 0) {
if(param_no == 1) {
if(ul.register_udomain((char *)*param, &d) < 0) {
LM_ERR("failed to register domain\n");
return E_UNSPEC;
}

*param = (void*)d;
*param = (void *)d;
}
return 0;
}

2 changes: 1 addition & 1 deletion src/modules/pua_reginfo/pua_reginfo.h
Expand Up @@ -32,7 +32,7 @@ extern str outbound_proxy;
extern str server_address;

extern usrloc_api_t ul; /*!< Structure containing pointers to usrloc functions*/
extern pua_api_t pua; /*!< Structure containing pointers to PUA functions*/
extern pua_api_t pua; /*!< Structure containing pointers to PUA functions*/

extern int reginfo_use_domain;

Expand Down
60 changes: 32 additions & 28 deletions src/modules/pua_reginfo/subscribe.c
Expand Up @@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -28,13 +28,14 @@
#include "../pua/pua.h"
#include "pua_reginfo.h"

int reginfo_subscribe_real(struct sip_msg* msg, pv_elem_t* uri, int expires) {
int reginfo_subscribe_real(struct sip_msg *msg, pv_elem_t *uri, int expires)
{
str uri_str = {0, 0};
char uri_buf[512];
int uri_buf_len = 512;
subs_info_t subs;
if (pv_printf(msg, uri, uri_buf, &uri_buf_len) < 0) {

if(pv_printf(msg, uri, uri_buf, &uri_buf_len) < 0) {
LM_ERR("cannot print uri into the format\n");
return -1;
}
Expand All @@ -46,57 +47,60 @@ int reginfo_subscribe_real(struct sip_msg* msg, pv_elem_t* uri, int expires) {
memset(&subs, 0, sizeof(subs_info_t));

subs.remote_target = &uri_str;
subs.pres_uri= &uri_str;
subs.watcher_uri= &server_address;
subs.pres_uri = &uri_str;
subs.watcher_uri = &server_address;
subs.expires = expires;

subs.source_flag= REGINFO_SUBSCRIBE;
subs.event= REGINFO_EVENT;
subs.contact= &server_address;
subs.source_flag = REGINFO_SUBSCRIBE;
subs.event = REGINFO_EVENT;
subs.contact = &server_address;

if(outbound_proxy.s && outbound_proxy.len)
subs.outbound_proxy= &outbound_proxy;
subs.outbound_proxy = &outbound_proxy;

subs.flag|= UPDATE_TYPE;
subs.flag |= UPDATE_TYPE;

if(pua.send_subscribe(&subs)< 0) {
if(pua.send_subscribe(&subs) < 0) {
LM_ERR("while sending subscribe\n");
}
}

return 1;
}

int reginfo_subscribe(struct sip_msg* msg, char* uri, char* s2) {
return reginfo_subscribe_real(msg, (pv_elem_t*)uri, 3600);
int reginfo_subscribe(struct sip_msg *msg, char *uri, char *s2)
{
return reginfo_subscribe_real(msg, (pv_elem_t *)uri, 3600);
}

int reginfo_subscribe2(struct sip_msg* msg, char* uri, char* param2) {
int reginfo_subscribe2(struct sip_msg *msg, char *uri, char *param2)
{
int expires;
if(fixup_get_ivalue(msg, (gparam_p)param2, &expires) != 0) {
LM_ERR("No expires provided!\n");
return -1;
}
return reginfo_subscribe_real(msg, (pv_elem_t*)uri, expires);
return reginfo_subscribe_real(msg, (pv_elem_t *)uri, expires);
}

int fixup_subscribe(void** param, int param_no) {
int fixup_subscribe(void **param, int param_no)
{
pv_elem_t *model;
str s;
if (param_no == 1) {
if(param_no == 1) {
if(*param) {
s.s = (char*)(*param);
s.s = (char *)(*param);
s.len = strlen(s.s);
if(pv_parse_format(&s, &model)<0) {
LM_ERR("wrong format[%s]\n",(char*)(*param));
if(pv_parse_format(&s, &model) < 0) {
LM_ERR("wrong format[%s]\n", (char *)(*param));
return E_UNSPEC;
}
*param = (void*)model;
*param = (void *)model;
return 1;
}
LM_ERR("null format\n");
return E_UNSPEC;
} else if (param_no == 2) {
} else if(param_no == 2) {
return fixup_igp_igp(param, param_no);
} else return 1;
} else
return 1;
}

10 changes: 5 additions & 5 deletions src/modules/pua_reginfo/subscribe.h
Expand Up @@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand All @@ -26,8 +26,8 @@

#include "../../core/parser/msg_parser.h"

int reginfo_subscribe(struct sip_msg*, char*, char*);
int reginfo_subscribe2(struct sip_msg*, char*, char*);
int fixup_subscribe(void** param, int param_no);
int reginfo_subscribe(struct sip_msg *, char *, char *);
int reginfo_subscribe2(struct sip_msg *, char *, char *);
int fixup_subscribe(void **param, int param_no);

#endif

0 comments on commit e2df1d9

Please sign in to comment.