From 00571fd1d07edbfb5950ca6786e898ecbc0b33f5 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 31 Oct 2016 13:21:27 +0100 Subject: [PATCH] uac: coherent indentation of code for replace from/to values --- modules/uac/replace.c | 49 ++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/modules/uac/replace.c b/modules/uac/replace.c index 540042b9581..05304b11ba0 100644 --- a/modules/uac/replace.c +++ b/modules/uac/replace.c @@ -290,13 +290,16 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri, avp_value.s.len = p - body->body.s + ((p[i]=='>') ? (i+1) : 0) ; avp_value.s.s=body->body.s; - LM_DBG("value to store is is '%.*s' and len is '%d'\n",avp_value.s.len, avp_value.s.s,avp_value.s.len); + LM_DBG("value to store is is '%.*s' and len is '%d'\n", + avp_value.s.len, avp_value.s.s,avp_value.s.len); if(check_from) { - LM_DBG("Storing in FROM-AVP (for use in reply): '%.*s' with len '%d'\n",avp_value.s.len, avp_value.s.s,avp_value.s.len); + LM_DBG("Storing in FROM-AVP (for use in reply): '%.*s' with len '%d'\n", + avp_value.s.len, avp_value.s.s,avp_value.s.len); add_avp(restore_from_avp_type, restore_from_avp_name, avp_value); } else { - LM_DBG("Storing in TO-AVP (for use in reply): '%.*s' with len '%d'\n",avp_value.s.len, avp_value.s.s,avp_value.s.len); + LM_DBG("Storing in TO-AVP (for use in reply): '%.*s' with len '%d'\n", + avp_value.s.len, avp_value.s.s,avp_value.s.len); add_avp(restore_to_avp_type, restore_to_avp_name, avp_value); } } @@ -309,9 +312,10 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri, /* first remove the existing display */ if ( body->display.len) { - LM_DBG("removing display [%.*s]\n", body->display.len,body->display.s); + LM_DBG("removing display [%.*s]\n", + body->display.len, body->display.s); /* build del lump */ - l = del_lump( msg, body->display.s-msg->buf, body->display.len, 0); + l = del_lump(msg, body->display.s-msg->buf, body->display.len, 0); if (l==0) { LM_ERR("display del lump failed\n"); @@ -404,10 +408,13 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri, goto error; } LM_DBG("Stored <%.*s> var in dialog with value %.*s\n", - dlgvar_names[0].len, dlgvar_names[0].s, body->uri.len, body->uri.s); + dlgvar_names[0].len, dlgvar_names[0].s, + body->uri.len, body->uri.s); - if (dlg_api.register_dlgcb(dlg, DLGCB_REQ_WITHIN|DLGCB_CONFIRMED|DLGCB_TERMINATED, - (void*)(unsigned long)replace_callback, (void*)(unsigned long)uac_flag, 0) != 0) { + if (dlg_api.register_dlgcb(dlg, + DLGCB_REQ_WITHIN|DLGCB_CONFIRMED|DLGCB_TERMINATED, + (void*)(unsigned long)replace_callback, + (void*)(unsigned long)uac_flag, 0) != 0) { LM_ERR("cannot register callback\n"); dlg_api.release_dlg(dlg); goto error; @@ -513,7 +520,8 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri, * return 0 - restored * -1 - not restored or error */ -int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp, int check_from) +int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp, + int check_from) { struct lump* l; str param_val; @@ -552,7 +560,8 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp, int check LM_ERR("no more pkg mem\n"); goto failed; } - add_to_rr.len = sprintf(add_to_rr.s, ";%.*s=%.*s", rr_param->len,rr_param->s,param_val.len,param_val.s); + add_to_rr.len = sprintf(add_to_rr.s, ";%.*s=%.*s", + rr_param->len, rr_param->s, param_val.len, param_val.s); if ( uac_rrb.add_rr_param(msg, &add_to_rr)!=0 ) { LM_ERR("add rr param failed\n"); @@ -598,10 +607,12 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp, int check avp_value.s.s=old_body->body.s; if(flag==FL_USE_UAC_FROM) { - LM_DBG("Storing in FROM-AVP (for use in reply): '%.*s' with len '%d'\n",avp_value.s.len, avp_value.s.s,avp_value.s.len); + LM_DBG("Storing in FROM-AVP (for use in reply): '%.*s' with len '%d'\n", + avp_value.s.len, avp_value.s.s,avp_value.s.len); add_avp(restore_from_avp_type, restore_from_avp_name, avp_value); } else { - LM_DBG("Storing in TO-AVP (for use in reply): '%.*s' with len '%d'\n",avp_value.s.len, avp_value.s.s,avp_value.s.len); + LM_DBG("Storing in TO-AVP (for use in reply): '%.*s' with len '%d'\n", + avp_value.s.len, avp_value.s.s,avp_value.s.len); add_avp(restore_to_avp_type, restore_to_avp_name, avp_value); } } @@ -770,7 +781,8 @@ void restore_uris_reply(struct cell* t, int type, struct tmcb_params *p) avp_value.s.len=0; if(restore_from_avp.s) { - search_first_avp(restore_from_avp_type, restore_from_avp_name, &avp_value,0); + search_first_avp(restore_from_avp_type, restore_from_avp_name, + &avp_value,0); } if (restore_uri_reply( rpl, rpl->from, req->from, &avp_value.s)) { @@ -789,7 +801,8 @@ void restore_uris_reply(struct cell* t, int type, struct tmcb_params *p) avp_value.s.len=0; if(restore_to_avp.s) { - search_first_avp(restore_to_avp_type, restore_to_avp_name, &avp_value,0); + search_first_avp(restore_to_avp_type, restore_to_avp_name, + &avp_value, 0); } if (restore_uri_reply( rpl, rpl->to, req->to, &avp_value.s)) { @@ -825,8 +838,9 @@ static void replace_callback(struct dlg_cell *dlg, int type, dlgvar_names = (uac_flag==FL_USE_UAC_FROM)?from_dlgvar:to_dlgvar; /* check the request direction */ - if ( ((uac_flag == FL_USE_UAC_TO) && _params->direction == DLG_DIR_DOWNSTREAM) || - ((uac_flag != FL_USE_UAC_TO) && _params->direction == DLG_DIR_UPSTREAM) ) { + if ( ((uac_flag == FL_USE_UAC_TO) && _params->direction == DLG_DIR_DOWNSTREAM) + || ((uac_flag != FL_USE_UAC_TO) + && _params->direction == DLG_DIR_UPSTREAM) ) { /* replace the TO URI */ if ( msg->to==0 && (parse_headers(msg,HDR_TO_F,0)!=0 || msg->to==0) ) { LM_ERR("failed to parse TO hdr\n"); @@ -880,7 +894,8 @@ static void replace_callback(struct dlg_cell *dlg, int type, goto free; } - /* register tm callback to change replies but only if not registered earlier */ + /* register tm callback to change replies, + * but only if not registered earlier */ if (!(msg->msg_flags & (FL_USE_UAC_FROM|FL_USE_UAC_TO)) && uac_tmb.register_tmcb( msg, 0, TMCB_RESPONSE_IN, restore_uris_reply, 0, 0) != 1 ) {