Browse Source

kamailio.cfg: more coherent use of curly braces for blocks

- use them always when execution actions in if-else blocks that are not
  return-exit-drop
- single line blocks with return-exit-drop made single line with the if
  statement
Daniel-Constantin Mierla 9 years ago
parent
commit
3db2f281af
1 changed files with 26 additions and 28 deletions
  1. 26 28
      etc/kamailio.cfg

+ 26 - 28
etc/kamailio.cfg

@@ -489,8 +489,9 @@ request_route {
 	# record routing for dialog forming requests (in case they are routed)
 	# record routing for dialog forming requests (in case they are routed)
 	# - remove preloaded route headers
 	# - remove preloaded route headers
 	remove_hf("Route");
 	remove_hf("Route");
-	if (is_method("INVITE|SUBSCRIBE"))
+	if (is_method("INVITE|SUBSCRIBE")) {
 		record_route();
 		record_route();
+	}
 
 
 	# account only INVITEs
 	# account only INVITEs
 	if (is_method("INVITE")) {
 	if (is_method("INVITE")) {
@@ -594,12 +595,10 @@ route[WITHINDLG] {
 		if (is_method("BYE")) {
 		if (is_method("BYE")) {
 			setflag(FLT_ACC); # do accounting ...
 			setflag(FLT_ACC); # do accounting ...
 			setflag(FLT_ACCFAILED); # ... even if the transaction fails
 			setflag(FLT_ACCFAILED); # ... even if the transaction fails
-		}
-		else if ( is_method("ACK") ) {
+		} else if ( is_method("ACK") ) {
 			# ACK is forwarded statelessy
 			# ACK is forwarded statelessy
 			route(NATMANAGE);
 			route(NATMANAGE);
-		}
-		else if ( is_method("NOTIFY") ) {
+		} else if ( is_method("NOTIFY") ) {
 			# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
 			# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
 			record_route();
 			record_route();
 		}
 		}
@@ -639,8 +638,9 @@ route[REGISTRAR] {
 		setbflag(FLB_NATSIPPING);
 		setbflag(FLB_NATSIPPING);
 #!endif
 #!endif
 	}
 	}
-	if (!save("location"))
+	if (!save("location")) {
 		sl_reply_error();
 		sl_reply_error();
+	}
 	exit;
 	exit;
 }
 }
 
 
@@ -649,15 +649,18 @@ route[LOCATION] {
 
 
 #!ifdef WITH_SPEEDDIAL
 #!ifdef WITH_SPEEDDIAL
 	# search for short dialing - 2-digit extension
 	# search for short dialing - 2-digit extension
-	if($rU=~"^[0-9][0-9]$")
-		if(sd_lookup("speed_dial"))
+	if($rU=~"^[0-9][0-9]$") {
+		if(sd_lookup("speed_dial")) {
 			route(SIPOUT);
 			route(SIPOUT);
+		}
+	}
 #!endif
 #!endif
 
 
 #!ifdef WITH_ALIASDB
 #!ifdef WITH_ALIASDB
 	# search in DB-based aliases
 	# search in DB-based aliases
-	if(alias_db_lookup("dbaliases"))
+	if(alias_db_lookup("dbaliases")) {
 		route(SIPOUT);
 		route(SIPOUT);
+	}
 #!endif
 #!endif
 
 
 	$avp(oexten) = $rU;
 	$avp(oexten) = $rU;
@@ -687,8 +690,7 @@ route[LOCATION] {
 
 
 # Presence server processing
 # Presence server processing
 route[PRESENCE] {
 route[PRESENCE] {
-	if(!is_method("PUBLISH|SUBSCRIBE"))
-		return;
+	if(!is_method("PUBLISH|SUBSCRIBE")) return;
 
 
 	if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
 	if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
 		route(TOVOICEMAIL);
 		route(TOVOICEMAIL);
@@ -732,8 +734,7 @@ route[AUTH] {
 	}
 	}
 #!endif
 #!endif
 
 
-	if (is_method("REGISTER") || from_uri==myself)
-	{
+	if (is_method("REGISTER") || from_uri==myself) {
 		# authenticate requests
 		# authenticate requests
 		if (!auth_check("$fd", "subscriber", "1")) {
 		if (!auth_check("$fd", "subscriber", "1")) {
 			auth_challenge("$fd", "0");
 			auth_challenge("$fd", "0");
@@ -762,8 +763,9 @@ route[NATDETECT] {
 		if (is_method("REGISTER")) {
 		if (is_method("REGISTER")) {
 			fix_nated_register();
 			fix_nated_register();
 		} else {
 		} else {
-			if(is_first_hop())
+			if(is_first_hop()) {
 				set_contact_alias();
 				set_contact_alias();
+			}
 		}
 		}
 		setflag(FLT_NATS);
 		setflag(FLT_NATS);
 	}
 	}
@@ -781,8 +783,7 @@ route[NATMANAGE] {
 			}
 			}
 		}
 		}
 	}
 	}
-	if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
-		return;
+	if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;
 
 
 	if(nat_uac_test("8")) {
 	if(nat_uac_test("8")) {
 		rtpproxy_manage("co");
 		rtpproxy_manage("co");
@@ -838,8 +839,7 @@ route[PSTN] {
 	# route to PSTN dialed numbers starting with '+' or '00'
 	# route to PSTN dialed numbers starting with '+' or '00'
 	#     (international format)
 	#     (international format)
 	# - update the condition to match your dialing rules for PSTN routing
 	# - update the condition to match your dialing rules for PSTN routing
-	if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
-		return;
+	if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$")) return;
 
 
 	# only local users allowed to call
 	# only local users allowed to call
 	if(from_uri!=myself) {
 	if(from_uri!=myself) {
@@ -883,8 +883,7 @@ route[XMLRPC] {
 # Routing to voicemail server
 # Routing to voicemail server
 route[TOVOICEMAIL] {
 route[TOVOICEMAIL] {
 #!ifdef WITH_VOICEMAIL
 #!ifdef WITH_VOICEMAIL
-	if(!is_method("INVITE|SUBSCRIBE"))
-		return;
+	if(!is_method("INVITE|SUBSCRIBE")) return;
 
 
 	# check if VoiceMail server IP is defined
 	# check if VoiceMail server IP is defined
 	if (strempty($sel(cfg_get.voicemail.srv_ip))) {
 	if (strempty($sel(cfg_get.voicemail.srv_ip))) {
@@ -892,13 +891,13 @@ route[TOVOICEMAIL] {
 		return;
 		return;
 	}
 	}
 	if(is_method("INVITE")) {
 	if(is_method("INVITE")) {
-		if($avp(oexten)==$null)
-			return;
+		if($avp(oexten)==$null) return;
+
 		$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
 		$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
 				+ ":" + $sel(cfg_get.voicemail.srv_port);
 				+ ":" + $sel(cfg_get.voicemail.srv_port);
 	} else {
 	} else {
-		if($rU==$null)
-			return;
+		if($rU==$null) return;
+
 		$ru = "sip:" + $rU + "@" + $sel(cfg_get.voicemail.srv_ip)
 		$ru = "sip:" + $rU + "@" + $sel(cfg_get.voicemail.srv_ip)
 				+ ":" + $sel(cfg_get.voicemail.srv_port);
 				+ ":" + $sel(cfg_get.voicemail.srv_port);
 	}
 	}
@@ -918,17 +917,16 @@ branch_route[MANAGE_BRANCH] {
 # Manage incoming replies
 # Manage incoming replies
 onreply_route[MANAGE_REPLY] {
 onreply_route[MANAGE_REPLY] {
 	xdbg("incoming reply\n");
 	xdbg("incoming reply\n");
-	if(status=~"[12][0-9][0-9]")
+	if(status=~"[12][0-9][0-9]") {
 		route(NATMANAGE);
 		route(NATMANAGE);
+	}
 }
 }
 
 
 # Manage failure routing cases
 # Manage failure routing cases
 failure_route[MANAGE_FAILURE] {
 failure_route[MANAGE_FAILURE] {
 	route(NATMANAGE);
 	route(NATMANAGE);
 
 
-	if (t_is_canceled()) {
-		exit;
-	}
+	if (t_is_canceled()) exit;
 
 
 #!ifdef WITH_BLOCK3XX
 #!ifdef WITH_BLOCK3XX
 	# block call redirect based on 3xx replies.
 	# block call redirect based on 3xx replies.