2
0
Эх сурвалжийг харах

tsilo: clang-format for coherent indentation and coding style

Victor Seva 2 жил өмнө
parent
commit
8187f19564

+ 32 - 25
src/modules/tsilo/ts_append.c

@@ -36,9 +36,10 @@
 #include "ts_hash.h"
 #include "ts_append.h"
 
-int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
-	ts_urecord_t* _r;
-	ts_transaction_t* ptr;
+int ts_append(struct sip_msg *msg, str *ruri, str *contact, char *table)
+{
+	ts_urecord_t *_r;
+	ts_transaction_t *ptr;
 
 	struct sip_uri p_uri;
 	struct sip_uri c_uri;
@@ -48,7 +49,7 @@ int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
 	int appended;
 
 	/* parse R-URI */
-	if (use_domain) {
+	if(use_domain) {
 		t_uri = ruri;
 	} else {
 		if(parse_uri(ruri->s, ruri->len, &p_uri) < 0) {
@@ -60,7 +61,7 @@ int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
 
 	/* parse contact if given */
 	if(contact->s != NULL && contact->len != 0) {
-		if (parse_uri(contact->s, contact->len, &c_uri) < 0) {
+		if(parse_uri(contact->s, contact->len, &c_uri) < 0) {
 			LM_ERR("failed to parse contact %.*s\n", contact->len, contact->s);
 			return -1;
 		}
@@ -71,7 +72,7 @@ int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
 
 	res = get_ts_urecord(t_uri, &_r);
 
-	if (res != 0) {
+	if(res != 0) {
 		LM_DBG("no record for %.*s\n", t_uri->len, t_uri->s);
 		unlock_entry_by_ruri(t_uri);
 		return -2;
@@ -81,10 +82,12 @@ int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
 	ptr = _r->transactions;
 
 	while(ptr) {
-		LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s);
+		LM_DBG("transaction %u:%u found for %.*s, going to append branches\n",
+				ptr->tindex, ptr->tlabel, t_uri->len, t_uri->s);
 
-		appended = ts_append_to(msg, ptr->tindex, ptr->tlabel, table, ruri, contact);
-		if (appended > 0)
+		appended = ts_append_to(
+				msg, ptr->tindex, ptr->tlabel, table, ruri, contact);
+		if(appended > 0)
 			update_stat(added_branches, appended);
 		ptr = ptr->next;
 	}
@@ -94,38 +97,40 @@ int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table) {
 	return 1;
 }
 
-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact) {
-	struct cell     *t=0;
-	struct cell     *orig_t;	/* a pointer to an existing transaction or 0 if lookup fails */
+int ts_append_to(struct sip_msg *msg, int tindex, int tlabel, char *table,
+		str *uri, str *contact)
+{
+	struct cell *t = 0;
+	struct cell *
+			orig_t; /* a pointer to an existing transaction or 0 if lookup fails */
 	struct sip_msg *orig_msg;
 	int ret;
 	str stable;
 	int orig_branch;
 
-	if(contact->s!=NULL && contact->len > 0) {
-		LM_DBG("trying to append based on specific contact <%.*s>\n", contact->len, contact->s);
+	if(contact->s != NULL && contact->len > 0) {
+		LM_DBG("trying to append based on specific contact <%.*s>\n",
+				contact->len, contact->s);
 	}
 
 	orig_t = _tmb.t_gett();
-	orig_branch =  _tmb.t_gett_branch();
+	orig_branch = _tmb.t_gett_branch();
 
 	/* lookup a transaction based on its identifier (hash_index:label) */
-	if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0)
-	{
-		LM_ERR("transaction [%u:%u] not found\n",	tindex, tlabel);
+	if(_tmb.t_lookup_ident(&t, tindex, tlabel) < 0) {
+		LM_ERR("transaction [%u:%u] not found\n", tindex, tlabel);
 		ret = -1;
 		goto done;
 	}
 
 	/* check if the dialog is still in the early stage */
-	if (t->flags & T_CANCELED) {
-		LM_DBG("trasaction [%u:%u] was cancelled\n",
-				tindex, tlabel);
+	if(t->flags & T_CANCELED) {
+		LM_DBG("trasaction [%u:%u] was cancelled\n", tindex, tlabel);
 		ret = -2;
 		goto done;
 	}
 
-	if (t->uas.status >= 200) {
+	if(t->uas.status >= 200) {
 		LM_DBG("trasaction [%u:%u] sent out a final response already - %d\n",
 				tindex, tlabel, t->uas.status);
 		ret = -3;
@@ -137,14 +142,15 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *
 	stable.s = table;
 	stable.len = strlen(stable.s);
 
-	if(uri==NULL || uri->s==NULL || uri->len<=0) {
+	if(uri == NULL || uri->s == NULL || uri->len <= 0) {
 		ret = _regapi.lookup_to_dset(orig_msg, &stable, NULL);
 	} else {
 		ret = _regapi.lookup_to_dset(orig_msg, &stable, uri);
 	}
 
 	if(ret != 1) {
-		LM_ERR("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel, ret);
+		LM_ERR("transaction %u:%u: error updating dset (%d)\n", tindex, tlabel,
+				ret);
 		ret = -4;
 		goto done;
 	}
@@ -156,7 +162,8 @@ int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *
 done:
 	/* unref the transaction which had been referred by t_lookup_ident() call.
 	 * Restore the original transaction (if any) */
-	if(t) _tmb.unref_cell(t);
+	if(t)
+		_tmb.unref_cell(t);
 	_tmb.t_sett(orig_t, orig_branch);
 
 	return ret;

+ 3 - 2
src/modules/tsilo/ts_append.h

@@ -22,7 +22,8 @@
 #ifndef _TS_APPEND_H
 #define _TS_APPEND_H
 
-int ts_append(struct sip_msg* msg, str *ruri, str *contact, char *table);
-int ts_append_to(struct sip_msg* msg, int tindex, int tlabel, char *table, str *uri, str *contact);
+int ts_append(struct sip_msg *msg, str *ruri, str *contact, char *table);
+int ts_append_to(struct sip_msg *msg, int tindex, int tlabel, char *table,
+		str *uri, str *contact);
 
 #endif

+ 28 - 20
src/modules/tsilo/ts_handlers.c

@@ -38,53 +38,61 @@ extern struct ts_table *t_table;
  */
 int ts_set_tm_callbacks(struct cell *t, sip_msg_t *req, ts_transaction_t *ts)
 {
-	ts_transaction_t* ts_clone;
+	ts_transaction_t *ts_clone;
 
-	if(t==NULL)
+	if(t == NULL)
 		return -1;
 
-	if ( (ts_clone=clone_ts_transaction(ts)) == NULL ) {
+	if((ts_clone = clone_ts_transaction(ts)) == NULL) {
 		LM_ERR("failed to clone transaction\n");
 		return -1;
 	}
 
-	if ( _tmb.register_tmcb( req, t,TMCB_DESTROY,
-			ts_onreply, (void*)ts_clone, free_ts_transaction)<0 ) {
-		LM_ERR("failed to register TMCB for transaction %d:%d\n", t->hash_index, t->label);
+	if(_tmb.register_tmcb(req, t, TMCB_DESTROY, ts_onreply, (void *)ts_clone,
+			   free_ts_transaction)
+			< 0) {
+		LM_ERR("failed to register TMCB for transaction %d:%d\n", t->hash_index,
+				t->label);
 		return -1;
 	}
-	LM_DBG("registered TMCB for transaction %d:%d\n", ts_clone->tindex, ts_clone->tlabel);
+	LM_DBG("registered TMCB for transaction %d:%d\n", ts_clone->tindex,
+			ts_clone->tlabel);
 
 	return 0;
 }
 
-void ts_onreply(struct cell* t, int type, struct tmcb_params *param)
+void ts_onreply(struct cell *t, int type, struct tmcb_params *param)
 {
-	ts_urecord_t* _r;
-	ts_entry_t* _e;
+	ts_urecord_t *_r;
+	ts_entry_t *_e;
 	ts_transaction_t *cb_ptr, *ptr;
 
-	if(t_table==0) return;
-	if((type & (TMCB_DESTROY)) && destroy_modules_phase()) return;
+	if(t_table == 0)
+		return;
+	if((type & (TMCB_DESTROY)) && destroy_modules_phase())
+		return;
 
-	cb_ptr = (ts_transaction_t*)(*param->param);
-	if (cb_ptr == NULL) {
+	cb_ptr = (ts_transaction_t *)(*param->param);
+	if(cb_ptr == NULL) {
 		LM_DBG("NULL param for type %d\n", type);
 		return;
 	}
 
-	if (type &(TMCB_DESTROY)) {
-		LM_DBG("TMCB_DESTROY called for transaction %u:%u\n", cb_ptr->tindex, cb_ptr->tlabel);
+	if(type & (TMCB_DESTROY)) {
+		LM_DBG("TMCB_DESTROY called for transaction %u:%u\n", cb_ptr->tindex,
+				cb_ptr->tlabel);
 		_r = cb_ptr->urecord;
 		_e = _r->entry;
 		lock_entry(_e);
 		ptr = _r->transactions;
 		while(ptr) {
-			if ((ptr->tindex == cb_ptr->tindex) && (ptr->tlabel == cb_ptr->tlabel)) {
+			if((ptr->tindex == cb_ptr->tindex)
+					&& (ptr->tlabel == cb_ptr->tlabel)) {
 				remove_ts_transaction(ptr);
 
-				if (_r->transactions == NULL) {
-					LM_DBG("last transaction for %.*s, removing urecord\n", _r->ruri.len, _r->ruri.s);
+				if(_r->transactions == NULL) {
+					LM_DBG("last transaction for %.*s, removing urecord\n",
+							_r->ruri.len, _r->ruri.s);
 					remove_ts_urecord(_r);
 				}
 				unlock_entry(_e);
@@ -92,7 +100,7 @@ void ts_onreply(struct cell* t, int type, struct tmcb_params *param)
 			}
 			ptr = ptr->next;
 		}
-		LM_DBG("transaction %u:%u not found\n",cb_ptr->tindex, cb_ptr->tlabel);
+		LM_DBG("transaction %u:%u not found\n", cb_ptr->tindex, cb_ptr->tlabel);
 		unlock_entry(_e);
 	} else {
 		LM_DBG("called with unknown type %d\n", type);

+ 1 - 1
src/modules/tsilo/ts_handlers.h

@@ -36,6 +36,6 @@ int ts_set_tm_callbacks(struct cell *t, sip_msg_t *req, ts_transaction_t *ts);
 /*
  *
  */
-void ts_onreply(struct cell* t, int type, struct tmcb_params *param);
+void ts_onreply(struct cell *t, int type, struct tmcb_params *param);
 
 #endif

+ 75 - 71
src/modules/tsilo/ts_hash.c

@@ -47,7 +47,7 @@ struct ts_table *t_table = 0;
 void free_ts_urecord(struct ts_urecord *urecord)
 {
 	LM_DBG("destroying urecord %p\n", urecord);
-	ts_transaction_t* ptr;
+	ts_transaction_t *ptr;
 
 	while(urecord->transactions) {
 		ptr = urecord->transactions;
@@ -55,7 +55,8 @@ void free_ts_urecord(struct ts_urecord *urecord)
 		free_ts_transaction(ptr);
 	}
 
-	if (urecord->ruri.s) shm_free(urecord->ruri.s);
+	if(urecord->ruri.s)
+		shm_free(urecord->ruri.s);
 
 	shm_free(urecord);
 
@@ -72,22 +73,22 @@ int init_ts_table(unsigned int size)
 	unsigned int n;
 	unsigned int i;
 
-	t_table = (struct ts_table*)shm_malloc( sizeof(struct ts_table));
-	if (t_table==0) {
+	t_table = (struct ts_table *)shm_malloc(sizeof(struct ts_table));
+	if(t_table == 0) {
 		SHM_MEM_ERROR;
 		return -1;
 	}
 
-	memset( t_table, 0, sizeof(struct ts_table) );
+	memset(t_table, 0, sizeof(struct ts_table));
 
 	t_table->size = size;
 
-	n = (size<MAX_TS_LOCKS)?size:MAX_TS_LOCKS;
-	for(  ; n>=MIN_TS_LOCKS ; n-- ) {
+	n = (size < MAX_TS_LOCKS) ? size : MAX_TS_LOCKS;
+	for(; n >= MIN_TS_LOCKS; n--) {
 		t_table->locks = lock_set_alloc(n);
-		if (t_table->locks==0)
+		if(t_table->locks == 0)
 			continue;
-		if (lock_set_init(t_table->locks)==0) {
+		if(lock_set_init(t_table->locks) == 0) {
 			lock_set_dealloc(t_table->locks);
 			t_table->locks = 0;
 			continue;
@@ -96,27 +97,27 @@ int init_ts_table(unsigned int size)
 		break;
 	}
 
-	if (t_table->locks==0) {
+	if(t_table->locks == 0) {
 		LM_ERR("unable to allocted at least %d locks for the hash table\n",
-			MIN_TS_LOCKS);
+				MIN_TS_LOCKS);
 		goto error;
 	}
 
-	t_table->entries = (ts_entry_t*)shm_malloc(sizeof(ts_entry_t) * size);
-	if (!t_table->entries) {
+	t_table->entries = (ts_entry_t *)shm_malloc(sizeof(ts_entry_t) * size);
+	if(!t_table->entries) {
 		SHM_MEM_ERROR;
 		goto error;
 	}
 
-	for( i=0 ; i<size; i++ ) {
-		memset( &(t_table->entries[i]), 0, sizeof(struct ts_entry) );
-		t_table->entries[i].next_id = kam_rand() % (3*size);
+	for(i = 0; i < size; i++) {
+		memset(&(t_table->entries[i]), 0, sizeof(struct ts_entry));
+		t_table->entries[i].next_id = kam_rand() % (3 * size);
 		t_table->entries[i].lock_idx = i % t_table->locks_no;
 	}
 
 	return 0;
 error:
-	shm_free( t_table );
+	shm_free(t_table);
 	t_table = NULL;
 	return -1;
 }
@@ -129,17 +130,17 @@ void destroy_ts_table(void)
 	struct ts_urecord *ts_u, *l_ts_u;
 	unsigned int i;
 
-	if (t_table==0)
+	if(t_table == 0)
 		return;
 
-	if (t_table->locks) {
+	if(t_table->locks) {
 		lock_set_destroy(t_table->locks);
 		lock_set_dealloc(t_table->locks);
 	}
 
-	for( i=0 ; i<t_table->size; i++ ) {
+	for(i = 0; i < t_table->size; i++) {
 		ts_u = t_table->entries[i].first;
-		while (ts_u) {
+		while(ts_u) {
 			l_ts_u = ts_u;
 			ts_u = ts_u->next;
 			free_ts_urecord(l_ts_u);
@@ -152,52 +153,54 @@ void destroy_ts_table(void)
 	return;
 }
 
-void lock_entry(ts_entry_t *entry) {
+void lock_entry(ts_entry_t *entry)
+{
 	ts_lock(t_table, entry);
 }
 
-void unlock_entry(ts_entry_t *entry) {
+void unlock_entry(ts_entry_t *entry)
+{
 	ts_unlock(t_table, entry);
 }
 
-void lock_entry_by_ruri(str* ruri)
+void lock_entry_by_ruri(str *ruri)
 {
 	unsigned int sl;
 
-	sl = core_hash(ruri, 0, 0) & (t_table->size-1);
+	sl = core_hash(ruri, 0, 0) & (t_table->size - 1);
 	ts_lock(t_table, &t_table->entries[sl]);
 }
 
-void unlock_entry_by_ruri(str* ruri)
+void unlock_entry_by_ruri(str *ruri)
 {
 	unsigned int sl;
 
-	sl = core_hash(ruri, 0, 0) & (t_table->size-1);
+	sl = core_hash(ruri, 0, 0) & (t_table->size - 1);
 	ts_unlock(t_table, &t_table->entries[sl]);
 }
 
 /*
  * Obtain a urecord pointer if the urecord exists in the table
  */
-int get_ts_urecord(str* ruri, struct ts_urecord** _r)
+int get_ts_urecord(str *ruri, struct ts_urecord **_r)
 {
 	int sl, i, rurihash;
-	ts_urecord_t* r;
+	ts_urecord_t *r;
 
 	rurihash = core_hash(ruri, 0, 0);
-	sl = rurihash&(t_table->size-1);
+	sl = rurihash & (t_table->size - 1);
 	r = t_table->entries[sl].first;
 
-	for(i = 0; r!=NULL && i < t_table->entries[sl].n; i++) {
-		if((r->rurihash==rurihash) && (r->ruri.len==ruri->len)
-				&& !memcmp(r->ruri.s,ruri->s,ruri->len)){
+	for(i = 0; r != NULL && i < t_table->entries[sl].n; i++) {
+		if((r->rurihash == rurihash) && (r->ruri.len == ruri->len)
+				&& !memcmp(r->ruri.s, ruri->s, ruri->len)) {
 			*_r = r;
 			return 0;
 		}
 		r = r->next;
 	}
 
-	return 1;   /* Nothing found */
+	return 1; /* Nothing found */
 }
 
 /*!
@@ -206,17 +209,17 @@ int get_ts_urecord(str* ruri, struct ts_urecord** _r)
  * \param _r pointer to the new record
  * \return 0 on success, negative on failure
  */
-int new_ts_urecord(str* ruri, ts_urecord_t** _r)
+int new_ts_urecord(str *ruri, ts_urecord_t **_r)
 {
-	*_r = (ts_urecord_t*)shm_malloc(sizeof(ts_urecord_t));
-	if (*_r == 0) {
+	*_r = (ts_urecord_t *)shm_malloc(sizeof(ts_urecord_t));
+	if(*_r == 0) {
 		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(*_r, 0, sizeof(ts_urecord_t));
 
-	(*_r)->ruri.s = (char*)shm_malloc(ruri->len);
-	if ((*_r)->ruri.s == 0) {
+	(*_r)->ruri.s = (char *)shm_malloc(ruri->len);
+	if((*_r)->ruri.s == 0) {
 		SHM_MEM_ERROR;
 		shm_free(*_r);
 		*_r = 0;
@@ -234,21 +237,21 @@ int new_ts_urecord(str* ruri, ts_urecord_t** _r)
  * \param _r pointer to the new record
  * \return 0 on success, -1 on failure
  */
-int insert_ts_urecord(str* ruri, ts_urecord_t** _r)
+int insert_ts_urecord(str *ruri, ts_urecord_t **_r)
 {
-	ts_entry_t* entry;
+	ts_entry_t *entry;
 
 	int sl;
 
-	if (new_ts_urecord(ruri, _r) < 0) {
+	if(new_ts_urecord(ruri, _r) < 0) {
 		LM_ERR("creating urecord failed\n");
 		return -1;
 	}
 
-	sl = ((*_r)->rurihash)&(t_table->size-1);
+	sl = ((*_r)->rurihash) & (t_table->size - 1);
 	entry = &t_table->entries[sl];
 
-	if (entry->n == 0) {
+	if(entry->n == 0) {
 		entry->first = entry->last = *_r;
 	} else {
 		(*_r)->prev = entry->last;
@@ -261,7 +264,7 @@ int insert_ts_urecord(str* ruri, ts_urecord_t** _r)
 	update_stat(stored_ruris, 1);
 	update_stat(total_ruris, 1);
 
-	LM_DBG("urecord entry %p",entry);
+	LM_DBG("urecord entry %p", entry);
 	return 0;
 }
 
@@ -270,20 +273,20 @@ int insert_ts_urecord(str* ruri, ts_urecord_t** _r)
  * \param _r urecord
  * \return 0 on success, -1 on failure
  */
-void remove_ts_urecord(ts_urecord_t* _r)
+void remove_ts_urecord(ts_urecord_t *_r)
 {
-	ts_entry_t* entry;
+	ts_entry_t *entry;
 
 	entry = _r->entry;
 
-	if (_r->prev)
+	if(_r->prev)
 		_r->prev->next = _r->next;
-	if (_r->next)
+	if(_r->next)
 		_r->next->prev = _r->prev;
 
-	if (entry->first == _r)
+	if(entry->first == _r)
 		entry->first = _r->next;
-	if (entry->last == _r)
+	if(entry->last == _r)
 		entry->last = _r->prev;
 
 	update_stat(stored_ruris, -1);
@@ -291,7 +294,7 @@ void remove_ts_urecord(ts_urecord_t* _r)
 	entry->n--;
 	free_ts_urecord(_r);
 
-        return;
+	return;
 }
 
 /*!
@@ -301,10 +304,11 @@ void remove_ts_urecord(ts_urecord_t* _r)
  * \param _r urecord
  * \return 0 on success, -1 otherwise
  */
-int insert_ts_transaction(struct cell* t, struct sip_msg* msg, struct ts_urecord* _r)
+int insert_ts_transaction(
+		struct cell *t, struct sip_msg *msg, struct ts_urecord *_r)
 {
 	ts_transaction_t *ptr, *prev;
-	ts_transaction_t* ts;
+	ts_transaction_t *ts;
 
 	unsigned int tindex;
 	unsigned int tlabel;
@@ -316,7 +320,7 @@ int insert_ts_transaction(struct cell* t, struct sip_msg* msg, struct ts_urecord
 	ptr = _r->transactions;
 
 	while(ptr) {
-		if ((ptr->tindex == tindex) && (ptr->tlabel == tlabel)) {
+		if((ptr->tindex == tindex) && (ptr->tlabel == tlabel)) {
 			LM_DBG("transaction already inserted\n");
 			return -1;
 		}
@@ -324,7 +328,7 @@ int insert_ts_transaction(struct cell* t, struct sip_msg* msg, struct ts_urecord
 		ptr = ptr->next;
 	}
 
-	if ( (ts=new_ts_transaction(tindex, tlabel) ) == 0) {
+	if((ts = new_ts_transaction(tindex, tlabel)) == 0) {
 		LM_ERR("failed to create new transaction\n");
 		return -1;
 	}
@@ -332,14 +336,14 @@ int insert_ts_transaction(struct cell* t, struct sip_msg* msg, struct ts_urecord
 	ts->urecord = _r;
 	/* add the new transaction at the end of the list */
 
-	if (prev) {
+	if(prev) {
 		prev->next = ts;
 		ts->prev = prev;
 	} else {
 		_r->transactions = ts;
 	}
 
-	if (ts_set_tm_callbacks(t, msg, ts) < 0) {
+	if(ts_set_tm_callbacks(t, msg, ts) < 0) {
 		LM_ERR("failed to set transaction %d:%d callbacks\n", tindex, tlabel);
 	}
 
@@ -354,14 +358,14 @@ int insert_ts_transaction(struct cell* t, struct sip_msg* msg, struct ts_urecord
  * \param tlabel transaction label in tm table
  * \return created transaction structure on success, NULL otherwise
  */
-ts_transaction_t* new_ts_transaction(int tindex, int tlabel)
+ts_transaction_t *new_ts_transaction(int tindex, int tlabel)
 {
 	ts_transaction_t *ts;
 	int len;
 
 	len = sizeof(ts_transaction_t);
-	ts = (ts_transaction_t*)shm_malloc(len);
-	if (ts==0) {
+	ts = (ts_transaction_t *)shm_malloc(len);
+	if(ts == 0) {
 		SHM_MEM_ERROR_FMT("len %d\n", len);
 		return 0;
 	}
@@ -377,17 +381,17 @@ ts_transaction_t* new_ts_transaction(int tindex, int tlabel)
  * \param ts transaction to be cloned
  * \return cloned transaction structure on success, NULL otherwise
  */
-ts_transaction_t* clone_ts_transaction(ts_transaction_t* ts)
+ts_transaction_t *clone_ts_transaction(ts_transaction_t *ts)
 {
 	ts_transaction_t *ts_clone;
 	int len;
 
-	if (ts == NULL)
+	if(ts == NULL)
 		return NULL;
 
 	len = sizeof(ts_transaction_t);
-	ts_clone = (ts_transaction_t*)shm_malloc(len);
-	if (ts_clone==NULL) {
+	ts_clone = (ts_transaction_t *)shm_malloc(len);
+	if(ts_clone == NULL) {
 		SHM_MEM_ERROR_FMT("len %d\n", len);
 		return NULL;
 	}
@@ -400,19 +404,19 @@ ts_transaction_t* clone_ts_transaction(ts_transaction_t* ts)
  * \brief remove a transaction from the urecord transactions list
  * \param ts_t unlinked transaction
  */
-void remove_ts_transaction(ts_transaction_t* ts_t)
+void remove_ts_transaction(ts_transaction_t *ts_t)
 {
-	if (ts_t->next)
+	if(ts_t->next)
 		ts_t->next->prev = ts_t->prev;
-	if (ts_t->prev)
+	if(ts_t->prev)
 		ts_t->prev->next = ts_t->next;
 
-	if (ts_t->urecord->transactions == ts_t)
+	if(ts_t->urecord->transactions == ts_t)
 		ts_t->urecord->transactions = ts_t->next;
 
 	update_stat(stored_transactions, -1);
 
-	free_ts_transaction((void*)ts_t);
+	free_ts_transaction((void *)ts_t);
 
 	return;
 }
@@ -424,6 +428,6 @@ void remove_ts_transaction(ts_transaction_t* ts_t)
  */
 void free_ts_transaction(void *ts_t)
 {
-	shm_free((struct ts_transaction*)ts_t);
+	shm_free((struct ts_transaction *)ts_t);
 	ts_t = 0;
 }

+ 36 - 34
src/modules/tsilo/ts_hash.h

@@ -32,8 +32,8 @@
 #include "../../core/locking.h"
 #include "../../modules/tm/tm_load.h"
 
-#define MAX_TS_LOCKS  2048
-#define MIN_TS_LOCKS  2
+#define MAX_TS_LOCKS 2048
+#define MIN_TS_LOCKS 2
 
 extern stat_var *stored_ruris;
 extern stat_var *stored_transactions;
@@ -43,47 +43,48 @@ extern stat_var *added_branches;
 
 typedef struct ts_transaction
 {
-	unsigned int		tindex;		/*!< transaction index */
-	unsigned int		tlabel;		/*!< transaction label */
+	unsigned int tindex; /*!< transaction index */
+	unsigned int tlabel; /*!< transaction label */
 
-	struct ts_urecord	*urecord;	/*!< > urecord entry the transaction belongs to */
+	struct ts_urecord
+			*urecord; /*!< > urecord entry the transaction belongs to */
 
-	struct ts_transaction	*next;		/*!< next entry in the list */
-	struct ts_transaction	*prev;		/*!< previous entry in the list */
+	struct ts_transaction *next; /*!< next entry in the list */
+	struct ts_transaction *prev; /*!< previous entry in the list */
 } ts_transaction_t;
 
 /*! entries in the transaction list */
 typedef struct ts_urecord
 {
-	str		     ruri;		/*!< request uri of the transaction */
-	unsigned int	     rurihash;		/*!< hash request uri of the transaction */
+	str ruri;			   /*!< request uri of the transaction */
+	unsigned int rurihash; /*!< hash request uri of the transaction */
 
-	struct ts_entry     *entry;		/*!< Collision slot in the hash table */
-	ts_transaction_t    *transactions;	/*!< One or more transactions */
+	struct ts_entry *entry;			/*!< Collision slot in the hash table */
+	ts_transaction_t *transactions; /*!< One or more transactions */
 
-	struct ts_urecord   *next;		/*!< next entry in the list */
-	struct ts_urecord   *prev;		/*!< previous entry in the list */
+	struct ts_urecord *next; /*!< next entry in the list */
+	struct ts_urecord *prev; /*!< previous entry in the list */
 } ts_urecord_t;
 
 
 /*! entries in the main transaction table */
 typedef struct ts_entry
 {
-	int n;                  	    /*!< Number of elements in the collision slot */
-	struct ts_urecord    *first;	/*!< urecord list */
-	struct ts_urecord    *last;	    /*!< optimisation, end of the urecord list */
-	unsigned int       next_id;	    /*!< next id */
-	unsigned int       lock_idx;	/*!< lock index */
+	int n;					  /*!< Number of elements in the collision slot */
+	struct ts_urecord *first; /*!< urecord list */
+	struct ts_urecord *last;  /*!< optimisation, end of the urecord list */
+	unsigned int next_id;	  /*!< next id */
+	unsigned int lock_idx;	  /*!< lock index */
 } ts_entry_t;
 
 
 /*! main transaction table */
 typedef struct ts_table
 {
-	unsigned int       size;	    /*!< size of the tsilo table */
-	struct ts_entry    *entries;	/*!< urecord hash table */
-	unsigned int       locks_no;	/*!< number of locks */
-	gen_lock_set_t     *locks;	    /*!< lock table */
+	unsigned int size;		  /*!< size of the tsilo table */
+	struct ts_entry *entries; /*!< urecord hash table */
+	unsigned int locks_no;	  /*!< number of locks */
+	gen_lock_set_t *locks;	  /*!< lock table */
 } ts_table_t;
 
 /*! global transactions table */
@@ -95,7 +96,7 @@ extern ts_table_t *t_table;
  * \param _entry locked entry
  */
 #define ts_lock(_table, _entry) \
-		lock_set_get( (_table)->locks, (_entry)->lock_idx);
+	lock_set_get((_table)->locks, (_entry)->lock_idx);
 
 /*!
  * \brief Release a transaction lock
@@ -103,13 +104,13 @@ extern ts_table_t *t_table;
  * \param _entry locked entry
  */
 #define ts_unlock(_table, _entry) \
-		lock_set_release( (_table)->locks, (_entry)->lock_idx);
+	lock_set_release((_table)->locks, (_entry)->lock_idx);
 
 void lock_entry(ts_entry_t *entry);
 void unlock_entry(ts_entry_t *entry);
 
-void lock_entry_by_ruri(str* ruri);
-void unlock_entry_by_ruri(str* ruri);
+void lock_entry_by_ruri(str *ruri);
+void unlock_entry_by_ruri(str *ruri);
 
 /*!
  * \brief Initialize the per user transactions table
@@ -126,7 +127,7 @@ void destroy_ts_table(void);
 /*
  * Obtain a urecord pointer if the urecord exists in the table
  */
-int get_ts_urecord(str* ruri, struct ts_urecord** _r);
+int get_ts_urecord(str *ruri, struct ts_urecord **_r);
 
 /*!
  * \brief Create and initialize new record structure
@@ -134,7 +135,7 @@ int get_ts_urecord(str* ruri, struct ts_urecord** _r);
  * \param _r pointer to the new record
  * \return 0 on success, negative on failure
  */
-int new_ts_urecord(str* ruri, ts_urecord_t** _r);
+int new_ts_urecord(str *ruri, ts_urecord_t **_r);
 
 /*!
  * \brief Insert a new record into transactions table
@@ -142,14 +143,14 @@ int new_ts_urecord(str* ruri, ts_urecord_t** _r);
  * \param _r pointer to the new record
  * \return 0 on success, -1 on failure
  */
-int insert_ts_urecord(str* ruri, ts_urecord_t** _r);
+int insert_ts_urecord(str *ruri, ts_urecord_t **_r);
 
 /*!
  * \brief remove a urecord from table and free the memory
  * \param _r urecord
  * \return 0 on success, -1 on failure
  */
-void remove_ts_urecord(ts_urecord_t* _r);
+void remove_ts_urecord(ts_urecord_t *_r);
 
 /*!
  * \brief Insert a new transaction structure into urecord
@@ -158,7 +159,8 @@ void remove_ts_urecord(ts_urecord_t* _r);
  * \param _r urecord
  * \return 0 on success, -1 otherwise
  */
-int insert_ts_transaction(struct cell* t, sip_msg_t* msg, struct ts_urecord* _r);
+int insert_ts_transaction(
+		struct cell *t, sip_msg_t *msg, struct ts_urecord *_r);
 
 /*!
  * \brief Create a new transaction structure
@@ -166,20 +168,20 @@ int insert_ts_transaction(struct cell* t, sip_msg_t* msg, struct ts_urecord* _r)
  * \param tlabel transaction label in tm table
  * \return created transaction structure on success, NULL otherwise
  */
-ts_transaction_t* new_ts_transaction(int tindex, int tlabel);
+ts_transaction_t *new_ts_transaction(int tindex, int tlabel);
 
 /*!
  * \brief Clone a transaction structure
  * \param ts transaction to be cloned
  * \return cloned transaction structure on success, NULL otherwise
  */
-ts_transaction_t* clone_ts_transaction(ts_transaction_t* ts);
+ts_transaction_t *clone_ts_transaction(ts_transaction_t *ts);
 
 /*!
  * \brief remove a transaction from the urecord transactions list
  * \param ts_t unlinked transaction
  */
-void remove_ts_transaction(ts_transaction_t* ts_t);
+void remove_ts_transaction(ts_transaction_t *ts_t);
 
 void free_ts_transaction(void *ts_t);
 #endif

+ 48 - 67
src/modules/tsilo/ts_rpc.c

@@ -25,40 +25,35 @@
 #include "ts_rpc.h"
 
 
-static const char* rpc_tsilo_dump_doc[2] = {
-	"Dump tsilo transactions table",
-	0
-};
+static const char *rpc_tsilo_dump_doc[2] = {"Dump tsilo transactions table", 0};
 
 
-static const char* rpc_tsilo_lookup_doc[2] = {
-	"Lookup one R-URI in the tsilo transactions table",
-	0
-};
+static const char *rpc_tsilo_lookup_doc[2] = {
+		"Lookup one R-URI in the tsilo transactions table", 0};
 
 /************************ helper functions ****************************/
 
 /*!
  * \brief Add a node for a transaction
  */
-static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_transaction_t* t)
+static inline int rpc_dump_transaction(
+		rpc_t *rpc, void *ctx, void *ih, ts_transaction_t *t)
 {
-	void* vh;
+	void *vh;
 
-	if(t==NULL)
+	if(t == NULL)
 		return -1;
 
-	if(rpc->struct_add(ih, "{", "Transaction", &vh)<0)
-	{
+	if(rpc->struct_add(ih, "{", "Transaction", &vh) < 0) {
 		rpc->fault(ctx, 500, "Internal error creating transaction struct");
 		return -1;
 	}
-	if(rpc->struct_add(vh, "d", "Tindex", t->tindex)<0) {
+	if(rpc->struct_add(vh, "d", "Tindex", t->tindex) < 0) {
 		rpc->fault(ctx, 500, "Internal error adding tindex");
 		return -1;
 	}
 
-	if(rpc->struct_add(vh, "d", "Tlabel", t->tlabel)<0) {
+	if(rpc->struct_add(vh, "d", "Tlabel", t->tlabel) < 0) {
 		rpc->fault(ctx, 500, "Internal error adding tlabel");
 		return -1;
 	}
@@ -76,72 +71,64 @@ static inline int rpc_dump_transaction(rpc_t* rpc, void* ctx, void *ih, ts_trans
  */
 static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 {
-	ts_transaction_t* trans = NULL;
-	struct ts_urecord* record = NULL;
-	struct ts_entry* entry = NULL;
+	ts_transaction_t *trans = NULL;
+	struct ts_urecord *record = NULL;
+	struct ts_entry *entry = NULL;
 
 	str brief = {0, 0};
 
 	int max, res, n, ntrans, i;
 	int short_dump = 0;
 
-	void* th;
-	void* ah;
-	void* ih;
-	void* sh;
+	void *th;
+	void *ah;
+	void *ih;
+	void *sh;
 
 	rpc->scan(c, "*S", &brief);
 
-	if(brief.len==5 && (strncmp(brief.s, "brief", 5)==0))
+	if(brief.len == 5 && (strncmp(brief.s, "brief", 5) == 0))
 		/* short version */
 		short_dump = 1;
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
+	if(rpc->add(c, "{", &th) < 0) {
 		rpc->fault(c, 500, "Internal error creating top rpc");
 		return;
 	}
 
-	if (short_dump==0) {
-		res = rpc->struct_add(th, "d{",
-			"Size",		t_table->size,
-			"R-URIs",	&ah);
+	if(short_dump == 0) {
+		res = rpc->struct_add(th, "d{", "Size", t_table->size, "R-URIs", &ah);
 	} else {
-		res = rpc->struct_add(th, "d",
-			"Size",		t_table->size);
+		res = rpc->struct_add(th, "d", "Size", t_table->size);
 	}
-	if (res<0)
-	{
+	if(res < 0) {
 		rpc->fault(c, 500, "Internal error creating inner struct");
 		return;
 	}
 
 	/* add the entries per hash */
-	for(i=0,n=0,max=0,ntrans=0; i<t_table->size; i++) {
+	for(i = 0, n = 0, max = 0, ntrans = 0; i < t_table->size; i++) {
 		lock_entry(&t_table->entries[i]);
 		entry = &t_table->entries[i];
 
 		n += entry->n;
-		if(max<entry->n)
-			max= entry->n;
-		for( record = entry->first ; record ; record=record->next ) {
+		if(max < entry->n)
+			max = entry->n;
+		for(record = entry->first; record; record = record->next) {
 			/* add entry */
-			if(short_dump==0)
-			{
-				if(rpc->struct_add(ah, "Sd{",
-					"R-URI", &record->ruri,
-					"Hash", record->rurihash,
-					"Transactions", &ih)<0)
-				{
+			if(short_dump == 0) {
+				if(rpc->struct_add(ah, "Sd{", "R-URI", &record->ruri, "Hash",
+						   record->rurihash, "Transactions", &ih)
+						< 0) {
 					unlock_entry(&t_table->entries[i]);
 					rpc->fault(c, 500, "Internal error creating ruri struct");
 					return;
 				}
 			}
-			for( trans=record->transactions ; trans ; trans=trans->next) {
+			for(trans = record->transactions; trans; trans = trans->next) {
 				ntrans += 1;
-				if (short_dump==0) {
-					if (rpc_dump_transaction(rpc, c, ih, trans) == -1) {
+				if(short_dump == 0) {
+					if(rpc_dump_transaction(rpc, c, ih, trans) == -1) {
 						unlock_entry(&t_table->entries[i]);
 						return;
 					}
@@ -152,15 +139,13 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c)
 	}
 
 	/* extra attributes node */
-	if(rpc->struct_add(th, "{", "Stats",    &sh)<0)	{
+	if(rpc->struct_add(th, "{", "Stats", &sh) < 0) {
 		rpc->fault(c, 500, "Internal error creating stats struct");
 		return;
 	}
-	if(rpc->struct_add(sh, "ddd",
-		"RURIs", n,
-		"Max-Slots", max,
-		"Transactions", ntrans)<0)
-	{
+	if(rpc->struct_add(
+			   sh, "ddd", "RURIs", n, "Max-Slots", max, "Transactions", ntrans)
+			< 0) {
 		rpc->fault(c, 500, "Internal error adding stats");
 		return;
 	}
@@ -172,16 +157,16 @@ static void rpc_tsilo_dump(rpc_t *rpc, void *c)
  */
 static void rpc_tsilo_lookup(rpc_t *rpc, void *c)
 {
-	ts_transaction_t* trans;
-	struct ts_urecord* record;
+	ts_transaction_t *trans;
+	struct ts_urecord *record;
 
 	str ruri = {0, 0};
 
 	int res;
 
-	void* th;
+	void *th;
 
-	if (rpc->scan(c, "S", &ruri) != 1) {
+	if(rpc->scan(c, "S", &ruri) != 1) {
 		rpc->fault(c, 500, "No RURI to lookup specified");
 		return;
 	}
@@ -190,22 +175,21 @@ static void rpc_tsilo_lookup(rpc_t *rpc, void *c)
 
 	/* look for urecord */
 	res = get_ts_urecord(&ruri, &record);
-	if (res) {
+	if(res) {
 		unlock_entry_by_ruri(&ruri);
 		rpc->fault(c, 404, "RURI not found in tsilo table");
 		return;
 	}
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
+	if(rpc->add(c, "{", &th) < 0) {
 		unlock_entry_by_ruri(&ruri);
 		rpc->fault(c, 500, "Internal error creating top rpc");
 		return;
 	}
 
 	/* add the transactions */
-	for( trans=record->transactions ; trans ; trans=trans->next) {
-		if (rpc_dump_transaction(rpc, c, th, trans) == -1) {
+	for(trans = record->transactions; trans; trans = trans->next) {
+		if(rpc_dump_transaction(rpc, c, th, trans) == -1) {
 			unlock_entry_by_ruri(&ruri);
 			return;
 		}
@@ -215,8 +199,5 @@ static void rpc_tsilo_lookup(rpc_t *rpc, void *c)
 }
 
 rpc_export_t rpc_methods[] = {
-	{ "ts.dump",	rpc_tsilo_dump,		rpc_tsilo_dump_doc,		0 },
-	{ "ts.lookup",	rpc_tsilo_lookup,	rpc_tsilo_lookup_doc,	0 },
-    { 0, 0, 0, 0}
-};
-
+		{"ts.dump", rpc_tsilo_dump, rpc_tsilo_dump_doc, 0},
+		{"ts.lookup", rpc_tsilo_lookup, rpc_tsilo_lookup_doc, 0}, {0, 0, 0, 0}};

+ 18 - 18
src/modules/tsilo/ts_store.c

@@ -37,19 +37,20 @@
 #include "ts_hash.h"
 #include "ts_store.h"
 
-int ts_store(struct sip_msg* msg, str *puri) {
-	struct cell		*t;
+int ts_store(struct sip_msg *msg, str *puri)
+{
+	struct cell *t;
 	str aor;
 	struct sip_uri ruri;
 	str suri;
 
-	ts_urecord_t* r;
+	ts_urecord_t *r;
 	int res;
 
-	if(puri && puri->s && puri->len>0) {
+	if(puri && puri->s && puri->len > 0) {
 		suri = *puri;
 	} else {
-		if (msg->new_uri.s!=NULL) {
+		if(msg->new_uri.s != NULL) {
 			/* incoming r-uri was chaged by cfg or other component */
 			suri = msg->new_uri;
 		} else {
@@ -58,44 +59,42 @@ int ts_store(struct sip_msg* msg, str *puri) {
 		}
 	}
 
-	if (parse_uri(suri.s, suri.len, &ruri)!=0)
-	{
-		LM_ERR("bad uri [%.*s]\n",
-				suri.len,
-				suri.s);
+	if(parse_uri(suri.s, suri.len, &ruri) != 0) {
+		LM_ERR("bad uri [%.*s]\n", suri.len, suri.s);
 		return -1;
 	}
 
-	if (use_domain)
+	if(use_domain)
 		aor = suri;
 	else
 		aor = ruri.user;
 
-	if(aor.s==NULL) {
+	if(aor.s == NULL) {
 		LM_ERR("malformed aor from uri[%.*s]\n", suri.len, suri.s);
 		return -1;
 	}
 
 	t = _tmb.t_gett();
-	if (!t || t==T_UNDEFINED) {
+	if(!t || t == T_UNDEFINED) {
 		LM_ERR("no transaction defined for %.*s\n", aor.len, aor.s);
 		return -1;
 	}
 
-	LM_DBG("storing transaction %u:%u for r-uri: %.*s\n", t->hash_index, t->label, aor.len, aor.s);
+	LM_DBG("storing transaction %u:%u for r-uri: %.*s\n", t->hash_index,
+			t->label, aor.len, aor.s);
 
 	lock_entry_by_ruri(&aor);
 
 	res = get_ts_urecord(&aor, &r);
 
-	if (res < 0) {
+	if(res < 0) {
 		LM_ERR("failed to retrieve record for %.*s\n", aor.len, aor.s);
 		unlock_entry_by_ruri(&aor);
 		return -1;
 	}
 
-	if (res != 0) { /* entry not found for the ruri */
-		if (insert_ts_urecord(&aor, &r) < 0) {
+	if(res != 0) { /* entry not found for the ruri */
+		if(insert_ts_urecord(&aor, &r) < 0) {
 			LM_ERR("failed to insert new record structure\n");
 			unlock_entry_by_ruri(&aor);
 			return -1;
@@ -105,7 +104,8 @@ int ts_store(struct sip_msg* msg, str *puri) {
 	insert_ts_transaction(t, msg, r);
 	unlock_entry_by_ruri(&aor);
 
-	LM_DBG("transaction %u:%u (ruri: %.*s) inserted\n", t->hash_index, t->label, aor.len, aor.s);
+	LM_DBG("transaction %u:%u (ruri: %.*s) inserted\n", t->hash_index, t->label,
+			aor.len, aor.s);
 
 	return 1;
 }

+ 1 - 1
src/modules/tsilo/ts_store.h

@@ -22,6 +22,6 @@
 #ifndef _TS_STORE_H
 #define _TS_STORE_H
 
-int ts_store(struct sip_msg* msg, str *puri);
+int ts_store(struct sip_msg *msg, str *puri);
 
 #endif

+ 182 - 167
src/modules/tsilo/tsilo.c

@@ -58,16 +58,19 @@ int use_domain = 0;
 static int mod_init(void);
 static void destroy(void);
 
-static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d);
-static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *d, char *ruri);
-static int fixup_ts_append_to(void** param, int param_no);
-static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri);
-static int fixup_ts_append(void** param, int param_no);
-static int w_ts_append_by_contact2(struct sip_msg* _msg, char *_table, char *_ruri);
-static int w_ts_append_by_contact3(struct sip_msg* _msg, char *_table, char *_ruri, char *_contact);
-static int fixup_ts_append_by_contact(void** param, int param_no);
-static int w_ts_store(struct sip_msg* msg, char *p1, char *p2);
-static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2);
+static int w_ts_append_to(struct sip_msg *msg, char *idx, char *lbl, char *d);
+static int w_ts_append_to2(
+		struct sip_msg *msg, char *idx, char *lbl, char *d, char *ruri);
+static int fixup_ts_append_to(void **param, int param_no);
+static int w_ts_append(struct sip_msg *_msg, char *_table, char *_ruri);
+static int fixup_ts_append(void **param, int param_no);
+static int w_ts_append_by_contact2(
+		struct sip_msg *_msg, char *_table, char *_ruri);
+static int w_ts_append_by_contact3(
+		struct sip_msg *_msg, char *_table, char *_ruri, char *_contact);
+static int fixup_ts_append_by_contact(void **param, int param_no);
+static int w_ts_store(struct sip_msg *msg, char *p1, char *p2);
+static int w_ts_store1(struct sip_msg *msg, char *_ruri, char *p2);
 
 stat_var *stored_ruris;
 stat_var *stored_transactions;
@@ -75,54 +78,49 @@ stat_var *total_ruris;
 stat_var *total_transactions;
 stat_var *added_branches;
 
-static cmd_export_t cmds[]={
-	{"ts_append_to", (cmd_function)w_ts_append_to,  3,
-		fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_append_to", (cmd_function)w_ts_append_to2,  4,
-		fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_append", (cmd_function)w_ts_append,  2,
-		fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_append_by_contact", (cmd_function)w_ts_append_by_contact2,  2,	/* for two parameters */
-		fixup_ts_append_by_contact, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_append_by_contact", (cmd_function)w_ts_append_by_contact3,  3,	/* for three parameters */
-		fixup_ts_append_by_contact, 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_store", (cmd_function)w_ts_store,  0,
-		0 , 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{"ts_store", (cmd_function)w_ts_store1,  1,
-		fixup_spve_null , 0, REQUEST_ROUTE | FAILURE_ROUTE },
-	{0,0,0,0,0,0}
-};
-
-static param_export_t params[]={
-	{"hash_size",	INT_PARAM,	&hash_size},
-	{"use_domain",	INT_PARAM,	&use_domain},
-	{0,0,0}
-};
+static cmd_export_t cmds[] = {
+		{"ts_append_to", (cmd_function)w_ts_append_to, 3, fixup_ts_append_to, 0,
+				REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_append_to", (cmd_function)w_ts_append_to2, 4, fixup_ts_append_to,
+				0, REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_append", (cmd_function)w_ts_append, 2, fixup_ts_append, 0,
+				REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_append_by_contact", (cmd_function)w_ts_append_by_contact2,
+				2, /* for two parameters */
+				fixup_ts_append_by_contact, 0, REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_append_by_contact", (cmd_function)w_ts_append_by_contact3,
+				3, /* for three parameters */
+				fixup_ts_append_by_contact, 0, REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_store", (cmd_function)w_ts_store, 0, 0, 0,
+				REQUEST_ROUTE | FAILURE_ROUTE},
+		{"ts_store", (cmd_function)w_ts_store1, 1, fixup_spve_null, 0,
+				REQUEST_ROUTE | FAILURE_ROUTE},
+		{0, 0, 0, 0, 0, 0}};
+
+static param_export_t params[] = {{"hash_size", INT_PARAM, &hash_size},
+		{"use_domain", INT_PARAM, &use_domain}, {0, 0, 0}};
 
 #ifdef STATISTICS
 /*! \brief We expose internal variables via the statistic framework below.*/
-stat_export_t mod_stats[] = {
-	{"stored_ruris",	STAT_NO_RESET, 	&stored_ruris  },
-	{"stored_transactions",	STAT_NO_RESET, 	&stored_transactions  },
-	{"total_ruris",		STAT_NO_RESET, 	&total_ruris  },
-	{"total_transactions",	STAT_NO_RESET, 	&total_transactions  },
-	{"added_branches",	STAT_NO_RESET, 	&added_branches  },
-	{0, 0, 0}
-};
+stat_export_t mod_stats[] = {{"stored_ruris", STAT_NO_RESET, &stored_ruris},
+		{"stored_transactions", STAT_NO_RESET, &stored_transactions},
+		{"total_ruris", STAT_NO_RESET, &total_ruris},
+		{"total_transactions", STAT_NO_RESET, &total_transactions},
+		{"added_branches", STAT_NO_RESET, &added_branches}, {0, 0, 0}};
 #endif
 
 /** module exports */
 struct module_exports exports = {
-	"tsilo",         /* module name */
-	DEFAULT_DLFLAGS, /* dlopen flags */
-	cmds,            /* exported functions */
-	params,          /* exported parameters */
-	0,               /* exported RPC methods */
-	0,               /* exported pseudo-variables */
-	0,               /* response handling function */
-	mod_init,        /* module initialization function */
-	0,               /* per-child init function */
-	destroy          /* destroy function */
+		"tsilo",		 /* module name */
+		DEFAULT_DLFLAGS, /* dlopen flags */
+		cmds,			 /* exported functions */
+		params,			 /* exported parameters */
+		0,				 /* exported RPC methods */
+		0,				 /* exported pseudo-variables */
+		0,				 /* response handling function */
+		mod_init,		 /* module initialization function */
+		0,				 /* per-child init function */
+		destroy			 /* destroy function */
 };
 
 /**
@@ -133,59 +131,57 @@ static int mod_init(void)
 	unsigned int n;
 
 	/* register the RPC methods */
-	if(rpc_register_array(rpc_methods)!=0)
-	{
-        LM_ERR("failed to register RPC commands\n");
-        return -1;
+	if(rpc_register_array(rpc_methods) != 0) {
+		LM_ERR("failed to register RPC commands\n");
+		return -1;
 	}
 	/* load the TM API */
-	if (load_tm_api(&_tmb)!=0) {
+	if(load_tm_api(&_tmb) != 0) {
 		LM_ERR("can't load TM API\n");
 		return -1;
 	}
 
 	/* load the REGISTRAR API */
-	if (registrar_load_api(&_regapi) != 0) {
+	if(registrar_load_api(&_regapi) != 0) {
 		LM_ERR("cannot load REGISTRAR API\n");
 		return -1;
 	}
 
 	/* sanitize hash_size */
-	if (hash_size < 1){
+	if(hash_size < 1) {
 		LM_WARN("hash_size is smaller "
-			"than 1  -> rounding from %d to 1\n",
-			hash_size);
+				"than 1  -> rounding from %d to 1\n",
+				hash_size);
 		hash_size = 1;
 	}
 
 	/* initialize the hash table */
-	for( n=0 ; n<(8*sizeof(n)) ; n++) {
-		if (hash_size==(1<<n))
+	for(n = 0; n < (8 * sizeof(n)); n++) {
+		if(hash_size == (1 << n))
 			break;
-		if (n && hash_size<(1<<n)) {
+		if(n && hash_size < (1 << n)) {
 			LM_WARN("hash_size is not a power "
-				"of 2 as it should be -> rounding from %d to %d (n=%d)\n",
-				hash_size, 1<<(n-1), n);
-			hash_size = 1<<(n-1);
+					"of 2 as it should be -> rounding from %d to %d (n=%d)\n",
+					hash_size, 1 << (n - 1), n);
+			hash_size = 1 << (n - 1);
 			break;
 		}
 	}
 
 	LM_DBG("creating table with size %d", hash_size);
-	if ( init_ts_table(hash_size)<0 ) {
+	if(init_ts_table(hash_size) < 0) {
 		LM_ERR("failed to create hash table\n");
 		return -1;
 	}
 
 #ifdef STATISTICS
 	/* register statistics */
-	if (register_module_stats(exports.name, mod_stats)!=0 ) {
+	if(register_module_stats(exports.name, mod_stats) != 0) {
 		LM_ERR("failed to register core statistics\n");
 		return -1;
 	}
 	return 0;
 #endif
-
 }
 
 /**
@@ -200,11 +196,8 @@ static void destroy(void)
 static int ts_check_uri(str *uri)
 {
 	struct sip_uri ruri;
-	if (parse_uri(uri->s, uri->len, &ruri)!=0)
-	{
-		LM_ERR("bad uri [%.*s]\n",
-				uri->len,
-				uri->s);
+	if(parse_uri(uri->s, uri->len, &ruri) != 0) {
+		LM_ERR("bad uri [%.*s]\n", uri->len, uri->s);
 		return -1;
 	}
 	return 0;
@@ -212,54 +205,57 @@ static int ts_check_uri(str *uri)
 /**
  *
  */
-static int fixup_ts_append_to(void** param, int param_no)
+static int fixup_ts_append_to(void **param, int param_no)
 {
-	if (param_no==1 || param_no==2) {
+	if(param_no == 1 || param_no == 2) {
 		return fixup_igp_null(param, 1);
 	}
 
-	if (param_no==3) {
-		if(strlen((char*)*param)<=1 && (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
-			*param = (void*)0;
+	if(param_no == 3) {
+		if(strlen((char *)*param) <= 1
+				&& (*(char *)(*param) == 0 || *(char *)(*param) == '0')) {
+			*param = (void *)0;
 			LM_ERR("empty table name\n");
 			return -1;
 		}
 	}
 
-	if (param_no==4) {
+	if(param_no == 4) {
 		return fixup_spve_null(param, 1);
 	}
 	return 0;
 }
 
-static int fixup_ts_append(void** param, int param_no)
+static int fixup_ts_append(void **param, int param_no)
 {
-	if (param_no==1) {
-		if(strlen((char*)*param)<=1 && (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
-			*param = (void*)0;
+	if(param_no == 1) {
+		if(strlen((char *)*param) <= 1
+				&& (*(char *)(*param) == 0 || *(char *)(*param) == '0')) {
+			*param = (void *)0;
 			LM_ERR("empty table name\n");
 			return -1;
 		}
 	}
 
-	if (param_no==2 || param_no==3) {
+	if(param_no == 2 || param_no == 3) {
 		return fixup_spve_null(param, 1);
 	}
 
 	return 0;
 }
 
-static int fixup_ts_append_by_contact(void** param, int param_no)
+static int fixup_ts_append_by_contact(void **param, int param_no)
 {
-	if (param_no==1) {
-		if(strlen((char*)*param)<=1 && (*(char*)(*param)==0 || *(char*)(*param)=='0')) {
-			*param = (void*)0;
+	if(param_no == 1) {
+		if(strlen((char *)*param) <= 1
+				&& (*(char *)(*param) == 0 || *(char *)(*param) == '0')) {
+			*param = (void *)0;
 			LM_ERR("empty table name\n");
 			return -1;
 		}
 	}
 
-	if (param_no==2 || param_no==3) {
+	if(param_no == 2 || param_no == 3) {
 		return fixup_spve_null(param, 1);
 	}
 
@@ -269,23 +265,25 @@ static int fixup_ts_append_by_contact(void** param, int param_no)
 /**
  *
  */
-static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri)
+static int w_ts_append(struct sip_msg *_msg, char *_table, char *_ruri)
 {
-	str tmp  = STR_NULL;
+	str tmp = STR_NULL;
 	str ruri = STR_NULL;
 	int rc;
 
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
 
-	if(_ruri==NULL || (fixup_get_svalue(_msg, (gparam_p)_ruri, &tmp)!=0 || tmp.len<=0)) {
+	if(_ruri == NULL
+			|| (fixup_get_svalue(_msg, (gparam_p)_ruri, &tmp) != 0
+					|| tmp.len <= 0)) {
 		LM_ERR("invalid ruri parameter\n");
 		return -1;
 	}
-	if(ts_check_uri(&tmp)<0)
+	if(ts_check_uri(&tmp) < 0)
 		return -1;
 
-	if (pkg_str_dup(&ruri, &tmp) < 0)
+	if(pkg_str_dup(&ruri, &tmp) < 0)
 		return -1;
 
 	rc = ts_append(_msg, &ruri, &contact, _table);
@@ -298,7 +296,7 @@ static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri)
 /**
  *
  */
-static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri)
+static int ki_ts_append(sip_msg_t *_msg, str *_table, str *_ruri)
 {
 	str ruri = STR_NULL;
 	int rc;
@@ -306,10 +304,10 @@ static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri)
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
 
-	if(ts_check_uri(_ruri)<0)
+	if(ts_check_uri(_ruri) < 0)
 		return -1;
 
-	if (pkg_str_dup(&ruri, _ruri) < 0)
+	if(pkg_str_dup(&ruri, _ruri) < 0)
 		return -1;
 
 	rc = ts_append(_msg, &ruri, &contact, _table->s);
@@ -322,7 +320,8 @@ static int ki_ts_append(sip_msg_t* _msg, str *_table, str *_ruri)
 /**
  *
  */
-static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table)
+static int w_ts_append_to(
+		struct sip_msg *msg, char *idx, char *lbl, char *table)
 {
 	unsigned int tindex;
 	unsigned int tlabel;
@@ -330,12 +329,12 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
 
-	if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) {
+	if(fixup_get_ivalue(msg, (gparam_p)idx, (int *)&tindex) < 0) {
 		LM_ERR("cannot get transaction index\n");
 		return -1;
 	}
 
-	if(fixup_get_ivalue(msg, (gparam_p)lbl, (int*)&tlabel)<0) {
+	if(fixup_get_ivalue(msg, (gparam_p)lbl, (int *)&tlabel) < 0) {
 		LM_ERR("cannot get transaction label\n");
 		return -1;
 	}
@@ -347,7 +346,7 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *table
 /**
  *
  */
-static int ki_ts_append_to(sip_msg_t* _msg, int tindex, int tlabel, str *_table)
+static int ki_ts_append_to(sip_msg_t *_msg, int tindex, int tlabel, str *_table)
 {
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
@@ -360,7 +359,8 @@ static int ki_ts_append_to(sip_msg_t* _msg, int tindex, int tlabel, str *_table)
 /**
  *
  */
-static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *table, char *ruri)
+static int w_ts_append_to2(
+		struct sip_msg *msg, char *idx, char *lbl, char *table, char *ruri)
 {
 	unsigned int tindex;
 	unsigned int tlabel;
@@ -369,21 +369,21 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
 
-	if(fixup_get_ivalue(msg, (gparam_p)idx, (int*)&tindex)<0) {
+	if(fixup_get_ivalue(msg, (gparam_p)idx, (int *)&tindex) < 0) {
 		LM_ERR("cannot get transaction index\n");
 		return -1;
 	}
 
-	if(fixup_get_ivalue(msg, (gparam_p)lbl, (int*)&tlabel)<0) {
+	if(fixup_get_ivalue(msg, (gparam_p)lbl, (int *)&tlabel) < 0) {
 		LM_ERR("cannot get transaction label\n");
 		return -1;
 	}
 
-	if(fixup_get_svalue(msg, (gparam_t*)ruri, &suri)!=0) {
+	if(fixup_get_svalue(msg, (gparam_t *)ruri, &suri) != 0) {
 		LM_ERR("failed to conert r-uri parameter\n");
 		return -1;
 	}
-	if(ts_check_uri(&suri)<0)
+	if(ts_check_uri(&suri) < 0)
 		return -1;
 
 	/* we do not want to do append by particular location here */
@@ -393,8 +393,8 @@ static int w_ts_append_to2(struct sip_msg* msg, char *idx, char *lbl, char *tabl
 /**
  *
  */
-static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel,
-		str *_table, str *_uri)
+static int ki_ts_append_to_uri(
+		sip_msg_t *_msg, int tindex, int tlabel, str *_table, str *_uri)
 {
 	/* we do not want to do append by particular location */
 	str contact = STR_NULL;
@@ -407,7 +407,8 @@ static int ki_ts_append_to_uri(sip_msg_t* _msg, int tindex, int tlabel,
 /**
  *
  */
-static int w_ts_append_by_contact2(struct sip_msg* _msg, char *_table, char *_ruri)
+static int w_ts_append_by_contact2(
+		struct sip_msg *_msg, char *_table, char *_ruri)
 {
 	str ruri = STR_NULL;
 	str ruri_fixed = STR_NULL;
@@ -418,65 +419,72 @@ static int w_ts_append_by_contact2(struct sip_msg* _msg, char *_table, char *_ru
 
 	int rc;
 
-	if (_ruri==NULL) {
+	if(_ruri == NULL) {
 		LM_ERR("invalid ruri parameter\n");
 		return -1;
 	}
 
 	/* parse R-URI */
-	if (fixup_get_svalue(_msg, (gparam_t*)_ruri, &ruri_fixed)!=0) {
+	if(fixup_get_svalue(_msg, (gparam_t *)_ruri, &ruri_fixed) != 0) {
 		LM_ERR("failed to convert r-uri parameter\n");
 		return -1;
 	}
 
-	if (ruri_fixed.s == NULL || ruri_fixed.len <= 0) {
+	if(ruri_fixed.s == NULL || ruri_fixed.len <= 0) {
 		LM_ERR("invalid ruri parameter - empty or negative length\n");
 		return -1;
 	}
 
-	if (pkg_str_dup(&ruri, &ruri_fixed) < 0) {
+	if(pkg_str_dup(&ruri, &ruri_fixed) < 0) {
 		LM_ERR("failed to copy r-uri parameter\n");
 		return -1;
 	}
 
-	if (ts_check_uri(&ruri) < 0) {
+	if(ts_check_uri(&ruri) < 0) {
 		LM_ERR("failed to parse R-URI.\n");
 		return -1;
 	}
 
 	/* parse Contact header */
-	if ((!_msg->contact && parse_headers(_msg, HDR_CONTACT_F, 0) != 0)
+	if((!_msg->contact && parse_headers(_msg, HDR_CONTACT_F, 0) != 0)
 			|| !_msg->contact) {
 		LM_WARN("missing contact header or the value is empty/malformed.\n");
 		return -1;
 	}
-	if (_msg->contact) {
-		if (parse_contact(_msg->contact) < 0) {
+	if(_msg->contact) {
+		if(parse_contact(_msg->contact) < 0) {
 			LM_WARN("failed to parse Contact header.\n");
 			return -1;
 		}
-		if (parse_uri(
-						((struct contact_body*)_msg->contact->parsed)->contacts->uri.s,
-						((struct contact_body*)_msg->contact->parsed)->contacts->uri.len,
-						&curi) != 0 ) {
-			if (ts_check_uri(&_msg->contact->body) < 0) {	/* one more attempt */
+		if(parse_uri(((struct contact_body *)_msg->contact->parsed)
+							 ->contacts->uri.s,
+				   ((struct contact_body *)_msg->contact->parsed)
+						   ->contacts->uri.len,
+				   &curi)
+				!= 0) {
+			if(ts_check_uri(&_msg->contact->body) < 0) { /* one more attempt */
 				LM_WARN("failed to parse Contact header.\n");
 				return -1;
 			}
 		}
 
-		tmp_contact.len = ((struct contact_body*)_msg->contact->parsed)->contacts->uri.len;
-		tmp_contact.s = (char*)pkg_malloc(tmp_contact.len+1);
-		if (tmp_contact.s == NULL) {
+		tmp_contact.len = ((struct contact_body *)_msg->contact->parsed)
+								  ->contacts->uri.len;
+		tmp_contact.s = (char *)pkg_malloc(tmp_contact.len + 1);
+		if(tmp_contact.s == NULL) {
 			PKG_MEM_ERROR;
 			return -1;
 		}
-		memcpy(tmp_contact.s, ((struct contact_body*)_msg->contact->parsed)->contacts->uri.s, tmp_contact.len);
+		memcpy(tmp_contact.s,
+				((struct contact_body *)_msg->contact->parsed)->contacts->uri.s,
+				tmp_contact.len);
 		tmp_contact.s[tmp_contact.len] = '\0';
 
-		if (pkg_str_dup(&contact, &tmp_contact) < 0) {
-			if (pkg_str_dup(&contact, &_msg->contact->body) < 0) { /* one more attempt */
-				LM_ERR("problems when calling ts_append_contact(), cannot copy Contact parameter.\n");
+		if(pkg_str_dup(&contact, &tmp_contact) < 0) {
+			if(pkg_str_dup(&contact, &_msg->contact->body)
+					< 0) { /* one more attempt */
+				LM_ERR("problems when calling ts_append_contact(), cannot copy "
+					   "Contact parameter.\n");
 				return -1;
 			}
 		}
@@ -496,7 +504,7 @@ static int w_ts_append_by_contact2(struct sip_msg* _msg, char *_table, char *_ru
 /**
  *
  */
-static int ki_ts_append_by_contact(sip_msg_t* _msg, str *_table, str *_ruri)
+static int ki_ts_append_by_contact(sip_msg_t *_msg, str *_table, str *_ruri)
 {
 	str ruri = STR_NULL;
 	str contact = STR_NULL;
@@ -505,37 +513,44 @@ static int ki_ts_append_by_contact(sip_msg_t* _msg, str *_table, str *_ruri)
 	int rc;
 
 	/* parse R-URI */
-	if (ts_check_uri(_ruri) < 0)
+	if(ts_check_uri(_ruri) < 0)
 		return -1;
-	if (pkg_str_dup(&ruri, _ruri) < 0)
+	if(pkg_str_dup(&ruri, _ruri) < 0)
 		return -1;
 
 	/* parse Contact header */
-	if ((!_msg->contact && parse_headers(_msg, HDR_CONTACT_F, 0) != 0) || !_msg->contact)
+	if((!_msg->contact && parse_headers(_msg, HDR_CONTACT_F, 0) != 0)
+			|| !_msg->contact)
 		return -1;
 
-	if (_msg->contact) {
-		if (parse_contact(_msg->contact) < 0)
+	if(_msg->contact) {
+		if(parse_contact(_msg->contact) < 0)
 			return -1;
-		if (parse_uri(
-						((struct contact_body*)_msg->contact->parsed)->contacts->uri.s,
-						((struct contact_body*)_msg->contact->parsed)->contacts->uri.len,
-						&curi) != 0 ) {
-			if (ts_check_uri(&_msg->contact->body) < 0) /* one more attempt */
+		if(parse_uri(((struct contact_body *)_msg->contact->parsed)
+							 ->contacts->uri.s,
+				   ((struct contact_body *)_msg->contact->parsed)
+						   ->contacts->uri.len,
+				   &curi)
+				!= 0) {
+			if(ts_check_uri(&_msg->contact->body) < 0) /* one more attempt */
 				return -1;
 		}
 
-		tmp_contact.len = ((struct contact_body*)_msg->contact->parsed)->contacts->uri.len;
-		tmp_contact.s = (char*)pkg_malloc(tmp_contact.len+1);
-		if (tmp_contact.s == NULL) {
+		tmp_contact.len = ((struct contact_body *)_msg->contact->parsed)
+								  ->contacts->uri.len;
+		tmp_contact.s = (char *)pkg_malloc(tmp_contact.len + 1);
+		if(tmp_contact.s == NULL) {
 			PKG_MEM_ERROR;
 			return -1;
 		}
-		memcpy(tmp_contact.s, ((struct contact_body*)_msg->contact->parsed)->contacts->uri.s, tmp_contact.len);
+		memcpy(tmp_contact.s,
+				((struct contact_body *)_msg->contact->parsed)->contacts->uri.s,
+				tmp_contact.len);
 		tmp_contact.s[tmp_contact.len] = '\0';
 
-		if (pkg_str_dup(&contact, &tmp_contact) < 0) {
-			if (pkg_str_dup(&contact, &_msg->contact->body) < 0) /* one more attempt */
+		if(pkg_str_dup(&contact, &tmp_contact) < 0) {
+			if(pkg_str_dup(&contact, &_msg->contact->body)
+					< 0) /* one more attempt */
 				return -1;
 		}
 	}
@@ -553,8 +568,8 @@ static int ki_ts_append_by_contact(sip_msg_t* _msg, str *_table, str *_ruri)
 /**
  *
  */
-static int w_ts_append_by_contact3(struct sip_msg* _msg, char *_table,
-		char *_ruri, char *_contact)
+static int w_ts_append_by_contact3(
+		struct sip_msg *_msg, char *_table, char *_ruri, char *_contact)
 {
 	str ruri = STR_NULL;
 	str ruri_fixed = STR_NULL;
@@ -564,48 +579,48 @@ static int w_ts_append_by_contact3(struct sip_msg* _msg, char *_table,
 
 	int rc;
 
-	if (_ruri==NULL || _contact==NULL) {
+	if(_ruri == NULL || _contact == NULL) {
 		LM_ERR("invalid ruri or contact parameters\n");
 		return -1;
 	}
 	/* parse R-URI */
-	if (fixup_get_svalue(_msg, (gparam_t*)_ruri, &ruri_fixed)!=0) {
+	if(fixup_get_svalue(_msg, (gparam_t *)_ruri, &ruri_fixed) != 0) {
 		LM_ERR("failed to convert r-uri parameter\n");
 		return -1;
 	}
 
-	if (ruri_fixed.s == NULL || ruri_fixed.len <= 0) {
+	if(ruri_fixed.s == NULL || ruri_fixed.len <= 0) {
 		LM_ERR("invalid ruri parameter - empty or negative length\n");
 		return -1;
 	}
 
-	if (pkg_str_dup(&ruri, &ruri_fixed) < 0) {
+	if(pkg_str_dup(&ruri, &ruri_fixed) < 0) {
 		LM_ERR("failed to copy r-uri parameter\n");
 		return -1;
 	}
 
-	if (ts_check_uri(&ruri) < 0) {
+	if(ts_check_uri(&ruri) < 0) {
 		LM_ERR("failed to parse R-URI.\n");
 		return -1;
 	}
 
 	/* parse Contact header */
-	if (fixup_get_svalue(_msg, (gparam_t*)_contact, &contact_fixed)!=0) {
+	if(fixup_get_svalue(_msg, (gparam_t *)_contact, &contact_fixed) != 0) {
 		LM_ERR("failed to convert contact parameter\n");
 		return -1;
 	}
 
-	if (contact_fixed.s == NULL || contact_fixed.len <= 0) {
+	if(contact_fixed.s == NULL || contact_fixed.len <= 0) {
 		LM_ERR("invalid contact parameter value\n");
 		return -1;
 	}
 
-	if (pkg_str_dup(&contact, &contact_fixed) < 0) {
+	if(pkg_str_dup(&contact, &contact_fixed) < 0) {
 		LM_ERR("failed to copy r-uri parameter\n");
 		return -1;
 	}
 
-	if (ts_check_uri(&contact) < 0) {
+	if(ts_check_uri(&contact) < 0) {
 		LM_ERR("failed to parse Contact parameter.\n");
 		return -1;
 	}
@@ -622,8 +637,8 @@ static int w_ts_append_by_contact3(struct sip_msg* _msg, char *_table,
 /**
  *
  */
-static int ki_ts_append_by_contact_uri(sip_msg_t* _msg, str *_table, str *_ruri,
-		str *_contact)
+static int ki_ts_append_by_contact_uri(
+		sip_msg_t *_msg, str *_table, str *_ruri, str *_contact)
 {
 	str ruri = STR_NULL;
 	str contact = STR_NULL;
@@ -633,13 +648,13 @@ static int ki_ts_append_by_contact_uri(sip_msg_t* _msg, str *_table, str *_ruri,
 	/* parse R-URI */
 	if(ts_check_uri(_ruri) < 0)
 		return -1;
-	if (pkg_str_dup(&ruri, _ruri) < 0)
+	if(pkg_str_dup(&ruri, _ruri) < 0)
 		return -1;
 
 	/* parse Contact header */
-	if (ts_check_uri(_contact) < 0)
+	if(ts_check_uri(_contact) < 0)
 		return -1;
-	if (pkg_str_dup(&contact, _contact) < 0)
+	if(pkg_str_dup(&contact, _contact) < 0)
 		return -1;
 
 	/* contact must be of syntax: sip:<user>@<host>:<port> with no parameters list */
@@ -654,7 +669,7 @@ static int ki_ts_append_by_contact_uri(sip_msg_t* _msg, str *_table, str *_ruri,
 /**
  *
  */
-static int w_ts_store(struct sip_msg* msg, char *p1, char *p2)
+static int w_ts_store(struct sip_msg *msg, char *p1, char *p2)
 {
 	return ts_store(msg, 0);
 }
@@ -662,7 +677,7 @@ static int w_ts_store(struct sip_msg* msg, char *p1, char *p2)
 /**
  *
  */
-static int ki_ts_store(sip_msg_t* msg)
+static int ki_ts_store(sip_msg_t *msg)
 {
 	return ts_store(msg, 0);
 }
@@ -670,11 +685,11 @@ static int ki_ts_store(sip_msg_t* msg)
 /**
  *
  */
-static int w_ts_store1(struct sip_msg* msg, char *_ruri, char *p2)
+static int w_ts_store1(struct sip_msg *msg, char *_ruri, char *p2)
 {
 	str suri;
 
-	if(fixup_get_svalue(msg, (gparam_t*)_ruri, &suri)!=0) {
+	if(fixup_get_svalue(msg, (gparam_t *)_ruri, &suri) != 0) {
 		LM_ERR("failed to conert r-uri parameter\n");
 		return -1;
 	}