Bladeren bron

siputils: coherent indentation and whitespacing

Daniel-Constantin Mierla 9 jaren geleden
bovenliggende
commit
5a31031e62

+ 13 - 13
modules/siputils/chargingvector.c

@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
@@ -80,7 +80,7 @@ static void sip_generate_charging_vector(char * pcv)
 					if (in->s_addr == LOOPBACK_IP )
 					{
 						if ( ip.s_addr  == 0 )
-						{  
+						{
 							ip=*in;
 						}
 					}
@@ -105,7 +105,7 @@ static void sip_generate_charging_vector(char * pcv)
 	{
 		if ( idx < 7 )
 		{
-			// 3-6 =IP 
+			// 3-6 =IP
 			newConferenceIdentifier[idx]=((ip.s_addr>>(ipx*8))&0xff);
 			ipx++;
 		}
@@ -221,13 +221,13 @@ static int sip_get_charging_vector(struct sip_msg *msg, struct hdr_field ** hf_p
 
 		if ( cmp_hdrname_str(&hf->name, &hdrname) == 0)
 		{
-			/* 
+			/*
 			 * append p charging vector valus after the header name "P-Charging-Vector" and
 			 * the ": " (+2)
 			 */
 			char * pcv_body = pcv_buf + strlen(P_CHARGING_VECTOR) + 2;
 
-			if (hf->body.len > 0) 
+			if (hf->body.len > 0)
 			{
 				memcpy( pcv_body, hf->body.s, hf->body.len );
 				pcv.len = hf->body.len + strlen(P_CHARGING_VECTOR) + 2;
@@ -265,7 +265,7 @@ static int  sip_remove_charging_vector(struct sip_msg *msg, struct hdr_field *hf
 	if ( hf != NULL )
 	{
 		l=del_lump(msg, hf->name.s-msg->buf, hf->len, 0);
-		if (l==0) 
+		if (l==0)
 		{
 			LM_ERR("no memory\n");
 			return -1;
@@ -284,7 +284,7 @@ static int sip_add_charging_vector(struct sip_msg *msg)
 	char * s;
 
 	anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0);
-	if(anchor == 0) 
+	if(anchor == 0)
 	{
 		LM_ERR("can't get anchor\n");
 		return -1;
@@ -311,7 +311,7 @@ int sip_handle_pcv(struct sip_msg *msg, char *flags, char *str2)
 	int generate_pcv = 0;
 	int remove_pcv = 0;
 	int replace_pcv = 0;
-	int i;    
+	int i;
 	str flag_str;
 	struct hdr_field * hf_pcv = NULL;
 
@@ -358,7 +358,7 @@ int sip_handle_pcv(struct sip_msg *msg, char *flags, char *str2)
 		if (i <= 0) return i;
 	}
 
-	/* Generate PCV if 
+	/* Generate PCV if
 	 * - we were asked to generate it and it could not be obtained from the inbound packet
 	 * - or if we were asked to replace it alltogether regardless its former value
 	 */
@@ -379,8 +379,8 @@ int sip_handle_pcv(struct sip_msg *msg, char *flags, char *str2)
 
 		sip_generate_charging_vector(pcv_value);
 
-		pcv.len = snprintf( pcv_body, PVC_BUF_SIZE - 19, "icid-value=%.*s; icid-generated-at=%.*s\r\n", 32, pcv_value, 
-				msg->rcv.bind_address->address_str.len, 
+		pcv.len = snprintf( pcv_body, PVC_BUF_SIZE - 19, "icid-value=%.*s; icid-generated-at=%.*s\r\n", 32, pcv_value,
+				msg->rcv.bind_address->address_str.len,
 				msg->rcv.bind_address->address_str.s );
 		pcv.len += 19;
 
@@ -441,7 +441,7 @@ int pv_get_charging_vector(struct sip_msg *msg, pv_param_t *param, pv_value_t *r
 					break;
 			}
 
-			if ( pcv_pv.len > 0 ) 
+			if ( pcv_pv.len > 0 )
 				return pv_get_strval(msg, param, res, &pcv_pv );
 			else
 				LM_WARN("No value for pseudo-var $pcv but status was %d.\n", pcv_status);

+ 3 - 3
modules/siputils/chargingvector.h

@@ -13,12 +13,12 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-/* 
+/*
  * Support for rfc3455 P-Charging-Vector
  * - parse charging vector from SIP message
  * - generate new unique charging vector

+ 5 - 5
modules/siputils/checks.c

@@ -17,8 +17,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
@@ -354,15 +354,15 @@ int tel2sip(struct sip_msg* _msg, char* _uri, char* _hostpart, char* _res)
 		return -1;
 	}
 
-	/* Remove visual separators before converting to SIP URI. Don't remove 
-	   visual separators in TEL URI parameters (after the first ";") */
+	/* Remove visual separators before converting to SIP URI. Don't remove
+	 * visual separators in TEL URI parameters (after the first ";") */
 	for (i=0, j=0; i < uri.len; i++) {
 		if (in_tel_parameters == 0) {
 			if (uri.s[i] == ';')
 				in_tel_parameters = 1;
 		}
 		if (in_tel_parameters == 0) {
-			if ((uri.s[i] != '-') && (uri.s[i] != '.') && 
+			if ((uri.s[i] != '-') && (uri.s[i] != '.') &&
 					(uri.s[i] != '(') && (uri.s[i] != ')'))
 				tel_uri.s[j++] = tolower(uri.s[i]);
 		} else {

+ 2 - 2
modules/siputils/checks.h

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */

+ 1 - 1
modules/siputils/config.c

@@ -18,7 +18,7 @@
  */
 
 /*!
- * \file 
+ * \file
  * \brief Siputils :: Configuration
  * \ingroup Siputils
  */

+ 1 - 1
modules/siputils/config.h

@@ -17,7 +17,7 @@
  */
 
 /*!
- * \file 
+ * \file
  * \brief Siputils :: Configuration
  * \ingroup siputils
  */

+ 183 - 184
modules/siputils/contact_ops.c

@@ -45,7 +45,7 @@
 
 
 //#define DEBUG
-int
+	int
 encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 {
 
@@ -59,20 +59,20 @@ encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 
 
 	/*
-	 * I have a list of contacts in contact->parsed which is of type contact_body_t 
+	 * I have a list of contacts in contact->parsed which is of type contact_body_t
 	 * inside i have a contact->parsed->contact which is the head of the list of contacts
-	 * inside it is a 
+	 * inside it is a
 	 * str uri;
 	 * struct contact *next;
 	 * I just have to visit each uri and encode each uri according to a scheme
 	 */
-	
+
 	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) ||
 				(msg->contact == NULL) ))
-		{
+	{
 		LM_ERR("no Contact header present\n");
 		return -1;
-		}
+	}
 
 
 	separator = DEFAULT_SEPARATOR[0];
@@ -90,56 +90,56 @@ encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 		{
 			uri = c->uri;
 			res = encode_uri (uri, encoding_prefix, public_ip,separator, &newUri);
-			
+
 			if (res != 0)
-				{
+			{
 				LM_ERR("failed encoding contact.Code %d\n", res);
 #ifdef STRICT_CHECK
 				return res;
 #endif
-				}
+			}
 			else
 				if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
 				{
 					LM_ERR("lumping failed in mangling port \n");
 					return -2;
 				}
-			
+
 			/* encoding next contacts too?*/
 #ifdef ENCODE_ALL_CONTACTS
 			while (c->next != NULL)
 			{
 				c = c->next;
 				uri = c->uri;
-				
+
 				res = encode_uri (uri, encoding_prefix,public_ip,separator,&newUri);
 				if (res != 0)
-					{
+				{
 					LM_ERR("failed encode_uri.Code %d\n",res);
 #ifdef STRICT_CHECK
-				return res;
+					return res;
 #endif
-					}
-				else
-				if (patch (msg, uri.s, uri.len, newUri.s, newUri.len)< 0)
-				{
-					LM_ERR("lumping failed in mangling port \n");
-					return -3;
 				}
+				else
+					if (patch (msg, uri.s, uri.len, newUri.s, newUri.len)< 0)
+					{
+						LM_ERR("lumping failed in mangling port \n");
+						return -3;
+					}
 			} /* while */
 #endif /* ENCODE_ALL_CONTACTS */
 		} /* if c != NULL */
 
 	} /* end if */
 	else /* after parsing still NULL */
-		{
-			LM_ERR("unable to parse Contact header\n");
-			return -4;
-		}
+	{
+		LM_ERR("unable to parse Contact header\n");
+		return -4;
+	}
 	return 1;
 }
 
-int
+	int
 decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 {
 
@@ -153,7 +153,7 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 
 #ifdef DEBUG
 	fprintf (stdout,"---START--------DECODE CONTACT-----------------\n");
-        fprintf (stdout,"%.*s\n",50,msg->buf);
+	fprintf (stdout,"%.*s\n",50,msg->buf);
 	fprintf (stdout, "INITIAL.s=[%.*s]\n", uri.len, uri.s);
 #endif
 
@@ -161,22 +161,22 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 	if (contact_flds_separator != NULL)
 		if (strlen(contact_flds_separator)>=1)
 			separator = contact_flds_separator[0];
-		
+
 	if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0))
 	{
 		uri = msg->first_line.u.request.uri;
-		if (uri.s == NULL) 
+		if (uri.s == NULL)
 			return -1;
 	}
 	else
 	{
 		uri = msg->new_uri;
 	}
-	
+
 	res = decode_uri (uri, separator, &newUri);
-	
+
 #ifdef DEBUG
-	if (res == 0) 
+	if (res == 0)
 		fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s);
 #endif
 	if (res != 0)
@@ -189,18 +189,18 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 	else
 	{
 		/* we do not modify the original first line */
-		if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0)) 
+		if ((msg->new_uri.s == NULL) || (msg->new_uri.len == 0))
 			msg->new_uri = newUri;
 		else
 		{
 			pkg_free(msg->new_uri.s);
 			msg->new_uri = newUri;
-		}		
+		}
 	}
 	return 1;
 }
 
-int
+	int
 decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 {
 
@@ -210,8 +210,8 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 	str newUri;
 	char separator;
 	int res;
-	
-	
+
+
 #ifdef DEBUG
 	str* ruri;
 	fprintf (stdout,"---START--------DECODE CONTACT HEADER-----------------\n");
@@ -219,10 +219,10 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 
 	if ((msg->contact == NULL)&&((parse_headers(msg,HDR_CONTACT_F,0) == -1) ||
 				(msg->contact== NULL) ))
-		{
+	{
 		LM_ERR("no Contact header present\n");
 		return -1;
-		}
+	}
 
 	separator = DEFAULT_SEPARATOR[0];
 	if (contact_flds_separator != NULL)
@@ -237,64 +237,64 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 	ruri = &msg->first_line.u.request.uri;
 	fprintf (stdout, "INITIAL.s=[%.*s]\n", ruri->len, ruri->s);
 #endif
-		
+
 	if (msg->contact->parsed == NULL) parse_contact (msg->contact);
 	if (msg->contact->parsed != NULL)
 	{
 		cb = (contact_body_t *) msg->contact->parsed;
 		c = cb->contacts;
-		// we visit each contact 
-	 if (c != NULL)
-	  {
-		uri = c->uri;
+		// we visit each contact
+		if (c != NULL)
+		{
+			uri = c->uri;
 
-		res = decode_uri (uri, separator, &newUri);
+			res = decode_uri (uri, separator, &newUri);
 #ifdef DEBUG
-		fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s);
+			fprintf (stdout, "newuri.s=[%.*s]\n", newUri.len, newUri.s);
 #endif
-		if (res != 0)
-		{
-			LM_ERR("failed decoding contact.Code %d\n", res);
+			if (res != 0)
+			{
+				LM_ERR("failed decoding contact.Code %d\n", res);
 #ifdef STRICT_CHECK
 				return res;
 #endif
-		}
-		else
-		if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
-		{
-			LM_ERR("lumping failed in mangling port \n");
-			return -2;
-		}
+			}
+			else
+				if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
+				{
+					LM_ERR("lumping failed in mangling port \n");
+					return -2;
+				}
 
 #ifdef DECODE_ALL_CONTACTS
-		while (c->next != NULL)
-		{
-			c = c->next;
-			uri = c->uri;
+			while (c->next != NULL)
+			{
+				c = c->next;
+				uri = c->uri;
 
-			res = decode_uri (uri, separator, &newUri);
-			if (res != 0)
+				res = decode_uri (uri, separator, &newUri);
+				if (res != 0)
 				{
-				LM_ERR("failed decoding contact.Code %d\n",res);
+					LM_ERR("failed decoding contact.Code %d\n",res);
 #ifdef STRICT_CHECK
-				return res;
+					return res;
 #endif
 				}
-			else
-			if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
-			{
-				LM_ERR("lumping failed in mangling port \n");
-				return -3;
-			}
-		} // end while 
+				else
+					if (patch (msg, uri.s, uri.len, newUri.s, newUri.len) < 0)
+					{
+						LM_ERR("lumping failed in mangling port \n");
+						return -3;
+					}
+			} // end while
 #endif
-	   } // if c!= NULL 
-	} // end if 
-	else // after parsing still NULL 
-		{
-			LM_ERR("unable to parse Contact header\n");
-			return -4;
-		}
+		} // if c!= NULL
+	} // end if
+	else // after parsing still NULL
+	{
+		LM_ERR("unable to parse Contact header\n");
+		return -4;
+	}
 #ifdef DEBUG
 	fprintf (stdout,"---END--------DECODE CONTACT HEADER-----------------\n");fflush(stdout);
 #endif
@@ -304,7 +304,7 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 
 
 
-int
+	int
 encode2format (str uri, struct uri_format *format)
 {
 	int foo;
@@ -354,53 +354,52 @@ encode2format (str uri, struct uri_format *format)
 		return foo-10;
 	}
 
-	
+
 	format->username = sipUri.user;
 	format->password = sipUri.passwd;
 	format->ip = sipUri.host;
 	format->port = sipUri.port;
 	format->protocol = sipUri.transport_val;
-	
-#ifdef DEBUG	
+
+#ifdef DEBUG
 	fprintf (stdout, "transport=[%.*s] transportval=[%.*s]\n", sipUri.transport.len,sipUri.transport.s,sipUri.transport_val.len,sipUri.transport_val.s);
 	fprintf(stdout,"First %d,second %d\n",format->first,format->second);
-	#endif
-	
+#endif
+
 	return 0;
 
 }
 
 
