From e5bff977cf4e59aab006297a7a91520356f0a39f Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:36:54 +0200 Subject: [PATCH] jwt: clang-format for coherent indentation and coding style --- src/modules/jwt/jwt_mod.c | 280 +++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/src/modules/jwt/jwt_mod.c b/src/modules/jwt/jwt_mod.c index adda8d38456..6d4b6f7e6ec 100644 --- a/src/modules/jwt/jwt_mod.c +++ b/src/modules/jwt/jwt_mod.c @@ -38,23 +38,26 @@ MODULE_VERSION -static int mod_init(void); -static int child_init(int); +static int mod_init(void); +static int child_init(int); static void mod_destroy(void); -static int w_jwt_generate_4(sip_msg_t* msg, char* pkey, char* palg, char* pclaims, char* pheaders); -static int w_jwt_generate_3(sip_msg_t* msg, char* pkey, char* palg, char* pclaims); -static int w_jwt_verify(sip_msg_t* msg, char* pkeypath, char* palg, char* pclaims, - char *pjwtval); -static int w_jwt_verify_key(sip_msg_t* msg, char* pkey, char* palg, char* pclaims, - char *pjwtval); +static int w_jwt_generate_4( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims, char *pheaders); +static int w_jwt_generate_3( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims); +static int w_jwt_verify(sip_msg_t *msg, char *pkeypath, char *palg, + char *pclaims, char *pjwtval); +static int w_jwt_verify_key( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims, char *pjwtval); static int _jwt_key_mode = 0; static str _jwt_result = STR_NULL; static unsigned int _jwt_verify_status = 0; -typedef struct jwt_fcache { +typedef struct jwt_fcache +{ str fname; str fdata; struct jwt_fcache *next; @@ -62,43 +65,38 @@ typedef struct jwt_fcache { static jwt_fcache_t *_jwt_fcache_list = NULL; -static cmd_export_t cmds[]={ - {"jwt_generate", (cmd_function)w_jwt_generate_4, 4, - fixup_spve_all, 0, ANY_ROUTE}, - {"jwt_generate", (cmd_function)w_jwt_generate_3, 3, - fixup_spve_all, 0, ANY_ROUTE}, - {"jwt_verify", (cmd_function)w_jwt_verify, 4, - fixup_spve_all, 0, ANY_ROUTE}, - {"jwt_verify_key", (cmd_function)w_jwt_verify_key, 4, - fixup_spve_all, 0, ANY_ROUTE}, - {0, 0, 0, 0, 0, 0} -}; +static cmd_export_t cmds[] = {{"jwt_generate", (cmd_function)w_jwt_generate_4, + 4, fixup_spve_all, 0, ANY_ROUTE}, + {"jwt_generate", (cmd_function)w_jwt_generate_3, 3, fixup_spve_all, 0, + ANY_ROUTE}, + {"jwt_verify", (cmd_function)w_jwt_verify, 4, fixup_spve_all, 0, + ANY_ROUTE}, + {"jwt_verify_key", (cmd_function)w_jwt_verify_key, 4, fixup_spve_all, 0, + ANY_ROUTE}, + {0, 0, 0, 0, 0, 0}}; -static param_export_t params[]={ - { "key_mode", PARAM_INT, &_jwt_key_mode }, +static param_export_t params[] = {{"key_mode", PARAM_INT, &_jwt_key_mode}, - { 0, 0, 0 } -}; + {0, 0, 0}}; static int jwt_pv_get(sip_msg_t *msg, pv_param_t *param, pv_value_t *res); static int jwt_pv_parse_name(pv_spec_t *sp, str *in); static pv_export_t mod_pvs[] = { - { {"jwt", sizeof("jwt")-1}, PVT_OTHER, jwt_pv_get, 0, - jwt_pv_parse_name, 0, 0, 0 }, - { {0, 0}, 0, 0, 0, 0, 0, 0, 0 } -}; + {{"jwt", sizeof("jwt") - 1}, PVT_OTHER, jwt_pv_get, 0, + jwt_pv_parse_name, 0, 0, 0}, + {{0, 0}, 0, 0, 0, 0, 0, 0, 0}}; struct module_exports exports = { - "jwt", /* 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 */ - child_init, /* per-child init function */ - mod_destroy /* module destroy function */ + "jwt", /* 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 */ + child_init, /* per-child init function */ + mod_destroy /* module destroy function */ }; @@ -133,12 +131,12 @@ static int jwt_fcache_get(str *key, str *kdata) { jwt_fcache_t *fc = NULL; - if(_jwt_key_mode!=1) { + if(_jwt_key_mode != 1) { return -1; } - for(fc=_jwt_fcache_list; fc!=NULL; fc=fc->next) { - if(fc->fname.len==key->len - && strncmp(fc->fname.s, key->s, key->len)==0) { + for(fc = _jwt_fcache_list; fc != NULL; fc = fc->next) { + if(fc->fname.len == key->len + && strncmp(fc->fname.s, key->s, key->len) == 0) { LM_DBG("file found in cache: %.*s\n", key->len, key->s); *kdata = fc->fdata; break; @@ -154,17 +152,17 @@ static int jwt_fcache_add(str *key, str *kdata) { jwt_fcache_t *fc = NULL; - if(_jwt_key_mode!=1) { + if(_jwt_key_mode != 1) { return -1; } - fc = (jwt_fcache_t*)pkg_malloc(sizeof(jwt_fcache_t) + key->len - + kdata->len + 2); - if(fc==NULL) { + fc = (jwt_fcache_t *)pkg_malloc( + sizeof(jwt_fcache_t) + key->len + kdata->len + 2); + if(fc == NULL) { PKG_MEM_ERROR; return -1; } memset(fc, 0, sizeof(jwt_fcache_t) + key->len + kdata->len + 2); - fc->fname.s = (char*)fc + sizeof(jwt_fcache_t); + fc->fname.s = (char *)fc + sizeof(jwt_fcache_t); fc->fname.len = key->len; memcpy(fc->fname.s, key->s, key->len); fc->fdata.s = fc->fname.s + fc->fname.len + 1; @@ -179,8 +177,8 @@ static int jwt_fcache_add(str *key, str *kdata) /** * */ -static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, - str *headers) +static int ki_jwt_generate_hdrs( + sip_msg_t *msg, str *key, str *alg, str *claims, str *headers) { str dupclaims = STR_NULL; str sparams = STR_NULL; @@ -192,8 +190,8 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, FILE *fpk = NULL; unsigned char keybuf[10240]; size_t keybuf_len = 0; - param_t* params_list = NULL; - param_t* headers_list = NULL; + param_t *params_list = NULL; + param_t *headers_list = NULL; param_hooks_t phooks; param_t *pit = NULL; param_t *header = NULL; @@ -202,8 +200,8 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, jwt_t *jwt = NULL; long lval = 0; - if(key==NULL || key->s==NULL || alg==NULL || alg->s==NULL - || claims==NULL || claims->s==NULL || claims->len<=0) { + if(key == NULL || key->s == NULL || alg == NULL || alg->s == NULL + || claims == NULL || claims->s == NULL || claims->len <= 0) { LM_ERR("invalid parameters\n"); return -1; } @@ -213,63 +211,63 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, _jwt_result.len = 0; } valg = jwt_str_alg(alg->s); - if (valg == JWT_ALG_INVAL) { + if(valg == JWT_ALG_INVAL) { LM_ERR("not supported algorithm: %s\n", alg->s); return -1; } - if(pkg_str_dup(&dupclaims, claims)<0) { + if(pkg_str_dup(&dupclaims, claims) < 0) { LM_ERR("failed to duplicate claims\n"); return -1; } - if (headers!=NULL) { - if(pkg_str_dup(&dupheaders, headers)<0) { + if(headers != NULL) { + if(pkg_str_dup(&dupheaders, headers) < 0) { LM_ERR("failed to duplicate headers\n"); return -1; } } jwt_fcache_get(key, &kdata); - if(kdata.s==NULL) { - fpk= fopen(key->s, "r"); - if(fpk==NULL) { + if(kdata.s == NULL) { + fpk = fopen(key->s, "r"); + if(fpk == NULL) { LM_ERR("failed to read key file: %s\n", key->s); goto error; } keybuf_len = fread(keybuf, 1, sizeof(keybuf), fpk); fclose(fpk); - if(keybuf_len==0) { + if(keybuf_len == 0) { LM_ERR("unable to read key file content: %s\n", key->s); goto error; } keybuf[keybuf_len] = '\0'; - kdata.s = (char*)keybuf; + kdata.s = (char *)keybuf; kdata.len = (int)keybuf_len; jwt_fcache_add(key, &kdata); } sparams = dupclaims; - if(sparams.s[sparams.len-1]==';') { + if(sparams.s[sparams.len - 1] == ';') { sparams.len--; } - if (headers!=NULL) { + if(headers != NULL) { sheaders = dupheaders; - if(sheaders.s[sheaders.len-1]==';') { + if(sheaders.s[sheaders.len - 1] == ';') { sheaders.len--; } } - if (parse_params(&sparams, CLASS_ANY, &phooks, ¶ms_list)<0) { + if(parse_params(&sparams, CLASS_ANY, &phooks, ¶ms_list) < 0) { LM_ERR("failed to parse claims\n"); goto error; } - if (headers!=NULL && headers->s!=NULL && headers->len>0) { - if (parse_params(&sheaders, CLASS_ANY, &phooks, &headers_list)<0) { + if(headers != NULL && headers->s != NULL && headers->len > 0) { + if(parse_params(&sheaders, CLASS_ANY, &phooks, &headers_list) < 0) { LM_ERR("failed to parse headers\n"); goto error; } } ret = jwt_new(&jwt); - if (ret != 0 || jwt == NULL) { + if(ret != 0 || jwt == NULL) { LM_ERR("failed to initialize jwt\n"); goto error; } @@ -281,13 +279,13 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, LM_ERR("failed to add iat grant\n"); goto error; } - for (pit = params_list; pit; pit=pit->next) { - if(pit->name.len>0 && pit->body.len>0) { + for(pit = params_list; pit; pit = pit->next) { + if(pit->name.len > 0 && pit->body.len > 0) { pit->name.s[pit->name.len] = '\0'; pit->body.s[pit->body.len] = '\0'; if(pit->body.s[-1] == '\"' || pit->body.s[-1] == '\'') { ret = jwt_add_grant(jwt, pit->name.s, pit->body.s); - } else if(str2slong(&pit->body, &lval)==0) { + } else if(str2slong(&pit->body, &lval) == 0) { ret = jwt_add_grant_int(jwt, pit->name.s, lval); } else { ret = jwt_add_grant(jwt, pit->name.s, pit->body.s); @@ -299,13 +297,13 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, } } - for (header = headers_list; header; header=header->next) { - if(header->name.len>0 && header->body.len>0) { + for(header = headers_list; header; header = header->next) { + if(header->name.len > 0 && header->body.len > 0) { header->name.s[header->name.len] = '\0'; header->body.s[header->body.len] = '\0'; if(header->body.s[-1] == '\"' || header->body.s[-1] == '\'') { ret = jwt_add_header(jwt, header->name.s, header->body.s); - } else if(str2slong(&header->body, &lval)==0) { + } else if(str2slong(&header->body, &lval) == 0) { ret = jwt_add_header_int(jwt, header->name.s, lval); } else { ret = jwt_add_header(jwt, header->name.s, header->body.s); @@ -317,8 +315,8 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, } } - ret = jwt_set_alg(jwt, valg, (unsigned char*)kdata.s, (size_t)kdata.len); - if (ret != 0) { + ret = jwt_set_alg(jwt, valg, (unsigned char *)kdata.s, (size_t)kdata.len); + if(ret != 0) { LM_ERR("failed to set algorithm and key\n"); goto error; } @@ -335,19 +333,19 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, return 1; error: - if(params_list!=NULL) { + if(params_list != NULL) { free_params(params_list); } - if(dupclaims.s!=NULL) { + if(dupclaims.s != NULL) { pkg_free(dupclaims.s); } - if(headers_list!=NULL) { + if(headers_list != NULL) { free_params(headers_list); } - if(dupheaders.s!=NULL) { + if(dupheaders.s != NULL) { pkg_free(dupheaders.s); } - if(jwt!=NULL) { + if(jwt != NULL) { jwt_free(jwt); } return -1; @@ -356,7 +354,7 @@ static int ki_jwt_generate_hdrs(sip_msg_t* msg, str *key, str *alg, str *claims, /** * */ -static int ki_jwt_generate(sip_msg_t* msg, str *key, str *alg, str *claims) +static int ki_jwt_generate(sip_msg_t *msg, str *key, str *alg, str *claims) { return ki_jwt_generate_hdrs(msg, key, alg, claims, NULL); } @@ -364,22 +362,23 @@ static int ki_jwt_generate(sip_msg_t* msg, str *key, str *alg, str *claims) /** * */ -static int w_jwt_generate_3(sip_msg_t* msg, char* pkey, char* palg, char* pclaims) +static int w_jwt_generate_3( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims) { str skey = STR_NULL; str salg = STR_NULL; str sclaims = STR_NULL; - if (fixup_get_svalue(msg, (gparam_t*)pkey, &skey) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pkey, &skey) != 0) { LM_ERR("cannot get path to the key file\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)palg, &salg) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)palg, &salg) != 0) { LM_ERR("cannot get algorithm value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pclaims, &sclaims) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pclaims, &sclaims) != 0) { LM_ERR("cannot get claims value\n"); return -1; } @@ -390,28 +389,29 @@ static int w_jwt_generate_3(sip_msg_t* msg, char* pkey, char* palg, char* pclaim /** * */ -static int w_jwt_generate_4(sip_msg_t* msg, char* pkey, char* palg, char* pclaims, char* pheaders) +static int w_jwt_generate_4( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims, char *pheaders) { str skey = STR_NULL; str salg = STR_NULL; str sclaims = STR_NULL; str sheaders = STR_NULL; - if (fixup_get_svalue(msg, (gparam_t*)pkey, &skey) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pkey, &skey) != 0) { LM_ERR("cannot get path to the key file\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)palg, &salg) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)palg, &salg) != 0) { LM_ERR("cannot get algorithm value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pclaims, &sclaims) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pclaims, &sclaims) != 0) { LM_ERR("cannot get claims value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pheaders, &sheaders) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pheaders, &sheaders) != 0) { LM_ERR("cannot get headers value\n"); return -1; } @@ -422,14 +422,14 @@ static int w_jwt_generate_4(sip_msg_t* msg, char* pkey, char* palg, char* pclaim /** * */ -static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, - str *jwtval) +static int ki_jwt_verify_key( + sip_msg_t *msg, str *key, str *alg, str *claims, str *jwtval) { str dupclaims = STR_NULL; jwt_alg_t valg = JWT_ALG_NONE; str kdata = STR_NULL; time_t iat; - param_t* params_list = NULL; + param_t *params_list = NULL; param_hooks_t phooks; param_t *pit = NULL; int ret = 0; @@ -438,9 +438,9 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, str sparams = STR_NULL; long lval = 0; - if(key==NULL || key->s==NULL || alg==NULL || alg->s==NULL - || claims==NULL || claims->s==NULL || claims->len<=0 - || jwtval==NULL || jwtval->s==NULL || jwtval->len<=0) { + if(key == NULL || key->s == NULL || alg == NULL || alg->s == NULL + || claims == NULL || claims->s == NULL || claims->len <= 0 + || jwtval == NULL || jwtval->s == NULL || jwtval->len <= 0) { LM_ERR("invalid parameters\n"); return -1; } @@ -450,25 +450,25 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, kdata = *key; trim(&kdata); valg = jwt_str_alg(alg->s); - if (valg == JWT_ALG_INVAL) { + if(valg == JWT_ALG_INVAL) { LM_ERR("not supported algorithm: %s\n", alg->s); return -1; } - if(pkg_str_dup(&dupclaims, claims)<0) { + if(pkg_str_dup(&dupclaims, claims) < 0) { LM_ERR("failed to duplicate claims\n"); return -1; } sparams = dupclaims; - if(sparams.s[sparams.len-1]==';') { + if(sparams.s[sparams.len - 1] == ';') { sparams.len--; } - if (parse_params(&sparams, CLASS_ANY, &phooks, ¶ms_list)<0) { + if(parse_params(&sparams, CLASS_ANY, &phooks, ¶ms_list) < 0) { LM_ERR("failed to parse claims\n"); goto error; } ret = jwt_valid_new(&jwt_valid, valg); - if (ret != 0 || jwt_valid == NULL) { + if(ret != 0 || jwt_valid == NULL) { LM_ERR("failed to initialize jwt valid\n"); goto error; } @@ -477,13 +477,13 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, jwt_valid_set_headers(jwt_valid, 1); jwt_valid_set_now(jwt_valid, iat); - for (pit = params_list; pit; pit=pit->next) { - if(pit->name.len>0 && pit->body.len>0) { + for(pit = params_list; pit; pit = pit->next) { + if(pit->name.len > 0 && pit->body.len > 0) { pit->name.s[pit->name.len] = '\0'; pit->body.s[pit->body.len] = '\0'; if(pit->body.s[-1] == '\"' || pit->body.s[-1] == '\'') { ret = jwt_valid_add_grant(jwt_valid, pit->name.s, pit->body.s); - } else if(str2slong(&pit->body, &lval)==0) { + } else if(str2slong(&pit->body, &lval) == 0) { ret = jwt_valid_add_grant_int(jwt_valid, pit->name.s, lval); } else { ret = jwt_valid_add_grant(jwt_valid, pit->name.s, pit->body.s); @@ -495,12 +495,13 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, } } - ret = jwt_decode(&jwt, jwtval->s, (unsigned char*)kdata.s, (size_t)kdata.len); - if (ret!=0 || jwt==NULL) { + ret = jwt_decode( + &jwt, jwtval->s, (unsigned char *)kdata.s, (size_t)kdata.len); + if(ret != 0 || jwt == NULL) { LM_ERR("failed to decode jwt value\n"); goto error; } - if (jwt_validate(jwt, jwt_valid) != 0) { + if(jwt_validate(jwt, jwt_valid) != 0) { _jwt_verify_status = jwt_valid_get_status(jwt_valid); LM_ERR("failed to validate jwt: %08x\n", _jwt_verify_status); goto error; @@ -514,16 +515,16 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, return 1; error: - if(params_list!=NULL) { + if(params_list != NULL) { free_params(params_list); } - if(dupclaims.s!=NULL) { + if(dupclaims.s != NULL) { pkg_free(dupclaims.s); } - if(jwt!=NULL) { + if(jwt != NULL) { jwt_free(jwt); } - if(jwt_valid!=NULL) { + if(jwt_valid != NULL) { jwt_valid_free(jwt_valid); } return -1; @@ -532,35 +533,35 @@ static int ki_jwt_verify_key(sip_msg_t* msg, str *key, str *alg, str *claims, /** * */ -static int ki_jwt_verify(sip_msg_t* msg, str *keypath, str *alg, str *claims, - str *jwtval) +static int ki_jwt_verify( + sip_msg_t *msg, str *keypath, str *alg, str *claims, str *jwtval) { str kdata = STR_NULL; FILE *fpk = NULL; unsigned char keybuf[10240]; size_t keybuf_len = 0; - if(keypath==NULL || keypath->s==NULL || alg==NULL || alg->s==NULL - || claims==NULL || claims->s==NULL || claims->len<=0 - || jwtval==NULL || jwtval->s==NULL || jwtval->len<=0) { + if(keypath == NULL || keypath->s == NULL || alg == NULL || alg->s == NULL + || claims == NULL || claims->s == NULL || claims->len <= 0 + || jwtval == NULL || jwtval->s == NULL || jwtval->len <= 0) { LM_ERR("invalid parameters\n"); return -1; } jwt_fcache_get(keypath, &kdata); - if(kdata.s==NULL) { - fpk= fopen(keypath->s, "r"); - if(fpk==NULL) { + if(kdata.s == NULL) { + fpk = fopen(keypath->s, "r"); + if(fpk == NULL) { LM_ERR("failed to read key file: %s\n", keypath->s); return -1; } keybuf_len = fread(keybuf, 1, sizeof(keybuf), fpk); fclose(fpk); - if(keybuf_len==0) { + if(keybuf_len == 0) { LM_ERR("unable to read key file content: %s\n", keypath->s); return -1; } - kdata.s = (char*)keybuf; + kdata.s = (char *)keybuf; kdata.len = (int)keybuf_len; trim(&kdata); kdata.s[keybuf_len] = '\0'; @@ -572,27 +573,27 @@ static int ki_jwt_verify(sip_msg_t* msg, str *keypath, str *alg, str *claims, /** * */ -static int w_jwt_verify(sip_msg_t* msg, char* pkeypath, char* palg, char* pclaims, - char *pjwtval) +static int w_jwt_verify(sip_msg_t *msg, char *pkeypath, char *palg, + char *pclaims, char *pjwtval) { str skeypath = STR_NULL; str salg = STR_NULL; str sclaims = STR_NULL; str sjwtval = STR_NULL; - if (fixup_get_svalue(msg, (gparam_t*)pkeypath, &skeypath) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pkeypath, &skeypath) != 0) { LM_ERR("cannot get path to the key file\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)palg, &salg) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)palg, &salg) != 0) { LM_ERR("cannot get algorithm value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pclaims, &sclaims) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pclaims, &sclaims) != 0) { LM_ERR("cannot get claims value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pjwtval, &sjwtval) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pjwtval, &sjwtval) != 0) { LM_ERR("cannot get jwt value\n"); return -1; } @@ -603,27 +604,27 @@ static int w_jwt_verify(sip_msg_t* msg, char* pkeypath, char* palg, char* pclaim /** * */ -static int w_jwt_verify_key(sip_msg_t* msg, char* pkey, char* palg, char* pclaims, - char *pjwtval) +static int w_jwt_verify_key( + sip_msg_t *msg, char *pkey, char *palg, char *pclaims, char *pjwtval) { str skey = STR_NULL; str salg = STR_NULL; str sclaims = STR_NULL; str sjwtval = STR_NULL; - if (fixup_get_svalue(msg, (gparam_t*)pkey, &skey) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pkey, &skey) != 0) { LM_ERR("cannot get the key value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)palg, &salg) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)palg, &salg) != 0) { LM_ERR("cannot get algorithm value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pclaims, &sclaims) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pclaims, &sclaims) != 0) { LM_ERR("cannot get claims value\n"); return -1; } - if (fixup_get_svalue(msg, (gparam_t*)pjwtval, &sjwtval) != 0) { + if(fixup_get_svalue(msg, (gparam_t *)pjwtval, &sjwtval) != 0) { LM_ERR("cannot get jwt value\n"); return -1; } @@ -636,10 +637,9 @@ static int w_jwt_verify_key(sip_msg_t* msg, char* pkey, char* palg, char* pclaim */ static int jwt_pv_get(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) { - switch(param->pvn.u.isname.name.n) - { + switch(param->pvn.u.isname.name.n) { case 0: - if(_jwt_result.s==NULL) + if(_jwt_result.s == NULL) return pv_get_null(msg, param, res); return pv_get_strval(msg, param, res, &_jwt_result); case 1: @@ -654,9 +654,9 @@ static int jwt_pv_get(sip_msg_t *msg, pv_param_t *param, pv_value_t *res) */ static int jwt_pv_parse_name(pv_spec_t *sp, str *in) { - if(in->len==3 && strncmp(in->s, "val", 3)==0) { + if(in->len == 3 && strncmp(in->s, "val", 3) == 0) { sp->pvp.pvn.u.isname.name.n = 0; - } else if(in->len==6 && strncmp(in->s, "status", 6)==0) { + } else if(in->len == 6 && strncmp(in->s, "status", 6) == 0) { sp->pvp.pvn.u.isname.name.n = 1; } else { LM_ERR("unknown inner name [%.*s]\n", in->len, in->s);