From 15605096ffdb540ce34f160bd8da601266bbc3a5 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:37:06 +0200 Subject: [PATCH] phonenum: clang-format for coherent indentation and coding style --- src/modules/phonenum/cphonenumber.h | 42 +++++++++++++++-------------- src/modules/phonenum/phonenum_mod.c | 21 ++++++++------- src/modules/phonenum/phonenum_pv.c | 28 +++++++++---------- src/modules/phonenum/phonenum_pv.h | 4 +-- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/modules/phonenum/cphonenumber.h b/src/modules/phonenum/cphonenumber.h index ab73b938fde..1a6a06df861 100644 --- a/src/modules/phonenum/cphonenumber.h +++ b/src/modules/phonenum/cphonenumber.h @@ -25,30 +25,32 @@ #define _CPHONENUMBER_H_ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -// Phone number details -typedef struct telnum { - char* number; - char* normalized; - char* ltype; - char* ndesc; - char* ccname; - char* error; - int cctel; - int valid; -} telnum_t; + // Phone number details + typedef struct telnum + { + char *number; + char *normalized; + char *ltype; + char *ndesc; + char *ccname; + char *error; + int cctel; + int valid; + } telnum_t; -telnum_t* telnum_new(char*); -void telnum_free(telnum_t*); + telnum_t *telnum_new(char *); + void telnum_free(telnum_t *); -// test if number is possible -int telnum_possible(char* number, char* region); -// parse a number -telnum_t* telnum_parse(char* number, char* region); -// get country code for number -char* telnum_cc(char* number); + // test if number is possible + int telnum_possible(char *number, char *region); + // parse a number + telnum_t *telnum_parse(char *number, char *region); + // get country code for number + char *telnum_cc(char *number); #ifdef __cplusplus } diff --git a/src/modules/phonenum/phonenum_mod.c b/src/modules/phonenum/phonenum_mod.c index ea49e73a86a..5f07635099c 100644 --- a/src/modules/phonenum/phonenum_mod.c +++ b/src/modules/phonenum/phonenum_mod.c @@ -43,11 +43,11 @@ static int mod_init(void); static void mod_destroy(void); static int w_phonenum_match(struct sip_msg *msg, char *str1, char *str2); -static int w_phonenum_match_cn(struct sip_msg *msg, char *str1, char *str2, - char *str3); +static int w_phonenum_match_cn( + struct sip_msg *msg, char *str1, char *str2, char *str3); static int phonenum_match(sip_msg_t *msg, str *tomatch, str *pvclass); -static int phonenum_resid_param(modparam_t type, void* val); +static int phonenum_resid_param(modparam_t type, void *val); /* clang-format off */ static pv_export_t mod_pvs[] = { @@ -108,14 +108,14 @@ static void mod_destroy(void) /** * */ -static int phonenum_resid_param(modparam_t type, void* val) +static int phonenum_resid_param(modparam_t type, void *val) { str rname; - rname = *((str*)val); + rname = *((str *)val); if(sr_phonenum_add_resid(&rname) < 0) { - LM_ERR("failed to register result container with id: %.*s\n", - rname.len, rname.s); + LM_ERR("failed to register result container with id: %.*s\n", rname.len, + rname.s); return -1; } return 0; @@ -150,15 +150,16 @@ static int w_phonenum_match(sip_msg_t *msg, char *target, char *pvname) return phonenum_match(msg, &tomatch, &pvclass); } -static int phonenum_match_cn(sip_msg_t *msg, str *tomatch, str *cnc, str *pvclass) +static int phonenum_match_cn( + sip_msg_t *msg, str *tomatch, str *cnc, str *pvclass) { phonenum_pv_reset(pvclass); return phonenum_update_pv(tomatch, cnc, pvclass); } -static int w_phonenum_match_cn(sip_msg_t *msg, char *target, char *cncstr, - char *pvname) +static int w_phonenum_match_cn( + sip_msg_t *msg, char *target, char *cncstr, char *pvname) { str tomatch = STR_NULL; str pvclass = STR_NULL; diff --git a/src/modules/phonenum/phonenum_pv.c b/src/modules/phonenum/phonenum_pv.c index 6115d9daadb..f6bcc025f66 100644 --- a/src/modules/phonenum/phonenum_pv.c +++ b/src/modules/phonenum/phonenum_pv.c @@ -113,7 +113,7 @@ sr_phonenum_item_t *sr_phonenum_add_item(str *name) int sr_phonenum_add_resid(str *rname) { - if(sr_phonenum_add_item(rname)==NULL) { + if(sr_phonenum_add_item(rname) == NULL) { return -1; } return 0; @@ -239,25 +239,25 @@ int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) return -1; if(gpv->item == NULL) return pv_get_null(msg, param, res); - if(gpv->item->r.record==NULL) + if(gpv->item->r.record == NULL) return pv_get_null(msg, param, res); switch(gpv->type) { case 1: /* normalized */ - if(gpv->item->r.record->normalized==NULL) + if(gpv->item->r.record->normalized == NULL) return pv_get_null(msg, param, res); - return pv_get_strzval(msg, param, res, - gpv->item->r.record->normalized); + return pv_get_strzval( + msg, param, res, gpv->item->r.record->normalized); case 2: /* ltype */ - if(gpv->item->r.record->ltype==NULL) + if(gpv->item->r.record->ltype == NULL) return pv_get_null(msg, param, res); return pv_get_strzval(msg, param, res, gpv->item->r.record->ltype); case 3: /* ndesc */ - if(gpv->item->r.record->ndesc==NULL) + if(gpv->item->r.record->ndesc == NULL) return pv_get_null(msg, param, res); return pv_get_strzval(msg, param, res, gpv->item->r.record->ndesc); case 4: /* error */ - if(gpv->item->r.record->error==NULL) + if(gpv->item->r.record->error == NULL) return pv_get_null(msg, param, res); return pv_get_strzval(msg, param, res, gpv->item->r.record->error); case 5: /* cctel */ @@ -265,11 +265,11 @@ int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param, pv_value_t *res) case 6: /* valid */ return pv_get_sintval(msg, param, res, gpv->item->r.record->valid); case 7: /* ccname */ - if(gpv->item->r.record->ccname==NULL) + if(gpv->item->r.record->ccname == NULL) return pv_get_null(msg, param, res); return pv_get_strzval(msg, param, res, gpv->item->r.record->ccname); default: /* number */ - if(gpv->item->r.record->number==NULL) + if(gpv->item->r.record->number == NULL) return pv_get_null(msg, param, res); return pv_get_strzval(msg, param, res, gpv->item->r.record->number); } @@ -323,16 +323,16 @@ int phonenum_update_pv(str *tomatch, str *cncode, str *name) strncpy(gr->tomatch, tomatch->s, tomatch->len); gr->tomatch[tomatch->len] = '\0'; LM_DBG("attempt to match: %s\n", gr->tomatch); - gr->record = telnum_parse(gr->tomatch, - (cncode && cncode->len>0)?cncode->s:"ZZ"); + gr->record = telnum_parse( + gr->tomatch, (cncode && cncode->len > 0) ? cncode->s : "ZZ"); if(gr->record == NULL) { LM_DBG("no match for: %s\n", gr->tomatch); return -2; } LM_DBG("phonenum PV updated for: %s (%d/%s/%s)\n", gr->tomatch, gr->record->valid, - (gr->record->normalized)?gr->record->normalized:"none", - (gr->record->error)?gr->record->error:"none"); + (gr->record->normalized) ? gr->record->normalized : "none", + (gr->record->error) ? gr->record->error : "none"); return 1; } diff --git a/src/modules/phonenum/phonenum_pv.h b/src/modules/phonenum/phonenum_pv.h index 938bbac297a..7fd1e1d6127 100644 --- a/src/modules/phonenum/phonenum_pv.h +++ b/src/modules/phonenum/phonenum_pv.h @@ -27,8 +27,7 @@ #include "../../core/pvar.h" int pv_parse_phonenum_name(pv_spec_p sp, str *in); -int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param, - pv_value_t *res); +int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); int phonenum_init_pv(int smode); void phonenum_destroy_pv(void); @@ -37,4 +36,3 @@ int phonenum_update_pv(str *tomatch, str *cncode, str *pvclass); int sr_phonenum_add_resid(str *rname); #endif -