-int
+	int
 encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str * result)
 {
 	struct uri_format format;
 	char *pos;
 	int foo,res;
 
-	
 	result->s = NULL;
 	result->len = 0;
 	if (uri.len <= 1)
 		return -1;	/* no contact or an invalid one */
-	if (public_ip == NULL) 
-		{
-			LM_ERR("invalid NULL value for public_ip parameter\n");
-			return -2;
-		}
+	if (public_ip == NULL)
+	{
+		LM_ERR("invalid NULL value for public_ip parameter\n");
+		return -2;
+	}
 #ifdef DEBUG
 	fprintf (stdout, "Primit cerere de encodare a [%.*s] cu %s-%s\n", uri.len,uri.s, encoding_prefix, public_ip);
 #endif
 	fflush (stdout);
 	foo = encode2format (uri, &format);
 	if (foo < 0)
-		{
+	{
 		LM_ERR("unable to encode Contact URI [%.*s].Return code %d\n",uri.len,uri.s,foo);
 		return foo - 20;
-		}
+	}
 #ifdef DEBUG
 	fprintf(stdout,"user=%.*s ip=%.*s port=%.*s protocol=%.*s\n",format.username.len,format.username.s,format.ip.len,format.ip.s,
-	     format.port.len,format.port.s,format.protocol.len,format.protocol.s);   
+			format.port.len,format.port.s,format.protocol.len,format.protocol.s);
 #endif
 
 	/* a complete uri would be sip:username@ip:port;transport=protocol goes to
@@ -418,27 +417,27 @@ encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str
 	result->s = pkg_malloc (result->len);
 	pos = result->s;
 	if (pos == NULL)
-		{
+	{
 #ifdef DEBUG
-			fprintf (stdout, "Unable to alloc result [%d] end=%d\n",result->len, format.second);
+		fprintf (stdout, "Unable to alloc result [%d] end=%d\n",result->len, format.second);
 #endif
-			LM_ERR("unable to alloc pkg memory\n");
-			return -3;
-		}
+		LM_ERR("unable to alloc pkg memory\n");
+		return -3;
+	}
 #ifdef DEBUG
 	fprintf (stdout, "[pass=%d][Allocated %d bytes][first=%d][lengthsec=%d]\nAdding [%d] ->%.*s\n",format.password.len,result->len,format.first,uri.len-format.second,format.first, format.first,uri.s);fflush (stdout);
 #endif
-	 	
+
 	res = snprintf(pos,result->len,"%.*s%s%c%.*s%c%.*s%c%.*s%c%.*s%c%.*s@",format.first,uri.s,encoding_prefix,separator,
-	format.username.len,format.username.s,separator,format.password.len,format.password.s,
-	separator,format.ip.len,format.ip.s,separator,format.port.len,format.port.s,separator,format.protocol.len,format.protocol.s);
+			format.username.len,format.username.s,separator,format.password.len,format.password.s,
+			separator,format.ip.len,format.ip.s,separator,format.port.len,format.port.s,separator,format.protocol.len,format.protocol.s);
 
-	if ((res < 0 )||(res>result->len)) 
-		{
-			LM_ERR("unable to construct new uri.\n");
-			if (result->s != NULL) pkg_free(result->s);
-			return -4;
-		}
+	if ((res < 0 )||(res>result->len))
+	{
+		LM_ERR("unable to construct new uri.\n");
+		if (result->s != NULL) pkg_free(result->s);
+		return -4;
+	}
 #ifdef DEBUG
 	fprintf(stdout,"res= %d\npos=%s\n",res,pos);
 #endif
@@ -447,7 +446,7 @@ encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str
 	pos = pos + strlen (public_ip);
 	memcpy (pos, uri.s + format.second, uri.len - format.second);
 
-#ifdef DEBUG	
+#ifdef DEBUG
 	fprintf (stdout, "Adding2 [%d] ->%.*s\n", uri.len - format.second,uri.len - format.second, uri.s + format.second);
 	fprintf (stdout, "NEW NEW uri is->[%.*s]\n", result->len, result->s);
 #endif
@@ -458,7 +457,7 @@ encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str
 }
 
 
-int
+	int
 decode2format (str uri, char separator, struct uri_format *format)
 {
 	char *start, *end, *pos,*lastpos;
@@ -468,12 +467,12 @@ decode2format (str uri, char separator, struct uri_format *format)
 	//memset (format, 0, sizeof ((struct uri_format)));
 
 	if (uri.s == NULL)
-		{
+	{
 		LM_ERR("invalid parameter uri.It is NULL\n");
 		return -1;
-		}
+	}
 	/* sip:enc_pref*username*password*ip*port*protocol@public_ip */
