Skip to content

Commit

Permalink
geoip: 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 41cd7a2 commit 0b273ce
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 193 deletions.
66 changes: 30 additions & 36 deletions src/modules/geoip/geoip_mod.c
Expand Up @@ -39,41 +39,36 @@ MODULE_VERSION

static char *geoip_path = NULL;

static int mod_init(void);
static int mod_init(void);
static void mod_destroy(void);

static int w_geoip_match(struct sip_msg* msg, char* str1, char* str2);
static int w_geoip_match(struct sip_msg *msg, char *str1, char *str2);
static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass);

static pv_export_t mod_pvs[] = {
{ {"gip", sizeof("gip")-1}, PVT_OTHER, pv_get_geoip, 0,
pv_parse_geoip_name, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
{{"gip", sizeof("gip") - 1}, PVT_OTHER, pv_get_geoip, 0,
pv_parse_geoip_name, 0, 0, 0},
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}};


static cmd_export_t cmds[]={
{"geoip_match", (cmd_function)w_geoip_match, 2, fixup_spve_spve,
0, ANY_ROUTE},
{0, 0, 0, 0, 0, 0}
};
static cmd_export_t cmds[] = {{"geoip_match", (cmd_function)w_geoip_match, 2,
fixup_spve_spve, 0, ANY_ROUTE},
{0, 0, 0, 0, 0, 0}};

static param_export_t params[]={
{"path", PARAM_STRING, &geoip_path},
{0, 0, 0}
};
static param_export_t params[] = {
{"path", PARAM_STRING, &geoip_path}, {0, 0, 0}};

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


Expand All @@ -83,14 +78,12 @@ struct module_exports exports = {
static int mod_init(void)
{

if(geoip_path==NULL || strlen(geoip_path)==0)
{
if(geoip_path == NULL || strlen(geoip_path) == 0) {
LM_ERR("path to GeoIP database file not set\n");
return -1;
}

if(geoip_init_pv(geoip_path)!=0)
{
if(geoip_init_pv(geoip_path) != 0) {
LM_ERR("cannot init for database file at: %s\n", geoip_path);
return -1;
}
Expand All @@ -113,21 +106,21 @@ static int geoip_match(sip_msg_t *msg, str *tomatch, str *pvclass)
return geoip_update_pv(tomatch, pvclass);
}

static int w_geoip_match(sip_msg_t* msg, char* target, char* pvname)
static int w_geoip_match(sip_msg_t *msg, char *target, char *pvname)
{
str tomatch = STR_NULL;
str pvclass = STR_NULL;

if(msg==NULL) {
if(msg == NULL) {
LM_ERR("received null msg\n");
return -1;
}

if(fixup_get_svalue(msg, (gparam_t*)target, &tomatch)<0) {
if(fixup_get_svalue(msg, (gparam_t *)target, &tomatch) < 0) {
LM_ERR("cannot get the address\n");
return -1;
}
if(fixup_get_svalue(msg, (gparam_t*)pvname, &pvclass)<0) {
if(fixup_get_svalue(msg, (gparam_t *)pvname, &pvclass) < 0) {
LM_ERR("cannot get the pv class\n");
return -1;
}
Expand All @@ -150,7 +143,8 @@ static sr_kemi_t sr_kemi_geoip_exports[] = {
};
/* clang-format on */

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

0 comments on commit 0b273ce

Please sign in to comment.