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

pua: convert to PKG/SHM memory logging helper functions

* remove trailing spaces
Victor Seva 5 жил өмнө
parent
commit
c91e852d20

+ 31 - 31
src/modules/pua/add_events.c

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  *
  */
  */
@@ -35,7 +35,7 @@ extern int dlginfo_increase_version;
 int pua_add_events(void)
 int pua_add_events(void)
 {
 {
 	/* add presence */
 	/* add presence */
-	if(add_pua_event(PRESENCE_EVENT, "presence", "application/pidf+xml", 
+	if(add_pua_event(PRESENCE_EVENT, "presence", "application/pidf+xml",
 				pres_process_body)< 0)
 				pres_process_body)< 0)
 	{
 	{
 		LM_ERR("while adding event presence\n");
 		LM_ERR("while adding event presence\n");
@@ -68,20 +68,20 @@ int pua_add_events(void)
 	}
 	}
 
 
 	/* add message-summary*/
 	/* add message-summary*/
-	if(add_pua_event(MSGSUM_EVENT, "message-summary", 
+	if(add_pua_event(MSGSUM_EVENT, "message-summary",
 				"application/simple-message-summary", mwi_process_body)< 0)
 				"application/simple-message-summary", mwi_process_body)< 0)
 	{
 	{
 		LM_ERR("while adding event message-summary\n");
 		LM_ERR("while adding event message-summary\n");
 		return -1;
 		return -1;
 	}
 	}
-	
+
 	/* add presence;winfo */
 	/* add presence;winfo */
 	if(add_pua_event(PWINFO_EVENT, "presence.winfo", NULL, NULL)< 0)
 	if(add_pua_event(PWINFO_EVENT, "presence.winfo", NULL, NULL)< 0)
 	{
 	{
 		LM_ERR("while adding event presence.winfo\n");
 		LM_ERR("while adding event presence.winfo\n");
 		return -1;
 		return -1;
 	}
 	}
-	
+
 	/* add application/reginfo+xml */
 	/* add application/reginfo+xml */
 	if (dlginfo_increase_version) {
 	if (dlginfo_increase_version) {
 		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", reginfo_process_body)< 0) {
 		if(add_pua_event(REGINFO_EVENT, "reg", "application/reginfo+xml", reginfo_process_body)< 0) {
@@ -94,7 +94,7 @@ int pua_add_events(void)
 			return -1;
 			return -1;
 		}
 		}
 	}
 	}
-	
+
 	/* add xcap-diff */
 	/* add xcap-diff */
 	if(add_pua_event(XCAPDIFF_EVENT, "xcap-diff",
 	if(add_pua_event(XCAPDIFF_EVENT, "xcap-diff",
 				"application/xcap-diff+xml", 0)< 0)
 				"application/xcap-diff+xml", 0)< 0)
@@ -105,7 +105,7 @@ int pua_add_events(void)
 
 
 	return 0;
 	return 0;
 
 
-}	
+}
 
 
 int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_param)
 int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_param)
 {
 {
@@ -142,19 +142,19 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 		{
 		{
 			tuple_id= buf;
 			tuple_id= buf;
 			tuple_id_len= sprintf(tuple_id, "%p", publ);
 			tuple_id_len= sprintf(tuple_id, "%p", publ);
-			tuple_id[tuple_id_len]= '\0'; 
+			tuple_id[tuple_id_len]= '\0';
 
 
 			tuple=(str*)pkg_malloc(sizeof(str));
 			tuple=(str*)pkg_malloc(sizeof(str));
 			if(tuple== NULL)
 			if(tuple== NULL)
 			{
 			{
-				LM_ERR("No more memory\n");
+				PKG_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			alloc_tuple = 1;
 			alloc_tuple = 1;
 			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
 			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
 			if(tuple->s== NULL)
 			if(tuple->s== NULL)
 			{
 			{
-				LM_ERR("NO more memory\n");
+				PKG_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			memcpy(tuple->s, tuple_id, tuple_id_len);
 			memcpy(tuple->s, tuple_id, tuple_id_len);
@@ -191,18 +191,18 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 			xmlFree(tuple_id);
 			xmlFree(tuple_id);
 			tuple_id= buf;
 			tuple_id= buf;
 			tuple_id_len= strlen(tuple_id);
 			tuple_id_len= strlen(tuple_id);
-		
+
 			tuple=(str*)pkg_malloc(sizeof(str));
 			tuple=(str*)pkg_malloc(sizeof(str));
 			if(tuple== NULL)
 			if(tuple== NULL)
 			{
 			{
-				LM_ERR("No more memory\n");
+				PKG_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			alloc_tuple= 1;
 			alloc_tuple= 1;
 			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
 			tuple->s= (char*)pkg_malloc(tuple_id_len* sizeof(char));
 			if(tuple->s== NULL)
 			if(tuple->s== NULL)
 			{
 			{
-				LM_ERR("NO more memory\n");
+				PKG_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			memcpy(tuple->s, tuple_id, tuple_id_len);
 			memcpy(tuple->s, tuple_id, tuple_id_len);
@@ -217,7 +217,7 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 		LM_DBG("found person node\n");
 		LM_DBG("found person node\n");
 		person_id= xmlNodeGetAttrContentByName(node, "id");
 		person_id= xmlNodeGetAttrContentByName(node, "id");
 		if(person_id== NULL)
 		if(person_id== NULL)
-		{	
+		{
 			if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
 			if(!xmlNewProp(node, BAD_CAST "id", BAD_CAST tuple_id))
 			{
 			{
 				LM_ERR("while extracting xml"
 				LM_ERR("while extracting xml"
@@ -229,23 +229,23 @@ int pres_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple_pa
 		{
 		{
 			xmlFree(person_id);
 			xmlFree(person_id);
 		}
 		}
-	}	
+	}
 	body= (str*)pkg_malloc(sizeof(str));
 	body= (str*)pkg_malloc(sizeof(str));
 	if(body== NULL)
 	if(body== NULL)
 	{
 	{
-		LM_ERR("NO more memory left\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memset(body, 0, sizeof(str));
 	memset(body, 0, sizeof(str));
-	xmlDocDumpFormatMemory(doc,(xmlChar**)(void*)&body->s, &body->len, 1);	
+	xmlDocDumpFormatMemory(doc,(xmlChar**)(void*)&body->s, &body->len, 1);
 	if(body->s== NULL || body->len== 0)
 	if(body->s== NULL || body->len== 0)
 	{
 	{
 		LM_ERR("while dumping xml format\n");
 		LM_ERR("while dumping xml format\n");
 		goto error;
 		goto error;
-	}	
+	}
 	xmlFreeDoc(doc);
 	xmlFreeDoc(doc);
 	doc= NULL;
 	doc= NULL;
-	
+
 	*fin_body= body;
 	*fin_body= body;
 	xmlMemoryDump();
 	xmlMemoryDump();
 	xmlCleanupParser();
 	xmlCleanupParser();
@@ -263,7 +263,7 @@ error:
 	}
 	}
 	return -1;
 	return -1;
 
 
-}	
+}
 
 
 int bla_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
 int bla_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
 {
 {
@@ -295,20 +295,20 @@ int bla_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple)
 	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL)
 	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL)
 	{
 	{
 		LM_ERR("while setting version attribute\n");
 		LM_ERR("while setting version attribute\n");
-		goto error;	
+		goto error;
 	}
 	}
 	body= (str*)pkg_malloc(sizeof(str));
 	body= (str*)pkg_malloc(sizeof(str));
 	if(body== NULL)
 	if(body== NULL)
 	{
 	{
-		LM_ERR("NO more memory left\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memset(body, 0, sizeof(str));
 	memset(body, 0, sizeof(str));
-	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
+	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);
 
 
 	xmlFreeDoc(doc);
 	xmlFreeDoc(doc);
 	doc= NULL;
 	doc= NULL;
-	*fin_body= body;	
+	*fin_body= body;
 	if(*fin_body== NULL)
 	if(*fin_body== NULL)
 		LM_DBG("NULL fin_body\n");
 		LM_DBG("NULL fin_body\n");
 
 
@@ -322,7 +322,7 @@ error:
 		xmlFreeDoc(doc);
 		xmlFreeDoc(doc);
 	if(body)
 	if(body)
 		pkg_free(body);
 		pkg_free(body);
-	
+
 	xmlMemoryDump();
 	xmlMemoryDump();
 	xmlCleanupParser();
 	xmlCleanupParser();
 	return -1;
 	return -1;
@@ -355,19 +355,19 @@ int reginfo_process_body(publ_info_t* publ, str** fin_body, int ver, str** tuple
 
 
 	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL) {
 	if( xmlSetProp(node, (const xmlChar *)"version",(const xmlChar*)version)== NULL) {
 		LM_ERR("while setting version attribute\n");
 		LM_ERR("while setting version attribute\n");
-		goto error;	
+		goto error;
 	}
 	}
 	body= (str*)pkg_malloc(sizeof(str));
 	body= (str*)pkg_malloc(sizeof(str));
 	if(body== NULL) {
 	if(body== NULL) {
-		LM_ERR("NO more memory left\n");
+		PKG_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memset(body, 0, sizeof(str));
 	memset(body, 0, sizeof(str));
-	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);	
+	xmlDocDumpFormatMemory(doc, (xmlChar**)(void*)&body->s, &body->len, 1);
 
 
 	xmlFreeDoc(doc);
 	xmlFreeDoc(doc);
 	doc= NULL;
 	doc= NULL;
-	*fin_body= body;	
+	*fin_body= body;
 	if(*fin_body== NULL)
 	if(*fin_body== NULL)
 		LM_DBG("NULL fin_body\n");
 		LM_DBG("NULL fin_body\n");
 
 
@@ -381,7 +381,7 @@ error:
 		xmlFreeDoc(doc);
 		xmlFreeDoc(doc);
 	if(body)
 	if(body)
 		pkg_free(body);
 		pkg_free(body);
-	
+
 	xmlMemoryDump();
 	xmlMemoryDump();
 	xmlCleanupParser();
 	xmlCleanupParser();
 	return -1;
 	return -1;

+ 20 - 20
src/modules/pua/event_list.c

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  *
  */
  */
@@ -36,11 +36,11 @@ pua_event_t* init_pua_evlist(void)
 	list= (pua_event_t*)shm_malloc(sizeof(pua_event_t));
 	list= (pua_event_t*)shm_malloc(sizeof(pua_event_t));
 	if(list== NULL)
 	if(list== NULL)
 	{
 	{
-		LM_ERR("no more share memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	list->next= NULL;
 	list->next= NULL;
-	
+
 	return list;
 	return list;
 
 
 }
 }
@@ -48,12 +48,12 @@ pua_event_t* init_pua_evlist(void)
 int add_pua_event(int ev_flag, char* name, char* content_type,
 int add_pua_event(int ev_flag, char* name, char* content_type,
 		evs_process_body_t* process_body)
 		evs_process_body_t* process_body)
 {
 {
-		
+
 	pua_event_t* event= NULL;
 	pua_event_t* event= NULL;
 	int size;
 	int size;
 	int name_len;
 	int name_len;
 	int ctype_len= 0;
 	int ctype_len= 0;
-	str str_name;	
+	str str_name;
 
 
 	name_len= strlen(name);
 	name_len= strlen(name);
 	str_name.s= name;
 	str_name.s= name;
@@ -72,9 +72,9 @@ int add_pua_event(int ev_flag, char* name, char* content_type,
 	event= (pua_event_t*)shm_malloc(size);
 	event= (pua_event_t*)shm_malloc(size);
 	if(event== NULL)
 	if(event== NULL)
 	{
 	{
-		LM_ERR("No more share memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
-	}	
+	}
 	memset(event, 0, size);
 	memset(event, 0, size);
 	size= sizeof(pua_event_t);
 	size= sizeof(pua_event_t);
 
 
@@ -82,13 +82,13 @@ int add_pua_event(int ev_flag, char* name, char* content_type,
 	memcpy(event->name.s, name, name_len);
 	memcpy(event->name.s, name, name_len);
 	event->name.len= name_len;
 	event->name.len= name_len;
 	size+= name_len;
 	size+= name_len;
-			
+
 	if(content_type)
 	if(content_type)
 	{
 	{
 		event->content_type.s= (char*)event+ size;
 		event->content_type.s= (char*)event+ size;
 		memcpy(event->content_type.s, content_type, ctype_len);
 		memcpy(event->content_type.s, content_type, ctype_len);
 		event->content_type.len= ctype_len;
 		event->content_type.len= ctype_len;
-		size+= ctype_len;		
+		size+= ctype_len;
 	}
 	}
 
 
 	event->process_body= process_body;
 	event->process_body= process_body;
@@ -98,7 +98,7 @@ int add_pua_event(int ev_flag, char* name, char* content_type,
 	pua_evlist->next= event;
 	pua_evlist->next= event;
 
 
 	return 0;
 	return 0;
-}	
+}
 
 
 pua_event_t* contains_pua_event(str* name)
 pua_event_t* contains_pua_event(str* name)
 {
 {
@@ -110,12 +110,12 @@ pua_event_t* contains_pua_event(str* name)
 		if(event->name.len== name->len &&
 		if(event->name.len== name->len &&
 				strncmp(event->name.s, name->s, name->len)== 0)
 				strncmp(event->name.s, name->s, name->len)== 0)
 		{
 		{
-			return event;	
+			return event;
 		}
 		}
 		event= event->next;
 		event= event->next;
-	}	
+	}
 
 
-	return NULL;	
+	return NULL;
 }
 }
 
 
 pua_event_t* get_event(int ev_flag)
 pua_event_t* get_event(int ev_flag)
@@ -127,11 +127,11 @@ pua_event_t* get_event(int ev_flag)
 	{
 	{
 		if(event->ev_flag== ev_flag)
 		if(event->ev_flag== ev_flag)
 		{
 		{
-			return event;	
+			return event;
 		}
 		}
 		event= event->next;
 		event= event->next;
-	}	
-	return NULL;	
+	}
+	return NULL;
 }
 }
 
 
 
 
@@ -147,8 +147,8 @@ void destroy_pua_evlist(void)
 			e2= e1->next;
 			e2= e1->next;
 			shm_free(e1);
 			shm_free(e1);
 			e1= e2;
 			e1= e2;
-		}	
+		}
 		shm_free(pua_evlist);
 		shm_free(pua_evlist);
-	}	
+	}
 
 
-}	
+}

+ 56 - 52
src/modules/pua/hash.c

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
  */
 
 
@@ -31,7 +31,7 @@
 #include "../../core/hashes.h"
 #include "../../core/hashes.h"
 #include "../../core/parser/msg_parser.h"
 #include "../../core/parser/msg_parser.h"
 #include "../../core/parser/parse_from.h"
 #include "../../core/parser/parse_from.h"
-#include "hash.h" 
+#include "hash.h"
 #include "pua.h"
 #include "pua.h"
 #include "pua_db.h"
 #include "pua_db.h"
 #include "send_publish.h"
 #include "send_publish.h"
@@ -40,14 +40,14 @@ void print_ua_pres(ua_pres_t* p)
 {
 {
 	LM_DBG("\tpres_uri= %.*s   len= %d\n", p->pres_uri->len, p->pres_uri->s, p->pres_uri->len);
 	LM_DBG("\tpres_uri= %.*s   len= %d\n", p->pres_uri->len, p->pres_uri->s, p->pres_uri->len);
 	if(p->watcher_uri)
 	if(p->watcher_uri)
-	{	
+	{
 		LM_DBG("\twatcher_uri= %.*s  len= %d\n", p->watcher_uri->len, p->watcher_uri->s, p->watcher_uri->len);
 		LM_DBG("\twatcher_uri= %.*s  len= %d\n", p->watcher_uri->len, p->watcher_uri->s, p->watcher_uri->len);
 		LM_DBG("\tcall_id= %.*s   len= %d\n", p->call_id.len, p->call_id.s, p->call_id.len);
 		LM_DBG("\tcall_id= %.*s   len= %d\n", p->call_id.len, p->call_id.s, p->call_id.len);
 		LM_DBG("\tfrom_tag= %.*s   len= %d\n", p->from_tag.len, p->from_tag.s, p->from_tag.len);
 		LM_DBG("\tfrom_tag= %.*s   len= %d\n", p->from_tag.len, p->from_tag.s, p->from_tag.len);
 		LM_DBG("\tto_tag= %.*s  len= %d\n", p->to_tag.len, p->to_tag.s, p->to_tag.len);
 		LM_DBG("\tto_tag= %.*s  len= %d\n", p->to_tag.len, p->to_tag.s, p->to_tag.len);
 		LM_DBG("\tflag= %d\n", p->flag);
 		LM_DBG("\tflag= %d\n", p->flag);
 		LM_DBG("\tevent= %d\n", p->event);
 		LM_DBG("\tevent= %d\n", p->event);
-	}	
+	}
 	else
 	else
 	{
 	{
 		LM_DBG("\tetag= %.*s - len= %d\n", p->etag.len, p->etag.s, p->etag.len);
 		LM_DBG("\tetag= %.*s - len= %d\n", p->etag.len, p->etag.s, p->etag.len);
@@ -71,7 +71,7 @@ htable_t* new_htable(void)
 
 
 	if(H== NULL)
 	if(H== NULL)
 	{
 	{
-		LM_ERR("No more memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(H, 0, sizeof(htable_t));
 	memset(H, 0, sizeof(htable_t));
@@ -79,8 +79,8 @@ htable_t* new_htable(void)
 	H->p_records= (hash_entry_t*)shm_malloc(HASH_SIZE* sizeof(hash_entry_t));
 	H->p_records= (hash_entry_t*)shm_malloc(HASH_SIZE* sizeof(hash_entry_t));
 	if(H->p_records== NULL)
 	if(H->p_records== NULL)
 	{
 	{
-		LM_ERR("No more share memory\n");
-		goto error;		
+		SHM_MEM_ERROR;
+		goto error;
 	}
 	}
 
 
 	for(i=0; i<HASH_SIZE; i++)
 	for(i=0; i<HASH_SIZE; i++)
@@ -93,9 +93,9 @@ htable_t* new_htable(void)
 		H->p_records[i].entity= (ua_pres_t*)shm_malloc(sizeof(ua_pres_t));
 		H->p_records[i].entity= (ua_pres_t*)shm_malloc(sizeof(ua_pres_t));
 		if(H->p_records[i].entity== NULL)
 		if(H->p_records[i].entity== NULL)
 		{
 		{
-			LM_ERR("No more share memory\n");
-			goto error;		
-		}	
+			SHM_MEM_ERROR;
+			goto error;
+		}
 		H->p_records[i].entity->next= NULL;
 		H->p_records[i].entity->next= NULL;
 	}
 	}
 	return H;
 	return H;
@@ -138,12 +138,12 @@ ua_pres_t* search_htable(ua_pres_t* pres, unsigned int hash_code)
 			if((p->pres_uri->len==pres->pres_uri->len) &&
 			if((p->pres_uri->len==pres->pres_uri->len) &&
 					(strncmp(p->pres_uri->s, pres->pres_uri->s,pres->pres_uri->len)==0))
 					(strncmp(p->pres_uri->s, pres->pres_uri->s,pres->pres_uri->len)==0))
 			{
 			{
-				if(pres->id.s && pres->id.len) 
-				{	
+				if(pres->id.s && pres->id.len)
+				{
 					if(!(pres->id.len== p->id.len &&
 					if(!(pres->id.len== p->id.len &&
 						strncmp(p->id.s, pres->id.s,pres->id.len)==0))
 						strncmp(p->id.s, pres->id.s,pres->id.len)==0))
 							continue;
 							continue;
-				}				
+				}
 
 
 				if(pres->watcher_uri)
 				if(pres->watcher_uri)
 				{
 				{
@@ -167,7 +167,7 @@ ua_pres_t* search_htable(ua_pres_t* pres, unsigned int hash_code)
 					{
 					{
 						if(pres->etag.len== p->etag.len &&
 						if(pres->etag.len== p->etag.len &&
 							strncmp(p->etag.s, pres->etag.s,pres->etag.len)==0)
 							strncmp(p->etag.s, pres->etag.s,pres->etag.len)==0)
-							break;		
+							break;
 					}
 					}
 					else
 					else
 					{
 					{
@@ -198,16 +198,20 @@ void update_htable(ua_pres_t* p, time_t desired_expires, int expires,
 	}
 	}
 
 
 	if(etag)
 	if(etag)
-	{	
+	{
 		shm_free(p->etag.s);
 		shm_free(p->etag.s);
 		p->etag.s= (char*)shm_malloc(etag->len);
 		p->etag.s= (char*)shm_malloc(etag->len);
+		if(p->etag.s == NULL) {
+			SHM_MEM_ERROR;
+			return;
+		}
 		memcpy(p->etag.s, etag->s, etag->len);
 		memcpy(p->etag.s, etag->s, etag->len);
 		p->etag.len= etag->len;
 		p->etag.len= etag->len;
 	}
 	}
 
 
 	p->expires= expires+ (int)time(NULL);
 	p->expires= expires+ (int)time(NULL);
 	p->desired_expires= desired_expires;
 	p->desired_expires= desired_expires;
-		
+
 	if(p->db_flag & NO_UPDATEDB_FLAG)
 	if(p->db_flag & NO_UPDATEDB_FLAG)
 		p->db_flag= UPDATEDB_FLAG;
 		p->db_flag= UPDATEDB_FLAG;
 
 
@@ -216,7 +220,7 @@ void update_htable(ua_pres_t* p, time_t desired_expires, int expires,
 
 
 	if(contact)
 	if(contact)
 	{
 	{
-		if(!(p->remote_contact.len== contact->len && 
+		if(!(p->remote_contact.len== contact->len &&
 				strncmp(p->remote_contact.s, contact->s, contact->len)==0))
 				strncmp(p->remote_contact.s, contact->s, contact->len)==0))
 		{
 		{
 			/* update remote contact */
 			/* update remote contact */
@@ -224,7 +228,7 @@ void update_htable(ua_pres_t* p, time_t desired_expires, int expires,
 			p->remote_contact.s= (char*)shm_malloc(contact->len* sizeof(char));
 			p->remote_contact.s= (char*)shm_malloc(contact->len* sizeof(char));
 			if(p->remote_contact.s== NULL)
 			if(p->remote_contact.s== NULL)
 			{
 			{
-				LM_ERR("no more shared memory\n");
+				SHM_MEM_ERROR;
 				return;
 				return;
 			}
 			}
 			memcpy(p->remote_contact.s, contact->s, contact->len);
 			memcpy(p->remote_contact.s, contact->s, contact->len);
@@ -247,7 +251,7 @@ void insert_htable(ua_pres_t* presentity, unsigned int hash_code)
 
 
 	presentity->db_flag= INSERTDB_FLAG;
 	presentity->db_flag= INSERTDB_FLAG;
 	presentity->next= p->next;
 	presentity->next= p->next;
-	
+
 	p->next= presentity;
 	p->next= presentity;
 }
 }
 
 
@@ -256,7 +260,7 @@ void insert_htable(ua_pres_t* presentity, unsigned int hash_code)
    everywhere it is used it is passed a pointer to the correct
    everywhere it is used it is passed a pointer to the correct
    hash table entry already...  so let's just delete that */
    hash table entry already...  so let's just delete that */
 void delete_htable(ua_pres_t* presentity, unsigned int hash_code)
 void delete_htable(ua_pres_t* presentity, unsigned int hash_code)
-{ 
+{
 	ua_pres_t *q = NULL;
 	ua_pres_t *q = NULL;
 
 
 	if (dbmode==PUA_DB_ONLY)
 	if (dbmode==PUA_DB_ONLY)
@@ -273,7 +277,7 @@ void delete_htable(ua_pres_t* presentity, unsigned int hash_code)
 	while (q->next != presentity)
 	while (q->next != presentity)
 		q = q->next;
 		q = q->next;
 	q->next = presentity->next;
 	q->next = presentity->next;
-	
+
 	if(presentity->etag.s)
 	if(presentity->etag.s)
 		shm_free(presentity->etag.s);
 		shm_free(presentity->etag.s);
 	else
 	else
@@ -284,7 +288,7 @@ void delete_htable(ua_pres_t* presentity, unsigned int hash_code)
 	presentity = NULL;
 	presentity = NULL;
 
 
 }
 }
-	
+
 void destroy_htable(void)
 void destroy_htable(void)
 {
 {
 	ua_pres_t* p= NULL,*q= NULL;
 	ua_pres_t* p= NULL,*q= NULL;
@@ -297,7 +301,7 @@ void destroy_htable(void)
 	}
 	}
 
 
 	for(i=0; i<HASH_SIZE; i++)
 	for(i=0; i<HASH_SIZE; i++)
-	{	
+	{
 		lock_destroy(&HashT->p_records[i].lock);
 		lock_destroy(&HashT->p_records[i].lock);
 		p=HashT->p_records[i].entity;
 		p=HashT->p_records[i].entity;
 		while(p->next)
 		while(p->next)
@@ -317,7 +321,7 @@ void destroy_htable(void)
 	}
 	}
     shm_free(HashT->p_records);
     shm_free(HashT->p_records);
 	shm_free(HashT);
 	shm_free(HashT);
-  
+
   return;
   return;
 }
 }
 
 
@@ -326,7 +330,7 @@ int convert_temporary_dialog(ua_pres_t *dialog)
 	ua_pres_t *temp_dialog;
 	ua_pres_t *temp_dialog;
 	unsigned int hash_code;
 	unsigned int hash_code;
 
 
-	hash_code= core_hash(dialog->pres_uri,dialog->watcher_uri, HASH_SIZE); 
+	hash_code= core_hash(dialog->pres_uri,dialog->watcher_uri, HASH_SIZE);
 	lock_get(&HashT->p_records[hash_code].lock);
 	lock_get(&HashT->p_records[hash_code].lock);
 
 
 	temp_dialog = get_temporary_dialog(dialog, hash_code);
 	temp_dialog = get_temporary_dialog(dialog, hash_code);
@@ -374,19 +378,19 @@ ua_pres_t* get_dialog(ua_pres_t* dialog, unsigned int hash_code)
 
 
 			LM_DBG("searched to_tag= %.*s\tfrom_tag= %.*s\n",
 			LM_DBG("searched to_tag= %.*s\tfrom_tag= %.*s\n",
 				 p->to_tag.len, p->to_tag.s, p->from_tag.len, p->from_tag.s);
 				 p->to_tag.len, p->to_tag.s, p->from_tag.len, p->from_tag.s);
-	    
+
 			if( (strncmp(p->call_id.s, dialog->call_id.s, p->call_id.len)== 0) &&
 			if( (strncmp(p->call_id.s, dialog->call_id.s, p->call_id.len)== 0) &&
 				p->to_tag.len > 0 &&
 				p->to_tag.len > 0 &&
 				(strncmp(p->to_tag.s, dialog->to_tag.s, p->to_tag.len)== 0) &&
 				(strncmp(p->to_tag.s, dialog->to_tag.s, p->to_tag.len)== 0) &&
 				(strncmp(p->from_tag.s, dialog->from_tag.s, p->from_tag.len)== 0) )
 				(strncmp(p->from_tag.s, dialog->from_tag.s, p->from_tag.len)== 0) )
-				{	
+				{
 					LM_DBG("FOUND dialog\n");
 					LM_DBG("FOUND dialog\n");
 					break;
 					break;
 				}
 				}
-		}	
-	
+		}
+
 	}
 	}
-		
+
 	return p;
 	return p;
 }
 }
 
 
@@ -449,14 +453,14 @@ int get_record_id(ua_pres_t* dialog, str** rec_id)
 	id= (str*)pkg_malloc(sizeof(str));
 	id= (str*)pkg_malloc(sizeof(str));
 	if(id== NULL)
 	if(id== NULL)
 	{
 	{
-		LM_ERR("No more memory\n");
+		PKG_MEM_ERROR;
 		lock_release(&HashT->p_records[hash_code].lock);
 		lock_release(&HashT->p_records[hash_code].lock);
 		return -1;
 		return -1;
 	}
 	}
 	id->s= (char*)pkg_malloc(rec->id.len* sizeof(char));
 	id->s= (char*)pkg_malloc(rec->id.len* sizeof(char));
 	if(id->s== NULL)
 	if(id->s== NULL)
 	{
 	{
-		LM_ERR("No more memory\n");
+		PKG_MEM_ERROR;
 		pkg_free(id);
 		pkg_free(id);
 		lock_release(&HashT->p_records[hash_code].lock);
 		lock_release(&HashT->p_records[hash_code].lock);
 		return -1;
 		return -1;
@@ -484,7 +488,7 @@ int is_dialog(ua_pres_t* dialog)
 	if (dbmode==PUA_DB_ONLY)
 	if (dbmode==PUA_DB_ONLY)
 	{
 	{
 		return( is_dialog_puadb(dialog) );
 		return( is_dialog_puadb(dialog) );
-	}	
+	}
 
 
 	hash_code= core_hash(dialog->pres_uri, dialog->watcher_uri, HASH_SIZE);
 	hash_code= core_hash(dialog->pres_uri, dialog->watcher_uri, HASH_SIZE);
 	lock_get(&HashT->p_records[hash_code].lock);
 	lock_get(&HashT->p_records[hash_code].lock);
@@ -499,7 +503,7 @@ int is_dialog(ua_pres_t* dialog)
 		ret_code= 0;
 		ret_code= 0;
 	}
 	}
 	lock_release(&HashT->p_records[hash_code].lock);
 	lock_release(&HashT->p_records[hash_code].lock);
-	
+
 	return ret_code;
 	return ret_code;
 
 
 }
 }
@@ -522,8 +526,8 @@ int ki_pua_update_contact(struct sip_msg* msg)
 	{
 	{
 		LM_ERR("cannot parse callid header\n");
 		LM_ERR("cannot parse callid header\n");
 		return -1;
 		return -1;
-	}		
-	
+	}
+
 	if (!msg->from || !msg->from->body.s)
 	if (!msg->from || !msg->from->body.s)
 	{
 	{
 		LM_ERR("cannot find 'from' header!\n");
 		LM_ERR("cannot find 'from' header!\n");
@@ -531,27 +535,27 @@ int ki_pua_update_contact(struct sip_msg* msg)
 	}
 	}
 	if (msg->from->parsed == NULL)
 	if (msg->from->parsed == NULL)
 	{
 	{
-		if ( parse_from_header( msg )<0 ) 
+		if ( parse_from_header( msg )<0 )
 		{
 		{
 			LM_ERR("cannot parse From header\n");
 			LM_ERR("cannot parse From header\n");
 			return -1;
 			return -1;
 		}
 		}
 	}
 	}
-	
+
 	pfrom = (struct to_body*)msg->from->parsed;
 	pfrom = (struct to_body*)msg->from->parsed;
-	
+
 	if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
 	if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
 	{
 	{
 		LM_ERR("no from tag value present\n");
 		LM_ERR("no from tag value present\n");
 		return -1;
 		return -1;
-	}		
-	
+	}
+
 	if( msg->to==NULL || msg->to->body.s==NULL)
 	if( msg->to==NULL || msg->to->body.s==NULL)
 	{
 	{
 		LM_ERR("cannot parse TO header\n");
 		LM_ERR("cannot parse TO header\n");
 		return -1;
 		return -1;
-	}			
-	
+	}
+
 	if(msg->to->parsed != NULL)
 	if(msg->to->parsed != NULL)
 	{
 	{
 		pto = (struct to_body*)msg->to->parsed;
 		pto = (struct to_body*)msg->to->parsed;
@@ -561,24 +565,24 @@ int ki_pua_update_contact(struct sip_msg* msg)
 	{
 	{
 		parse_to(msg->to->body.s,msg->to->body.s +
 		parse_to(msg->to->body.s,msg->to->body.s +
 			msg->to->body.len + 1, &TO);
 			msg->to->body.len + 1, &TO);
-		if(TO.uri.len <= 0) 
+		if(TO.uri.len <= 0)
 		{
 		{
 			LM_DBG("'To' header NOT parsed\n");
 			LM_DBG("'To' header NOT parsed\n");
 			goto error;
 			goto error;
 		}
 		}
 		pto = &TO;
 		pto = &TO;
-	}			
+	}
 	if( pto->tag_value.s ==NULL || pto->tag_value.len == 0)
 	if( pto->tag_value.s ==NULL || pto->tag_value.len == 0)
 	{
 	{
 		LM_ERR("no from tag value present\n");
 		LM_ERR("no from tag value present\n");
 		goto error;
 		goto error;
 	}
 	}
 	hentity.watcher_uri= &pto->uri;
 	hentity.watcher_uri= &pto->uri;
-	hentity.pres_uri= &pfrom->uri; 
+	hentity.pres_uri= &pfrom->uri;
 	hentity.call_id=  msg->callid->body;
 	hentity.call_id=  msg->callid->body;
 	hentity.to_tag= pto->tag_value;
 	hentity.to_tag= pto->tag_value;
 	hentity.from_tag= pfrom->tag_value;
 	hentity.from_tag= pfrom->tag_value;
-	
+
 
 
 	/* extract the contact */
 	/* extract the contact */
 	if(msg->contact== NULL || msg->contact->body.s== NULL)
 	if(msg->contact== NULL || msg->contact->body.s== NULL)
@@ -610,7 +614,7 @@ int ki_pua_update_contact(struct sip_msg* msg)
 
 
 	shm_free(p->remote_contact.s);
 	shm_free(p->remote_contact.s);
 
 
-	if(!(p->remote_contact.len== contact.len && 
+	if(!(p->remote_contact.len== contact.len &&
 				strncmp(p->remote_contact.s, contact.s, contact.len)==0))
 				strncmp(p->remote_contact.s, contact.s, contact.len)==0))
 	{
 	{
 		/* update remote contact */
 		/* update remote contact */
@@ -618,7 +622,7 @@ int ki_pua_update_contact(struct sip_msg* msg)
 		p->remote_contact.s= (char*)shm_malloc(contact.len* sizeof(char));
 		p->remote_contact.s= (char*)shm_malloc(contact.len* sizeof(char));
 		if(p->remote_contact.s== NULL)
 		if(p->remote_contact.s== NULL)
 		{
 		{
-			LM_ERR("no more shared memory\n");
+			SHM_MEM_ERROR;
 			lock_release(&HashT->p_records[hash_code].lock);
 			lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 			goto error;
 		}
 		}
@@ -665,14 +669,14 @@ list_entry_t *get_subs_list(str *did)
 			{
 			{
 				if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
 				if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
 				{
 				{
-					LM_ERR("out of private memory\n");
+					PKG_MEM_ERROR;
 					lock_release(&HashT->p_records[i].lock);
 					lock_release(&HashT->p_records[i].lock);
 					goto done;
 					goto done;
 				}
 				}
 				if ((tmp_str->s = (char *)pkg_malloc(sizeof(char) * dialog->pres_uri->len + 1)) == NULL)
 				if ((tmp_str->s = (char *)pkg_malloc(sizeof(char) * dialog->pres_uri->len + 1)) == NULL)
 				{
 				{
 					pkg_free(tmp_str);
 					pkg_free(tmp_str);
-					LM_ERR("out of private memory\n");
+					PKG_MEM_ERROR;
 					lock_release(&HashT->p_records[i].lock);
 					lock_release(&HashT->p_records[i].lock);
 					goto done;
 					goto done;
 				}
 				}

+ 3 - 3
src/modules/pua/pua.c

@@ -498,7 +498,7 @@ static int db_restore(void)
 			p= (ua_pres_t*)shm_malloc(size);
 			p= (ua_pres_t*)shm_malloc(size);
 			if(p== NULL)
 			if(p== NULL)
 			{
 			{
-				LM_ERR("no more share memmory");
+				SHM_MEM_ERROR;
 				goto error;
 				goto error;
 			}
 			}
 			memset(p, 0, size);
 			memset(p, 0, size);
@@ -568,7 +568,7 @@ static int db_restore(void)
 				p->remote_contact.s= (char*)shm_malloc(remote_contact.len* sizeof(char));
 				p->remote_contact.s= (char*)shm_malloc(remote_contact.len* sizeof(char));
 				if(p->remote_contact.s== NULL)
 				if(p->remote_contact.s== NULL)
 				{
 				{
-					LM_ERR("No more shared memory\n");
+					SHM_MEM_ERROR;
 					goto error;
 					goto error;
 				}
 				}
 				memcpy(p->remote_contact.s, remote_contact.s, remote_contact.len);
 				memcpy(p->remote_contact.s, remote_contact.s, remote_contact.len);
@@ -600,7 +600,7 @@ static int db_restore(void)
 				p->etag.s= (char*)shm_malloc(etag.len* sizeof(char));
 				p->etag.s= (char*)shm_malloc(etag.len* sizeof(char));
 				if(p->etag.s==  NULL)
 				if(p->etag.s==  NULL)
 				{
 				{
-					LM_ERR("no more share memory\n");
+					SHM_MEM_ERROR;
 					goto error;
 					goto error;
 				}
 				}
 				memcpy(p->etag.s, etag.s, etag.len);
 				memcpy(p->etag.s, etag.s, etag.len);

+ 7 - 7
src/modules/pua/pua_callback.c

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
  */
 
 
@@ -35,7 +35,7 @@ int init_puacb_list(void)
 		( sizeof(struct puacb_head_list) );
 		( sizeof(struct puacb_head_list) );
 	if (puacb_list==0)
 	if (puacb_list==0)
 	{
 	{
-		LM_CRIT("no more shared mem\n");
+		SHM_MEM_ERROR;
 		return -1;
 		return -1;
 	}
 	}
 	puacb_list->first = 0;
 	puacb_list->first = 0;
@@ -55,7 +55,7 @@ void destroy_puacb_list(void)
 	{
 	{
 		cbp_tmp = cbp;
 		cbp_tmp = cbp;
 		cbp = cbp->next;
 		cbp = cbp->next;
-		if (cbp_tmp->param) 
+		if (cbp_tmp->param)
 			shm_free( cbp_tmp->param );
 			shm_free( cbp_tmp->param );
 		shm_free( cbp_tmp );
 		shm_free( cbp_tmp );
 	}
 	}
@@ -71,7 +71,7 @@ int register_puacb( int types, pua_cb f, void* param )
 	struct pua_callback *cbp;
 	struct pua_callback *cbp;
 
 
 	/* are the callback types valid?... */
 	/* are the callback types valid?... */
-	if ( types<0 || types>PUACB_MAX ) 
+	if ( types<0 || types>PUACB_MAX )
 	{
 	{
 		LM_CRIT("invalid callback types: mask=%d\n",types);
 		LM_CRIT("invalid callback types: mask=%d\n",types);
 		return E_BUG;
 		return E_BUG;
@@ -84,9 +84,9 @@ int register_puacb( int types, pua_cb f, void* param )
 	}
 	}
 
 
 	/* build a new callback structure */
 	/* build a new callback structure */
-	if (!(cbp=(struct pua_callback*)shm_malloc(sizeof( struct pua_callback)))) 
+	if (!(cbp=(struct pua_callback*)shm_malloc(sizeof( struct pua_callback))))
 	{
 	{
-		LM_ERR("out of share mem\n");
+		SHM_MEM_ERROR;
 		return E_OUT_OF_MEM;
 		return E_OUT_OF_MEM;
 	}
 	}
 
 

+ 83 - 83
src/modules/pua/pua_db.c

@@ -1,5 +1,5 @@
 /*
 /*
- * pua db - presence user agent database support 
+ * pua db - presence user agent database support
  *
  *
  * Copyright (C) 2011 Crocodile RCS Ltd
  * Copyright (C) 2011 Crocodile RCS Ltd
  *
  *
@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
  */
 
 
@@ -62,7 +62,7 @@ static str str_version_col = str_init("version");
 void free_results_puadb( db1_res_t *res )
 void free_results_puadb( db1_res_t *res )
 
 
 {
 {
-	if (res) 
+	if (res)
 	{
 	{
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		res = NULL;
 		res = NULL;
@@ -164,7 +164,7 @@ int clean_puadb( int update_period, int min_expires )
 	q_vals[0].type = DB1_INT;
 	q_vals[0].type = DB1_INT;
 	q_vals[0].nul = 0;
 	q_vals[0].nul = 0;
 	q_vals[0].val.int_val = now+update_period;
 	q_vals[0].val.int_val = now+update_period;
-	q_ops[0] = OP_LT; 	
+	q_ops[0] = OP_LT;
 
 
 	if (pua_dbf.use_table(pua_db, &db_table) < 0) {
 	if (pua_dbf.use_table(pua_db, &db_table) < 0) {
 	    LM_ERR("error in use_table pua\n");
 	    LM_ERR("error in use_table pua\n");
@@ -186,7 +186,7 @@ int clean_puadb( int update_period, int min_expires )
 
 
 	if (RES_ROW_N(res) == 0)
 	if (RES_ROW_N(res) == 0)
 	{
 	{
-		/* no match */ 
+		/* no match */
 		LM_DBG( "No records matched for clean\n");
 		LM_DBG( "No records matched for clean\n");
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		return(0);
 		return(0);
@@ -202,7 +202,7 @@ int clean_puadb( int update_period, int min_expires )
 		{
 		{
 			values = ROW_VALUES(rows+i);
 			values = ROW_VALUES(rows+i);
 
 
-			extract_row( values, &p ); 
+			extract_row( values, &p );
 			id = VAL_INT(values);
 			id = VAL_INT(values);
 
 
 			if((p.desired_expires> p.expires + min_expires) || (p.desired_expires== 0 ))
 			if((p.desired_expires> p.expires + min_expires) || (p.desired_expires== 0 ))
@@ -224,8 +224,8 @@ int clean_puadb( int update_period, int min_expires )
 
 
 				if ( pua_dbf.delete(pua_db, q_cols, 0, q_vals, 1) < 0 )
 				if ( pua_dbf.delete(pua_db, q_cols, 0, q_vals, 1) < 0 )
 				{
 				{
-					LM_ERR( "Failed to delete from db\n" ); 
-				}			
+					LM_ERR( "Failed to delete from db\n" );
+				}
 			}
 			}
 
 
 		}
 		}
@@ -238,7 +238,7 @@ int clean_puadb( int update_period, int min_expires )
 
 
 /******************************************************************************/
 /******************************************************************************/
 
 
-int is_dialog_puadb(ua_pres_t *pres) 
+int is_dialog_puadb(ua_pres_t *pres)
 
 
 {
 {
 	int nr_rows;
 	int nr_rows;
@@ -254,26 +254,26 @@ int is_dialog_puadb(ua_pres_t *pres)
 	}
 	}
 
 
 	/* cols and values used for search query */
 	/* cols and values used for search query */
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_to_tag_col;	
+	q_cols[n_query_cols] = &str_to_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
 	/* return the id column, even though don't actually need */
 	/* return the id column, even though don't actually need */
-	res_cols[n_res_cols] = &str_id_col;	
+	res_cols[n_res_cols] = &str_id_col;
 	n_res_cols++;
 	n_res_cols++;
 
 
 	if(pua_db == NULL)
 	if(pua_db == NULL)
@@ -306,7 +306,7 @@ int is_dialog_puadb(ua_pres_t *pres)
 
 
 	if (nr_rows == 0)
 	if (nr_rows == 0)
 	{
 	{
-		/* no match */ 
+		/* no match */
 		LM_DBG("No rows found.\n");
 		LM_DBG("No rows found.\n");
 		return(-1);
 		return(-1);
 	}
 	}
@@ -326,7 +326,7 @@ int is_dialog_puadb(ua_pres_t *pres)
 
 
 /******************************************************************************/
 /******************************************************************************/
 
 
-int get_record_id_puadb(ua_pres_t *pres, str **rec_id ) 
+int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
 
 
 {
 {
 	int nr_rows;
 	int nr_rows;
@@ -335,7 +335,7 @@ int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
 	db1_res_t *res= NULL;
 	db1_res_t *res= NULL;
 	db_val_t q_vals[3];
 	db_val_t q_vals[3];
 	int n_query_cols=0, n_res_cols=0;
 	int n_query_cols=0, n_res_cols=0;
-	db_val_t *values;	
+	db_val_t *values;
 	str *id;
 	str *id;
 	str to_tag;
 	str to_tag;
 
 
@@ -346,25 +346,25 @@ int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
 	}
 	}
 
 
 	/* cols and values used for search query */
 	/* cols and values used for search query */
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_to_tag_col;	
+	q_cols[n_query_cols] = &str_to_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	res_cols[n_res_cols] = &str_pres_id_col;	
+	res_cols[n_res_cols] = &str_pres_id_col;
 	n_res_cols++;
 	n_res_cols++;
 
 
 	*rec_id = NULL;
 	*rec_id = NULL;
@@ -467,7 +467,7 @@ int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
 
 
 	if(id== NULL)
 	if(id== NULL)
 	{
 	{
-		LM_ERR("No more memory\n");
+		PKG_MEM_ERROR;
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		return(-1);
 		return(-1);
 	}
 	}
@@ -476,7 +476,7 @@ int get_record_id_puadb(ua_pres_t *pres, str **rec_id )
 
 
 	if(id->s== NULL)
 	if(id->s== NULL)
 	{
 	{
-		LM_ERR("No more memory\n");
+		PKG_MEM_ERROR;
 		pkg_free(id);
 		pkg_free(id);
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		return(-1);
 		return(-1);
@@ -519,13 +519,13 @@ int convert_temporary_dialog_puadb(ua_pres_t *pres)
 	query_vals[n_query_cols].val.str_val.len = pres->pres_uri->len;
 	query_vals[n_query_cols].val.str_val.len = pres->pres_uri->len;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	query_cols[n_query_cols] = &str_call_id_col;	
+	query_cols[n_query_cols] = &str_call_id_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val = pres->call_id;
 	query_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	query_cols[n_query_cols] = &str_from_tag_col;	
+	query_cols[n_query_cols] = &str_from_tag_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val = pres->from_tag;
 	query_vals[n_query_cols].val.str_val = pres->from_tag;
@@ -601,7 +601,7 @@ int convert_temporary_dialog_puadb(ua_pres_t *pres)
 	}
 	}
 	n_query_cols++;
 	n_query_cols++;
 
 
-	query_cols[n_query_cols] = &str_event_col;	
+	query_cols[n_query_cols] = &str_event_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.int_val = pres->event;
 	query_vals[n_query_cols].val.int_val = pres->event;
@@ -609,21 +609,21 @@ int convert_temporary_dialog_puadb(ua_pres_t *pres)
 
 
 	query_cols[n_query_cols] = &str_watcher_uri_col;
 	query_cols[n_query_cols] = &str_watcher_uri_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].type = DB1_STR;
-	query_vals[n_query_cols].nul = 0; 
+	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val.s = pres->watcher_uri->s;
 	query_vals[n_query_cols].val.str_val.s = pres->watcher_uri->s;
 	query_vals[n_query_cols].val.str_val.len = pres->watcher_uri->len;
 	query_vals[n_query_cols].val.str_val.len = pres->watcher_uri->len;
 	n_query_cols++;
 	n_query_cols++;
 
 
 	query_cols[n_query_cols] = &str_etag_col;
 	query_cols[n_query_cols] = &str_etag_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].type = DB1_STR;
-	query_vals[n_query_cols].nul = 0; 
+	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val.s = 0;
 	query_vals[n_query_cols].val.str_val.s = 0;
 	query_vals[n_query_cols].val.str_val.len = 0;
 	query_vals[n_query_cols].val.str_val.len = 0;
 	n_query_cols++;
 	n_query_cols++;
 
 
 	query_cols[n_query_cols] = &str_tuple_id_col;
 	query_cols[n_query_cols] = &str_tuple_id_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].type = DB1_STR;
-	query_vals[n_query_cols].nul = 0; 
+	query_vals[n_query_cols].nul = 0;
 	query_vals[n_query_cols].val.str_val.s = 0;
 	query_vals[n_query_cols].val.str_val.s = 0;
 	query_vals[n_query_cols].val.str_val.len = 0;
 	query_vals[n_query_cols].val.str_val.len = 0;
 	n_query_cols++;
 	n_query_cols++;
@@ -692,14 +692,14 @@ int insert_record_puadb(ua_pres_t* pres)
 	db_vals[n_cols].val.str_val.len = pres->pres_uri->len;
 	db_vals[n_cols].val.str_val.len = pres->pres_uri->len;
 	n_cols++;
 	n_cols++;
 
 
-	db_cols[n_cols] = &str_pres_id_col;	
+	db_cols[n_cols] = &str_pres_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->id.s;
 	db_vals[n_cols].val.str_val.s = pres->id.s;
 	db_vals[n_cols].val.str_val.len = pres->id.len;
 	db_vals[n_cols].val.str_val.len = pres->id.len;
 	n_cols++;
 	n_cols++;
 
 
-	db_cols[n_cols] = &str_event_col;	
+	db_cols[n_cols] = &str_event_col;
 	db_vals[n_cols].type = DB1_INT;
 	db_vals[n_cols].type = DB1_INT;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.int_val = pres->event;
 	db_vals[n_cols].val.int_val = pres->event;
@@ -725,42 +725,42 @@ int insert_record_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_etag_col;
 	db_cols[n_cols] = &str_etag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->etag.s;
 	db_vals[n_cols].val.str_val.s = pres->etag.s;
 	db_vals[n_cols].val.str_val.len = pres->etag.len;
 	db_vals[n_cols].val.str_val.len = pres->etag.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_tuple_id_col;
 	db_cols[n_cols] = &str_tuple_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->tuple_id.s;
 	db_vals[n_cols].val.str_val.s = pres->tuple_id.s;
 	db_vals[n_cols].val.str_val.len = pres->tuple_id.len;
 	db_vals[n_cols].val.str_val.len = pres->tuple_id.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_watcher_uri_col;
 	db_cols[n_cols] = &str_watcher_uri_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_call_id_col;
 	db_cols[n_cols] = &str_call_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_to_tag_col;
 	db_cols[n_cols] = &str_to_tag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_from_tag_col;
 	db_cols[n_cols] = &str_from_tag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
@@ -773,21 +773,21 @@ int insert_record_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_record_route_col;
 	db_cols[n_cols] = &str_record_route_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_contact_col;
 	db_cols[n_cols] = &str_contact_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_remote_contact_col;
 	db_cols[n_cols] = &str_remote_contact_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
@@ -800,7 +800,7 @@ int insert_record_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_extra_headers_col;
 	db_cols[n_cols] = &str_extra_headers_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	if (pres->extra_headers)
 	if (pres->extra_headers)
 	{
 	{
 		db_vals[n_cols].val.str_val.s = pres->extra_headers->s;
 		db_vals[n_cols].val.str_val.s = pres->extra_headers->s;
@@ -819,7 +819,7 @@ int insert_record_puadb(ua_pres_t* pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	if(pua_dbf.insert(pua_db, db_cols, db_vals, n_cols) < 0)  
+	if(pua_dbf.insert(pua_db, db_cols, db_vals, n_cols) < 0)
 	{
 	{
 		LM_ERR("DB insert failed\n");
 		LM_ERR("DB insert failed\n");
 		return(-1);
 		return(-1);
@@ -839,7 +839,7 @@ ua_pres_t *get_record_puadb(str pres_id, str *etag, ua_pres_t *result, db1_res_t
 	int n_query_cols = 0, nr_rows;
 	int n_query_cols = 0, nr_rows;
 	db_query_f query_fn = pua_dbf.query_lock ? pua_dbf.query_lock : pua_dbf.query;
 	db_query_f query_fn = pua_dbf.query_lock ? pua_dbf.query_lock : pua_dbf.query;
 
 
-	q_cols[n_query_cols] = &str_pres_id_col;	
+	q_cols[n_query_cols] = &str_pres_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres_id;
 	q_vals[n_query_cols].val.str_val = pres_id;
@@ -884,7 +884,7 @@ ua_pres_t *get_record_puadb(str pres_id, str *etag, ua_pres_t *result, db1_res_t
 
 
 	if (nr_rows == 0)
 	if (nr_rows == 0)
 	{
 	{
-		/* no match */ 
+		/* no match */
 		LM_DBG("No rows found\n");
 		LM_DBG("No rows found\n");
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		return(NULL);
 		return(NULL);
@@ -922,7 +922,7 @@ int delete_record_puadb(ua_pres_t *pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	q_cols[n_query_cols] = &str_pres_id_col;	
+	q_cols[n_query_cols] = &str_pres_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->id;
 	q_vals[n_query_cols].val.str_val = pres->id;
@@ -949,7 +949,7 @@ int delete_record_puadb(ua_pres_t *pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0) 
+	if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0)
 	{
 	{
 		LM_ERR("deleting record\n");
 		LM_ERR("deleting record\n");
 		return -1;
 		return -1;
@@ -972,7 +972,7 @@ int update_record_puadb(ua_pres_t *pres, int expires, str *etag)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	q_cols[n_query_cols] = &str_pres_id_col;	
+	q_cols[n_query_cols] = &str_pres_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->id;
 	q_vals[n_query_cols].val.str_val = pres->id;
@@ -1056,14 +1056,14 @@ int insert_dialog_puadb(ua_pres_t* pres)
 	db_vals[n_cols].val.str_val.len = pres->pres_uri->len;
 	db_vals[n_cols].val.str_val.len = pres->pres_uri->len;
 	n_cols++;
 	n_cols++;
 
 
-	db_cols[n_cols] = &str_pres_id_col;	
+	db_cols[n_cols] = &str_pres_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->id.s;
 	db_vals[n_cols].val.str_val.s = pres->id.s;
 	db_vals[n_cols].val.str_val.len = pres->id.len;
 	db_vals[n_cols].val.str_val.len = pres->id.len;
 	n_cols++;
 	n_cols++;
 
 
-	db_cols[n_cols] = &str_event_col;	
+	db_cols[n_cols] = &str_event_col;
 	db_vals[n_cols].type = DB1_INT;
 	db_vals[n_cols].type = DB1_INT;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.int_val = pres->event;
 	db_vals[n_cols].val.int_val = pres->event;
@@ -1089,42 +1089,42 @@ int insert_dialog_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_etag_col;
 	db_cols[n_cols] = &str_etag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_tuple_id_col;
 	db_cols[n_cols] = &str_tuple_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.s = "";
 	db_vals[n_cols].val.str_val.len = 0;
 	db_vals[n_cols].val.str_val.len = 0;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_watcher_uri_col;
 	db_cols[n_cols] = &str_watcher_uri_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->watcher_uri->s;
 	db_vals[n_cols].val.str_val.s = pres->watcher_uri->s;
 	db_vals[n_cols].val.str_val.len = pres->watcher_uri->len;
 	db_vals[n_cols].val.str_val.len = pres->watcher_uri->len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_call_id_col;
 	db_cols[n_cols] = &str_call_id_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->call_id.s;
 	db_vals[n_cols].val.str_val.s = pres->call_id.s;
 	db_vals[n_cols].val.str_val.len = pres->call_id.len;
 	db_vals[n_cols].val.str_val.len = pres->call_id.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_to_tag_col;
 	db_cols[n_cols] = &str_to_tag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->to_tag.s;
 	db_vals[n_cols].val.str_val.s = pres->to_tag.s;
 	db_vals[n_cols].val.str_val.len = pres->to_tag.len;
 	db_vals[n_cols].val.str_val.len = pres->to_tag.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_from_tag_col;
 	db_cols[n_cols] = &str_from_tag_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->from_tag.s;
 	db_vals[n_cols].val.str_val.s = pres->from_tag.s;
 	db_vals[n_cols].val.str_val.len = pres->from_tag.len;
 	db_vals[n_cols].val.str_val.len = pres->from_tag.len;
 	n_cols++;
 	n_cols++;
@@ -1137,21 +1137,21 @@ int insert_dialog_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_record_route_col;
 	db_cols[n_cols] = &str_record_route_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->record_route.s;
 	db_vals[n_cols].val.str_val.s = pres->record_route.s;
 	db_vals[n_cols].val.str_val.len = pres->record_route.len;
 	db_vals[n_cols].val.str_val.len = pres->record_route.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_contact_col;
 	db_cols[n_cols] = &str_contact_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->contact.s;
 	db_vals[n_cols].val.str_val.s = pres->contact.s;
 	db_vals[n_cols].val.str_val.len = pres->contact.len;
 	db_vals[n_cols].val.str_val.len = pres->contact.len;
 	n_cols++;
 	n_cols++;
 
 
 	db_cols[n_cols] = &str_remote_contact_col;
 	db_cols[n_cols] = &str_remote_contact_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	db_vals[n_cols].val.str_val.s = pres->remote_contact.s;
 	db_vals[n_cols].val.str_val.s = pres->remote_contact.s;
 	db_vals[n_cols].val.str_val.len = pres->remote_contact.len;
 	db_vals[n_cols].val.str_val.len = pres->remote_contact.len;
 	n_cols++;
 	n_cols++;
@@ -1164,7 +1164,7 @@ int insert_dialog_puadb(ua_pres_t* pres)
 
 
 	db_cols[n_cols] = &str_extra_headers_col;
 	db_cols[n_cols] = &str_extra_headers_col;
 	db_vals[n_cols].type = DB1_STR;
 	db_vals[n_cols].type = DB1_STR;
-	db_vals[n_cols].nul = 0; 
+	db_vals[n_cols].nul = 0;
 	if (pres->extra_headers)
 	if (pres->extra_headers)
 	{
 	{
 		db_vals[n_cols].val.str_val.s = pres->extra_headers->s;
 		db_vals[n_cols].val.str_val.s = pres->extra_headers->s;
@@ -1183,7 +1183,7 @@ int insert_dialog_puadb(ua_pres_t* pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	if(pua_dbf.insert(pua_db, db_cols, db_vals, n_cols) < 0)  
+	if(pua_dbf.insert(pua_db, db_cols, db_vals, n_cols) < 0)
 	{
 	{
 		LM_ERR("DB insert failed\n");
 		LM_ERR("DB insert failed\n");
 		return(-1);
 		return(-1);
@@ -1209,7 +1209,7 @@ ua_pres_t *get_dialog_puadb(str pres_id, str *pres_uri, ua_pres_t *result, db1_r
 		return(NULL);
 		return(NULL);
 	}
 	}
 
 
-	q_cols[n_query_cols] = &str_pres_id_col;	
+	q_cols[n_query_cols] = &str_pres_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres_id;
 	q_vals[n_query_cols].val.str_val = pres_id;
@@ -1251,7 +1251,7 @@ ua_pres_t *get_dialog_puadb(str pres_id, str *pres_uri, ua_pres_t *result, db1_r
 
 
 	if (nr_rows == 0)
 	if (nr_rows == 0)
 	{
 	{
-		/* no match */ 
+		/* no match */
 		LM_DBG("No rows found\n");
 		LM_DBG("No rows found\n");
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 		return(NULL);
 		return(NULL);
@@ -1261,7 +1261,7 @@ ua_pres_t *get_dialog_puadb(str pres_id, str *pres_uri, ua_pres_t *result, db1_r
 		LM_ERR("Too many rows found (%d)... deleting\n", nr_rows);
 		LM_ERR("Too many rows found (%d)... deleting\n", nr_rows);
 		pua_dbf.free_result(pua_db, res);
 		pua_dbf.free_result(pua_db, res);
 
 
-		if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0) 
+		if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0)
 			LM_ERR("deleting record(s)\n");
 			LM_ERR("deleting record(s)\n");
 
 
 		return(NULL);
 		return(NULL);
@@ -1293,13 +1293,13 @@ int delete_dialog_puadb(ua_pres_t *pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
@@ -1307,13 +1307,13 @@ int delete_dialog_puadb(ua_pres_t *pres)
 
 
 	if (pres->to_tag.len > 0 && pres->to_tag.s != NULL)
 	if (pres->to_tag.len > 0 && pres->to_tag.s != NULL)
 	{
 	{
-		q_cols[n_query_cols] = &str_to_tag_col;	
+		q_cols[n_query_cols] = &str_to_tag_col;
 		q_vals[n_query_cols].type = DB1_STR;
 		q_vals[n_query_cols].type = DB1_STR;
 		q_vals[n_query_cols].nul = 0;
 		q_vals[n_query_cols].nul = 0;
 		q_vals[n_query_cols].val.str_val = pres->to_tag;
 		q_vals[n_query_cols].val.str_val = pres->to_tag;
 		n_query_cols++;
 		n_query_cols++;
 	}
 	}
-	
+
 	if(pua_db == NULL)
 	if(pua_db == NULL)
 	{
 	{
 		LM_ERR("null database connection\n");
 		LM_ERR("null database connection\n");
@@ -1326,7 +1326,7 @@ int delete_dialog_puadb(ua_pres_t *pres)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0) 
+	if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0)
 	{
 	{
 		LM_ERR("deleting record\n");
 		LM_ERR("deleting record\n");
 		return -1;
 		return -1;
@@ -1349,19 +1349,19 @@ int update_dialog_puadb(ua_pres_t *pres, int expires, str *contact)
 		return(-1);
 		return(-1);
 	}
 	}
 
 
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_to_tag_col;	
+	q_cols[n_query_cols] = &str_to_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
@@ -1416,7 +1416,7 @@ int update_dialog_puadb(ua_pres_t *pres, int expires, str *contact)
 
 
 /******************************************************************************/
 /******************************************************************************/
 
 
-int update_contact_puadb(ua_pres_t *pres, str *contact) 
+int update_contact_puadb(ua_pres_t *pres, str *contact)
 
 
 {
 {
 	db_key_t q_cols[3], db_cols[1];
 	db_key_t q_cols[3], db_cols[1];
@@ -1430,19 +1430,19 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
 	}
 	}
 
 
 	/* cols and values used for search query */
 	/* cols and values used for search query */
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_to_tag_col;	
+	q_cols[n_query_cols] = &str_to_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
@@ -1451,7 +1451,7 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
 	/* we overwrite contact even if not changed */
 	/* we overwrite contact even if not changed */
 	db_cols[n_update_cols] = &str_remote_contact_col;
 	db_cols[n_update_cols] = &str_remote_contact_col;
 	db_vals[n_update_cols].type = DB1_STR;
 	db_vals[n_update_cols].type = DB1_STR;
-	db_vals[n_update_cols].nul = 0; 
+	db_vals[n_update_cols].nul = 0;
 	db_vals[n_update_cols].val.str_val.s = contact->s;
 	db_vals[n_update_cols].val.str_val.s = contact->s;
 	db_vals[n_update_cols].val.str_val.len = contact->len;
 	db_vals[n_update_cols].val.str_val.len = contact->len;
 	n_update_cols++;
 	n_update_cols++;
@@ -1482,7 +1482,7 @@ int update_contact_puadb(ua_pres_t *pres, str *contact)
 
 
 /******************************************************************************/
 /******************************************************************************/
 
 
-int update_version_puadb(ua_pres_t *pres) 
+int update_version_puadb(ua_pres_t *pres)
 
 
 {
 {
 	db_key_t q_cols[3], db_cols[1];
 	db_key_t q_cols[3], db_cols[1];
@@ -1496,19 +1496,19 @@ int update_version_puadb(ua_pres_t *pres)
 	}
 	}
 
 
 	/* cols and values used for search query */
 	/* cols and values used for search query */
-	q_cols[n_query_cols] = &str_call_id_col;	
+	q_cols[n_query_cols] = &str_call_id_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	q_vals[n_query_cols].val.str_val = pres->call_id;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_to_tag_col;	
+	q_cols[n_query_cols] = &str_to_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	q_vals[n_query_cols].val.str_val = pres->to_tag;
 	n_query_cols++;
 	n_query_cols++;
 
 
-	q_cols[n_query_cols] = &str_from_tag_col;	
+	q_cols[n_query_cols] = &str_from_tag_col;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].type = DB1_STR;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].nul = 0;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
 	q_vals[n_query_cols].val.str_val = pres->from_tag;
@@ -1611,14 +1611,14 @@ list_entry_t *get_subs_list_puadb(str *did)
 
 
 			if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
 			if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
 			{
 			{
-				LM_ERR("out of private memory\n");
+				PKG_MEM_ERROR;
 				pua_dbf.free_result(pua_db, res);
 				pua_dbf.free_result(pua_db, res);
 				return list;
 				return list;
 			}
 			}
 			if ((tmp_str->s = (char *)pkg_malloc(sizeof(char) * strng.len + 1)) == NULL)
 			if ((tmp_str->s = (char *)pkg_malloc(sizeof(char) * strng.len + 1)) == NULL)
 			{
 			{
 				pkg_free(tmp_str);
 				pkg_free(tmp_str);
-				LM_ERR("out of private memory\n");
+				PKG_MEM_ERROR;
 				pua_dbf.free_result(pua_db, res);
 				pua_dbf.free_result(pua_db, res);
 				return list;
 				return list;
 			}
 			}
@@ -1632,6 +1632,6 @@ list_entry_t *get_subs_list_puadb(str *did)
 			&& (RES_ROWS(res)>0));
 			&& (RES_ROWS(res)>0));
 
 
 	pua_dbf.free_result(pua_db, res);
 	pua_dbf.free_result(pua_db, res);
-	
+
 	return list;
 	return list;
 }
 }

+ 68 - 69
src/modules/pua/send_publish.c

@@ -59,7 +59,7 @@ str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag,
 	str_hdr =(str*)pkg_malloc(sizeof(str));
 	str_hdr =(str*)pkg_malloc(sizeof(str));
 	if(str_hdr== NULL)
 	if(str_hdr== NULL)
 	{
 	{
-		LM_ERR("no more memory\n");
+		PKG_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(str_hdr, 0 , sizeof(str));
 	memset(str_hdr, 0 , sizeof(str));
@@ -79,12 +79,12 @@ str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag,
 	str_hdr->len+= ev->name.len;
 	str_hdr->len+= ev->name.len;
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	str_hdr->len += CRLF_LEN;
 	str_hdr->len += CRLF_LEN;
-	
+
 
 
 	memcpy(str_hdr->s+str_hdr->len ,"Expires: ", 9);
 	memcpy(str_hdr->s+str_hdr->len ,"Expires: ", 9);
 	str_hdr->len += 9;
 	str_hdr->len += 9;
 
 
-	t= expires; 
+	t= expires;
 
 
 	if( t<=0 )
 	if( t<=0 )
 	{
 	{
@@ -100,7 +100,7 @@ str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag,
 	str_hdr->len+= len;
 	str_hdr->len+= len;
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	str_hdr->len += CRLF_LEN;
 	str_hdr->len += CRLF_LEN;
-	
+
 	if(etag)
 	if(etag)
 	{
 	{
 		LM_DBG("UPDATE_TYPE [etag]= %.*s\n", etag->len, etag->s);
 		LM_DBG("UPDATE_TYPE [etag]= %.*s\n", etag->len, etag->s);
@@ -112,13 +112,13 @@ str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag,
 		str_hdr->len += CRLF_LEN;
 		str_hdr->len += CRLF_LEN;
 	}
 	}
 	if(is_body)
 	if(is_body)
-	{	
+	{
 		if(content_type== NULL || content_type->s== NULL || content_type->len== 0)
 		if(content_type== NULL || content_type->s== NULL || content_type->len== 0)
 		{
 		{
-			ctype= ev->content_type; /* use event default value */ 
+			ctype= ev->content_type; /* use event default value */
 		}
 		}
 		else
 		else
-		{	
+		{
 			ctype.s=   content_type->s;
 			ctype.s=   content_type->s;
 			ctype.len= content_type->len;
 			ctype.len= content_type->len;
 		}
 		}
@@ -135,9 +135,9 @@ str* publ_build_hdr(int expires, pua_event_t* ev, str* content_type, str* etag,
 	{
 	{
 		memcpy(str_hdr->s+str_hdr->len,extra_headers->s , extra_headers->len);
 		memcpy(str_hdr->s+str_hdr->len,extra_headers->s , extra_headers->len);
 		str_hdr->len += extra_headers->len;
 		str_hdr->len += extra_headers->len;
-	}	
+	}
 	str_hdr->s[str_hdr->len] = '\0';
 	str_hdr->s[str_hdr->len] = '\0';
-	
+
 	return str_hdr;
 	return str_hdr;
 
 
 }
 }
@@ -194,7 +194,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	struct hdr_field* hdr= NULL;
 	struct hdr_field* hdr= NULL;
 	struct sip_msg* msg= NULL;
 	struct sip_msg* msg= NULL;
 	ua_pres_t* presentity= NULL;
 	ua_pres_t* presentity= NULL;
-	ua_pres_t* db_presentity= NULL; 
+	ua_pres_t* db_presentity= NULL;
 	ua_pres_t* hentity= NULL;
 	ua_pres_t* hentity= NULL;
 	int found = 0;
 	int found = 0;
 	int size= 0;
 	int size= 0;
@@ -233,7 +233,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 		LM_ERR("no reply message found\n ");
 		LM_ERR("no reply message found\n ");
 		goto error;
 		goto error;
 	}
 	}
-	
+
 
 
 	if(msg== FAKED_REPLY)
 	if(msg== FAKED_REPLY)
 	{
 	{
@@ -255,9 +255,9 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 			LM_DBG("received a 412 reply- try again to send PUBLISH\n");
 			LM_DBG("received a 412 reply- try again to send PUBLISH\n");
 			publ_info_t publ;
 			publ_info_t publ;
 			memset(&publ, 0, sizeof(publ_info_t));
 			memset(&publ, 0, sizeof(publ_info_t));
-			publ.pres_uri= hentity->pres_uri; 
+			publ.pres_uri= hentity->pres_uri;
 			publ.body= hentity->body;
 			publ.body= hentity->body;
-			
+
 			if(hentity->desired_expires== 0)
 			if(hentity->desired_expires== 0)
 				publ.expires= -1;
 				publ.expires= -1;
 			else
 			else
@@ -268,7 +268,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 
 
 			publ.source_flag|= hentity->flag;
 			publ.source_flag|= hentity->flag;
 			publ.event|= hentity->event;
 			publ.event|= hentity->event;
-			publ.content_type= hentity->content_type;	
+			publ.content_type= hentity->content_type;
 			publ.id= hentity->id;
 			publ.id= hentity->id;
 			publ.extra_headers= hentity->extra_headers;
 			publ.extra_headers= hentity->extra_headers;
 			publ.outbound_proxy = hentity->outbound_proxy;
 			publ.outbound_proxy = hentity->outbound_proxy;
@@ -293,18 +293,18 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 		}
 		}
 		goto done;
 		goto done;
 	} /* code >= 300 */
 	} /* code >= 300 */
-	
+
 	if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
 	if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
 	{
 	{
 		LM_ERR("parsing headers\n");
 		LM_ERR("parsing headers\n");
 		goto error;
 		goto error;
-	}	
+	}
 	if(msg->expires== NULL || msg->expires->body.len<= 0)
 	if(msg->expires== NULL || msg->expires->body.len<= 0)
 	{
 	{
 			LM_ERR("No Expires header found\n");
 			LM_ERR("No Expires header found\n");
 			goto error;
 			goto error;
-	}	
-	
+	}
+
 	if (!msg->expires->parsed && (parse_expires(msg->expires) < 0))
 	if (!msg->expires->parsed && (parse_expires(msg->expires) < 0))
 	{
 	{
 		LM_ERR("cannot parse Expires header\n");
 		LM_ERR("cannot parse Expires header\n");
@@ -312,7 +312,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	}
 	}
 	lexpire = ((exp_body_t*)msg->expires->parsed)->val;
 	lexpire = ((exp_body_t*)msg->expires->parsed)->val;
 	LM_DBG("lexpire= %u\n", lexpire);
 	LM_DBG("lexpire= %u\n", lexpire);
-		
+
 	hdr = msg->headers;
 	hdr = msg->headers;
 	while (hdr!= NULL)
 	while (hdr!= NULL)
 	{
 	{
@@ -324,12 +324,12 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 		hdr = hdr->next;
 		hdr = hdr->next;
 	}
 	}
 	if(found== 0) /* must find SIP-Etag header field in 200 OK msg*/
 	if(found== 0) /* must find SIP-Etag header field in 200 OK msg*/
-	{	
+	{
 		LM_ERR("no SIP-ETag header field found\n");
 		LM_ERR("no SIP-ETag header field found\n");
 		goto error;
 		goto error;
 	}
 	}
 	etag= hdr->body;
 	etag= hdr->body;
-		
+
 	LM_DBG("completed with status %d [contact:%.*s]\n",
 	LM_DBG("completed with status %d [contact:%.*s]\n",
 	       ps->code, hentity->pres_uri->len, hentity->pres_uri->s);
 	       ps->code, hentity->pres_uri->len, hentity->pres_uri->s);
 
 
@@ -354,8 +354,8 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 		}
 		}
 	}
 	}
 
 
-	size= sizeof(ua_pres_t)+ sizeof(str)+ 
-		(hentity->pres_uri->len+ hentity->tuple_id.len + 
+	size= sizeof(ua_pres_t)+ sizeof(str)+
+		(hentity->pres_uri->len+ hentity->tuple_id.len +
 		 hentity->id.len)* sizeof(char);
 		 hentity->id.len)* sizeof(char);
 	if(hentity->extra_headers)
 	if(hentity->extra_headers)
 		size+= sizeof(str)+ hentity->extra_headers->len* sizeof(char);
 		size+= sizeof(str)+ hentity->extra_headers->len* sizeof(char);
@@ -363,9 +363,9 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	presentity= (ua_pres_t*)shm_malloc(size);
 	presentity= (ua_pres_t*)shm_malloc(size);
 	if(presentity== NULL)
 	if(presentity== NULL)
 	{
 	{
-		LM_ERR("no more share memory\n");
+		SHM_MEM_ERROR;
 		goto error;
 		goto error;
-	}	
+	}
 	memset(presentity, 0, size);
 	memset(presentity, 0, size);
 
 
 	size= sizeof(ua_pres_t);
 	size= sizeof(ua_pres_t);
@@ -373,11 +373,11 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	size+= sizeof(str);
 	size+= sizeof(str);
 
 
 	presentity->pres_uri->s= (char*)presentity+ size;
 	presentity->pres_uri->s= (char*)presentity+ size;
-	memcpy(presentity->pres_uri->s, hentity->pres_uri->s, 
+	memcpy(presentity->pres_uri->s, hentity->pres_uri->s,
 			hentity->pres_uri->len);
 			hentity->pres_uri->len);
 	presentity->pres_uri->len= hentity->pres_uri->len;
 	presentity->pres_uri->len= hentity->pres_uri->len;
 	size+= hentity->pres_uri->len;
 	size+= hentity->pres_uri->len;
-	
+
 	presentity->tuple_id.s= (char*)presentity+ size;
 	presentity->tuple_id.s= (char*)presentity+ size;
 	memcpy(presentity->tuple_id.s, hentity->tuple_id.s,
 	memcpy(presentity->tuple_id.s, hentity->tuple_id.s,
 			hentity->tuple_id.len);
 			hentity->tuple_id.len);
@@ -385,17 +385,17 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	size+= presentity->tuple_id.len;
 	size+= presentity->tuple_id.len;
 
 
 	presentity->id.s=(char*)presentity+ size;
 	presentity->id.s=(char*)presentity+ size;
-	memcpy(presentity->id.s, hentity->id.s, 
+	memcpy(presentity->id.s, hentity->id.s,
 			hentity->id.len);
 			hentity->id.len);
-	presentity->id.len= hentity->id.len; 
+	presentity->id.len= hentity->id.len;
 	size+= presentity->id.len;
 	size+= presentity->id.len;
-		
+
 	if(hentity->extra_headers)
 	if(hentity->extra_headers)
 	{
 	{
 		presentity->extra_headers= (str*)((char*)presentity+ size);
 		presentity->extra_headers= (str*)((char*)presentity+ size);
 		size+= sizeof(str);
 		size+= sizeof(str);
 		presentity->extra_headers->s= (char*)presentity+ size;
 		presentity->extra_headers->s= (char*)presentity+ size;
-		memcpy(presentity->extra_headers->s, hentity->extra_headers->s, 
+		memcpy(presentity->extra_headers->s, hentity->extra_headers->s,
 				hentity->extra_headers->len);
 				hentity->extra_headers->len);
 		presentity->extra_headers->len= hentity->extra_headers->len;
 		presentity->extra_headers->len= hentity->extra_headers->len;
 		size+= hentity->extra_headers->len;
 		size+= hentity->extra_headers->len;
@@ -409,7 +409,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 	presentity->etag.s= (char*)shm_malloc(etag.len* sizeof(char));
 	presentity->etag.s= (char*)shm_malloc(etag.len* sizeof(char));
 	if(presentity->etag.s== NULL)
 	if(presentity->etag.s== NULL)
 	{
 	{
-		LM_ERR("No more share memory\n");
+		SHM_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
 	memcpy(presentity->etag.s, etag.s, etag.len);
 	memcpy(presentity->etag.s, etag.s, etag.len);
@@ -473,7 +473,7 @@ error:
 	}
 	}
 
 
 	return;
 	return;
-}	
+}
 
 
 int send_publish( publ_info_t* publ )
 int send_publish( publ_info_t* publ )
 {
 {
@@ -491,12 +491,12 @@ int send_publish( publ_info_t* publ )
 	pua_event_t* ev= NULL;
 	pua_event_t* ev= NULL;
 	uac_req_t uac_r;
 	uac_req_t uac_r;
 	db1_res_t *res=NULL;
 	db1_res_t *res=NULL;
-	ua_pres_t dbpres; 
+	ua_pres_t dbpres;
 	str pres_uri={0,0}, watcher_uri={0,0}, extra_headers={0,0};
 	str pres_uri={0,0}, watcher_uri={0,0}, extra_headers={0,0};
 	int ret = -1;
 	int ret = -1;
 
 
 	LM_DBG("pres_uri=%.*s\n", publ->pres_uri->len, publ->pres_uri->s );
 	LM_DBG("pres_uri=%.*s\n", publ->pres_uri->len, publ->pres_uri->s );
-	
+
 	if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction)
 	if (dbmode == PUA_DB_ONLY && pua_dbf.start_transaction)
 	{
 	{
 		if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0)
 		if (pua_dbf.start_transaction(pua_db, db_table_lock) < 0)
@@ -512,7 +512,7 @@ int send_publish( publ_info_t* publ )
 	{
 	{
 		LM_ERR("event not found in list\n");
 		LM_ERR("event not found in list\n");
 		goto error;
 		goto error;
-	}	
+	}
 
 
 	if (dbmode==PUA_DB_ONLY)
 	if (dbmode==PUA_DB_ONLY)
 	{
 	{
@@ -544,7 +544,7 @@ int send_publish( publ_info_t* publ )
 
 
 	if(publ->etag && presentity== NULL)
 	if(publ->etag && presentity== NULL)
 	{
 	{
-		if (dbmode!=PUA_DB_ONLY) 
+		if (dbmode!=PUA_DB_ONLY)
 			lock_release(&HashT->p_records[hash_code].lock);
 			lock_release(&HashT->p_records[hash_code].lock);
 		ret = 418;
 		ret = 418;
 		goto error;
 		goto error;
@@ -555,14 +555,14 @@ int send_publish( publ_info_t* publ )
 		LM_DBG("Insert flag set\n");
 		LM_DBG("Insert flag set\n");
 		goto insert;
 		goto insert;
 	}
 	}
-	
+
 	if(presentity== NULL)
 	if(presentity== NULL)
 	{
 	{
-insert:	
-		if (dbmode!=PUA_DB_ONLY) 
+insert:
+		if (dbmode!=PUA_DB_ONLY)
 			lock_release(&HashT->p_records[hash_code].lock);
 			lock_release(&HashT->p_records[hash_code].lock);
-		LM_DBG("insert type\n"); 
-		
+		LM_DBG("insert type\n");
+
 		if(publ->flag & UPDATE_TYPE )
 		if(publ->flag & UPDATE_TYPE )
 		{
 		{
 			LM_DBG("UPDATE_TYPE and no record found \n");
 			LM_DBG("UPDATE_TYPE and no record found \n");
@@ -573,7 +573,7 @@ insert:
 			LM_DBG("request for a publish with expires 0 and"
 			LM_DBG("request for a publish with expires 0 and"
 					" no record found\n");
 					" no record found\n");
 			goto done;
 			goto done;
-			
+
 		}
 		}
 		if(publ->body== NULL)
 		if(publ->body== NULL)
 		{
 		{
@@ -589,8 +589,8 @@ insert:
 		etag.s= (char*)pkg_malloc(presentity->etag.len* sizeof(char));
 		etag.s= (char*)pkg_malloc(presentity->etag.len* sizeof(char));
 		if(etag.s== NULL)
 		if(etag.s== NULL)
 		{
 		{
-			LM_ERR("while allocating memory\n");
-			if (dbmode!=PUA_DB_ONLY) 
+			PKG_MEM_ERROR;
+			if (dbmode!=PUA_DB_ONLY)
 				lock_release(&HashT->p_records[hash_code].lock);
 				lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 			goto error;
 		}
 		}
@@ -598,24 +598,24 @@ insert:
 		etag.len= presentity->etag.len;
 		etag.len= presentity->etag.len;
 
 
 		if(presentity->tuple_id.s && presentity->tuple_id.len)
 		if(presentity->tuple_id.s && presentity->tuple_id.len)
-		{	
+		{
 			/* get tuple_id*/
 			/* get tuple_id*/
 			tuple_id=(str*)pkg_malloc(sizeof(str));
 			tuple_id=(str*)pkg_malloc(sizeof(str));
 			if(tuple_id== NULL)
 			if(tuple_id== NULL)
 			{
 			{
-				LM_ERR("No more memory\n");
-				if (dbmode!=PUA_DB_ONLY) 
+				PKG_MEM_ERROR;
+				if (dbmode!=PUA_DB_ONLY)
 					lock_release(&HashT->p_records[hash_code].lock);
 					lock_release(&HashT->p_records[hash_code].lock);
 				goto error;
 				goto error;
-			}	
+			}
 			tuple_id->s= (char*)pkg_malloc(presentity->tuple_id.len* sizeof(char));
 			tuple_id->s= (char*)pkg_malloc(presentity->tuple_id.len* sizeof(char));
 			if(tuple_id->s== NULL)
 			if(tuple_id->s== NULL)
 			{
 			{
-				LM_ERR("No more memory\n");
-				if (dbmode!=PUA_DB_ONLY) 
+				PKG_MEM_ERROR;
+				if (dbmode!=PUA_DB_ONLY)
 					lock_release(&HashT->p_records[hash_code].lock);
 					lock_release(&HashT->p_records[hash_code].lock);
 				goto error;
 				goto error;
-			}	
+			}
 			memcpy(tuple_id->s, presentity->tuple_id.s, presentity->tuple_id.len);
 			memcpy(tuple_id->s, presentity->tuple_id.s, presentity->tuple_id.len);
 			tuple_id->len= presentity->tuple_id.len;
 			tuple_id->len= presentity->tuple_id.len;
 		}
 		}
@@ -623,16 +623,16 @@ insert:
 		if(publ->expires== 0)
 		if(publ->expires== 0)
 		{
 		{
 			LM_DBG("expires= 0- delete from hash table\n");
 			LM_DBG("expires= 0- delete from hash table\n");
-			if (dbmode!=PUA_DB_ONLY) 
+			if (dbmode!=PUA_DB_ONLY)
 				lock_release(&HashT->p_records[hash_code].lock);
 				lock_release(&HashT->p_records[hash_code].lock);
 			goto send_publish;
 			goto send_publish;
 		}
 		}
 
 
-		presentity->version++; 
+		presentity->version++;
 		ver= presentity->version;
 		ver= presentity->version;
 
 
 		if (dbmode==PUA_DB_ONLY)
 		if (dbmode==PUA_DB_ONLY)
-		{ 
+		{
 			update_version_puadb(presentity);
 			update_version_puadb(presentity);
 		}
 		}
 		else
 		else
@@ -655,9 +655,9 @@ insert:
 	}
 	}
 	if(tuple_id)
 	if(tuple_id)
 		LM_DBG("tuple_id= %.*s\n", tuple_id->len, tuple_id->s  );
 		LM_DBG("tuple_id= %.*s\n", tuple_id->len, tuple_id->s  );
-	
+
 send_publish:
 send_publish:
-	
+
 	/* construct the callback parameter */
 	/* construct the callback parameter */
 	if(etag.s && etag.len)
 	if(etag.s && etag.len)
 		publ->etag = &etag;
 		publ->etag = &etag;
@@ -671,7 +671,7 @@ send_publish:
 
 
 	if(publ->flag & UPDATE_TYPE)
 	if(publ->flag & UPDATE_TYPE)
 		LM_DBG("etag:%.*s\n", etag.len, etag.s);
 		LM_DBG("etag:%.*s\n", etag.len, etag.s);
-	str_hdr = publ_build_hdr((publ->expires< 0)?3600:publ->expires, ev, &publ->content_type, 
+	str_hdr = publ_build_hdr((publ->expires< 0)?3600:publ->expires, ev, &publ->content_type,
 				(publ->flag & UPDATE_TYPE)?&etag:NULL, publ->extra_headers, (body)?1:0);
 				(publ->flag & UPDATE_TYPE)?&etag:NULL, publ->extra_headers, (body)?1:0);
 
 
 	if(str_hdr == NULL)
 	if(str_hdr == NULL)
@@ -733,7 +733,7 @@ finish:
 		if(body->s)
 		if(body->s)
 			xmlFree(body->s);
 			xmlFree(body->s);
 		pkg_free(body);
 		pkg_free(body);
-	}	
+	}
 	if(str_hdr)
 	if(str_hdr)
 		pkg_free(str_hdr);
 		pkg_free(str_hdr);
 	if(tuple_id)
 	if(tuple_id)
@@ -753,7 +753,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 	int size;
 	int size;
 	ua_pres_t* cb_param= NULL;
 	ua_pres_t* cb_param= NULL;
 
 
-	size= sizeof(ua_pres_t)+ sizeof(str)+ (publ->pres_uri->len+ 
+	size= sizeof(ua_pres_t)+ sizeof(str)+ (publ->pres_uri->len+
 		+ publ->content_type.len+ publ->id.len+ 1)*sizeof(char);
 		+ publ->content_type.len+ publ->id.len+ 1)*sizeof(char);
 
 
 	if(publ->outbound_proxy)
 	if(publ->outbound_proxy)
@@ -770,12 +770,11 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 	cb_param= (ua_pres_t*)shm_malloc(size);
 	cb_param= (ua_pres_t*)shm_malloc(size);
 	if(cb_param== NULL)
 	if(cb_param== NULL)
 	{
 	{
-		LM_ERR("ERROR no more share memory while allocating cb_param"
-				" - size= %d\n", size);
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(cb_param, 0, size);
 	memset(cb_param, 0, size);
-	
+
 	size =  sizeof(ua_pres_t);
 	size =  sizeof(ua_pres_t);
 
 
 	cb_param->pres_uri = (str*)((char*)cb_param + size);
 	cb_param->pres_uri = (str*)((char*)cb_param + size);
@@ -787,7 +786,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 	size+= publ->pres_uri->len;
 	size+= publ->pres_uri->len;
 
 
 	if(publ->id.s && publ->id.len)
 	if(publ->id.s && publ->id.len)
-	{	
+	{
 		cb_param->id.s = ((char*)cb_param+ size);
 		cb_param->id.s = ((char*)cb_param+ size);
 		memcpy(cb_param->id.s, publ->id.s, publ->id.len);
 		memcpy(cb_param->id.s, publ->id.s, publ->id.len);
 		cb_param->id.len= publ->id.len;
 		cb_param->id.len= publ->id.len;
@@ -798,7 +797,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 	{
 	{
 		cb_param->body = (str*)((char*)cb_param  + size);
 		cb_param->body = (str*)((char*)cb_param  + size);
 		size+= sizeof(str);
 		size+= sizeof(str);
-		
+
 		cb_param->body->s = (char*)cb_param + size;
 		cb_param->body->s = (char*)cb_param + size;
 		memcpy(cb_param->body->s, body->s ,
 		memcpy(cb_param->body->s, body->s ,
 			body->len ) ;
 			body->len ) ;
@@ -822,7 +821,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 			publ->extra_headers->len ) ;
 			publ->extra_headers->len ) ;
 		cb_param->extra_headers->len= publ->extra_headers->len;
 		cb_param->extra_headers->len= publ->extra_headers->len;
 		size+= publ->extra_headers->len;
 		size+= publ->extra_headers->len;
-	}	
+	}
 	if(publ->outbound_proxy)
 	if(publ->outbound_proxy)
 	{
 	{
 		cb_param->outbound_proxy = (str*)((char*)cb_param + size);
 		cb_param->outbound_proxy = (str*)((char*)cb_param + size);
@@ -832,7 +831,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 		       publ->outbound_proxy->len);
 		       publ->outbound_proxy->len);
 		cb_param->outbound_proxy->len = publ->outbound_proxy->len;
 		cb_param->outbound_proxy->len = publ->outbound_proxy->len;
 		size+= publ->outbound_proxy->len;
 		size+= publ->outbound_proxy->len;
-	}	
+	}
 
 
 	if(publ->content_type.s && publ->content_type.len)
 	if(publ->content_type.s && publ->content_type.len)
 	{
 	{
@@ -840,9 +839,9 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 		memcpy(cb_param->content_type.s, publ->content_type.s, publ->content_type.len);
 		memcpy(cb_param->content_type.s, publ->content_type.s, publ->content_type.len);
 		cb_param->content_type.len= publ->content_type.len;
 		cb_param->content_type.len= publ->content_type.len;
 		size+=  publ->content_type.len;
 		size+=  publ->content_type.len;
-	}	
+	}
 	if(tuple_id)
 	if(tuple_id)
-	{	
+	{
 		cb_param->tuple_id.s = (char*)cb_param+ size;
 		cb_param->tuple_id.s = (char*)cb_param+ size;
 		memcpy(cb_param->tuple_id.s, tuple_id->s ,tuple_id->len);
 		memcpy(cb_param->tuple_id.s, tuple_id->s ,tuple_id->len);
 		cb_param->tuple_id.len= tuple_id->len;
 		cb_param->tuple_id.len= tuple_id->len;

+ 62 - 62
src/modules/pua/send_subscribe.c

@@ -15,8 +15,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  * 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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
  */
 
 
@@ -50,7 +50,7 @@ extern db_locking_t db_table_lock;
 
 
 void print_subs(subs_info_t* subs)
 void print_subs(subs_info_t* subs)
 {
 {
-	LM_DBG("pres_uri= %.*s - len: %d\n", 
+	LM_DBG("pres_uri= %.*s - len: %d\n",
 			subs->pres_uri->len,  subs->pres_uri->s, subs->pres_uri->len );
 			subs->pres_uri->len,  subs->pres_uri->s, subs->pres_uri->len );
 	LM_DBG("watcher_uri= %.*s - len: %d\n",
 	LM_DBG("watcher_uri= %.*s - len: %d\n",
 			subs->watcher_uri->len,  subs->watcher_uri->s,
 			subs->watcher_uri->len,  subs->watcher_uri->s,
@@ -64,18 +64,18 @@ str* subs_build_hdr(str* contact, int expires, int event, str* extra_headers)
 	static char buf[3000];
 	static char buf[3000];
 	char* subs_expires= NULL;
 	char* subs_expires= NULL;
 	int len= 1;
 	int len= 1;
-	pua_event_t* ev;	
+	pua_event_t* ev;
 
 
 	str_hdr= (str*)pkg_malloc(sizeof(str));
 	str_hdr= (str*)pkg_malloc(sizeof(str));
 	if(str_hdr== NULL)
 	if(str_hdr== NULL)
 	{
 	{
-		LM_ERR("no more memory\n");
+		PKG_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(str_hdr, 0, sizeof(str));
 	memset(str_hdr, 0, sizeof(str));
 	str_hdr->s= buf;
 	str_hdr->s= buf;
-	
-	ev= get_event(event);	
+
+	ev= get_event(event);
 	if(ev== NULL)
 	if(ev== NULL)
 	{
 	{
 		LM_ERR("getting event from list\n");
 		LM_ERR("getting event from list\n");
@@ -94,10 +94,10 @@ str* subs_build_hdr(str* contact, int expires, int event, str* extra_headers)
 	str_hdr->len+= ev->name.len;
 	str_hdr->len+= ev->name.len;
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	memcpy(str_hdr->s+str_hdr->len, CRLF, CRLF_LEN);
 	str_hdr->len += CRLF_LEN;
 	str_hdr->len += CRLF_LEN;
-	
+
 	memcpy(str_hdr->s+ str_hdr->len ,"Contact: <", 10);
 	memcpy(str_hdr->s+ str_hdr->len ,"Contact: <", 10);
 	str_hdr->len += 10;
 	str_hdr->len += 10;
-	memcpy(str_hdr->s +str_hdr->len, contact->s, 
+	memcpy(str_hdr->s +str_hdr->len, contact->s,
 			contact->len);
 			contact->len);
 	str_hdr->len+= contact->len;
 	str_hdr->len+= contact->len;
 	memcpy(str_hdr->s+ str_hdr->len, ">", 1);
 	memcpy(str_hdr->s+ str_hdr->len, ">", 1);
@@ -109,10 +109,10 @@ str* subs_build_hdr(str* contact, int expires, int event, str* extra_headers)
 	str_hdr->len += 9;
 	str_hdr->len += 9;
 
 
 	if( expires<= min_expires)
 	if( expires<= min_expires)
-		subs_expires= int2str(min_expires, &len);  
+		subs_expires= int2str(min_expires, &len);
 	else
 	else
 		subs_expires= int2str(expires+ 10, &len);
 		subs_expires= int2str(expires+ 10, &len);
-		
+
 	if(subs_expires == NULL || len == 0)
 	if(subs_expires == NULL || len == 0)
 	{
 	{
 		LM_ERR("while converting int to str\n");
 		LM_ERR("while converting int to str\n");
@@ -138,21 +138,21 @@ error:
 	if(str_hdr)
 	if(str_hdr)
 		pkg_free(str_hdr);
 		pkg_free(str_hdr);
 	return NULL;
 	return NULL;
-}	
+}
 
 
-dlg_t* pua_build_dlg_t(ua_pres_t* presentity)	
+dlg_t* pua_build_dlg_t(ua_pres_t* presentity)
 {
 {
 	dlg_t* td =NULL;
 	dlg_t* td =NULL;
 	int size;
 	int size;
 
 
 	size= sizeof(dlg_t)+ presentity->call_id.len+ presentity->to_tag.len+
 	size= sizeof(dlg_t)+ presentity->call_id.len+ presentity->to_tag.len+
-		presentity->from_tag.len+ presentity->watcher_uri->len+ 
+		presentity->from_tag.len+ presentity->watcher_uri->len+
 		presentity->pres_uri->len+ presentity->remote_contact.len;
 		presentity->pres_uri->len+ presentity->remote_contact.len;
 
 
 	td = (dlg_t*)pkg_malloc(size);
 	td = (dlg_t*)pkg_malloc(size);
 	if(td == NULL)
 	if(td == NULL)
 	{
 	{
-		LM_ERR("No memory left\n");
+		PKG_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(td, 0, size);
 	memset(td, 0, size);
@@ -167,18 +167,18 @@ dlg_t* pua_build_dlg_t(ua_pres_t* presentity)
 	memcpy(td->id.rem_tag.s, presentity->to_tag.s, presentity->to_tag.len);
 	memcpy(td->id.rem_tag.s, presentity->to_tag.s, presentity->to_tag.len);
 	td->id.rem_tag.len = presentity->to_tag.len;
 	td->id.rem_tag.len = presentity->to_tag.len;
 	size+= presentity->to_tag.len;
 	size+= presentity->to_tag.len;
-	
+
 	td->id.loc_tag.s = (char*)td+ size;
 	td->id.loc_tag.s = (char*)td+ size;
 	memcpy(td->id.loc_tag.s, presentity->from_tag.s, presentity->from_tag.len);
 	memcpy(td->id.loc_tag.s, presentity->from_tag.s, presentity->from_tag.len);
 	td->id.loc_tag.len =presentity->from_tag.len;
 	td->id.loc_tag.len =presentity->from_tag.len;
 	size+= presentity->from_tag.len;
 	size+= presentity->from_tag.len;
-	
+
 	td->loc_uri.s = (char*)td+ size;
 	td->loc_uri.s = (char*)td+ size;
 	memcpy(td->loc_uri.s, presentity->watcher_uri->s,
 	memcpy(td->loc_uri.s, presentity->watcher_uri->s,
 			presentity->watcher_uri->len) ;
 			presentity->watcher_uri->len) ;
 	td->loc_uri.len = presentity->watcher_uri->len;
 	td->loc_uri.len = presentity->watcher_uri->len;
 	size+= td->loc_uri.len;
 	size+= td->loc_uri.len;
-	
+
 	td->rem_uri.s = (char*)td+ size;
 	td->rem_uri.s = (char*)td+ size;
 	memcpy(td->rem_uri.s, presentity->pres_uri->s, presentity->pres_uri->len) ;
 	memcpy(td->rem_uri.s, presentity->pres_uri->s, presentity->pres_uri->len) ;
 	td->rem_uri.len = presentity->pres_uri->len;
 	td->rem_uri.len = presentity->pres_uri->len;
@@ -189,7 +189,7 @@ dlg_t* pua_build_dlg_t(ua_pres_t* presentity)
 			presentity->remote_contact.len) ;
 			presentity->remote_contact.len) ;
 	td->rem_target.len = presentity->remote_contact.len;
 	td->rem_target.len = presentity->remote_contact.len;
 	size+= td->rem_target.len;
 	size+= td->rem_target.len;
-	
+
 	if(presentity->record_route.s && presentity->record_route.len)
 	if(presentity->record_route.s && presentity->record_route.len)
 	{
 	{
 		if(parse_rr_body(presentity->record_route.s, presentity->record_route.len,
 		if(parse_rr_body(presentity->record_route.s, presentity->record_route.len,
@@ -199,12 +199,12 @@ dlg_t* pua_build_dlg_t(ua_pres_t* presentity)
 			pkg_free(td);
 			pkg_free(td);
 			return NULL;
 			return NULL;
 		}
 		}
-	}	
+	}
 
 
 	td->loc_seq.value = presentity->cseq;
 	td->loc_seq.value = presentity->cseq;
 	td->loc_seq.is_set = 1;
 	td->loc_seq.is_set = 1;
 	td->state= DLG_CONFIRMED ;
 	td->state= DLG_CONFIRMED ;
-	
+
 	LM_DBG("size = %d\n", size);
 	LM_DBG("size = %d\n", size);
 
 
 	return td;
 	return td;
@@ -331,7 +331,7 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *ps)
 		callid = (struct hdr_field *) pkg_malloc(sizeof(struct hdr_field));
 		callid = (struct hdr_field *) pkg_malloc(sizeof(struct hdr_field));
 		if (callid == NULL)
 		if (callid == NULL)
 		{
 		{
-			LM_ERR("Out of memory\n");
+			PKG_MEM_ERROR;
 			goto faked_error;
 			goto faked_error;
 		}
 		}
 		memset(callid, 0, sizeof(struct hdr_field));
 		memset(callid, 0, sizeof(struct hdr_field));
@@ -341,18 +341,18 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *ps)
 		from = (struct hdr_field *) pkg_malloc(sizeof(struct hdr_field));
 		from = (struct hdr_field *) pkg_malloc(sizeof(struct hdr_field));
 		if (from == NULL)
 		if (from == NULL)
 		{
 		{
-			LM_ERR("Out of memory\n");
+			PKG_MEM_ERROR;
 			goto faked_error;
 			goto faked_error;
 		}
 		}
 		memset(from, 0, sizeof(struct hdr_field));
 		memset(from, 0, sizeof(struct hdr_field));
 		get_hdr_field(t->from.s, t->from.s + t->from.len, from);
 		get_hdr_field(t->from.s, t->from.s + t->from.len, from);
 		parse_to(from->body.s, from->body.s + from->body.len + 1, &FROM);
 		parse_to(from->body.s, from->body.s + from->body.len + 1, &FROM);
-		if(FROM.uri.len <= 0) 
+		if(FROM.uri.len <= 0)
 		{
 		{
 			LM_ERR("'From' header NOT parsed\n");
 			LM_ERR("'From' header NOT parsed\n");
 			goto faked_error;
 			goto faked_error;
 		}
 		}
-	
+
 		hentity->call_id = callid->body;
 		hentity->call_id = callid->body;
 		hentity->from_tag = (&FROM)->tag_value;
 		hentity->from_tag = (&FROM)->tag_value;
 		hentity->to_tag.s = NULL;
 		hentity->to_tag.s = NULL;
@@ -365,7 +365,7 @@ faked_error:
 		if (from) pkg_free(from);
 		if (from) pkg_free(from);
 		goto done;
 		goto done;
 	}
 	}
-	
+
 	if ( parse_headers(msg,HDR_EOH_F, 0)==-1 )
 	if ( parse_headers(msg,HDR_EOH_F, 0)==-1 )
 	{
 	{
 		LM_ERR("when parsing headers\n");
 		LM_ERR("when parsing headers\n");
@@ -393,7 +393,7 @@ faked_error:
 			LM_ERR("cannot parse callid header\n");
 			LM_ERR("cannot parse callid header\n");
 			goto error;
 			goto error;
 		}
 		}
-		
+
 		if (!msg->from || !msg->from->body.s)
 		if (!msg->from || !msg->from->body.s)
 		{
 		{
 			LM_ERR("cannot find 'from' header!\n");
 			LM_ERR("cannot find 'from' header!\n");
@@ -401,14 +401,14 @@ faked_error:
 		}
 		}
 		if (msg->from->parsed == NULL)
 		if (msg->from->parsed == NULL)
 		{
 		{
-			if ( parse_from_header( msg )<0 ) 
+			if ( parse_from_header( msg )<0 )
 			{
 			{
 				LM_ERR("cannot parse From header\n");
 				LM_ERR("cannot parse From header\n");
 				goto error;
 				goto error;
 			}
 			}
 		}
 		}
 		pfrom = (struct to_body*)msg->from->parsed;
 		pfrom = (struct to_body*)msg->from->parsed;
-	
+
 		if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
 		if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
 		{
 		{
 			LM_ERR("no from tag value present\n");
 			LM_ERR("no from tag value present\n");
@@ -430,7 +430,7 @@ faked_error:
 		{
 		{
 			LM_ERR("cannot parse TO header\n");
 			LM_ERR("cannot parse TO header\n");
 			goto error;
 			goto error;
-		}			
+		}
 		if(msg->to->parsed != NULL)
 		if(msg->to->parsed != NULL)
 		{
 		{
 			pto = (struct to_body*)msg->to->parsed;
 			pto = (struct to_body*)msg->to->parsed;
@@ -440,13 +440,13 @@ faked_error:
 		{
 		{
 			parse_to(msg->to->body.s,msg->to->body.s +
 			parse_to(msg->to->body.s,msg->to->body.s +
 				msg->to->body.len + 1, &TO);
 				msg->to->body.len + 1, &TO);
-			if(TO.uri.len <= 0) 
+			if(TO.uri.len <= 0)
 			{
 			{
 				LM_ERR("'To' header NOT parsed\n");
 				LM_ERR("'To' header NOT parsed\n");
 				goto error;
 				goto error;
 			}
 			}
 			pto = &TO;
 			pto = &TO;
-		}			
+		}
 		if( pto->tag_value.s ==NULL || pto->tag_value.len == 0)
 		if( pto->tag_value.s ==NULL || pto->tag_value.len == 0)
 		{
 		{
 			LM_ERR("no to tag value present\n");
 			LM_ERR("no to tag value present\n");
@@ -456,9 +456,9 @@ faked_error:
 	}
 	}
 
 
 	if(ps->code >= 300 )
 	if(ps->code >= 300 )
-	{	/* if an error code and a stored dialog delete it and try to send 
-		   a subscription with type= INSERT_TYPE, else return*/	
-		
+	{	/* if an error code and a stored dialog delete it and try to send
+		   a subscription with type= INSERT_TYPE, else return*/
+
 		subs_info_t subs;
 		subs_info_t subs;
 
 
 		hentity->to_tag.s = NULL;
 		hentity->to_tag.s = NULL;
@@ -478,7 +478,7 @@ faked_error:
 
 
 		/* Redirect if the response 3XX */
 		/* Redirect if the response 3XX */
 		memset(&subs, 0, sizeof(subs_info_t));
 		memset(&subs, 0, sizeof(subs_info_t));
-		subs.pres_uri= hentity->pres_uri; 
+		subs.pres_uri= hentity->pres_uri;
 		subs.watcher_uri= hentity->watcher_uri;
 		subs.watcher_uri= hentity->watcher_uri;
 		subs.contact= &hentity->contact;
 		subs.contact= &hentity->contact;
 
 
@@ -500,7 +500,7 @@ faked_error:
 		subs.outbound_proxy= hentity->outbound_proxy;
 		subs.outbound_proxy= hentity->outbound_proxy;
 		subs.extra_headers= hentity->extra_headers;
 		subs.extra_headers= hentity->extra_headers;
 		subs.cb_param= hentity->cb_param;
 		subs.cb_param= hentity->cb_param;
-	
+
 		if(send_subscribe(&subs)< 0)
 		if(send_subscribe(&subs)< 0)
 		{
 		{
 			LM_ERR("when trying to send SUBSCRIBE\n");
 			LM_ERR("when trying to send SUBSCRIBE\n");
@@ -559,7 +559,7 @@ faked_error:
 		rt = print_rr_body(msg->record_route, &record_route, 1, 0);
 		rt = print_rr_body(msg->record_route, &record_route, 1, 0);
 		if(rt != 0)
 		if(rt != 0)
 		{
 		{
-			LM_ERR("parsing record route [%d]\n", rt);	
+			LM_ERR("parsing record route [%d]\n", rt);
 			record_route.s=NULL;
 			record_route.s=NULL;
 			record_route.len=0;
 			record_route.len=0;
 		}
 		}
@@ -576,10 +576,10 @@ faked_error:
 	presentity= (ua_pres_t*)shm_malloc(size);
 	presentity= (ua_pres_t*)shm_malloc(size);
 	if(presentity== NULL)
 	if(presentity== NULL)
 	{
 	{
-		LM_ERR("no more share memory\n");
+		SHM_MEM_ERROR;
 		goto error;
 		goto error;
 	}
 	}
-	
+
 	memset(presentity, 0, size);
 	memset(presentity, 0, size);
 	size= sizeof(ua_pres_t);
 	size= sizeof(ua_pres_t);
 
 
@@ -598,19 +598,19 @@ faked_error:
 	size+= pfrom->uri.len;
 	size+= pfrom->uri.len;
 
 
 	presentity->call_id.s= (char*)presentity + size;
 	presentity->call_id.s= (char*)presentity + size;
-	memcpy(presentity->call_id.s,msg->callid->body.s, 
+	memcpy(presentity->call_id.s,msg->callid->body.s,
 		msg->callid->body.len);
 		msg->callid->body.len);
 	presentity->call_id.len= msg->callid->body.len;
 	presentity->call_id.len= msg->callid->body.len;
 	size+= presentity->call_id.len;
 	size+= presentity->call_id.len;
 
 
 	presentity->to_tag.s= (char*)presentity + size;
 	presentity->to_tag.s= (char*)presentity + size;
-	memcpy(presentity->to_tag.s,pto->tag_value.s, 
+	memcpy(presentity->to_tag.s,pto->tag_value.s,
 			pto->tag_value.len);
 			pto->tag_value.len);
 	presentity->to_tag.len= pto->tag_value.len;
 	presentity->to_tag.len= pto->tag_value.len;
 	size+= pto->tag_value.len;
 	size+= pto->tag_value.len;
 
 
 	presentity->from_tag.s= (char*)presentity + size;
 	presentity->from_tag.s= (char*)presentity + size;
-	memcpy(presentity->from_tag.s,pfrom->tag_value.s, 
+	memcpy(presentity->from_tag.s,pfrom->tag_value.s,
 			pfrom->tag_value.len);
 			pfrom->tag_value.len);
 	presentity->from_tag.len= pfrom->tag_value.len;
 	presentity->from_tag.len= pfrom->tag_value.len;
 	size+= pfrom->tag_value.len;
 	size+= pfrom->tag_value.len;
@@ -633,9 +633,9 @@ faked_error:
 	if(hentity->id.s)
 	if(hentity->id.s)
 	{
 	{
 		presentity->id.s=(char*)presentity+ size;
 		presentity->id.s=(char*)presentity+ size;
-		memcpy(presentity->id.s, hentity->id.s, 
+		memcpy(presentity->id.s, hentity->id.s,
 			hentity->id.len);
 			hentity->id.len);
-		presentity->id.len= hentity->id.len; 
+		presentity->id.len= hentity->id.len;
 		size+= presentity->id.len;
 		size+= presentity->id.len;
 	}
 	}
 
 
@@ -644,9 +644,9 @@ faked_error:
 		presentity->extra_headers= (str*)((char*)presentity+ size);
 		presentity->extra_headers= (str*)((char*)presentity+ size);
 		size+= sizeof(str);
 		size+= sizeof(str);
 		presentity->extra_headers->s=(char*)presentity+ size;
 		presentity->extra_headers->s=(char*)presentity+ size;
-		memcpy(presentity->extra_headers->s, hentity->extra_headers->s, 
+		memcpy(presentity->extra_headers->s, hentity->extra_headers->s,
 			hentity->extra_headers->len);
 			hentity->extra_headers->len);
-		presentity->extra_headers->len= hentity->extra_headers->len; 
+		presentity->extra_headers->len= hentity->extra_headers->len;
 		size+= hentity->extra_headers->len;
 		size+= hentity->extra_headers->len;
 	}
 	}
 
 
@@ -668,7 +668,7 @@ faked_error:
 	if(BLA_SUBSCRIBE & presentity->flag)
 	if(BLA_SUBSCRIBE & presentity->flag)
 	{
 	{
 		LM_DBG("BLA_SUBSCRIBE FLAG inserted\n");
 		LM_DBG("BLA_SUBSCRIBE FLAG inserted\n");
-	}	
+	}
 	LM_DBG("record for subscribe from %.*s to %.*s inserted in database\n",
 	LM_DBG("record for subscribe from %.*s to %.*s inserted in database\n",
 			presentity->watcher_uri->len, presentity->watcher_uri->s,
 			presentity->watcher_uri->len, presentity->watcher_uri->s,
 			presentity->pres_uri->len, presentity->pres_uri->s);
 			presentity->pres_uri->len, presentity->pres_uri->s);
@@ -726,7 +726,7 @@ done:
 
 
 	goto end;
 	goto end;
 
 
-error:	
+error:
         if (presentity)
         if (presentity)
 	{
 	{
 		if (presentity->remote_contact.s) shm_free(presentity->remote_contact.s);
 		if (presentity->remote_contact.s) shm_free(presentity->remote_contact.s);
@@ -745,7 +745,7 @@ error:
 end:
 end:
 
 
 	if(hentity)
 	if(hentity)
-	{	
+	{
 		shm_free(hentity);
 		shm_free(hentity);
 		hentity= NULL;
 		hentity= NULL;
 	}
 	}
@@ -772,7 +772,7 @@ ua_pres_t* subscribe_cbparam(subs_info_t* subs, int ua_flag)
 	hentity= (ua_pres_t*)shm_malloc(size);
 	hentity= (ua_pres_t*)shm_malloc(size);
 	if(hentity== NULL)
 	if(hentity== NULL)
 	{
 	{
-		LM_ERR("No more share memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(hentity, 0, size);
 	memset(hentity, 0, size);
@@ -860,7 +860,7 @@ ua_pres_t* subs_cbparam_indlg(ua_pres_t* subs, int expires, int ua_flag)
 	hentity= (ua_pres_t*)shm_malloc(size);
 	hentity= (ua_pres_t*)shm_malloc(size);
 	if(hentity== NULL)
 	if(hentity== NULL)
 	{
 	{
-		LM_ERR("No more share memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 		return NULL;
 	}
 	}
 	memset(hentity, 0, size);
 	memset(hentity, 0, size);
@@ -962,7 +962,7 @@ int send_subscribe(subs_info_t* subs)
 	memset(&dbpres, 0, sizeof(dbpres));
 	memset(&dbpres, 0, sizeof(dbpres));
 	dbpres.pres_uri = &pres_uri;
 	dbpres.pres_uri = &pres_uri;
 	dbpres.watcher_uri = &watcher_uri;
 	dbpres.watcher_uri = &watcher_uri;
-	dbpres.extra_headers = &extra_headers; 
+	dbpres.extra_headers = &extra_headers;
 
 
 	print_subs(subs);
 	print_subs(subs);
 
 
@@ -975,7 +975,7 @@ int send_subscribe(subs_info_t* subs)
 	else
 	else
 		expires= subs->expires;
 		expires= subs->expires;
 
 
-	str_hdr= subs_build_hdr(subs->contact, expires, subs->event, 
+	str_hdr= subs_build_hdr(subs->contact, expires, subs->event,
 			subs->extra_headers);
 			subs->extra_headers);
 	if(str_hdr== NULL || str_hdr->s== NULL)
 	if(str_hdr== NULL || str_hdr->s== NULL)
 	{
 	{
@@ -1023,12 +1023,12 @@ int send_subscribe(subs_info_t* subs)
 		LM_DBG("A subscription request with insert type\n");
 		LM_DBG("A subscription request with insert type\n");
 		goto insert;
 		goto insert;
 	}
 	}
-	
+
 	if(presentity== NULL )
 	if(presentity== NULL )
 	{
 	{
 		int size;
 		int size;
 insert:
 insert:
-	
+
 		if (subs->expires == 0)
 		if (subs->expires == 0)
 		{
 		{
 			/* Don't create a new dialog when expires == 0 */
 			/* Don't create a new dialog when expires == 0 */
@@ -1042,7 +1042,7 @@ insert:
 			LM_DBG("request for a subscription with update type"
 			LM_DBG("request for a subscription with update type"
 					" and no record found\n");
 					" and no record found\n");
 			subs->flag= INSERT_TYPE;
 			subs->flag= INSERT_TYPE;
-		}	
+		}
 		hentity= subscribe_cbparam(subs, REQ_OTHER);
 		hentity= subscribe_cbparam(subs, REQ_OTHER);
 		if(hentity== NULL)
 		if(hentity== NULL)
 		{
 		{
@@ -1061,7 +1061,7 @@ insert:
 		subs->remote_target?subs->remote_target:subs->pres_uri,/* Request-URI*/
 		subs->remote_target?subs->remote_target:subs->pres_uri,/* Request-URI*/
 			subs->pres_uri,				  /* To */
 			subs->pres_uri,				  /* To */
 			subs->watcher_uri,			  /* From */
 			subs->watcher_uri,			  /* From */
-			subs->outbound_proxy		  /* Outbound_proxy */	
+			subs->outbound_proxy		  /* Outbound_proxy */
 			);
 			);
 		if(result< 0)
 		if(result< 0)
 		{
 		{
@@ -1096,8 +1096,8 @@ insert:
 		presentity= (ua_pres_t*)shm_malloc(size);
 		presentity= (ua_pres_t*)shm_malloc(size);
 		if(presentity== NULL)
 		if(presentity== NULL)
 		{
 		{
-			LM_ERR("no more share memory\n");
-       			if (dbmode != PUA_DB_ONLY)
+			SHM_MEM_ERROR;
+			if (dbmode != PUA_DB_ONLY)
 				lock_release(&HashT->p_records[hash_code].lock);
 				lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 			goto error;
 		}
 		}
@@ -1193,7 +1193,7 @@ insert:
 				lock_release(&HashT->p_records[hash_code].lock);
 				lock_release(&HashT->p_records[hash_code].lock);
 			goto error;
 			goto error;
 		}
 		}
-				
+
 		hentity= subs_cbparam_indlg(presentity, expires, REQ_OTHER);
 		hentity= subs_cbparam_indlg(presentity, expires, REQ_OTHER);
 		if(hentity== NULL)
 		if(hentity== NULL)
 		{
 		{
@@ -1205,7 +1205,7 @@ insert:
 		if (dbmode!=PUA_DB_ONLY)
 		if (dbmode!=PUA_DB_ONLY)
 			lock_release(&HashT->p_records[hash_code].lock);
 			lock_release(&HashT->p_records[hash_code].lock);
 
 
-		LM_DBG("event parameter: %d\n", hentity->event);	
+		LM_DBG("event parameter: %d\n", hentity->event);
 
 
 		set_uac_req(&uac_r, &met, str_hdr, 0, td, TMCB_LOCAL_COMPLETED,
 		set_uac_req(&uac_r, &met, str_hdr, 0, td, TMCB_LOCAL_COMPLETED,
 				subs_cback_func, (void*)hentity);
 				subs_cback_func, (void*)hentity);