-	
+
 	start = memchr (uri.s, ':', uri.len);
 	if (start == NULL)
 	{
@@ -482,86 +481,86 @@ decode2format (str uri, char separator, struct uri_format *format)
 	}			/* invalid uri */
 	start = start + 1;	/* jumping over sip: ATENTIE LA BUFFER OVERFLOW DACA E DOAR sip: */
 	format->first = start - uri.s;
-	
+
 	/* start */
 
 	end = memchr(start,'@',uri.len-(start-uri.s));
-	if (end == NULL) 
-		{
+	if (end == NULL)
+	{
 		LM_ERR("invalid SIP uri.Missing @\n");
 		return -3;/* no host address found */
-		}
+	}
 
 #ifdef DEBUG
-		fprintf (stdout, "Decoding %.*s\n", (int)(long)(end-start), start);
+	fprintf (stdout, "Decoding %.*s\n", (int)(long)(end-start), start);
 #endif
-	
+
 	state = EX_PREFIX;
 	lastpos = start;
-	
+
 	for (pos = start;pos<end;pos++)
+	{
+		if (*pos == separator)
 		{
-			if (*pos == separator)
-				{
-					/* we copy between lastpos and pos */
-					tmp.len = pos - lastpos;
-					if (tmp.len>0) tmp.s = lastpos;
-						else tmp.s = NULL;
-					switch (state)
-						{
-							case EX_PREFIX: state = EX_USER;break;
-							case EX_USER:format->username = tmp;state = EX_PASS;break;
-							case EX_PASS:format->password = tmp;state = EX_IP;break;
-							case EX_IP:format->ip = tmp;state = EX_PORT;break;
-							case EX_PORT:format->port = tmp;state = EX_PROT;break;
-							default:
-								{
-								/* this should not happen, we should find @ not separator */
-								return -4;
-								break;
-								}
-						}
-						
-					lastpos = pos+1;
-				
-				}
+			/* we copy between lastpos and pos */
+			tmp.len = pos - lastpos;
+			if (tmp.len>0) tmp.s = lastpos;
+			else tmp.s = NULL;
+			switch (state)
+			{
+				case EX_PREFIX: state = EX_USER;break;
+				case EX_USER:format->username = tmp;state = EX_PASS;break;
+				case EX_PASS:format->password = tmp;state = EX_IP;break;
+				case EX_IP:format->ip = tmp;state = EX_PORT;break;
+				case EX_PORT:format->port = tmp;state = EX_PROT;break;
+				default:
+					{
+						/* this should not happen, we should find @ not separator */
+						return -4;
+						break;
+					}
+			}
+
+			lastpos = pos+1;
+
 		}
-		
-		
+	}
+
+
 	/* we must be in state EX_PROT and protocol is between lastpos and end@ */
 	if (state != EX_PROT) return -6;
 	format->protocol.len = end - lastpos;
 	if (format->protocol.len>0) format->protocol.s = lastpos;
-		else format->protocol.s = NULL;
+	else format->protocol.s = NULL;
 	/* I should check perhaps that 	after @ there is something */
-		
+
 #ifdef DEBUG
-		fprintf (stdout, "username=%.*s\n", format->username.len,format->username.s);
-		fprintf (stdout, "password=%.*s\n", format->password.len,format->password.s);
-		fprintf (stdout, "ip=%.*s\n", format->ip.len, format->ip.s);
-		fprintf (stdout, "port=%.*s\n", format->port.len,format->port.s);
-		fprintf (stdout, "protocol=%.*s\n", format->protocol.len,format->protocol.s);
+	fprintf (stdout, "username=%.*s\n", format->username.len,format->username.s);
+	fprintf (stdout, "password=%.*s\n", format->password.len,format->password.s);
+	fprintf (stdout, "ip=%.*s\n", format->ip.len, format->ip.s);
+	fprintf (stdout, "port=%.*s\n", format->port.len,format->port.s);
+	fprintf (stdout, "protocol=%.*s\n", format->protocol.len,format->protocol.s);
 #endif
 
 	/* looking for the end of public ip */
 	start = end;/*we are now at @ */
 	for(pos = start;pos<uri.s+uri.len;pos++)
+	{
+		if ((*pos == ';')||(*pos == '>'))
 		{
-			if ((*pos == ';')||(*pos == '>'))
-				{
-				/* found end */
-				format->second = pos - uri.s;
-				return 0;
-				}
+			/* found end */
+			format->second = pos - uri.s;
+			return 0;
 		}
+	}
 	/* if we are here we did not find > or ; */
 	format->second = uri.len;
-	return 0;	
-	
+	return 0;
+
 }
 
 
-int
+	int
 decode_uri (str uri, char separator, str * result)
 {
 	char *pos;
@@ -572,59 +571,59 @@ decode_uri (str uri, char separator, str * result)
 	result->len = 0;
 
 	if ((uri.len <= 0) || (uri.s == NULL))
-		{
+	{
 		LM_ERR("invalid value for uri\n");
 		return -1;
-		}
+	}
 
 	foo = decode2format (uri, separator, &format);
 	if (foo < 0)
-		{
+	{
 		LM_ERR("failed to decode Contact uri .Error code %d\n",foo);
 		return foo - 20;
-		}
+	}
 	/* sanity check */
 	if (format.ip.len <= 0)
-		{
-			LM_ERR("unable to decode host address \n");
-			return -2;/* should I quit or ignore ? */
-		}			
+	{
+		LM_ERR("unable to decode host address \n");
+		return -2;/* should I quit or ignore ? */
+	}
 
 	if ((format.password.len > 0) && (format.username.len <= 0))
-		{
-			LM_ERR("password decoded but no username available\n");
-			return -3;
-		}
-		
+	{
+		LM_ERR("password decoded but no username available\n");
+		return -3;
+	}
+
 	/* a complete uri would be sip:username:password@ip:port;transport=protocol goes to
 	 * sip:enc_pref#username#password#ip#port#protocol@public_ip
 	 */
 	result->len = format.first + (uri.len - format.second);	/* not NULL terminated */
 	if (format.username.len > 0) result->len += format.username.len + 1;	//: or @
 	if (format.password.len > 0) result->len += format.password.len + 1;	//@
-		
+
 	/* if (format.ip.len > 0) */	     result->len += format.ip.len;
-		
+
 	if (format.port.len > 0)     result->len += 1 + format.port.len;	//:
 	if (format.protocol.len > 0) result->len += 1 + 10 + format.protocol.len;	//;transport=
 #ifdef DEBUG
 	fprintf (stdout, "Result size is %d.Original Uri size is %d\n",result->len, uri.len);
 #endif
-	
+
 	/* adding one comes from * */
 	result->s = pkg_malloc (result->len);
 	if (result->s == NULL)
-		{
-			LM_ERR("unable to allocate pkg memory\n");
-			return -4;
-		}
+	{
+		LM_ERR("unable to allocate pkg memory\n");
+		return -4;
+	}
 	pos = result->s;
 #ifdef DEBUG
 	fprintf (stdout, "Adding [%d] ->%.*s\n", format.first, format.first,uri.s);fflush (stdout);
 #endif
 	memcpy (pos, uri.s, format.first);	/* till sip: */
 	pos = pos + format.first;
-	
+
 	if (format.username.len > 0)
 	{
 		memcpy (pos, format.username.s, format.username.len);
@@ -644,9 +643,9 @@ decode_uri (str uri, char separator, str * result)
 	}
 	/* if (format.ip.len > 0) */
 
-		memcpy (pos, format.ip.s, format.ip.len);
-		pos = pos + format.ip.len;
-	
+	memcpy (pos, format.ip.s, format.ip.len);
+	pos = pos + format.ip.len;
+
 	if (format.port.len > 0)
 	{
 		memcpy (pos, ":", 1);

+ 1 - 5
modules/siputils/contact_ops.h

@@ -68,15 +68,11 @@ typedef struct uri_format contact_fields_t;
 int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip);
 int decode_contact (struct sip_msg *msg, char *unused1,char *unused2);
 int decode_contact_header (struct sip_msg *msg, char *unused1,char *unused2);
-	
+
 int encode2format (str uri, struct uri_format *format);
 int decode2format (str uri, char separator, struct uri_format *format);
 
 int encode_uri (str uri, char *encoding_prefix, char *public_ip,char separator, str * result);
 int decode_uri (str uri, char separator, str * result);
 
-
-
-
-
 #endif

+ 1 - 1
modules/siputils/options.c

@@ -62,7 +62,7 @@ int opt_reply(struct sip_msg* _msg, char* _foo, char* _bar) {
 	}
 
 	/* calculate the length and allocated the mem */
-	rpl_hf.len = ACPT_STR_LEN + ACPT_ENC_STR_LEN + ACPT_LAN_STR_LEN + 
+	rpl_hf.len = ACPT_STR_LEN + ACPT_ENC_STR_LEN + ACPT_LAN_STR_LEN +
 			SUPT_STR_LEN + 4*HF_SEP_STR_LEN + opt_accept.len + opt_accept_enc.len
 			+ opt_accept_lang.len + opt_supported.len;
 	rpl_hf.s = (char*)pkg_malloc(rpl_hf.len);

+ 3 - 3
modules/siputils/ring.c

@@ -155,7 +155,7 @@ static unsigned int hash(char *buf, int len)
 	unsigned int retval = 0;
 	MD5_CTX md5context;
 	char digest[16];
-	
+
 	MD5Init(&md5context);
 	MD5Update(&md5context, buf, len);
 	MD5Final(digest, &md5context);
@@ -196,7 +196,7 @@ static void insert(str callid)
 {
 	unsigned int index = hash(callid.s, callid.len) & HASHTABLEMASK;
 	struct ring_record_t* rr;
-	
+
 	remove_timeout(index);
 	rr = shm_malloc(sizeof(struct ring_record_t));
 	assert(rr);
@@ -261,7 +261,7 @@ static int conv183(struct sip_msg *msg)
 	char *chunk3_start;
 	int chunk3_len;
 	char *chunk3_dst;
-	
+
 	if (del1_start>del2_start) {
 		char *tmp = del1_start;
 		del1_start = del2_start;

+ 10 - 10
modules/siputils/rpid.c

@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
@@ -97,7 +97,7 @@ void get_rpid_avp( int_str *rpid_avp_p, int *rpid_avp_type_p )
 
 /*!
  * \brief Check if user is a E164 number
- * \param _user user 
+ * \param _user user
  * \note Copy of is_e164 from enum module
  * \return 1 if its a E164 number, -1 if not
  */
@@ -105,7 +105,7 @@ static inline int is_e164(str* _user)
 {
 	int i;
 	char c;
-	
+
 	if ((_user->len > 2) && (_user->len < 17) && ((_user->s)[0] == '+')) {
 		for (i = 1; i < _user->len; i++) {
 			c = (_user->s)[i];
@@ -113,7 +113,7 @@ static inline int is_e164(str* _user)
 		}
 		return 1;
 	} else {
-	    return -1;
+		return -1;
 	}
 }
 
@@ -128,18 +128,18 @@ static inline int is_e164(str* _user)
 static inline int append_rpid_helper(struct sip_msg* _m, str *_s)
 {
 	struct lump* anchor;
-	
+
 	if (parse_headers(_m, HDR_EOH_F, 0) == -1) {
 		LM_ERR("failed to parse message\n");
 		return -1;
 	}
-	
+
 	anchor = anchor_lump(_m, _m->unparsed - _m->buf, 0, 0);
 	if (!anchor) {
 		LM_ERR("can't get anchor\n");
 		return -2;
 	}
-	
+
 	if (!insert_new_lump_before(anchor, _s->s, _s->len, 0)) {
 		LM_ERR("can't insert lump\n");
 		return -3;
@@ -321,8 +321,8 @@ int is_rpid_user_e164(struct sip_msg* _m, char* _s1, char* _s2)
 	}
 
 	if (parse_uri(tmp.s, tmp.len, &uri) < 0) {
-	    LM_ERR("failed to parse RPID URI\n");
-	    goto err;
+		LM_ERR("failed to parse RPID URI\n");
+		goto err;
 	}
 
 	return is_e164(&uri.user);

+ 2 - 2
modules/siputils/rpid.h

@@ -13,8 +13,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */

+ 7 - 7
modules/siputils/sipops.c

@@ -90,7 +90,7 @@ int w_cmp_aor(struct sip_msg *msg, char *uri1, char *uri2)
 
 int w_is_gruu(sip_msg_t *msg, char *uri1, char *p2)
 {
-        str s1, *s2;
+	str s1, *s2;
 	sip_uri_t turi;
 	sip_uri_t *puri;
 
@@ -102,15 +102,15 @@ int w_is_gruu(sip_msg_t *msg, char *uri1, char *p2)
 			return -8;
 		}
 		if(parse_uri(s1.s, s1.len, &turi)!=0) {
-		    LM_ERR("parsing of uri '%.*s' failed\n", s1.len, s1.s);
-		    return -1;
+			LM_ERR("parsing of uri '%.*s' failed\n", s1.len, s1.s);
+			return -1;
 		}
 		puri = &turi;
 	} else {
-  	        if(parse_sip_msg_uri(msg)<0) {
-		    s2 = GET_RURI(msg);
-  		    LM_ERR("parsing of uri '%.*s' failed\n", s2->len, s2->s);
-		    return -1;
+		if(parse_sip_msg_uri(msg)<0) {
+			s2 = GET_RURI(msg);
+			LM_ERR("parsing of uri '%.*s' failed\n", s2->len, s2->s);
+			return -1;
 		}
 		puri = &msg->parsed_uri;
 	}

+ 122 - 122
modules/siputils/siputils.c

@@ -31,27 +31,27 @@
  * \defgroup siputils SIPUTILS :: Various SIP message handling functions
  *
  *
-   This module implement various functions and checks related to
-   SIP message handling and URI handling.
-
-   It offers some functions related to handle ringing. In a
-   parallel forking scenario you get several 183s with SDP. You
-   don't want that your customers hear more than one ringtone or
-   answer machine in parallel on the phone. So its necessary to
-   drop the 183 in this cases and send a 180 instead.
-
-   This module provides a function to answer OPTIONS requests
-   which are directed to the server itself. This means an OPTIONS
-   request which has the address of the server in the request
-   URI, and no username in the URI. The request will be answered
-   with a 200 OK which the capabilities of the server.
-
-   To answer OPTIONS request directed to your server is the
-   easiest way for is-alive-tests on the SIP (application) layer
-   from remote (similar to ICMP echo requests, also known as
-   "ping", on the network layer).
+ *  This module implement various functions and checks related to
+ *  SIP message handling and URI handling.
+ *
+ *  It offers some functions related to handle ringing. In a
+ *  parallel forking scenario you get several 183s with SDP. You
+ *  don't want that your customers hear more than one ringtone or
+ *  answer machine in parallel on the phone. So its necessary to
+ *  drop the 183 in this cases and send a 180 instead.
+ *
+ *  This module provides a function to answer OPTIONS requests
+ *  which are directed to the server itself. This means an OPTIONS
+ *  request which has the address of the server in the request
+ *  URI, and no username in the URI. The request will be answered
+ *  with a 200 OK which the capabilities of the server.
+ *
+ *  To answer OPTIONS request directed to your server is the
+ *  easiest way for is-alive-tests on the SIP (application) layer
+ *  from remote (similar to ICMP echo requests, also known as
+ *  "ping", on the network layer).
 
- */
+*/
 
 #include <assert.h>
 
@@ -132,10 +132,10 @@ static cmd_export_t cmds[]={
 		0, REQUEST_ROUTE|LOCAL_ROUTE},
 	{"add_uri_param",      (cmd_function)add_uri_param,     1, fixup_str_null,
 		0, REQUEST_ROUTE},
-	{"get_uri_param",      (cmd_function)get_uri_param,     2, fixup_get_uri_param, 
+	{"get_uri_param",      (cmd_function)get_uri_param,     2, fixup_get_uri_param,
 		free_fixup_get_uri_param, REQUEST_ROUTE|LOCAL_ROUTE},
 	{"tel2sip", (cmd_function)tel2sip, 3, fixup_tel2sip, 0,
-	 REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE},
+		REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE},
 	{"is_e164",            (cmd_function)is_e164,           1, fixup_pvar_null,
 		fixup_free_pvar_null, REQUEST_ROUTE|FAILURE_ROUTE|LOCAL_ROUTE},
 	{"is_uri_user_e164",   (cmd_function)w_is_uri_user_e164,  1, fixup_pvar_null,
@@ -151,21 +151,21 @@ static cmd_export_t cmds[]={
 	{"cmp_aor",  (cmd_function)w_cmp_aor,                   2, fixup_spve_spve,
 		0, ANY_ROUTE},
 	{"is_rpid_user_e164",   (cmd_function)is_rpid_user_e164, 0, 0,
-			0, REQUEST_ROUTE},
+		0, REQUEST_ROUTE},
 	{"append_rpid_hf",      (cmd_function)append_rpid_hf,    0, 0,
-			0, REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
+		0, REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
 	{"append_rpid_hf",      (cmd_function)append_rpid_hf_p,  2, fixup_str_str,
-			0, REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
+		0, REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE},
 	{"set_uri_user", (cmd_function)set_uri_user,             2, fixup_set_uri,
-		    fixup_free_set_uri,	ANY_ROUTE},
+		fixup_free_set_uri,	ANY_ROUTE},
 	{"set_uri_host", (cmd_function)set_uri_host,             2, fixup_set_uri,
-		    fixup_free_set_uri,	ANY_ROUTE},
+		fixup_free_set_uri,	ANY_ROUTE},
 	{"bind_siputils",       (cmd_function)bind_siputils,           1, 0,
-			0, 0},
+		0, 0},
 	{"is_request",          (cmd_function)w_is_request,            0, 0,
-			0, ANY_ROUTE},
+		0, ANY_ROUTE},
 	{"is_reply",            (cmd_function)w_is_reply,              0, 0,
-			0, ANY_ROUTE},
+		0, ANY_ROUTE},
 	{"is_gruu",  (cmd_function)w_is_gruu,                    0, 0,
 		0, ANY_ROUTE},
 	{"is_gruu",  (cmd_function)w_is_gruu,                    1, fixup_spve_null,
@@ -197,7 +197,7 @@ static param_export_t params[] = {
 };
 
 
- static pv_export_t mod_pvs[] =  {
+static pv_export_t mod_pvs[] =  {
 	{ {"pcv", (sizeof("pvc")-1)}, PVT_OTHER, pv_get_charging_vector,
 		0, pv_parse_charging_vector_name, 0, 0, 0},
 
@@ -242,7 +242,7 @@ static int mod_init(void)
 		LM_ERR("cannot bind to SL API\n");
 		return -1;
 	}
-	
+
 	if ( init_rpid_avp(rpid_avp_param)<0 ) {
 		LM_ERR("failed to init rpid AVP name\n");
 		return -1;
@@ -293,24 +293,24 @@ int bind_siputils(siputils_api_t* api)
  */
 static int fixup_set_uri(void** param, int param_no)
 {
-    if (param_no == 1) {
-	if (fixup_pvar_null(param, 1) != 0) {
-	    LM_ERR("failed to fixup uri pvar\n");
-	    return -1;
-	}
-	if (((pv_spec_t *)(*param))->setf == NULL) {
-	    LM_ERR("uri pvar is not writeble\n");
-	    return -1;
+	if (param_no == 1) {
+		if (fixup_pvar_null(param, 1) != 0) {
+			LM_ERR("failed to fixup uri pvar\n");
+			return -1;
+		}
+		if (((pv_spec_t *)(*param))->setf == NULL) {
+			LM_ERR("uri pvar is not writeble\n");
+			return -1;
+		}
+		return 0;
 	}
-	return 0;
-    }
 
-    if (param_no == 2) {
-	return fixup_pvar_null(param, 1);
-    }
+	if (param_no == 2) {
+		return fixup_pvar_null(param, 1);
+	}
 
-    LM_ERR("invalid parameter number <%d>\n", param_no);
-    return -1;
+	LM_ERR("invalid parameter number <%d>\n", param_no);
+	return -1;
 }
 
 /*
@@ -318,7 +318,7 @@ static int fixup_set_uri(void** param, int param_no)
  */
 static int fixup_free_set_uri(void** param, int param_no)
 {
-    return fixup_free_pvar_null(param, 1);
+	return fixup_free_pvar_null(param, 1);
 }
 
 
@@ -328,28 +328,28 @@ static int fixup_free_set_uri(void** param, int param_no)
  */
 static int fixup_tel2sip(void** param, int param_no)
 {
-    if ((param_no == 1) || (param_no == 2)) {
-	if (fixup_var_str_12(param, 1) < 0) {
-	    LM_ERR("failed to fixup uri or hostpart pvar\n");
-	    return -1;
+	if ((param_no == 1) || (param_no == 2)) {
+		if (fixup_var_str_12(param, 1) < 0) {
+			LM_ERR("failed to fixup uri or hostpart pvar\n");
+			return -1;
+		}
+		return 0;
 	}
-	return 0;
-    }
 
-    if (param_no == 3) {
-	if (fixup_pvar_null(param, 1) != 0) {
-	    LM_ERR("failed to fixup result pvar\n");
-	    return -1;
-	}
-	if (((pv_spec_t *)(*param))->setf == NULL) {
-	    LM_ERR("result pvar is not writeble\n");
-	    return -1;
+	if (param_no == 3) {
+		if (fixup_pvar_null(param, 1) != 0) {
+			LM_ERR("failed to fixup result pvar\n");
+			return -1;
+		}
+		if (((pv_spec_t *)(*param))->setf == NULL) {
+			LM_ERR("result pvar is not writeble\n");
+			return -1;
+		}
+		return 0;
 	}
-	return 0;
-    }
 
-    LM_ERR("invalid parameter number <%d>\n", param_no);
-    return -1;
+	LM_ERR("invalid parameter number <%d>\n", param_no);
+	return -1;
 }
 
 /* */
@@ -389,65 +389,65 @@ static int free_fixup_get_uri_param(void** param, int param_no) {
 /* */
 static int fixup_option(void** param, int param_no) {
 
-    char *option;
-    unsigned int option_len, res;
+	char *option;
+	unsigned int option_len, res;
 
-    option = (char *)*param;
-    option_len = strlen(option);
+	option = (char *)*param;
+	option_len = strlen(option);
 
-    if (param_no != 1) {
-	LM_ERR("invalid parameter number <%d>\n", param_no);
-	return -1;
-    }
-
-    switch (option_len) {
-    case 4:
-	if (strncasecmp(option, "path", 4) == 0)
-	    res = F_OPTION_TAG_PATH;
-	else if (strncasecmp(option, "gruu", 4) == 0)
-	    res = F_OPTION_TAG_GRUU;
-	else {
-	    LM_ERR("unknown option <%s>\n", option);
-	    return -1;
-	}
-	break;
-    case 5:
-	if (strncasecmp(option, "timer", 5) == 0)
-	    res = F_OPTION_TAG_TIMER;
-	else {
-	    LM_ERR("unknown option <%s>\n", option);
-	    return -1;
-	}
-	break;
-    case 6:
-	if (strncasecmp(option, "100rel", 6) == 0)
-	    res = F_OPTION_TAG_100REL;
-	else {
-	    LM_ERR("unknown option <%s>\n", option);
-	    return -1;
-	}
-	break;
-    case 8:
-	if (strncasecmp(option, "outbound", 8) == 0)
-	    res = F_OPTION_TAG_OUTBOUND;
-	else {
-	    LM_ERR("unknown option <%s>\n", option);
-	    return -1;
+	if (param_no != 1) {
+		LM_ERR("invalid parameter number <%d>\n", param_no);
+		return -1;
 	}
-	break;
-    case 9:
-	if (strncasecmp(option, "eventlist", 9) == 0)
-	    res = F_OPTION_TAG_EVENTLIST;
-	else {
-	    LM_ERR("unknown option <%s>\n", option);
-	    return -1;
+
+	switch (option_len) {
+		case 4:
+			if (strncasecmp(option, "path", 4) == 0)
+				res = F_OPTION_TAG_PATH;
+			else if (strncasecmp(option, "gruu", 4) == 0)
+				res = F_OPTION_TAG_GRUU;
+			else {
+				LM_ERR("unknown option <%s>\n", option);
+				return -1;
+			}
+			break;
+		case 5:
+			if (strncasecmp(option, "timer", 5) == 0)
+				res = F_OPTION_TAG_TIMER;
+			else {
+				LM_ERR("unknown option <%s>\n", option);
+				return -1;
+			}
+			break;
+		case 6:
+			if (strncasecmp(option, "100rel", 6) == 0)
+				res = F_OPTION_TAG_100REL;
+			else {
+				LM_ERR("unknown option <%s>\n", option);
+				return -1;
+			}
+			break;
+		case 8:
+			if (strncasecmp(option, "outbound", 8) == 0)
+				res = F_OPTION_TAG_OUTBOUND;
+			else {
+				LM_ERR("unknown option <%s>\n", option);
+				return -1;
+			}
+			break;
+		case 9:
+			if (strncasecmp(option, "eventlist", 9) == 0)
+				res = F_OPTION_TAG_EVENTLIST;
+			else {
+				LM_ERR("unknown option <%s>\n", option);
+				return -1;
+			}
+			break;
+		default:
+			LM_ERR("unknown option <%s>\n", option);
+			return -1;
 	}
-	break;
-    default:
-	LM_ERR("unknown option <%s>\n", option);
-	return -1;
-    }
 
-    *param = (void *)(long)res;
-    return 0;
+	*param = (void *)(long)res;
+	return 0;
 }

+ 7 - 7
modules/siputils/siputils.h

@@ -45,13 +45,13 @@ int bind_siputils(siputils_api_t* api);
 
 inline static int siputils_load_api(siputils_api_t *pxb)
 {
-        bind_siputils_t bind_siputils_exports;
-        if (!(bind_siputils_exports = (bind_siputils_t)find_export("bind_siputils", 1, 0)))
-        {
-                LM_ERR("Failed to import bind_siputils\n");
-                return -1;
-        }
-        return bind_siputils_exports(pxb);
+	bind_siputils_t bind_siputils_exports;
+	if (!(bind_siputils_exports = (bind_siputils_t)find_export("bind_siputils", 1, 0)))
+	{
+		LM_ERR("Failed to import bind_siputils\n");
+		return -1;
+	}
+	return bind_siputils_exports(pxb);
 }
 
 #endif

+ 2 - 3
modules/siputils/utils.c

@@ -41,7 +41,7 @@
 
 int
 patch (struct sip_msg *msg, char *oldstr, unsigned int oldlen, char *newstr,
-       unsigned int newlen)
+		unsigned int newlen)
 {
 	int off;
 	struct lump *anchor;
@@ -105,8 +105,7 @@ patch_content_length (struct sip_msg *msg, unsigned int newValue)
 	}
 	memcpy (s, pos, len);
 	/* perhaps we made it and no one called int2str,might use sprintf */
-	if (patch
-	    (msg, contentLength->body.s, contentLength->body.len, s, len) < 0)
+	if (patch(msg, contentLength->body.s, contentLength->body.len, s, len)<0)
 	{
 		pkg_free (s);
 		LM_ERR("lumping failed\n");

+ 4 - 4
modules/siputils/utils.h

@@ -34,22 +34,22 @@
 
 #include "../../parser/msg_parser.h"	/* struct sip_msg */
 
-/*  replace a part of a sip message identified by (start address,length) with a new part 
+/*  replace a part of a sip message identified by (start address,length) with a new part
 	@param msg a pointer to a sip message
 	@param oldstr the start address of the part to be modified
 	@param oldlen the length of the part being modified
 	@param newstr the start address of the part to be added
 	@param oldlen the length of the part being added
-	@return 0 in case of success, negative on error 
+	@return 0 in case of success, negative on error
 */
 
 int patch (struct sip_msg *msg, char *oldstr, unsigned int oldlen,
-	   char *newstr, unsigned int newlen);
+		char *newstr, unsigned int newlen);
 /*
 	modify the Content-Length header of a sip message
 	@param msg a pointer to a sip message
 	@param newValue the new value of Content-Length
-	@return 0 in case of success, negative on error 
+	@return 0 in case of success, negative on error
 */
 int patch_content_length (struct sip_msg *msg, unsigned int newValue);