소스 검색

presence: clang format the code

Daniel-Constantin Mierla 6 년 전
부모
커밋
4f692b418c

+ 25 - 27
src/modules/presence/bind_presence.c

@@ -16,8 +16,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
@@ -40,37 +40,35 @@
 #include "publish.h"
 #include "subscribe.h"
 
-int bind_presence(presence_api_t* api)
+int bind_presence(presence_api_t *api)
 {
-	if (!api) {
+	if(!api) {
 		LM_ERR("Invalid parameter value\n");
 		return -1;
 	}
-	
+
 	api->add_event = add_event;
-	api->contains_event= contains_event;
-	api->search_event= search_event;
-	api->get_event_list= get_event_list;
-	api->update_watchers_status= update_watchers_status;
-	api->new_shtable= new_shtable;
-	api->destroy_shtable= destroy_shtable;
-	api->insert_shtable= insert_shtable;
-	api->search_shtable= search_shtable;
-	api->delete_shtable= delete_shtable;
-	api->update_shtable= update_shtable;
-	api->mem_copy_subs= mem_copy_subs;
-	api->update_db_subs_timer= update_db_subs_timer;
-	api->extract_sdialog_info= extract_sdialog_info;
-	api->get_sphere= get_sphere;
-	api->get_presentity= get_p_notify_body;
-	api->free_presentity= free_notify_body;
-	api->pres_auth_status= pres_auth_status;
-	api->handle_publish= w_handle_publish;
-	api->handle_subscribe0= handle_subscribe0;
-	api->handle_subscribe= handle_subscribe;
+	api->contains_event = contains_event;
+	api->search_event = search_event;
+	api->get_event_list = get_event_list;
+	api->update_watchers_status = update_watchers_status;
+	api->new_shtable = new_shtable;
+	api->destroy_shtable = destroy_shtable;
+	api->insert_shtable = insert_shtable;
+	api->search_shtable = search_shtable;
+	api->delete_shtable = delete_shtable;
+	api->update_shtable = update_shtable;
+	api->mem_copy_subs = mem_copy_subs;
+	api->update_db_subs_timer = update_db_subs_timer;
+	api->extract_sdialog_info = extract_sdialog_info;
+	api->get_sphere = get_sphere;
+	api->get_presentity = get_p_notify_body;
+	api->free_presentity = free_notify_body;
+	api->pres_auth_status = pres_auth_status;
+	api->handle_publish = w_handle_publish;
+	api->handle_subscribe0 = handle_subscribe0;
+	api->handle_subscribe = handle_subscribe;
 	api->update_presentity = _api_update_presentity;
 	api->pres_refresh_watchers = _api_pres_refresh_watchers;
 	return 0;
 }
-
-

+ 19 - 15
src/modules/presence/bind_presence.h

@@ -35,18 +35,23 @@
 #include "presentity.h"
 #include "../../core/sr_module.h"
 
-typedef int (*update_watchers_t)(str pres_uri, pres_ev_t* ev, str* rules_doc);
-typedef str* (*pres_get_presentity_t)(str pres_uri, pres_ev_t *ev, str *etag, str *contact);
+typedef int (*update_watchers_t)(str pres_uri, pres_ev_t *ev, str *rules_doc);
+typedef str *(*pres_get_presentity_t)(
+		str pres_uri, pres_ev_t *ev, str *etag, str *contact);
 typedef void (*pres_free_presentity_t)(str *presentity, pres_ev_t *ev);
-typedef int (*pres_auth_status_t)(struct sip_msg* msg, str watcher_uri, str presentity_uri);
-typedef int (*pres_handle_publish_t)(struct sip_msg* msg, char *str1, char* str2);
-typedef int (*pres_handle_subscribe0_t)(struct sip_msg* msg);
-typedef int (*pres_handle_subscribe_t)(struct sip_msg* msg, str watcher_user, str watcher_domain);
-typedef int (*pres_update_presentity_t)(str *event, str *realm, str *user, str *etag,
-		str *sender, str *body, int expires, int new_t, int replace);
+typedef int (*pres_auth_status_t)(
+		struct sip_msg *msg, str watcher_uri, str presentity_uri);
+typedef int (*pres_handle_publish_t)(
+		struct sip_msg *msg, char *str1, char *str2);
+typedef int (*pres_handle_subscribe0_t)(struct sip_msg *msg);
+typedef int (*pres_handle_subscribe_t)(
+		struct sip_msg *msg, str watcher_user, str watcher_domain);
+typedef int (*pres_update_presentity_t)(str *event, str *realm, str *user,
+		str *etag, str *sender, str *body, int expires, int new_t, int replace);
 typedef int (*pres_refresh_watchers_t)(str *pres, str *event, int type);
 
-typedef struct presence_api {
+typedef struct presence_api
+{
 	add_event_t add_event;
 	contains_event_t contains_event;
 	search_event_t search_event;
@@ -59,7 +64,7 @@ typedef struct presence_api {
 	search_shtable_t search_shtable;
 	delete_shtable_t delete_shtable;
 	update_shtable_t update_shtable;
-	mem_copy_subs_t  mem_copy_subs;
+	mem_copy_subs_t mem_copy_subs;
 	update_db_subs_t update_db_subs_timer;
 	extract_sdialog_info_t extract_sdialog_info;
 	pres_get_sphere_t get_sphere;
@@ -73,15 +78,15 @@ typedef struct presence_api {
 	pres_refresh_watchers_t pres_refresh_watchers;
 } presence_api_t;
 
-int bind_presence(presence_api_t* api);
+int bind_presence(presence_api_t *api);
 
-typedef int (*bind_presence_t)(presence_api_t* api);
+typedef int (*bind_presence_t)(presence_api_t *api);
 
 inline static int presence_load_api(presence_api_t *api)
 {
 	bind_presence_t bind_presence_exports;
-	if (!(bind_presence_exports = (bind_presence_t)find_export("bind_presence", 1, 0)))
-	{
+	if(!(bind_presence_exports =
+					   (bind_presence_t)find_export("bind_presence", 1, 0))) {
 		LM_ERR("Failed to import bind_presence\n");
 		return -1;
 	}
@@ -89,4 +94,3 @@ inline static int presence_load_api(presence_api_t *api)
 }
 
 #endif
-

+ 175 - 206
src/modules/presence/event_list.c

@@ -27,7 +27,7 @@
 
 
 #include <stdlib.h>
-#include<stdio.h>
+#include <stdio.h>
 #include <string.h>
 #include "../../core/str.h"
 #include "../../core/dprint.h"
@@ -39,64 +39,60 @@
 
 #define MAX_EVNAME_SIZE 20
 
-int search_event_params(event_t* ev, event_t* searched_ev);
+int search_event_params(event_t *ev, event_t *searched_ev);
 
-event_t* shm_copy_event(event_t* e)
+event_t *shm_copy_event(event_t *e)
 {
-	event_t* ev= NULL;
-	param_t* p1, *p2;
+	event_t *ev = NULL;
+	param_t *p1, *p2;
 	int size;
 
-	ev= (event_t*)shm_malloc(sizeof(event_t));
-	if(ev== NULL)
-	{
+	ev = (event_t *)shm_malloc(sizeof(event_t));
+	if(ev == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memset(ev, 0, sizeof(event_t));
 
-	ev->name.s= (char*)shm_malloc(e->name.len* sizeof(char));
-	if(ev->name.s== NULL)
-	{
+	ev->name.s = (char *)shm_malloc(e->name.len * sizeof(char));
+	if(ev->name.s == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memcpy(ev->name.s, e->name.s, e->name.len);
-	ev->name.len= e->name.len;
-
-	p1= e->params.list;
-	while(p1)
-	{
-		size= sizeof(param_t)+ (p1->name.len+ p1->body.len)* sizeof(char);
-		p2= (param_t*)shm_malloc(size);
-		if(p2== NULL)
-		{
+	ev->name.len = e->name.len;
+
+	p1 = e->params.list;
+	while(p1) {
+		size = sizeof(param_t) + (p1->name.len + p1->body.len) * sizeof(char);
+		p2 = (param_t *)shm_malloc(size);
+		if(p2 == NULL) {
 			ERR_MEM(SHARE_MEM);
 		}
 		memset(p2, 0, size);
 
-		size= sizeof(param_t);
+		size = sizeof(param_t);
 		CONT_COPY(p2, p2->name, p1->name);
 		if(p1->body.s && p1->body.len)
 			CONT_COPY(p2, p2->body, p1->body);
-		p2->next= ev->params.list;
-		ev->params.list= p2;
+		p2->next = ev->params.list;
+		ev->params.list = p2;
 
 		/* Update parameter hooks in the shmmem copy, this is needed so that
 		 * we can test for the presence of the sla parameter even in the
 		 * shared copy of the event */
-		if (e->params.hooks.event_dialog.call_id == p1)
+		if(e->params.hooks.event_dialog.call_id == p1)
 			ev->params.hooks.event_dialog.call_id = p2;
-		if (e->params.hooks.event_dialog.from_tag == p1)
+		if(e->params.hooks.event_dialog.from_tag == p1)
 			ev->params.hooks.event_dialog.from_tag = p2;
-		if (e->params.hooks.event_dialog.to_tag == p1)
+		if(e->params.hooks.event_dialog.to_tag == p1)
 			ev->params.hooks.event_dialog.to_tag = p2;
-		if (e->params.hooks.event_dialog.include_session_description == p1)
+		if(e->params.hooks.event_dialog.include_session_description == p1)
 			ev->params.hooks.event_dialog.include_session_description = p2;
-		if (e->params.hooks.event_dialog.sla == p1)
+		if(e->params.hooks.event_dialog.sla == p1)
 			ev->params.hooks.event_dialog.sla = p2;
 
-		p1= p1->next;
+		p1 = p1->next;
 	}
-	ev->type= e->type;
+	ev->type = e->type;
 
 	return ev;
 
@@ -105,9 +101,9 @@ error:
 	return NULL;
 }
 
-void shm_free_event(event_t* ev)
+void shm_free_event(event_t *ev)
 {
-	if(ev== NULL)
+	if(ev == NULL)
 		return;
 
 	if(ev->name.s)
@@ -119,156 +115,142 @@ void shm_free_event(event_t* ev)
 }
 
 
-int add_event(pres_ev_t* event)
+int add_event(pres_ev_t *event)
 {
-	pres_ev_t* ev= NULL;
+	pres_ev_t *ev = NULL;
 	event_t parsed_event;
 	str wipeer_name;
-	char* sep;
+	char *sep;
 	char buf[50];
-	int not_in_list= 0;
+	int not_in_list = 0;
 
 	memset(&parsed_event, 0, sizeof(event_t));
 
-	if(event->name.s== NULL || event->name.len== 0)
-	{
+	if(event->name.s == NULL || event->name.len == 0) {
 		LM_ERR("NULL event name\n");
 		return -1;
 	}
 
-	if(event->content_type.s== NULL || event->content_type.len== 0)
-	{
+	if(event->content_type.s == NULL || event->content_type.len == 0) {
 		LM_ERR("NULL content_type param\n");
 		return -1;
 	}
 
-	ev= contains_event(&event->name, &parsed_event);
-	if(ev== NULL)
-	{
-		not_in_list= 1;
-		ev= (pres_ev_t*)shm_malloc(sizeof(pres_ev_t));
-		if(ev== NULL)
-		{
+	ev = contains_event(&event->name, &parsed_event);
+	if(ev == NULL) {
+		not_in_list = 1;
+		ev = (pres_ev_t *)shm_malloc(sizeof(pres_ev_t));
+		if(ev == NULL) {
 			free_event_params(parsed_event.params.list, PKG_MEM_TYPE);
 			ERR_MEM(SHARE_MEM);
 		}
 		memset(ev, 0, sizeof(pres_ev_t));
-		ev->name.s= (char*)shm_malloc(event->name.len* sizeof(char));
-		if(ev->name.s== NULL)
-		{
+		ev->name.s = (char *)shm_malloc(event->name.len * sizeof(char));
+		if(ev->name.s == NULL) {
 			ERR_MEM(SHARE_MEM);
 		}
 		memcpy(ev->name.s, event->name.s, event->name.len);
-		ev->name.len= event->name.len;
+		ev->name.len = event->name.len;
 
-		ev->evp= shm_copy_event(&parsed_event);
-		if(ev->evp== NULL)
-		{
+		ev->evp = shm_copy_event(&parsed_event);
+		if(ev->evp == NULL) {
 			LM_ERR("copying event_t structure\n");
 			goto error;
 		}
-	}
-	else
-	{
-		if(ev->content_type.s)
-		{
+	} else {
+		if(ev->content_type.s) {
 			LM_DBG("Event already registered\n");
 			goto done;
 		}
 	}
 
-	ev->content_type.s=
-			(char*)shm_malloc(event->content_type.len* sizeof(char)) ;
-	if(ev->content_type.s== NULL)
-	{
+	ev->content_type.s =
+			(char *)shm_malloc(event->content_type.len * sizeof(char));
+	if(ev->content_type.s == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
-	ev->content_type.len= event->content_type.len;
+	ev->content_type.len = event->content_type.len;
 	memcpy(ev->content_type.s, event->content_type.s, event->content_type.len);
 
-	for(sep=parsed_event.name.s; sep<parsed_event.name.s+parsed_event.name.len;
-			sep++)
-		if(*sep=='.') break;
-	if(sep>=parsed_event.name.s+parsed_event.name.len) sep=0;
-	if(sep && strncmp(sep+1, "winfo", 5)== 0)
-	{
-		ev->type= WINFO_TYPE;
-		wipeer_name.s= parsed_event.name.s;
-		wipeer_name.len= sep - parsed_event.name.s;
-		ev->wipeer= contains_event(&wipeer_name, NULL);
-		if (ev->wipeer) {
+	for(sep = parsed_event.name.s;
+			sep < parsed_event.name.s + parsed_event.name.len; sep++)
+		if(*sep == '.')
+			break;
+	if(sep >= parsed_event.name.s + parsed_event.name.len)
+		sep = 0;
+	if(sep && strncmp(sep + 1, "winfo", 5) == 0) {
+		ev->type = WINFO_TYPE;
+		wipeer_name.s = parsed_event.name.s;
+		wipeer_name.len = sep - parsed_event.name.s;
+		ev->wipeer = contains_event(&wipeer_name, NULL);
+		if(ev->wipeer) {
 			LM_DBG("Found wipeer event [%.*s] for event [%.*s]\n",
-					wipeer_name.len,wipeer_name.s,
-					parsed_event.name.len,parsed_event.name.s);
+					wipeer_name.len, wipeer_name.s, parsed_event.name.len,
+					parsed_event.name.s);
 		}
-	}
-	else
-	{
-		ev->type= PUBL_TYPE;
-		if (parsed_event.name.len + 6 > 50) {
+	} else {
+		ev->type = PUBL_TYPE;
+		if(parsed_event.name.len + 6 > 50) {
 			LM_ERR("buffer too small\n");
 			goto error;
 		}
-		wipeer_name.s= buf;
+		wipeer_name.s = buf;
 		memcpy(wipeer_name.s, parsed_event.name.s, parsed_event.name.len);
-		wipeer_name.len= parsed_event.name.len;
-		memcpy(wipeer_name.s+ wipeer_name.len, ".winfo", 6);
-		wipeer_name.len+= 6;
-		ev->wipeer= contains_event(&wipeer_name, NULL);
-		if (ev->wipeer) {
+		wipeer_name.len = parsed_event.name.len;
+		memcpy(wipeer_name.s + wipeer_name.len, ".winfo", 6);
+		wipeer_name.len += 6;
+		ev->wipeer = contains_event(&wipeer_name, NULL);
+		if(ev->wipeer) {
 			LM_DBG("Found wipeer event [%.*s] for event [%.*s]\n",
-					wipeer_name.len,wipeer_name.s,
-					parsed_event.name.len,parsed_event.name.s);
+					wipeer_name.len, wipeer_name.s, parsed_event.name.len,
+					parsed_event.name.s);
 		}
 	}
 
 	if(ev->wipeer)
-		ev->wipeer->wipeer= ev;
+		ev->wipeer->wipeer = ev;
 
-	if(event->req_auth &&
-		( event->get_auth_status==0 ||event->get_rules_doc== 0))
-	{
+	if(event->req_auth
+			&& (event->get_auth_status == 0 || event->get_rules_doc == 0)) {
 		LM_ERR("bad event structure\n");
 		goto error;
 	}
-	ev->req_auth= event->req_auth;
-	ev->agg_nbody= event->agg_nbody;
-	ev->apply_auth_nbody= event->apply_auth_nbody;
-	ev->get_auth_status= event->get_auth_status;
-	ev->get_rules_doc= event->get_rules_doc;
-	ev->get_pidf_doc= event->get_pidf_doc;
-	ev->evs_publ_handl= event->evs_publ_handl;
-	ev->evs_subs_handl= event->evs_subs_handl;
-	ev->etag_not_new= event->etag_not_new;
-	ev->aux_body_processing= event->aux_body_processing;
-	ev->aux_free_body= event->aux_free_body;
-	ev->free_body= event->free_body;
-	ev->default_expires= event->default_expires;
-
-	if(not_in_list)
-	{
-		ev->next= EvList->events;
-		EvList->events= ev;
+	ev->req_auth = event->req_auth;
+	ev->agg_nbody = event->agg_nbody;
+	ev->apply_auth_nbody = event->apply_auth_nbody;
+	ev->get_auth_status = event->get_auth_status;
+	ev->get_rules_doc = event->get_rules_doc;
+	ev->get_pidf_doc = event->get_pidf_doc;
+	ev->evs_publ_handl = event->evs_publ_handl;
+	ev->evs_subs_handl = event->evs_subs_handl;
+	ev->etag_not_new = event->etag_not_new;
+	ev->aux_body_processing = event->aux_body_processing;
+	ev->aux_free_body = event->aux_free_body;
+	ev->free_body = event->free_body;
+	ev->default_expires = event->default_expires;
+
+	if(not_in_list) {
+		ev->next = EvList->events;
+		EvList->events = ev;
 	}
 	EvList->ev_count++;
 
-	LM_DBG("successfully added event: %.*s - len= %d\n",ev->name.len,
+	LM_DBG("successfully added event: %.*s - len= %d\n", ev->name.len,
 			ev->name.s, ev->name.len);
 done:
 	free_event_params(parsed_event.params.list, PKG_MEM_TYPE);
 	return 0;
 error:
 	free_event_params(parsed_event.params.list, PKG_MEM_TYPE);
-	if(ev && not_in_list)
-	{
+	if(ev && not_in_list) {
 		free_pres_event(ev);
 	}
 	return -1;
 }
 
-void free_pres_event(pres_ev_t* ev)
+void free_pres_event(pres_ev_t *ev)
 {
-	if(ev== NULL)
+	if(ev == NULL)
 		return;
 
 	if(ev->name.s)
@@ -279,42 +261,38 @@ void free_pres_event(pres_ev_t* ev)
 		ev->wipeer->wipeer = 0;
 	shm_free_event(ev->evp);
 	shm_free(ev);
-
 }
 
-evlist_t* init_evlist(void)
+evlist_t *init_evlist(void)
 {
-	evlist_t*  list= NULL;
+	evlist_t *list = NULL;
 
-	list= (evlist_t*)shm_malloc(sizeof(evlist_t));
-	if(list== NULL)
-	{
+	list = (evlist_t *)shm_malloc(sizeof(evlist_t));
+	if(list == NULL) {
 		LM_ERR("no more share memory\n");
 		return NULL;
 	}
-	list->ev_count= 0;
-	list->events= NULL;
+	list->ev_count = 0;
+	list->events = NULL;
 
 	return list;
 }
 
-pres_ev_t* contains_event(str* sname, event_t* parsed_event)
+pres_ev_t *contains_event(str *sname, event_t *parsed_event)
 {
 	event_t event;
 	event_t *pe;
-	pres_ev_t* e;
+	pres_ev_t *e;
 
-	pe = (parsed_event)?parsed_event:&event;
+	pe = (parsed_event) ? parsed_event : &event;
 
 	memset(pe, 0, sizeof(event_t));
-	if(event_parser(sname->s, sname->len, pe)< 0)
-	{
+	if(event_parser(sname->s, sname->len, pe) < 0) {
 		LM_ERR("parsing event\n");
 		return NULL;
 	}
-	e= search_event(pe);
-	if(parsed_event==0)
-	{
+	e = search_event(pe);
+	if(parsed_event == 0) {
 		free_event_params(pe->params.list, PKG_MEM_TYPE);
 		pe->params.list = NULL;
 	}
@@ -322,148 +300,139 @@ pres_ev_t* contains_event(str* sname, event_t* parsed_event)
 	return e;
 }
 
-void free_event_params(param_t* params, int mem_type)
+void free_event_params(param_t *params, int mem_type)
 {
-	param_t* t1, *t2;
-	t2= t1= params;
+	param_t *t1, *t2;
+	t2 = t1 = params;
 
-	while(t1)
-	{
-		t2= t1->next;
+	while(t1) {
+		t2 = t1->next;
 		if(mem_type == SHM_MEM_TYPE)
 			shm_free(t1);
 		else
 			pkg_free(t1);
-		t1= t2;
+		t1 = t2;
 	}
-
 }
 
-pres_ev_t* search_event(event_t* event)
+pres_ev_t *search_event(event_t *event)
 {
-	pres_ev_t* pres_ev;
-	pres_ev= EvList->events;
+	pres_ev_t *pres_ev;
+	pres_ev = EvList->events;
 
 	LM_DBG("start event= [%.*s/%d]\n", event->name.len, event->name.s,
 			event->type);
 
-	while(pres_ev)
-	{
-		if((pres_ev->evp->type== event->type && event->type!=EVENT_OTHER)
-			|| (pres_ev->evp->name.len== event->name.len &&
-				strncasecmp(pres_ev->evp->name.s,event->name.s,
-					pres_ev->evp->name.len)== 0))
-		{
-			if(event->params.list== NULL && pres_ev->evp->params.list== NULL)
-			{
+	while(pres_ev) {
+		if((pres_ev->evp->type == event->type && event->type != EVENT_OTHER)
+				|| (pres_ev->evp->name.len == event->name.len
+						   && strncasecmp(pres_ev->evp->name.s, event->name.s,
+									  pres_ev->evp->name.len)
+									  == 0)) {
+			if(event->params.list == NULL
+					&& pres_ev->evp->params.list == NULL) {
 				return pres_ev;
 			}
 
 			/* search all parameters in event in ev */
-			if(search_event_params(event, pres_ev->evp)< 0)
+			if(search_event_params(event, pres_ev->evp) < 0)
 				goto cont;
 
 			/* search all parameters in ev in event */
-			if(search_event_params(pres_ev->evp, event)< 0)
+			if(search_event_params(pres_ev->evp, event) < 0)
 				goto cont;
 
 			return pres_ev;
 		}
-cont:		pres_ev= pres_ev->next;
+	cont:
+		pres_ev = pres_ev->next;
 	}
 	return NULL;
-
 }
 
-int search_event_params(event_t* ev, event_t* searched_ev)
+int search_event_params(event_t *ev, event_t *searched_ev)
 {
-	param_t* ps, *p;
+	param_t *ps, *p;
 	int found;
 
-	ps= ev->params.list;
+	ps = ev->params.list;
 
-	while(ps)
-	{
-		p= searched_ev->params.list;
-		found= 0;
+	while(ps) {
+		p = searched_ev->params.list;
+		found = 0;
 
-		while(p)
-		{
-			if(p->name.len==ps->name.len &&
-					strncmp(p->name.s, ps->name.s, ps->name.len)==0) {
-				if(p->body.s==0 && ps->body.s==0) {
-					found= 1;
+		while(p) {
+			if(p->name.len == ps->name.len
+					&& strncmp(p->name.s, ps->name.s, ps->name.len) == 0) {
+				if(p->body.s == 0 && ps->body.s == 0) {
+					found = 1;
 					break;
 				}
-				if(p->body.s!=0 && ps->body.s!=0 && p->body.len==ps->body.len
-						&& (strncmp(p->body.s, ps->body.s, ps->body.len)==0)) {
-					found= 1;
+				if(p->body.s != 0 && ps->body.s != 0
+						&& p->body.len == ps->body.len
+						&& (strncmp(p->body.s, ps->body.s, ps->body.len)
+								   == 0)) {
+					found = 1;
 					break;
 				}
 			}
-			p= p->next;
+			p = p->next;
 		}
-		if(found== 0)
+		if(found == 0)
 			return -1;
-		ps= ps->next;
+		ps = ps->next;
 	}
 
 	return 1;
-
 }
-int get_event_list(str** ev_list)
+int get_event_list(str **ev_list)
 {
-	pres_ev_t* ev= EvList->events;
+	pres_ev_t *ev = EvList->events;
 	int i;
-	str* list;
-	*ev_list= NULL;
+	str *list;
+	*ev_list = NULL;
 
-	if(EvList->ev_count== 0)
+	if(EvList->ev_count == 0)
 		return 0;
 
-	list= (str*)pkg_malloc(sizeof(str));
-	if(list== NULL)
-	{
+	list = (str *)pkg_malloc(sizeof(str));
+	if(list == NULL) {
 		LM_ERR("No more memory\n");
 		return -1;
 	}
 	memset(list, 0, sizeof(str));
-	list->s= (char*)pkg_malloc(EvList->ev_count* MAX_EVNAME_SIZE);
-	if(list->s== NULL)
-	{
+	list->s = (char *)pkg_malloc(EvList->ev_count * MAX_EVNAME_SIZE);
+	if(list->s == NULL) {
 		LM_ERR("No more memory\n");
 		pkg_free(list);
 		return -1;
 	}
-	list->s[0]= '\0';
-
-	for(i= 0; i< EvList->ev_count; i++)
-	{
-		if(i> 0)
-		{
-			memcpy(list->s+ list->len, ", ", 2);
-			list->len+= 2;
+	list->s[0] = '\0';
+
+	for(i = 0; i < EvList->ev_count; i++) {
+		if(i > 0) {
+			memcpy(list->s + list->len, ", ", 2);
+			list->len += 2;
 		}
-		memcpy(list->s+ list->len, ev->name.s, ev->name.len );
-		list->len+= ev->name.len ;
-		ev= ev->next;
+		memcpy(list->s + list->len, ev->name.s, ev->name.len);
+		list->len += ev->name.len;
+		ev = ev->next;
 	}
 
-	*ev_list= list;
+	*ev_list = list;
 	return 0;
 }
 
 void destroy_evlist(void)
 {
-	pres_ev_t* e1, *e2;
-	if (EvList) {
-		e1= EvList->events;
+	pres_ev_t *e1, *e2;
+	if(EvList) {
+		e1 = EvList->events;
 		while(e1) {
-			e2= e1->next;
+			e2 = e1->next;
 			free_pres_event(e1);
-			e1= e2;
+			e1 = e2;
 		}
 		shm_free(EvList);
 	}
 }
-

+ 42 - 41
src/modules/presence/event_list.h

@@ -27,7 +27,7 @@
 
 
 #ifndef _PRES_EV_LST_H
-#define  _PRES_EV_LST_H
+#define _PRES_EV_LST_H
 
 #include "../../core/parser/msg_parser.h"
 #include "../../core/parser/parse_event.h"
@@ -35,25 +35,26 @@
 #include "../../core/str.h"
 #include "subscribe.h"
 
-#define WINFO_TYPE			1<< 0
-#define PUBL_TYPE		    1<< 1
+#define WINFO_TYPE 1 << 0
+#define PUBL_TYPE 1 << 1
 
 struct subscription;
 
-typedef int (apply_auth_t)(str* , struct subscription*, str** );
+typedef int(apply_auth_t)(str *, struct subscription *, str **);
 
-typedef int (publ_handling_t)(struct sip_msg*);
+typedef int(publ_handling_t)(struct sip_msg *);
 
-typedef int (subs_handling_t)(struct sip_msg*);
+typedef int(subs_handling_t)(struct sip_msg *);
 
-typedef str* (agg_nbody_t)(str* pres_user, str* pres_domain, str** body_array, int n, int off_index);
+typedef str *(agg_nbody_t)(str *pres_user, str *pres_domain, str **body_array,
+		int n, int off_index);
 /* params for agg_body_t
  *	body_array= an array with all the bodies stored for that resource
  *	n= the number of bodies
  *	off_index= the index of the registration(etag) for which a Publish
  *				with Expires: 0 has just been received
  *	*/
-typedef str* (aux_body_processing_t)(struct subscription *subs, str* body);
+typedef str *(aux_body_processing_t)(struct subscription *subs, str *body);
 /* params for agg_body_t
  *	subs= a subscription structure to manipulate the body for a certain watcher
  *	body= the original body
@@ -62,9 +63,10 @@ typedef str* (aux_body_processing_t)(struct subscription *subs, str* body);
  *                  done directly in the original body
  *           pointer: a pointer to str for the "per watcher" body. gets freed by aux_free_body()
  *	*/
-typedef int (is_allowed_t)(struct subscription* subs);
-typedef int (get_rules_doc_t)(str* user, str* domain, str** rules_doc);
-typedef int (get_pidf_doc_t)(str* user, str* domain, str* file_uri, str** rules_doc);
+typedef int(is_allowed_t)(struct subscription *subs);
+typedef int(get_rules_doc_t)(str *user, str *domain, str **rules_doc);
+typedef int(get_pidf_doc_t)(
+		str *user, str *domain, str *file_uri, str **rules_doc);
 /* return code rules for is_allowed_t
  *	< 0  if error occurred
  *	=0	 if no change in status(if no xcap document exists)
@@ -72,12 +74,12 @@ typedef int (get_pidf_doc_t)(str* user, str* domain, str* file_uri, str** rules_
  *	*/
 
 /* event specific body free function */
-typedef void(free_body_t)(char* body);
+typedef void(free_body_t)(char *body);
 
 struct pres_ev
 {
 	str name;
-	event_t* evp;
+	event_t *evp;
 	str content_type;
 	unsigned int default_expires;
 	int type; /* category type: WINFO_TIPE, PUBL_TYPE, ...*/
@@ -93,20 +95,20 @@ struct pres_ev
 	 *  apply_auth_nbody    - alter the body according to authorization rules
 	 */
 	int req_auth;
-	get_rules_doc_t* get_rules_doc;
-	get_pidf_doc_t* get_pidf_doc;
-	apply_auth_t*  apply_auth_nbody;
-	is_allowed_t*  get_auth_status;
+	get_rules_doc_t *get_rules_doc;
+	get_pidf_doc_t *get_pidf_doc;
+	apply_auth_t *apply_auth_nbody;
+	is_allowed_t *get_auth_status;
 
 	/* an agg_body_t function should be registered if the event permits having
 	 * multiple published states and requires an aggregation of the information
 	 * otherwise, this field should be NULL and the last published state is taken
 	 * when constructing Notify msg
 	 * */
-	agg_nbody_t* agg_nbody;
-	publ_handling_t  * evs_publ_handl;
-	subs_handling_t  * evs_subs_handl;
-	free_body_t* free_body;
+	agg_nbody_t *agg_nbody;
+	publ_handling_t *evs_publ_handl;
+	subs_handling_t *evs_subs_handl;
+	free_body_t *free_body;
 	/* sometimes it is necessary that a module make changes for a body for each
 	 * active watcher (e.g. setting the "version" parameter in an XML document.
 	 * If a module registers the aux_body_processing callback, it gets called for
@@ -117,48 +119,47 @@ struct pres_ev
 	 * copy of the original body, it also has to register the aux_free_body() to 
 	 * free this "per watcher" body.
 	 */
-	aux_body_processing_t* aux_body_processing;
-	free_body_t* aux_free_body;
-	struct pres_ev* wipeer;
-	struct pres_ev* next;
-
+	aux_body_processing_t *aux_body_processing;
+	free_body_t *aux_free_body;
+	struct pres_ev *wipeer;
+	struct pres_ev *next;
 };
 typedef struct pres_ev pres_ev_t;
 
 typedef struct evlist
 {
 	int ev_count;
-	pres_ev_t* events;
+	pres_ev_t *events;
 } evlist_t;
 
-evlist_t* init_evlist(void);
+evlist_t *init_evlist(void);
 
-int add_event(pres_ev_t* event);
+int add_event(pres_ev_t *event);
 
-typedef int (*add_event_t)(pres_ev_t* event);
+typedef int (*add_event_t)(pres_ev_t *event);
 
-void free_event_params(param_t* params, int mem_type);
+void free_event_params(param_t *params, int mem_type);
 
-pres_ev_t* contains_event(str* name, event_t* parsed_event);
+pres_ev_t *contains_event(str *name, event_t *parsed_event);
 
-typedef pres_ev_t* (*contains_event_t)(str* name, event_t* parsed_event);
+typedef pres_ev_t *(*contains_event_t)(str *name, event_t *parsed_event);
 
-int get_event_list(str** ev_list);
+int get_event_list(str **ev_list);
 
-typedef int (*get_event_list_t) (str** ev_list);
+typedef int (*get_event_list_t)(str **ev_list);
 
 void destroy_evlist(void);
 
-extern evlist_t* EvList;
+extern evlist_t *EvList;
 
-pres_ev_t* search_event(event_t* event);
-typedef pres_ev_t* (*search_event_t)(event_t* event);
+pres_ev_t *search_event(event_t *event);
+typedef pres_ev_t *(*search_event_t)(event_t *event);
 
-event_t* shm_copy_event(event_t* e);
+event_t *shm_copy_event(event_t *e);
 
-void shm_free_event(event_t* ev);
+void shm_free_event(event_t *ev);
 
-void free_pres_event(pres_ev_t* ev);
+void free_pres_event(pres_ev_t *ev);
 
 
 #endif

+ 244 - 292
src/modules/presence/hash.c

@@ -46,113 +46,104 @@ extern int pres_subs_remove_match;
  */
 shtable_t new_shtable(int hash_size)
 {
-	shtable_t htable= NULL;
+	shtable_t htable = NULL;
 	int i, j;
 
 	i = 0;
-	htable= (subs_entry_t*)shm_malloc(hash_size* sizeof(subs_entry_t));
-	if(htable== NULL)
-	{
+	htable = (subs_entry_t *)shm_malloc(hash_size * sizeof(subs_entry_t));
+	if(htable == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
-	memset(htable, 0, hash_size* sizeof(subs_entry_t));
-	for(i= 0; i< hash_size; i++)
-	{
-		if(lock_init(&htable[i].lock)== 0)
-		{
+	memset(htable, 0, hash_size * sizeof(subs_entry_t));
+	for(i = 0; i < hash_size; i++) {
+		if(lock_init(&htable[i].lock) == 0) {
 			LM_ERR("initializing lock [%d]\n", i);
 			goto error;
 		}
-		htable[i].entries= (subs_t*)shm_malloc(sizeof(subs_t));
-		if(htable[i].entries== NULL)
-		{
+		htable[i].entries = (subs_t *)shm_malloc(sizeof(subs_t));
+		if(htable[i].entries == NULL) {
 			lock_destroy(&htable[i].lock);
 			ERR_MEM(SHARE_MEM);
 		}
 		memset(htable[i].entries, 0, sizeof(subs_t));
-		htable[i].entries->next= NULL;
+		htable[i].entries->next = NULL;
 	}
 
 	return htable;
 
 error:
-	if(htable)
-	{
-		for(j=0; j< i; j++)
-		{
+	if(htable) {
+		for(j = 0; j < i; j++) {
 			lock_destroy(&htable[j].lock);
 			shm_free(htable[j].entries);
 		}
 		shm_free(htable);
 	}
 	return NULL;
-
 }
 
 void destroy_shtable(shtable_t htable, int hash_size)
 {
 	int i;
 
-	if(htable== NULL)
+	if(htable == NULL)
 		return;
 
-	for(i= 0; i< hash_size; i++)
-	{
+	for(i = 0; i < hash_size; i++) {
 		lock_destroy(&htable[i].lock);
 		free_subs_list(htable[i].entries->next, SHM_MEM_TYPE, 1);
 		shm_free(htable[i].entries);
 		htable[i].entries = NULL;
 	}
 	shm_free(htable);
-	htable= NULL;
+	htable = NULL;
 }
 
-subs_t* search_shtable(shtable_t htable,str callid,str to_tag,
-		str from_tag,unsigned int hash_code)
+subs_t *search_shtable(shtable_t htable, str callid, str to_tag, str from_tag,
+		unsigned int hash_code)
 {
-	subs_t* s;
-
-	s= htable[hash_code].entries?htable[hash_code].entries->next:NULL;
-
-	while(s)
-	{
-		if(s->callid.len==callid.len &&
-				strncmp(s->callid.s, callid.s, callid.len)==0 &&
-			s->to_tag.len== to_tag.len &&
-				strncmp(s->to_tag.s, to_tag.s, to_tag.len)==0 &&
-			s->from_tag.len== from_tag.len &&
-				strncmp(s->from_tag.s, from_tag.s, from_tag.len)== 0)
+	subs_t *s;
+
+	s = htable[hash_code].entries ? htable[hash_code].entries->next : NULL;
+
+	while(s) {
+		if(s->callid.len == callid.len
+				&& strncmp(s->callid.s, callid.s, callid.len) == 0
+				&& s->to_tag.len == to_tag.len
+				&& strncmp(s->to_tag.s, to_tag.s, to_tag.len) == 0
+				&& s->from_tag.len == from_tag.len
+				&& strncmp(s->from_tag.s, from_tag.s, from_tag.len) == 0)
 			return s;
-		s= s->next;
+		s = s->next;
 	}
 
 	return NULL;
 }
 
-subs_t* mem_copy_subs(subs_t* s, int mem_type)
+subs_t *mem_copy_subs(subs_t *s, int mem_type)
 {
 	int size;
-	subs_t* dest;
+	subs_t *dest;
 
-	size= sizeof(subs_t)+ (s->pres_uri.len+ s->to_user.len
-		+ s->to_domain.len+ s->from_user.len+ s->from_domain.len+ s->callid.len
-		+ s->to_tag.len+ s->from_tag.len+s->sockinfo_str.len+s->event_id.len
-		+ s->local_contact.len+ s->contact.len+ s->record_route.len
-		+ s->reason.len+ s->watcher_user.len+ s->watcher_domain.len
-		+ s->user_agent.len
-		+ 1)*sizeof(char);
+	size = sizeof(subs_t)
+		   + (s->pres_uri.len + s->to_user.len + s->to_domain.len
+					 + s->from_user.len + s->from_domain.len + s->callid.len
+					 + s->to_tag.len + s->from_tag.len + s->sockinfo_str.len
+					 + s->event_id.len + s->local_contact.len + s->contact.len
+					 + s->record_route.len + s->reason.len + s->watcher_user.len
+					 + s->watcher_domain.len + s->user_agent.len + 1)
+					 * sizeof(char);
 
 	if(mem_type & PKG_MEM_TYPE)
-		dest= (subs_t*)pkg_malloc(size);
+		dest = (subs_t *)pkg_malloc(size);
 	else
-		dest= (subs_t*)shm_malloc(size);
+		dest = (subs_t *)shm_malloc(size);
 
-	if(dest== NULL)
-	{
-		ERR_MEM((mem_type==PKG_MEM_TYPE)?PKG_MEM_STR:SHARE_MEM);
+	if(dest == NULL) {
+		ERR_MEM((mem_type == PKG_MEM_TYPE) ? PKG_MEM_STR : SHARE_MEM);
 	}
 	memset(dest, 0, size);
-	size= sizeof(subs_t);
+	size = sizeof(subs_t);
 
 	CONT_COPY(dest, dest->pres_uri, s->pres_uri);
 	CONT_COPY(dest, dest->to_user, s->to_user);
@@ -174,15 +165,15 @@ subs_t* mem_copy_subs(subs_t* s, int mem_type)
 	if(s->reason.s)
 		CONT_COPY(dest, dest->reason, s->reason);
 
-	dest->event= s->event;
-	dest->local_cseq= s->local_cseq;
-	dest->remote_cseq= s->remote_cseq;
-	dest->status= s->status;
-	dest->version= s->version;
-	dest->send_on_cback= s->send_on_cback;
-	dest->expires= s->expires;
-	dest->db_flag= s->db_flag;
-	dest->flags= s->flags;
+	dest->event = s->event;
+	dest->local_cseq = s->local_cseq;
+	dest->remote_cseq = s->remote_cseq;
+	dest->status = s->status;
+	dest->version = s->version;
+	dest->send_on_cback = s->send_on_cback;
+	dest->expires = s->expires;
+	dest->db_flag = s->db_flag;
+	dest->flags = s->flags;
 
 	return dest;
 
@@ -191,26 +182,26 @@ error:
 }
 
 
-subs_t* mem_copy_subs_noc(subs_t* s)
+subs_t *mem_copy_subs_noc(subs_t *s)
 {
 	int size;
-	subs_t* dest;
-
-	size= sizeof(subs_t)+ (s->pres_uri.len+ s->to_user.len
-		+ s->to_domain.len+ s->from_user.len+ s->from_domain.len+ s->callid.len
-		+ s->to_tag.len+ s->from_tag.len+s->sockinfo_str.len+s->event_id.len
-		+ s->local_contact.len
-		+ s->reason.len+ s->watcher_user.len+ s->watcher_domain.len
-		+ s->user_agent.len
-		+ 1)*sizeof(char);
-
-	dest= (subs_t*)shm_malloc(size);
-	if(dest== NULL)
-	{
+	subs_t *dest;
+
+	size = sizeof(subs_t)
+		   + (s->pres_uri.len + s->to_user.len + s->to_domain.len
+					 + s->from_user.len + s->from_domain.len + s->callid.len
+					 + s->to_tag.len + s->from_tag.len + s->sockinfo_str.len
+					 + s->event_id.len + s->local_contact.len + s->reason.len
+					 + s->watcher_user.len + s->watcher_domain.len
+					 + s->user_agent.len + 1)
+					 * sizeof(char);
+
+	dest = (subs_t *)shm_malloc(size);
+	if(dest == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memset(dest, 0, size);
-	size= sizeof(subs_t);
+	size = sizeof(subs_t);
 
 	CONT_COPY(dest, dest->pres_uri, s->pres_uri);
 	CONT_COPY(dest, dest->to_user, s->to_user);
@@ -230,135 +221,130 @@ subs_t* mem_copy_subs_noc(subs_t* s)
 	if(s->reason.s)
 		CONT_COPY(dest, dest->reason, s->reason);
 
-	dest->event= s->event;
-	dest->local_cseq= s->local_cseq;
-	dest->remote_cseq= s->remote_cseq;
-	dest->status= s->status;
-	dest->version= s->version;
-	dest->send_on_cback= s->send_on_cback;
-	dest->expires= s->expires;
-	dest->db_flag= s->db_flag;
-	dest->flags= s->flags;
-
-	dest->contact.s= (char*)shm_malloc(s->contact.len* sizeof(char));
-	if(dest->contact.s== NULL)
-	{
+	dest->event = s->event;
+	dest->local_cseq = s->local_cseq;
+	dest->remote_cseq = s->remote_cseq;
+	dest->status = s->status;
+	dest->version = s->version;
+	dest->send_on_cback = s->send_on_cback;
+	dest->expires = s->expires;
+	dest->db_flag = s->db_flag;
+	dest->flags = s->flags;
+
+	dest->contact.s = (char *)shm_malloc(s->contact.len * sizeof(char));
+	if(dest->contact.s == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memcpy(dest->contact.s, s->contact.s, s->contact.len);
-	dest->contact.len= s->contact.len;
+	dest->contact.len = s->contact.len;
 
-	dest->record_route.s= (char*)shm_malloc((s->record_route.len + 1) * sizeof(char));
-	if(dest->record_route.s== NULL)
-	{
+	dest->record_route.s =
+			(char *)shm_malloc((s->record_route.len + 1) * sizeof(char));
+	if(dest->record_route.s == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memcpy(dest->record_route.s, s->record_route.s, s->record_route.len);
-	dest->record_route.len= s->record_route.len;
+	dest->record_route.len = s->record_route.len;
 
 	return dest;
 
 error:
 	if(dest)
-			shm_free(dest);
+		shm_free(dest);
 	return NULL;
 }
 
-int insert_shtable(shtable_t htable,unsigned int hash_code, subs_t* subs)
+int insert_shtable(shtable_t htable, unsigned int hash_code, subs_t *subs)
 {
-	subs_t* new_rec= NULL;
+	subs_t *new_rec = NULL;
 
-	new_rec= mem_copy_subs_noc(subs);
-	if(new_rec== NULL)
-	{
+	new_rec = mem_copy_subs_noc(subs);
+	if(new_rec == NULL) {
 		LM_ERR("copying in share memory a subs_t structure\n");
 		return -1;
 	}
-	new_rec->expires+= (int)time(NULL);
+	new_rec->expires += (int)time(NULL);
 
 	lock_get(&htable[hash_code].lock);
-	new_rec->next= htable[hash_code].entries->next;
-	htable[hash_code].entries->next= new_rec;
+	new_rec->next = htable[hash_code].entries->next;
+	htable[hash_code].entries->next = new_rec;
 	lock_release(&htable[hash_code].lock);
 
 	return 0;
 }
 
-int delete_shtable(shtable_t htable,unsigned int hash_code,subs_t* subs)
+int delete_shtable(shtable_t htable, unsigned int hash_code, subs_t *subs)
 {
-	subs_t* s= NULL, *ps= NULL;
-	int found= -1;
+	subs_t *s = NULL, *ps = NULL;
+	int found = -1;
 
 	lock_get(&htable[hash_code].lock);
-	
-	ps= htable[hash_code].entries;
-	s= ps?ps->next:NULL;
-		
-	while(s)
-	{
-		if(pres_subs_remove_match==0) {
+
+	ps = htable[hash_code].entries;
+	s = ps ? ps->next : NULL;
+
+	while(s) {
+		if(pres_subs_remove_match == 0) {
 			/* match on to-tag only (unique, local generated - faster) */
-			if(s->to_tag.len==subs->to_tag.len
-				&& strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0)
-			{
+			if(s->to_tag.len == subs->to_tag.len
+					&& strncmp(s->to_tag.s, subs->to_tag.s, subs->to_tag.len)
+							   == 0) {
 				found = 0;
 			}
 		} else {
 			/* match on all dialog attributes (distributed systems) */
-			if(s->callid.len==subs->callid.len
-				&& s->to_tag.len==subs->to_tag.len
-				&& s->from_tag.len==subs->from_tag.len
-				&& strncmp(s->callid.s,subs->callid.s,subs->callid.len)==0
-				&& strncmp(s->to_tag.s,subs->to_tag.s,subs->to_tag.len)==0
-				&& strncmp(s->from_tag.s,subs->from_tag.s,subs->from_tag.len)==0)
-			{
+			if(s->callid.len == subs->callid.len
+					&& s->to_tag.len == subs->to_tag.len
+					&& s->from_tag.len == subs->from_tag.len
+					&& strncmp(s->callid.s, subs->callid.s, subs->callid.len)
+							   == 0
+					&& strncmp(s->to_tag.s, subs->to_tag.s, subs->to_tag.len)
+							   == 0
+					&& strncmp(s->from_tag.s, subs->from_tag.s,
+							   subs->from_tag.len)
+							   == 0) {
 				found = 0;
 			}
 		}
-		if(found==0)
-		{
-			found= s->local_cseq +1;
-			ps->next= s->next;
-			if(s->contact.s!=NULL) {
+		if(found == 0) {
+			found = s->local_cseq + 1;
+			ps->next = s->next;
+			if(s->contact.s != NULL) {
 				shm_free(s->contact.s);
 				s->contact.s = NULL;
 			}
-			if(s->record_route.s!=NULL) {
+			if(s->record_route.s != NULL) {
 				shm_free(s->record_route.s);
 				s->record_route.s = NULL;
 			}
-			if (s) {
+			if(s) {
 				shm_free(s);
 				s = NULL;
 			}
 			break;
 		}
-		ps= s;
-		s= s->next;
+		ps = s;
+		s = s->next;
 	}
 	lock_release(&htable[hash_code].lock);
 	return found;
 }
 
-void free_subs_list(subs_t* s_array, int mem_type, int ic)
+void free_subs_list(subs_t *s_array, int mem_type, int ic)
 {
-	subs_t* s;
-
-	while(s_array)
-	{
-		s= s_array;
-		s_array= s_array->next;
-		if(mem_type & PKG_MEM_TYPE)
-		{
+	subs_t *s;
+
+	while(s_array) {
+		s = s_array;
+		s_array = s_array->next;
+		if(mem_type & PKG_MEM_TYPE) {
 			if(ic) {
 				pkg_free(s->contact.s);
 				s->contact.s = NULL;
 			}
 			pkg_free(s);
 			s = NULL;
-		}
-		else
-		{
+		} else {
 			if(ic) {
 				shm_free(s->contact.s);
 				s->contact.s = NULL;
@@ -367,137 +353,121 @@ void free_subs_list(subs_t* s_array, int mem_type, int ic)
 			s = NULL;
 		}
 	}
-	
 }
 
-int update_shtable(shtable_t htable,unsigned int hash_code, 
-		subs_t* subs, int type)
+int update_shtable(
+		shtable_t htable, unsigned int hash_code, subs_t *subs, int type)
 {
-	subs_t* s;
+	subs_t *s;
 
 	lock_get(&htable[hash_code].lock);
 
-	s= search_shtable(htable,subs->callid, subs->to_tag, subs->from_tag,
-			hash_code);
-	if(s== NULL)
-	{
+	s = search_shtable(
+			htable, subs->callid, subs->to_tag, subs->from_tag, hash_code);
+	if(s == NULL) {
 		LM_DBG("record not found in hash table\n");
 		lock_release(&htable[hash_code].lock);
 		return -1;
 	}
 
-	if(type & REMOTE_TYPE)
-	{
-		s->expires= subs->expires+ (int)time(NULL);
-		s->remote_cseq= subs->remote_cseq;
-	}
-	else
-	{
+	if(type & REMOTE_TYPE) {
+		s->expires = subs->expires + (int)time(NULL);
+		s->remote_cseq = subs->remote_cseq;
+	} else {
 		subs->local_cseq = ++s->local_cseq;
 		subs->version = ++s->version;
 	}
-	
-	if(presence_sip_uri_match(&s->contact, &subs->contact))
-	{
+
+	if(presence_sip_uri_match(&s->contact, &subs->contact)) {
 		shm_free(s->contact.s);
-		s->contact.s= (char*)shm_malloc(subs->contact.len* sizeof(char));
-		if(s->contact.s== NULL)
-		{
+		s->contact.s = (char *)shm_malloc(subs->contact.len * sizeof(char));
+		if(s->contact.s == NULL) {
 			lock_release(&htable[hash_code].lock);
 			LM_ERR("no more shared memory\n");
 			return -1;
 		}
 		memcpy(s->contact.s, subs->contact.s, subs->contact.len);
-		s->contact.len= subs->contact.len;
+		s->contact.len = subs->contact.len;
 	}
 
 	shm_free(s->record_route.s);
-	s->record_route.s= (char*)shm_malloc(subs->record_route.len* sizeof(char));
-	if(s->record_route.s== NULL)
-	{
+	s->record_route.s =
+			(char *)shm_malloc(subs->record_route.len * sizeof(char));
+	if(s->record_route.s == NULL) {
 		lock_release(&htable[hash_code].lock);
 		LM_ERR("no more shared memory\n");
 		return -1;
 	}
 	memcpy(s->record_route.s, subs->record_route.s, subs->record_route.len);
-	s->record_route.len= subs->record_route.len;
+	s->record_route.len = subs->record_route.len;
 
-	s->status= subs->status;
-	s->event= subs->event;
-	subs->db_flag= s->db_flag;
+	s->status = subs->status;
+	s->event = subs->event;
+	subs->db_flag = s->db_flag;
 
 	if(s->db_flag & NO_UPDATEDB_FLAG)
-		s->db_flag= UPDATEDB_FLAG;
+		s->db_flag = UPDATEDB_FLAG;
 
 	lock_release(&htable[hash_code].lock);
-	
+
 	return 0;
 }
 
-phtable_t* new_phtable(void)
+phtable_t *new_phtable(void)
 {
-	phtable_t* htable= NULL;
+	phtable_t *htable = NULL;
 	int i, j;
 
 	i = 0;
-	htable= (phtable_t*)shm_malloc(phtable_size* sizeof(phtable_t));
-	if(htable== NULL)
-	{
+	htable = (phtable_t *)shm_malloc(phtable_size * sizeof(phtable_t));
+	if(htable == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
-	memset(htable, 0, phtable_size* sizeof(phtable_t));
+	memset(htable, 0, phtable_size * sizeof(phtable_t));
 
-	for(i= 0; i< phtable_size; i++)
-	{
-		if(lock_init(&htable[i].lock)== 0)
-		{
+	for(i = 0; i < phtable_size; i++) {
+		if(lock_init(&htable[i].lock) == 0) {
 			LM_ERR("initializing lock [%d]\n", i);
 			goto error;
 		}
-		htable[i].entries= (pres_entry_t*)shm_malloc(sizeof(pres_entry_t));
-		if(htable[i].entries== NULL)
-		{
+		htable[i].entries = (pres_entry_t *)shm_malloc(sizeof(pres_entry_t));
+		if(htable[i].entries == NULL) {
 			ERR_MEM(SHARE_MEM);
 		}
 		memset(htable[i].entries, 0, sizeof(pres_entry_t));
-		htable[i].entries->next= NULL;
+		htable[i].entries->next = NULL;
 	}
 
 	return htable;
 
 error:
-	if(htable)
-	{
-		for(j=0; j< i; j++)
-		{
+	if(htable) {
+		for(j = 0; j < i; j++) {
 			if(htable[i].entries)
 				shm_free(htable[i].entries);
-			else 
+			else
 				break;
 			lock_destroy(&htable[i].lock);
 		}
 		shm_free(htable);
 	}
 	return NULL;
-
 }
 
 void destroy_phtable(void)
 {
 	int i;
-	pres_entry_t* p, *prev_p;
+	pres_entry_t *p, *prev_p;
 
-	if(pres_htable== NULL)
+	if(pres_htable == NULL)
 		return;
 
-	for(i= 0; i< phtable_size; i++)
-	{
+	for(i = 0; i < phtable_size; i++) {
 		lock_destroy(&pres_htable[i].lock);
-		p= pres_htable[i].entries;
-		while(p)
-		{
-			prev_p= p;
-			p= p->next;
+		p = pres_htable[i].entries;
+		while(p) {
+			prev_p = p;
+			p = p->next;
 			if(prev_p->sphere)
 				shm_free(prev_p->sphere);
 			shm_free(prev_p);
@@ -507,59 +477,54 @@ void destroy_phtable(void)
 }
 /* entry must be locked before calling this function */
 
-pres_entry_t* search_phtable(str* pres_uri,int event, unsigned int hash_code)
+pres_entry_t *search_phtable(str *pres_uri, int event, unsigned int hash_code)
 {
-	pres_entry_t* p;
-
-	LM_DBG("pres_uri= %.*s\n", pres_uri->len,  pres_uri->s);
-	p= pres_htable[hash_code].entries->next;
-	while(p)
-	{
-		if(p->event== event && p->pres_uri.len== pres_uri->len &&
-				presence_sip_uri_match(&p->pres_uri, pres_uri)== 0 )
+	pres_entry_t *p;
+
+	LM_DBG("pres_uri= %.*s\n", pres_uri->len, pres_uri->s);
+	p = pres_htable[hash_code].entries->next;
+	while(p) {
+		if(p->event == event && p->pres_uri.len == pres_uri->len
+				&& presence_sip_uri_match(&p->pres_uri, pres_uri) == 0)
 			return p;
-		p= p->next;
+		p = p->next;
 	}
 	return NULL;
 }
 
-int insert_phtable(str* pres_uri, int event, char* sphere)
+int insert_phtable(str *pres_uri, int event, char *sphere)
 {
 	unsigned int hash_code;
-	pres_entry_t* p= NULL;
+	pres_entry_t *p = NULL;
 	int size;
 
-	hash_code= core_case_hash(pres_uri, NULL, phtable_size);
+	hash_code = core_case_hash(pres_uri, NULL, phtable_size);
 
 	lock_get(&pres_htable[hash_code].lock);
-	
-	p= search_phtable(pres_uri, event, hash_code);
-	if(p)
-	{
+
+	p = search_phtable(pres_uri, event, hash_code);
+	if(p) {
 		p->publ_count++;
 		lock_release(&pres_htable[hash_code].lock);
 		return 0;
 	}
-	size= sizeof(pres_entry_t)+ pres_uri->len* sizeof(char);
+	size = sizeof(pres_entry_t) + pres_uri->len * sizeof(char);
 
-	p= (pres_entry_t*)shm_malloc(size);
-	if(p== NULL)
-	{
+	p = (pres_entry_t *)shm_malloc(size);
+	if(p == NULL) {
 		lock_release(&pres_htable[hash_code].lock);
 		ERR_MEM(SHARE_MEM);
 	}
 	memset(p, 0, size);
 
-	size= sizeof(pres_entry_t);
-	p->pres_uri.s= (char*)p+ size;
+	size = sizeof(pres_entry_t);
+	p->pres_uri.s = (char *)p + size;
 	memcpy(p->pres_uri.s, pres_uri->s, pres_uri->len);
-	p->pres_uri.len= pres_uri->len;
-	
-	if(sphere)
-	{
-		p->sphere= (char*)shm_malloc((strlen(sphere)+ 1)*sizeof(char));
-		if(p->sphere== NULL)
-		{
+	p->pres_uri.len = pres_uri->len;
+
+	if(sphere) {
+		p->sphere = (char *)shm_malloc((strlen(sphere) + 1) * sizeof(char));
+		if(p->sphere == NULL) {
 			lock_release(&pres_htable[hash_code].lock);
 			shm_free(p);
 			ERR_MEM(SHARE_MEM);
@@ -567,56 +532,52 @@ int insert_phtable(str* pres_uri, int event, char* sphere)
 		strcpy(p->sphere, sphere);
 	}
 
-	p->event= event;
-	p->publ_count=1;
+	p->event = event;
+	p->publ_count = 1;
 
 	/* link the item in the hash table */
-	p->next= pres_htable[hash_code].entries->next;
-	pres_htable[hash_code].entries->next= p;
+	p->next = pres_htable[hash_code].entries->next;
+	pres_htable[hash_code].entries->next = p;
 
 	lock_release(&pres_htable[hash_code].lock);
-	
+
 	return 0;
 
 error:
 	return -1;
 }
 
-int delete_phtable(str* pres_uri, int event)
+int delete_phtable(str *pres_uri, int event)
 {
 	unsigned int hash_code;
-	pres_entry_t* p= NULL, *prev_p= NULL;
+	pres_entry_t *p = NULL, *prev_p = NULL;
 
-	hash_code= core_case_hash(pres_uri, NULL, phtable_size);
+	hash_code = core_case_hash(pres_uri, NULL, phtable_size);
 
 	lock_get(&pres_htable[hash_code].lock);
-	
-	p= search_phtable(pres_uri, event, hash_code);
-	if(p== NULL)
-	{
+
+	p = search_phtable(pres_uri, event, hash_code);
+	if(p == NULL) {
 		LM_DBG("record not found\n");
 		lock_release(&pres_htable[hash_code].lock);
 		return 0;
 	}
-	
+
 	p->publ_count--;
-	if(p->publ_count== 0)
-	{
-		/* delete record */	
-		prev_p= pres_htable[hash_code].entries;
-		while(prev_p->next)
-		{
-			if(prev_p->next== p)
+	if(p->publ_count == 0) {
+		/* delete record */
+		prev_p = pres_htable[hash_code].entries;
+		while(prev_p->next) {
+			if(prev_p->next == p)
 				break;
-			prev_p= prev_p->next;
+			prev_p = prev_p->next;
 		}
-		if(prev_p->next== NULL)
-		{
+		if(prev_p->next == NULL) {
 			LM_ERR("record not found\n");
 			lock_release(&pres_htable[hash_code].lock);
 			return -1;
 		}
-		prev_p->next= p->next;
+		prev_p->next = p->next;
 		if(p->sphere)
 			shm_free(p->sphere);
 
@@ -624,73 +585,65 @@ int delete_phtable(str* pres_uri, int event)
 	}
 	lock_release(&pres_htable[hash_code].lock);
 
-	return 0;	
+	return 0;
 }
 
-int update_phtable(presentity_t* presentity, str pres_uri, str body)
+int update_phtable(presentity_t *presentity, str pres_uri, str body)
 {
-	char* sphere= NULL;
+	char *sphere = NULL;
 	unsigned int hash_code;
-	pres_entry_t* p;
-	int ret= 0;
-	str* xcap_doc= NULL;
+	pres_entry_t *p;
+	int ret = 0;
+	str *xcap_doc = NULL;
 
 	/* get new sphere */
-	sphere= extract_sphere(body);
-	if(sphere==NULL)
-	{
+	sphere = extract_sphere(body);
+	if(sphere == NULL) {
 		LM_DBG("no sphere defined in new body\n");
 		return 0;
 	}
 
 	/* search for record in hash table */
-	hash_code= core_case_hash(&pres_uri, NULL, phtable_size);
-	
+	hash_code = core_case_hash(&pres_uri, NULL, phtable_size);
+
 	lock_get(&pres_htable[hash_code].lock);
 
-	p= search_phtable(&pres_uri, presentity->event->evp->type, hash_code);
-	if(p== NULL)
-	{
+	p = search_phtable(&pres_uri, presentity->event->evp->type, hash_code);
+	if(p == NULL) {
 		lock_release(&pres_htable[hash_code].lock);
 		goto done;
 	}
-	
-	if(p->sphere)
-	{
-		if(strcmp(p->sphere, sphere)!= 0)
-		{
+
+	if(p->sphere) {
+		if(strcmp(p->sphere, sphere) != 0) {
 			/* new sphere definition */
 			shm_free(p->sphere);
-		}
-		else
-		{
+		} else {
 			/* no change in sphere definition */
 			lock_release(&pres_htable[hash_code].lock);
 			pkg_free(sphere);
 			return 0;
 		}
-	
 	}
 
 
-	p->sphere= (char*)shm_malloc((strlen(sphere)+ 1)*sizeof(char));
-	if(p->sphere== NULL)
-	{
+	p->sphere = (char *)shm_malloc((strlen(sphere) + 1) * sizeof(char));
+	if(p->sphere == NULL) {
 		lock_release(&pres_htable[hash_code].lock);
-		ret= -1;
+		ret = -1;
 		goto done;
 	}
 	strcpy(p->sphere, sphere);
-		
+
 	lock_release(&pres_htable[hash_code].lock);
 
 	/* call for watchers status update */
 
-	if(presentity->event->get_rules_doc(&presentity->user, &presentity->domain,
-				&xcap_doc)< 0)
-	{
+	if(presentity->event->get_rules_doc(
+			   &presentity->user, &presentity->domain, &xcap_doc)
+			< 0) {
 		LM_ERR("failed to retrieve xcap document\n");
-		ret= -1;
+		ret = -1;
 		goto done;
 	}
 
@@ -699,8 +652,7 @@ int update_phtable(presentity_t* presentity, str pres_uri, str body)
 
 done:
 
-	if(xcap_doc)
-	{
+	if(xcap_doc) {
 		if(xcap_doc->s)
 			pkg_free(xcap_doc->s);
 		pkg_free(xcap_doc);

+ 48 - 46
src/modules/presence/hash.h

@@ -27,82 +27,85 @@
  */
 
 
-
 #ifndef PS_HASH_H
 #define PS_HASH_H
 
 #include "../../core/lock_ops.h"
 
 struct presentity;
-#define REMOTE_TYPE   1<<1
-#define LOCAL_TYPE    1<<2
+#define REMOTE_TYPE 1 << 1
+#define LOCAL_TYPE 1 << 2
 
-#define PKG_MEM_STR       "pkg"
-#define SHARE_MEM         "share"
+#define PKG_MEM_STR "pkg"
+#define SHARE_MEM "share"
 
-#define ERR_MEM(mem_type)  do { \
-				LM_ERR("No more %s memory\n",mem_type); \
-				goto error; \
-			} while(0)
+#define ERR_MEM(mem_type)                        \
+	do {                                         \
+		LM_ERR("No more %s memory\n", mem_type); \
+		goto error;                              \
+	} while(0)
 
-#define CONT_COPY(buf, dest, source)\
-	do{ \
-		dest.s= (char*)buf+ size; \
+#define CONT_COPY(buf, dest, source)          \
+	do {                                      \
+		dest.s = (char *)buf + size;          \
 		memcpy(dest.s, source.s, source.len); \
-		dest.len= source.len; \
-		size+= source.len; \
+		dest.len = source.len;                \
+		size += source.len;                   \
 	} while(0)
 
-#define PKG_MEM_TYPE     1<< 1
-#define SHM_MEM_TYPE     1<< 2
+#define PKG_MEM_TYPE 1 << 1
+#define SHM_MEM_TYPE 1 << 2
 
 /* subscribe hash entry */
 struct subscription;
 
 typedef struct subs_entry
 {
-	struct subscription* entries;
+	struct subscription *entries;
 	gen_lock_t lock;
-}subs_entry_t;	
+} subs_entry_t;
 
-typedef subs_entry_t* shtable_t;
+typedef subs_entry_t *shtable_t;
 
 shtable_t new_shtable(int hash_size);
 
-struct subscription* search_shtable(shtable_t htable, str callid,str to_tag,str from_tag,
-		unsigned int hash_code);
+struct subscription *search_shtable(shtable_t htable, str callid, str to_tag,
+		str from_tag, unsigned int hash_code);
 
-int insert_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs);
+int insert_shtable(
+		shtable_t htable, unsigned int hash_code, struct subscription *subs);
 
-int delete_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs);
+int delete_shtable(
+		shtable_t htable, unsigned int hash_code, struct subscription *subs);
 
-int update_shtable(shtable_t htable, unsigned int hash_code, struct subscription* subs,
-		int type);
+int update_shtable(shtable_t htable, unsigned int hash_code,
+		struct subscription *subs, int type);
 
-struct subscription* mem_copy_subs(struct subscription* s, int mem_type);
+struct subscription *mem_copy_subs(struct subscription *s, int mem_type);
 
-void free_subs_list(struct subscription* s_array, int mem_type, int ic);
+void free_subs_list(struct subscription *s_array, int mem_type, int ic);
 
 void destroy_shtable(shtable_t htable, int hash_size);
 
 /* subs htable functions type definitions */
 typedef shtable_t (*new_shtable_t)(int hash_size);
 
-typedef struct subscription* (*search_shtable_t)(shtable_t htable, str callid,str to_tag,
-		str from_tag, unsigned int hash_code);
+typedef struct subscription *(*search_shtable_t)(shtable_t htable, str callid,
+		str to_tag, str from_tag, unsigned int hash_code);
 
-typedef int (*insert_shtable_t)(shtable_t htable, unsigned int hash_code,
-		struct subscription* subs);
+typedef int (*insert_shtable_t)(
+		shtable_t htable, unsigned int hash_code, struct subscription *subs);
 
-typedef int (*delete_shtable_t)(shtable_t htable, unsigned int hash_code,
-		struct subscription* subs);
+typedef int (*delete_shtable_t)(
+		shtable_t htable, unsigned int hash_code, struct subscription *subs);
 
 typedef int (*update_shtable_t)(shtable_t htable, unsigned int hash_code,
-		struct subscription* subs, int type);
+		struct subscription *subs, int type);
 
 typedef void (*destroy_shtable_t)(shtable_t htable, int hash_size);
 
-typedef struct subscription* (*mem_copy_subs_t)(struct subscription* s, int mem_type);
+typedef struct subscription *(*mem_copy_subs_t)(
+		struct subscription *s, int mem_type);
 
 
 /* presentity hash table */
@@ -111,27 +114,26 @@ typedef struct pres_entry
 	str pres_uri;
 	int event;
 	int publ_count;
-	char* sphere;
-	struct pres_entry* next;
-}pres_entry_t;
+	char *sphere;
+	struct pres_entry *next;
+} pres_entry_t;
 
 typedef struct pres_htable
 {
-	pres_entry_t* entries;
+	pres_entry_t *entries;
 	gen_lock_t lock;
-}phtable_t;
+} phtable_t;
 
-phtable_t* new_phtable(void);
+phtable_t *new_phtable(void);
 
-pres_entry_t* search_phtable(str* pres_uri, int event, unsigned int hash_code);
+pres_entry_t *search_phtable(str *pres_uri, int event, unsigned int hash_code);
 
-int insert_phtable(str* pres_uri, int event, char* sphere);
+int insert_phtable(str *pres_uri, int event, char *sphere);
 
-int update_phtable(struct presentity* presentity, str pres_uri, str body);
+int update_phtable(struct presentity *presentity, str pres_uri, str body);
 
-int delete_phtable(str* pres_uri, int event);
+int delete_phtable(str *pres_uri, int event);
 
 void destroy_phtable(void);
 
 #endif
-

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 264 - 296
src/modules/presence/notify.c


+ 18 - 16
src/modules/presence/notify.h

@@ -35,8 +35,8 @@
 #ifndef NOTIFY_H
 #define NOTIFY_H
 
-#define FULL_STATE_FLAG (1<<0)
-#define PARTIAL_STATE_FLAG (1<<1)
+#define FULL_STATE_FLAG (1 << 0)
+#define PARTIAL_STATE_FLAG (1 << 1)
 
 #define PRES_LEN 8
 #define PWINFO_LEN 14
@@ -52,17 +52,17 @@ typedef struct watcher
 	str display_name;
 	str expiration;
 	str duration_subscribed;
-	struct watcher* next;
-}watcher_t;
+	struct watcher *next;
+} watcher_t;
 
 typedef struct wid_cback
 {
 	str pres_uri;
 	str ev_name;
-	str to_tag;   /* to identify the exact record */
+	str to_tag; /* to identify the exact record */
 	str from_tag;
 	str callid;
-}c_back_param;
+} c_back_param;
 
 extern str str_to_user_col;
 extern str str_username_col;
@@ -103,26 +103,28 @@ extern str str_user_agent_col;
 
 extern int goto_on_notify_reply;
 int pv_parse_notify_reply_var_name(pv_spec_p sp, str *in);
-int pv_get_notify_reply(struct sip_msg *msg,  pv_param_t *param, pv_value_t *res);
+int pv_get_notify_reply(
+		struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 
-void PRINT_DLG(FILE* out, dlg_t* _d);
+void PRINT_DLG(FILE *out, dlg_t *_d);
 
-void printf_subs(subs_t* subs);
+void printf_subs(subs_t *subs);
 
-int query_db_notify(str* pres_uri,pres_ev_t* event, subs_t* watcher_subs );
+int query_db_notify(str *pres_uri, pres_ev_t *event, subs_t *watcher_subs);
 
-int publ_notify(presentity_t* p, str pres_uri, str* body, str* offline_etag,
-		str* rules_doc);
+int publ_notify(presentity_t *p, str pres_uri, str *body, str *offline_etag,
+		str *rules_doc);
 int publ_notify_notifier(str pres_uri, pres_ev_t *event);
 int set_updated(subs_t *sub);
 int set_wipeer_subs_updated(str *pres_uri, pres_ev_t *event, int full);
 
-int notify(subs_t* subs, subs_t* watcher_subs, str* n_body,int force_null_body, aux_body_processing_t* aux_body_processing);
+int notify(subs_t *subs, subs_t *watcher_subs, str *n_body, int force_null_body,
+		aux_body_processing_t *aux_body_processing);
 
-int send_notify_request(subs_t* subs, subs_t * watcher_subs,
-		str* n_body,int force_null_body);
+int send_notify_request(
+		subs_t *subs, subs_t *watcher_subs, str *n_body, int force_null_body);
 
-char* get_status_str(int flag);
+char *get_status_str(int flag);
 
 str *get_p_notify_body(str pres_uri, pres_ev_t *event, str *etag, str *contact);
 void free_notify_body(str *body, pres_ev_t *ev);

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 309 - 350
src/modules/presence/presence.c


+ 13 - 12
src/modules/presence/presence.h

@@ -41,16 +41,16 @@
 /* DB modes */
 
 /** subscriptions are stored only in memory */
-#define NO_DB            0
+#define NO_DB 0
 /** subscriptions are written in memory and in DB synchronously and read only from memory */
-#define WRITE_THROUGH    1
+#define WRITE_THROUGH 1
 /** subscriptions are stored in memory and periodically updated in DB */
-#define WRITE_BACK       2
+#define WRITE_BACK 2
 /** subscriptions are stored only in database */
-#define DB_ONLY          3
+#define DB_ONLY 3
 
-#define NO_UPDATE_TYPE	-1
-#define UPDATED_TYPE	1
+#define NO_UPDATE_TYPE -1
+#define UPDATED_TYPE 1
 
 /** TM bind */
 extern struct tm_binds tmb;
@@ -59,7 +59,7 @@ extern sl_api_t slb;
 
 /* DB module bind */
 extern db_func_t pa_dbf;
-extern db1_con_t* pa_db;
+extern db1_con_t *pa_db;
 
 /* PRESENCE database */
 extern str pres_db_url;
@@ -98,20 +98,21 @@ extern str pres_retrieve_order_by;
 extern int pres_enable_dmq;
 
 extern int phtable_size;
-extern phtable_t* pres_htable;
+extern phtable_t *pres_htable;
 
 extern sruid_t pres_sruid;
 
 extern db_locking_t db_table_lock;
 
-int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc);
-int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri);
+int update_watchers_status(str pres_uri, pres_ev_t *ev, str *rules_doc);
+int pres_auth_status(struct sip_msg *msg, str watcher_uri, str presentity_uri);
 int _api_pres_refresh_watchers(str *pres, str *event, int type);
 
-typedef int (*sip_uri_match_f) (str* s1, str* s2);
+typedef int (*sip_uri_match_f)(str *s1, str *s2);
 extern sip_uri_match_f presence_sip_uri_match;
 
-int pv_get_subscription(struct sip_msg *msg, pv_param_t *param,	pv_value_t *res);
+int pv_get_subscription(
+		struct sip_msg *msg, pv_param_t *param, pv_value_t *res);
 int pv_parse_subscription_name(pv_spec_p sp, str *in);
 
 #endif /* PA_MOD_H */

+ 3 - 2
src/modules/presence/presence_dmq.c

@@ -306,9 +306,10 @@ int pres_dmq_handle_msg(
 
 	switch(action) {
 		case PRES_DMQ_UPDATE_PRESENTITY:
-			if(presentity==NULL
+			if(presentity == NULL
 					|| update_presentity(NULL, presentity, &p_body, t_new,
-							&sent_reply, sphere, &cur_etag, &ruid, 0) < 0) {
+							   &sent_reply, sphere, &cur_etag, &ruid, 0)
+							   < 0) {
 				goto error;
 			}
 			break;

+ 9 - 8
src/modules/presence/presence_dmq.h

@@ -30,20 +30,21 @@
 #include "../../core/parser/parse_content.h"
 
 extern dmq_api_t pres_dmqb;
-extern dmq_peer_t* pres_dmq_peer;
+extern dmq_peer_t *pres_dmq_peer;
 extern dmq_resp_cback_t pres_dmq_resp_callback;
 
-typedef enum {
+typedef enum
+{
 	PRES_DMQ_NONE,
 	PRES_DMQ_UPDATE_PRESENTITY,
 	PRES_DMQ_SYNC,
 } pres_dmq_action_t;
 
 int pres_dmq_initialize();
-int pres_dmq_handle_msg(struct sip_msg* msg, peer_reponse_t* resp,
-		dmq_node_t* node);
-int pres_dmq_replicate_presentity(presentity_t* presentity, str* body, int new_t, 
-		str* cur_etag, char* sphere, str* ruid, dmq_node_t* node);
-int pres_dmq_resp_callback_f(struct sip_msg* msg, int code, dmq_node_t* node,
-		void* param);
+int pres_dmq_handle_msg(
+		struct sip_msg *msg, peer_reponse_t *resp, dmq_node_t *node);
+int pres_dmq_replicate_presentity(presentity_t *presentity, str *body,
+		int new_t, str *cur_etag, char *sphere, str *ruid, dmq_node_t *node);
+int pres_dmq_resp_callback_f(
+		struct sip_msg *msg, int code, dmq_node_t *node, void *param);
 #endif

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 266 - 310
src/modules/presence/presentity.c


+ 12 - 12
src/modules/presence/presentity.h

@@ -30,7 +30,7 @@
 #define PRESENTITY_H
 
 #include "../../core/str.h"
-#include "../../core/parser/msg_parser.h" 
+#include "../../core/parser/msg_parser.h"
 #include "event_list.h"
 
 extern char prefix;
@@ -40,21 +40,22 @@ typedef struct presentity
 	int presid;
 	str user;
 	str domain;
-	pres_ev_t* event;
+	pres_ev_t *event;
 	str etag;
-	str* sender;
+	str *sender;
 	time_t expires;
 	time_t received_time;
 	unsigned int priority;
 } presentity_t;
 
 /* create new presentity */
-presentity_t* new_presentity( str* domain,str* user,int expires, 
- 		pres_ev_t* event, str* etag, str* sender);
+presentity_t *new_presentity(str *domain, str *user, int expires,
+		pres_ev_t *event, str *etag, str *sender);
 
 /* update presentity in database */
-int update_presentity(struct sip_msg* msg,presentity_t* p,str* body,int t_new,
-		int* sent_reply, char* sphere, str* etag_override, str* ruid, int replace);
+int update_presentity(struct sip_msg *msg, presentity_t *p, str *body,
+		int t_new, int *sent_reply, char *sphere, str *etag_override, str *ruid,
+		int replace);
 
 /* update presentity in database using API */
 int _api_update_presentity(str *event, str *realm, str *user, str *etag,
@@ -63,18 +64,17 @@ int _api_update_presentity(str *event, str *realm, str *user, str *etag,
 /* free memory */
 void free_presentity(presentity_t *p);
 
-char* generate_ETag(int publ_count);
+char *generate_ETag(int publ_count);
 
 int pres_htable_restore(void);
 
-char* extract_sphere(str body);
+char *extract_sphere(str body);
 
-char* get_sphere(str* pres_uri);
-typedef char* (*pres_get_sphere_t)(str* pres_uri);
+char *get_sphere(str *pres_uri);
+typedef char *(*pres_get_sphere_t)(str *pres_uri);
 
 int mark_presentity_for_delete(presentity_t *pres, str *ruid);
 int delete_presentity(presentity_t *pres, str *ruid);
 int delete_offline_presentities(str *pres_uri, pres_ev_t *event);
 
 #endif
-

+ 176 - 244
src/modules/presence/publish.c

@@ -46,24 +46,24 @@
 #include "publish.h"
 #include "presentity.h"
 
-extern gen_lock_set_t* set;
+extern gen_lock_set_t *set;
 
 static str pu_400a_rpl = str_init("Bad request");
 static str pu_400b_rpl = str_init("Invalid request");
-static str pu_500_rpl  = str_init("Server Internal Error");
-static str pu_489_rpl  = str_init("Bad Event");
+static str pu_500_rpl = str_init("Server Internal Error");
+static str pu_489_rpl = str_init("Bad Event");
 
 struct p_modif
 {
-	presentity_t* p;
+	presentity_t *p;
 	str uri;
 };
 
-void msg_presentity_clean(unsigned int ticks,void *param)
+void msg_presentity_clean(unsigned int ticks, void *param)
 {
 	db_key_t db_keys[2], result_cols[4];
 	db_val_t db_vals[2], *values;
-	db_op_t  db_ops[2] ;
+	db_op_t db_ops[2];
 	db1_res_t *result = NULL;
 	db_row_t *rows;
 	int n_db_cols = 0, n_result_cols = 0;
@@ -74,10 +74,9 @@ void msg_presentity_clean(unsigned int ticks,void *param)
 	static str query_str;
 
 	LM_DBG("cleaning expired presentity information\n");
-	if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
-	{
+	if(pa_dbf.use_table(pa_db, &presentity_table) < 0) {
 		LM_ERR("in use_table\n");
-		return ;
+		return;
 	}
 
 	db_keys[n_db_cols] = &str_expires_col;
@@ -94,169 +93,141 @@ void msg_presentity_clean(unsigned int ticks,void *param)
 	db_vals[n_db_cols].val.int_val = 0;
 	n_db_cols++;
 
-	result_cols[user_col= n_result_cols++] = &str_username_col;
-	result_cols[domain_col=n_result_cols++] = &str_domain_col;
-	result_cols[etag_col=n_result_cols++] = &str_etag_col;
-	result_cols[event_col=n_result_cols++] = &str_event_col;
+	result_cols[user_col = n_result_cols++] = &str_username_col;
+	result_cols[domain_col = n_result_cols++] = &str_domain_col;
+	result_cols[etag_col = n_result_cols++] = &str_etag_col;
+	result_cols[event_col = n_result_cols++] = &str_event_col;
 
 	query_str = str_username_col;
-	if (db_fetch_query(&pa_dbf, pres_fetch_rows, pa_db, db_keys, db_ops,
-				db_vals, result_cols, n_db_cols, n_result_cols,
-				&query_str, &result) < 0)
-	{
+	if(db_fetch_query(&pa_dbf, pres_fetch_rows, pa_db, db_keys, db_ops, db_vals,
+			   result_cols, n_db_cols, n_result_cols, &query_str, &result)
+			< 0) {
 		LM_ERR("failed to query database for expired messages\n");
 		goto delete_pres;
 	}
 
-	if(result == NULL)
-	{
+	if(result == NULL) {
 		LM_ERR("bad result\n");
 		return;
 	}
 
-	LM_DBG("found n= %d expires messages\n ",result->n);
+	LM_DBG("found n= %d expires messages\n ", result->n);
 
 	do {
 		rows = RES_ROWS(result);
 
-		for(i = 0; i < RES_ROW_N(result); i++)
-		{
+		for(i = 0; i < RES_ROW_N(result); i++) {
 			values = ROW_VALUES(&rows[i]);
 			memset(&pres, 0, sizeof(presentity_t));
 
-			pres.user.s = (char *) VAL_STRING(&values[user_col]);
+			pres.user.s = (char *)VAL_STRING(&values[user_col]);
 			pres.user.len = strlen(pres.user.s);
-			pres.domain.s = (char *) VAL_STRING(&values[domain_col]);
+			pres.domain.s = (char *)VAL_STRING(&values[domain_col]);
 			pres.domain.len = strlen(pres.domain.s);
-			pres.etag.s = (char *) VAL_STRING(&values[etag_col]);
+			pres.etag.s = (char *)VAL_STRING(&values[etag_col]);
 			pres.etag.len = strlen(pres.etag.s);
-			event.s = (char *) VAL_STRING(&values[event_col]);
+			event.s = (char *)VAL_STRING(&values[event_col]);
 			event.len = strlen(event.s);
-			pres.event= contains_event(&event, NULL);
-			if(pres.event==NULL || pres.event->evp==NULL)
-			{
+			pres.event = contains_event(&event, NULL);
+			if(pres.event == NULL || pres.event->evp == NULL) {
 				LM_ERR("event not found\n");
 				goto error;
 			}
 
-			if(uandd_to_uri(pres.user, pres.domain, &uri)< 0)
-			{
+			if(uandd_to_uri(pres.user, pres.domain, &uri) < 0) {
 				LM_ERR("constructing uri\n");
 				goto error;
 			}
 
 			/* delete from hash table */
-			if(publ_cache_enabled && delete_phtable(&uri, pres.event->evp->type)< 0)
-			{
+			if(publ_cache_enabled
+					&& delete_phtable(&uri, pres.event->evp->type) < 0) {
 				LM_ERR("deleting from presentity hash table\n");
 				goto error;
 			}
 
 			LM_DBG("found expired publish for [user]=%.*s  [domanin]=%.*s\n",
-				pres.user.len,pres.user.s, pres.domain.len, pres.domain.s);
+					pres.user.len, pres.user.s, pres.domain.len, pres.domain.s);
 
-			if (pres_force_delete == 1)
-			{
-				if (delete_presentity(&pres, NULL) < 0)
-				{
+			if(pres_force_delete == 1) {
+				if(delete_presentity(&pres, NULL) < 0) {
 					LM_ERR("Deleting presentity\n");
 					goto error;
 				}
-			}
-			else if (pres_notifier_processes > 0)
-			{
-				if (pa_dbf.start_transaction)
-				{
-					if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0)
-					{
+			} else if(pres_notifier_processes > 0) {
+				if(pa_dbf.start_transaction) {
+					if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
 						LM_ERR("in start_transaction\n");
 						goto error;
 					}
 				}
-				if ((num_watchers = publ_notify_notifier(uri, pres.event)) < 0)
-				{
+				if((num_watchers = publ_notify_notifier(uri, pres.event)) < 0) {
 					LM_ERR("Updating watcher records\n");
-					if (pa_dbf.abort_transaction)
-					{
-						if (pa_dbf.abort_transaction(pa_db) < 0)
+					if(pa_dbf.abort_transaction) {
+						if(pa_dbf.abort_transaction(pa_db) < 0)
 							LM_ERR("in abort_transaction\n");
 					}
 					goto error;
 				}
 
-				if (num_watchers > 0)
-				{
-					if (mark_presentity_for_delete(&pres, NULL) < 0)
-					{
+				if(num_watchers > 0) {
+					if(mark_presentity_for_delete(&pres, NULL) < 0) {
 						LM_ERR("Marking presentity\n");
-						if (pa_dbf.abort_transaction)
-						{
-							if (pa_dbf.abort_transaction(pa_db) < 0)
+						if(pa_dbf.abort_transaction) {
+							if(pa_dbf.abort_transaction(pa_db) < 0)
 								LM_ERR("in abort_transaction\n");
 						}
 						goto error;
 					}
-				}
-				else
-				{
-					if (delete_presentity(&pres, NULL) < 0)
-					{
+				} else {
+					if(delete_presentity(&pres, NULL) < 0) {
 						LM_ERR("Deleting presentity\n");
 						goto error;
 					}
 				}
-				if (pa_dbf.end_transaction)
-				{
-					if (pa_dbf.end_transaction(pa_db) < 0)
-					{
+				if(pa_dbf.end_transaction) {
+					if(pa_dbf.end_transaction(pa_db) < 0) {
 						LM_ERR("in end_transaction\n");
 						goto error;
 					}
 				}
-			}
-			else
-			{
-				if(pres.event->get_rules_doc &&
-					pres.event->get_rules_doc(&pres.user,
-									&pres.domain,
-									&rules_doc)< 0)
-				{
+			} else {
+				if(pres.event->get_rules_doc
+						&& pres.event->get_rules_doc(
+								   &pres.user, &pres.domain, &rules_doc)
+								   < 0) {
 					LM_ERR("getting rules doc\n");
 					goto error;
 				}
-				if(publ_notify(&pres, uri, NULL, &pres.etag, rules_doc)< 0)
-				{
+				if(publ_notify(&pres, uri, NULL, &pres.etag, rules_doc) < 0) {
 					LM_ERR("sending Notify request\n");
 					goto error;
 				}
-				if(rules_doc)
-				{
+				if(rules_doc) {
 					if(rules_doc->s)
 						pkg_free(rules_doc->s);
 					pkg_free(rules_doc);
-					rules_doc= NULL;
+					rules_doc = NULL;
 				}
 			}
 
 			pkg_free(uri.s);
 			uri.s = NULL;
 		}
-	} while (db_fetch_next(&pa_dbf, pres_fetch_rows, pa_db, &result) == 1
+	} while(db_fetch_next(&pa_dbf, pres_fetch_rows, pa_db, &result) == 1
 			&& RES_ROW_N(result) > 0);
 
 	pa_dbf.free_result(pa_db, result);
 	result = NULL;
 
-	if (pa_dbf.use_table(pa_db, &presentity_table) < 0)
-	{
+	if(pa_dbf.use_table(pa_db, &presentity_table) < 0) {
 		LM_ERR("in use_table\n");
 		goto error;
 	}
 
-	if (pres_notifier_processes == 0)
-	{
-delete_pres:
-		if (pa_dbf.delete(pa_db, db_keys, db_ops, db_vals, n_db_cols) < 0)
+	if(pres_notifier_processes == 0) {
+	delete_pres:
+		if(pa_dbf.delete(pa_db, db_keys, db_ops, db_vals, n_db_cols) < 0)
 			LM_ERR("failed to delete expired records from DB\n");
 	}
 
@@ -265,9 +236,9 @@ delete_pres:
 error:
 	if(result)
 		pa_dbf.free_result(pa_db, result);
-	if(uri.s) pkg_free(uri.s);
-	if(rules_doc)
-	{
+	if(uri.s)
+		pkg_free(uri.s);
+	if(rules_doc) {
 		if(rules_doc->s)
 			pkg_free(rules_doc->s);
 		pkg_free(rules_doc);
@@ -280,203 +251,171 @@ error:
  * PUBLISH request handling
  *
  */
-int ki_handle_publish_uri(struct sip_msg* msg, str* sender_uri)
+int ki_handle_publish_uri(struct sip_msg *msg, str *sender_uri)
 {
 	struct sip_uri puri;
 	str body;
 	int lexpire;
-	presentity_t* presentity = 0;
-	struct hdr_field* hdr;
-	int found= 0, etag_gen = 0;
-	str etag={0, 0};
-	str* sender= NULL;
+	presentity_t *presentity = 0;
+	struct hdr_field *hdr;
+	int found = 0, etag_gen = 0;
+	str etag = {0, 0};
+	str *sender = NULL;
 	static char buf[256];
-	int buf_len= 255;
-	pres_ev_t* event= NULL;
+	int buf_len = 255;
+	pres_ev_t *event = NULL;
 	str pres_user;
 	str pres_domain;
 	int reply_code;
 	str reply_str;
-	int sent_reply= 0;
-	char* sphere= NULL;
+	int sent_reply = 0;
+	char *sphere = NULL;
 
-	reply_code= 500;
-	reply_str= pu_500_rpl;
+	reply_code = 500;
+	reply_str = pu_500_rpl;
 
 	counter++;
-	if ( parse_headers(msg,HDR_EOH_F, 0)==-1 )
-	{
+	if(parse_headers(msg, HDR_EOH_F, 0) == -1) {
 		LM_ERR("parsing headers\n");
-		reply_code= 400;
-		reply_str= pu_400a_rpl;
+		reply_code = 400;
+		reply_str = pu_400a_rpl;
 		goto error;
 	}
 	memset(&body, 0, sizeof(str));
 
 	/* inspecting the Event header field */
 
-	if(msg->event && msg->event->body.len > 0)
-	{
-		if (!msg->event->parsed && (parse_event(msg->event) < 0))
-		{
+	if(msg->event && msg->event->body.len > 0) {
+		if(!msg->event->parsed && (parse_event(msg->event) < 0)) {
 			LM_ERR("cannot parse Event header\n");
-			reply_code= 400;
-			reply_str= pu_400a_rpl;
+			reply_code = 400;
+			reply_str = pu_400a_rpl;
 			goto error;
 		}
-	}
-	else
+	} else
 		goto unsupported_event;
 
 	/* search event in the list */
-	event= search_event((event_t*)msg->event->parsed);
-	if(event== NULL)
-	{
+	event = search_event((event_t *)msg->event->parsed);
+	if(event == NULL) {
 		goto unsupported_event;
 	}
 
 	/* examine the SIP-If-Match header field */
 	hdr = msg->headers;
-	while (hdr!= NULL)
-	{
-		if(cmp_hdrname_strzn(&hdr->name, "SIP-If-Match", 12)==0)
-		{
+	while(hdr != NULL) {
+		if(cmp_hdrname_strzn(&hdr->name, "SIP-If-Match", 12) == 0) {
 			found = 1;
 			break;
 		}
 		hdr = hdr->next;
 	}
-	if(found==0 )
-	{
+	if(found == 0) {
 		LM_DBG("SIP-If-Match header not found\n");
 		etag.s = generate_ETag(0);
-		if(etag.s == NULL)
-		{
+		if(etag.s == NULL) {
 			LM_ERR("when generating etag\n");
 			goto error;
 		}
-		etag.len=(strlen(etag.s));
-		etag_gen=1;
-		LM_DBG("new etag  = %.*s \n", etag.len,	etag.s);
-	}
-	else
-	{
+		etag.len = (strlen(etag.s));
+		etag_gen = 1;
+		LM_DBG("new etag  = %.*s \n", etag.len, etag.s);
+	} else {
 		LM_DBG("SIP-If-Match header found\n");
-		etag.s = (char*)pkg_malloc((hdr->body.len+ 1)* sizeof(char));
-		if(etag.s== NULL)
-		{
+		etag.s = (char *)pkg_malloc((hdr->body.len + 1) * sizeof(char));
+		if(etag.s == NULL) {
 			ERR_MEM(PKG_MEM_STR);
 		}
-		memcpy(etag.s, hdr->body.s, hdr->body.len );
+		memcpy(etag.s, hdr->body.s, hdr->body.len);
 		etag.len = hdr->body.len;
-		etag.s[ etag.len] = '\0';
+		etag.s[etag.len] = '\0';
 		LM_DBG("existing etag  = %.*s \n", etag.len, etag.s);
 	}
 
 	/* examine the expire header field */
-	if(msg->expires && msg->expires->body.len > 0)
-	{
-		if (!msg->expires->parsed && (parse_expires(msg->expires) < 0))
-		{
+	if(msg->expires && msg->expires->body.len > 0) {
+		if(!msg->expires->parsed && (parse_expires(msg->expires) < 0)) {
 			LM_ERR("cannot parse Expires header\n");
 			goto error;
 		}
-		lexpire = ((exp_body_t*)msg->expires->parsed)->val;
+		lexpire = ((exp_body_t *)msg->expires->parsed)->val;
 		LM_DBG("Expires header found, value= %d\n", lexpire);
 
-	}
-	else
-	{
-		LM_DBG("'expires' not found; default=%d\n",	event->default_expires);
+	} else {
+		LM_DBG("'expires' not found; default=%d\n", event->default_expires);
 		lexpire = event->default_expires;
 	}
 	if(lexpire > max_expires)
 		lexpire = max_expires;
 
 	/* get pres_uri from Request-URI*/
-	if(parse_sip_msg_uri(msg)< 0)
-	{
+	if(parse_sip_msg_uri(msg) < 0) {
 		LM_ERR("parsing Request URI\n");
-		reply_code= 400;
-		reply_str= pu_400a_rpl;
+		reply_code = 400;
+		reply_str = pu_400a_rpl;
 		goto error;
 	}
-	pres_user= msg->parsed_uri.user;
-	pres_domain= msg->parsed_uri.host;
+	pres_user = msg->parsed_uri.user;
+	pres_domain = msg->parsed_uri.host;
 
-	if (!msg->content_length)
-	{
+	if(!msg->content_length) {
 		LM_ERR("no Content-Length header found!\n");
-		reply_code= 400;
-		reply_str= pu_400a_rpl;
+		reply_code = 400;
+		reply_str = pu_400a_rpl;
 		goto error;
 	}
 
 	/* process the body */
-	if ( get_content_length(msg) == 0 )
-	{
+	if(get_content_length(msg) == 0) {
 		body.s = NULL;
-		if (etag_gen)
-		{
+		if(etag_gen) {
 			LM_ERR("No E-Tag and no body found\n");
-			reply_code= 400;
-			reply_str= pu_400b_rpl;
+			reply_code = 400;
+			reply_str = pu_400b_rpl;
 			goto error;
 		}
-	}
-	else
-	{
-		body.s=get_body(msg);
-		if (body.s== NULL)
-		{
+	} else {
+		body.s = get_body(msg);
+		if(body.s == NULL) {
 			LM_ERR("cannot extract body\n");
-			reply_code= 400;
-			reply_str= pu_400a_rpl;
+			reply_code = 400;
+			reply_str = pu_400a_rpl;
 			goto error;
 		}
-		body.len= get_content_length( msg );
+		body.len = get_content_length(msg);
 
-		if(sphere_enable && event->evp->type == EVENT_PRESENCE &&
-				get_content_type(msg)== SUBTYPE_PIDFXML)
-		{
-			sphere= extract_sphere(body);
+		if(sphere_enable && event->evp->type == EVENT_PRESENCE
+				&& get_content_type(msg) == SUBTYPE_PIDFXML) {
+			sphere = extract_sphere(body);
 		}
-
 	}
 	memset(&puri, 0, sizeof(struct sip_uri));
-	if(sender_uri)
-	{
-		sender=(str*)pkg_malloc(sizeof(str));
-		if(sender== NULL)
-		{
+	if(sender_uri) {
+		sender = (str *)pkg_malloc(sizeof(str));
+		if(sender == NULL) {
 			ERR_MEM(PKG_MEM_STR);
 		}
-		if(sender_uri->len >= buf_len-1) {
+		if(sender_uri->len >= buf_len - 1) {
 			LM_ERR("cannot use sender uri -- too long value\n");
 			goto error;
 		}
 		strncpy(buf, sender_uri->s, sender_uri->len);
 		buf_len = sender_uri->len;
 		buf[buf_len] = '\0';
-		if(parse_uri(buf, buf_len, &puri)!=0)
-		{
+		if(parse_uri(buf, buf_len, &puri) != 0) {
 			LM_ERR("bad sender SIP address!\n");
-			reply_code= 400;
-			reply_str= pu_400a_rpl;
+			reply_code = 400;
+			reply_str = pu_400a_rpl;
 			goto error;
+		} else {
+			LM_DBG("using user id [%.*s]\n", buf_len, buf);
 		}
-		else
-		{
-			LM_DBG("using user id [%.*s]\n",buf_len,buf);
-		}
-		sender->s= buf;
-		sender->len= buf_len;
+		sender->s = buf;
+		sender->len = buf_len;
 	}
 	/* call event specific handling function*/
-	if(event->evs_publ_handl)
-	{
-		if(event->evs_publ_handl(msg)< 0)
-		{
+	if(event->evs_publ_handl) {
+		if(event->evs_publ_handl(msg) < 0) {
 			LM_ERR("in event specific publish handling\n");
 			goto error;
 		}
@@ -485,17 +424,17 @@ int ki_handle_publish_uri(struct sip_msg* msg, str* sender_uri)
 	/* now we have all the necessary values */
 	/* fill in the filds of the structure */
 
-	presentity= new_presentity(&pres_domain, &pres_user, lexpire, event,
-			&etag, sender);
-	if(presentity== NULL)
-	{
+	presentity = new_presentity(
+			&pres_domain, &pres_user, lexpire, event, &etag, sender);
+	if(presentity == NULL) {
 		LM_ERR("creating presentity structure\n");
 		goto error;
 	}
 
 	/* querry the database and update or insert */
-	if(update_presentity(msg, presentity, &body, etag_gen, &sent_reply, sphere, NULL, NULL, 0) <0)
-	{
+	if(update_presentity(msg, presentity, &body, etag_gen, &sent_reply, sphere,
+			   NULL, NULL, 0)
+			< 0) {
 		LM_ERR("when updating presentity\n");
 		goto error;
 	}
@@ -515,17 +454,15 @@ unsupported_event:
 
 	LM_WARN("Missing or unsupported event header field value\n");
 
-	if(msg->event && msg->event->body.s && msg->event->body.len>0)
+	if(msg->event && msg->event->body.s && msg->event->body.len > 0)
 		LM_ERR("    event=[%.*s]\n", msg->event->body.len, msg->event->body.s);
 
-	reply_code= BAD_EVENT_CODE;
-	reply_str=	pu_489_rpl;
+	reply_code = BAD_EVENT_CODE;
+	reply_str = pu_489_rpl;
 
 error:
-	if(sent_reply== 0)
-	{
-		if(send_error_reply(msg, reply_code, reply_str)< 0)
-		{
+	if(sent_reply == 0) {
+		if(send_error_reply(msg, reply_code, reply_str) < 0) {
 			LM_ERR("failed to send error reply\n");
 		}
 	}
@@ -540,10 +477,9 @@ error:
 		pkg_free(sphere);
 
 	return -1;
-
 }
 
-int ki_handle_publish(struct sip_msg* msg)
+int ki_handle_publish(struct sip_msg *msg)
 {
 	return ki_handle_publish_uri(msg, NULL);
 }
@@ -552,20 +488,21 @@ int ki_handle_publish(struct sip_msg* msg)
  * PUBLISH request handling
  *
  */
-int w_handle_publish(struct sip_msg* msg, char* sender_uri, char* str2)
+int w_handle_publish(struct sip_msg *msg, char *sender_uri, char *str2)
 {
 	str suri;
 
-	if (sender_uri!=NULL
-			&& fixup_get_svalue(msg, (gparam_t*)sender_uri, &suri) != 0) {
+	if(sender_uri != NULL
+			&& fixup_get_svalue(msg, (gparam_t *)sender_uri, &suri) != 0) {
 		LM_ERR("invalid uri parameter\n");
 		return -1;
 	}
 
-	return ki_handle_publish_uri(msg, (sender_uri)?&suri:NULL);
+	return ki_handle_publish_uri(msg, (sender_uri) ? &suri : NULL);
 }
 
-int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *filename)
+int update_hard_presentity(
+		str *pres_uri, pres_ev_t *event, str *file_uri, str *filename)
 {
 	int ret = -1, new_t, pidf_result;
 	str *pidf_doc = 0;
@@ -573,42 +510,37 @@ int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *
 	presentity_t *pres = NULL;
 	struct sip_uri parsed_uri;
 
-	LM_INFO("Hard-state file %.*s (uri %.*s) updated for %.*s\n",
-		filename->len, filename->s,
-		file_uri->len, file_uri->s,
-		pres_uri->len, pres_uri->s);
+	LM_INFO("Hard-state file %.*s (uri %.*s) updated for %.*s\n", filename->len,
+			filename->s, file_uri->len, file_uri->s, pres_uri->len,
+			pres_uri->s);
 
-	if (!event->get_pidf_doc)
-	{
-		LM_WARN("pidf-manipulation not supported for %.*s\n", event->name.len, event->name.s);
+	if(!event->get_pidf_doc) {
+		LM_WARN("pidf-manipulation not supported for %.*s\n", event->name.len,
+				event->name.s);
 		return -1;
 	}
 
-	if (parse_uri(pres_uri->s, pres_uri->len, &parsed_uri) < 0)
-	{
+	if(parse_uri(pres_uri->s, pres_uri->len, &parsed_uri) < 0) {
 		LM_ERR("bad presentity URI\n");
 		return -1;
 	}
 
-	pidf_result = event->get_pidf_doc(&parsed_uri.user, &parsed_uri.host, file_uri, &pidf_doc);
+	pidf_result = event->get_pidf_doc(
+			&parsed_uri.user, &parsed_uri.host, file_uri, &pidf_doc);
 
-	if (pidf_result < 0)
-	{
+	if(pidf_result < 0) {
 		LM_ERR("retrieving pidf-manipulation document\n");
 		return -1;
-	}
-	else if (pidf_result > 0)
-	{
+	} else if(pidf_result > 0) {
 		/* Insert/replace presentity... */
 		LM_DBG("INSERT/REPLACE\n");
 		xmlDocPtr doc;
 
-		if (sphere_enable)
+		if(sphere_enable)
 			sphere = extract_sphere(*pidf_doc);
 
 		doc = xmlParseMemory(pidf_doc->s, pidf_doc->len);
-		if (doc == NULL)
-		{
+		if(doc == NULL) {
 			LM_ERR("bad body format\n");
 			xmlFreeDoc(doc);
 			xmlCleanupParser();
@@ -620,23 +552,22 @@ int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *
 		xmlMemoryDump();
 
 		new_t = 1;
-	}
-	else
-	{
+	} else {
 		/* Delete presentity... */
 		LM_DBG("DELETE\n");
 		new_t = 0;
 	}
 
-	pres = new_presentity(&parsed_uri.host, &parsed_uri.user, -1, event, filename, NULL);
-	if (pres == NULL)
-	{
+	pres = new_presentity(
+			&parsed_uri.host, &parsed_uri.user, -1, event, filename, NULL);
+	if(pres == NULL) {
 		LM_ERR("creating presentity structure\n");
 		goto done;
 	}
 
-	if (update_presentity(NULL, pres, pidf_doc, new_t, NULL, sphere, NULL, NULL, 0) < 0)
-	{
+	if(update_presentity(
+			   NULL, pres, pidf_doc, new_t, NULL, sphere, NULL, NULL, 0)
+			< 0) {
 		LM_ERR("updating presentity\n");
 		goto done;
 	}
@@ -644,10 +575,11 @@ int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *
 	ret = 1;
 
 done:
-	if (pres) pkg_free(pres);
-	if (sphere) pkg_free(sphere);
-	if(pidf_doc)
-	{
+	if(pres)
+		pkg_free(pres);
+	if(sphere)
+		pkg_free(sphere);
+	if(pidf_doc) {
 		if(pidf_doc->s)
 			pkg_free(pidf_doc->s);
 		pkg_free(pidf_doc);

+ 6 - 5
src/modules/presence/publish.h

@@ -42,11 +42,12 @@
 #include "presentity.h"
 #include "../alias_db/alias_db.h"
 
-void msg_presentity_clean(unsigned int ticks,void *param);
+void msg_presentity_clean(unsigned int ticks, void *param);
 
-int w_handle_publish(struct sip_msg* msg, char* str1, char* str2);
-int ki_handle_publish(sip_msg_t* msg);
-int ki_handle_publish_uri(sip_msg_t* msg, str* suri);
-int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *filename);
+int w_handle_publish(struct sip_msg *msg, char *str1, char *str2);
+int ki_handle_publish(sip_msg_t *msg);
+int ki_handle_publish_uri(sip_msg_t *msg, str *suri);
+int update_hard_presentity(
+		str *pres_uri, pres_ev_t *event, str *file_uri, str *filename);
 
 #endif

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 244 - 291
src/modules/presence/subscribe.c


+ 37 - 36
src/modules/presence/subscribe.h

@@ -38,18 +38,18 @@ struct pres_ev;
 #include "event_list.h"
 #include "hash.h"
 
-#define ACTIVE_STATUS        1
-#define PENDING_STATUS       2
-#define TERMINATED_STATUS    3
-#define WAITING_STATUS       4
+#define ACTIVE_STATUS 1
+#define PENDING_STATUS 2
+#define TERMINATED_STATUS 3
+#define WAITING_STATUS 4
 /* Additional value returned from pres_auth_status when the status is ACTIVE
  * and reason is polite-block */
-#define POLITE_BLOCK_STATUS  5
+#define POLITE_BLOCK_STATUS 5
 
-#define PRES_SUBSCRIBE_RECV		1
+#define PRES_SUBSCRIBE_RECV 1
 
-#define INTERNAL_UPDATE_FALSE	0
-#define INTERNAL_UPDATE_TRUE	1
+#define INTERNAL_UPDATE_FALSE 0
+#define INTERNAL_UPDATE_TRUE 1
 
 struct subscription
 {
@@ -60,7 +60,7 @@ struct subscription
 	str from_domain;
 	str watcher_user;
 	str watcher_domain;
-	struct pres_ev* event;
+	struct pres_ev *event;
 	str event_id;
 	str to_tag;
 	str from_tag;
@@ -77,52 +77,53 @@ struct subscription
 	int version;
 	int send_on_cback;
 	int db_flag;
-	str* auth_rules_doc;
+	str *auth_rules_doc;
 	int recv_event;
 	int internal_update_flag;
 	int updated;
 	int updated_winfo;
 	flag_t flags;
 	str user_agent;
-	struct subscription* next;
-
+	struct subscription *next;
 };
 typedef struct subscription subs_t;
 
-void msg_active_watchers_clean(unsigned int ticks,void *param);
+void msg_active_watchers_clean(unsigned int ticks, void *param);
 
-void msg_watchers_clean(unsigned int ticks,void *param);
+void msg_watchers_clean(unsigned int ticks, void *param);
 
-int handle_subscribe0(struct sip_msg*);
-int w_handle_subscribe0(struct sip_msg*, char*, char*);
-int w_handle_subscribe(struct sip_msg*, char *watcher_uri, char *p2);
-int w_handle_subscribe1(struct sip_msg*, char *watcher_uri);
-int handle_subscribe_uri(struct sip_msg*, str*);
-int handle_subscribe(struct sip_msg*, str watcher_user, str watcher_domain);
+int handle_subscribe0(struct sip_msg *);
+int w_handle_subscribe0(struct sip_msg *, char *, char *);
+int w_handle_subscribe(struct sip_msg *, char *watcher_uri, char *p2);
+int w_handle_subscribe1(struct sip_msg *, char *watcher_uri);
+int handle_subscribe_uri(struct sip_msg *, str *);
+int handle_subscribe(struct sip_msg *, str watcher_user, str watcher_domain);
 
-void timer_db_update(unsigned int ticks,void *param);
+void timer_db_update(unsigned int ticks, void *param);
 
-int update_subs_db(subs_t* subs, int type);
+int update_subs_db(subs_t *subs, int type);
 
 int restore_db_subs(void);
 
-typedef int (*handle_expired_func_t)(subs_t* );
+typedef int (*handle_expired_func_t)(subs_t *);
 
-void update_db_subs_timer(db1_con_t *db,db_func_t *dbf, shtable_t hash_table,
-	int htable_size, int no_lock, handle_expired_func_t handle_expired_func);
+void update_db_subs_timer(db1_con_t *db, db_func_t *dbf, shtable_t hash_table,
+		int htable_size, int no_lock,
+		handle_expired_func_t handle_expired_func);
 
-typedef void (*update_db_subs_t)(db1_con_t* ,db_func_t* ,shtable_t ,int ,int ,
-		handle_expired_func_t);
+typedef void (*update_db_subs_t)(
+		db1_con_t *, db_func_t *, shtable_t, int, int, handle_expired_func_t);
 
-int extract_sdialog_info_ex(subs_t* subs,struct sip_msg* msg, uint32_t min_expire,
-		uint32_t max_expire, int* to_tag_gen, str scontact, str watcher_user,
-		str watcher_domain, int* reply_code,str* reply_txt);
-int extract_sdialog_info(subs_t* subs,struct sip_msg* msg, int max_expire,
-		int* to_tag_gen, str scontact, str watcher_user, str watcher_domain);
-typedef int (*extract_sdialog_info_t)(subs_t* subs, struct sip_msg* msg,
-		int max_expire, int* to_tag_gen, str scontact, str watcher_user,
+int extract_sdialog_info_ex(subs_t *subs, struct sip_msg *msg,
+		uint32_t min_expire, uint32_t max_expire, int *to_tag_gen, str scontact,
+		str watcher_user, str watcher_domain, int *reply_code, str *reply_txt);
+int extract_sdialog_info(subs_t *subs, struct sip_msg *msg, int max_expire,
+		int *to_tag_gen, str scontact, str watcher_user, str watcher_domain);
+typedef int (*extract_sdialog_info_t)(subs_t *subs, struct sip_msg *msg,
+		int max_expire, int *to_tag_gen, str scontact, str watcher_user,
 		str watcher_domain);
-void delete_subs(str* pres_uri, str* ev_name, str* to_tag, str* from_tag, str* callid);
-int get_subscribers_count(struct sip_msg* msg, str pres_uri, str event);
+void delete_subs(
+		str *pres_uri, str *ev_name, str *to_tag, str *from_tag, str *callid);
+int get_subscribers_count(struct sip_msg *msg, str pres_uri, str event);
 
 #endif

+ 52 - 65
src/modules/presence/utils_func.c

@@ -41,12 +41,11 @@
 
 
 static const char base64digits[] =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+		"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
 {
-	for (; inlen >= 3; inlen -= 3)
-	{
+	for(; inlen >= 3; inlen -= 3) {
 		*out++ = base64digits[in[0] >> 2];
 		*out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
 		*out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
@@ -54,100 +53,88 @@ void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
 		in += 3;
 	}
 
-	if (inlen > 0)
-	{
+	if(inlen > 0) {
 		unsigned char fragment;
 
 		*out++ = base64digits[in[0] >> 2];
 		fragment = (in[0] << 4) & 0x30;
 
-		if (inlen > 1)
+		if(inlen > 1)
 			fragment |= in[1] >> 4;
 
 		*out++ = base64digits[fragment];
 		*out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
 		*out++ = '=';
 	}
-		*out = '\0';
-		
+	*out = '\0';
 }
 
-int a_to_i (char *s,int len)
+int a_to_i(char *s, int len)
 {
-	int n = 0, i= 0;
-	
-	while( i<len  )		
-		n=n*10+( s[i++] -'0');
-	
+	int n = 0, i = 0;
+
+	while(i < len)
+		n = n * 10 + (s[i++] - '0');
+
 	return n;
 }
 
-int send_error_reply(struct sip_msg* msg, int reply_code, str reply_str)
+int send_error_reply(struct sip_msg *msg, int reply_code, str reply_str)
 {
-    str hdr_append;
-    char buffer[256];
-    int i;
-    pres_ev_t* ev= EvList->events;
+	str hdr_append;
+	char buffer[256];
+	int i;
+	pres_ev_t *ev = EvList->events;
 
-    if(reply_code== BAD_EVENT_CODE)
-	{
+	if(reply_code == BAD_EVENT_CODE) {
 		hdr_append.s = buffer;
-		hdr_append.s[0]='\0';
+		hdr_append.s[0] = '\0';
 		hdr_append.len = sprintf(hdr_append.s, "Allow-Events: ");
-		if(hdr_append.len < 0)
-		{
+		if(hdr_append.len < 0) {
 			LM_ERR("unsuccessful sprintf\n");
 			return -1;
 		}
 
-		for(i= 0; i< EvList->ev_count; i++)
-		{
-			if(i> 0)
-			{
-				memcpy(hdr_append.s+ hdr_append.len, ", ", 2);
-				hdr_append.len+= 2;
-			}	
-			memcpy(hdr_append.s+ hdr_append.len, ev->name.s, ev->name.len );
-			hdr_append.len+= ev->name.len ;
-			ev= ev->next;
+		for(i = 0; i < EvList->ev_count; i++) {
+			if(i > 0) {
+				memcpy(hdr_append.s + hdr_append.len, ", ", 2);
+				hdr_append.len += 2;
+			}
+			memcpy(hdr_append.s + hdr_append.len, ev->name.s, ev->name.len);
+			hdr_append.len += ev->name.len;
+			ev = ev->next;
+		}
+		memcpy(hdr_append.s + hdr_append.len, CRLF, CRLF_LEN);
+		hdr_append.len += CRLF_LEN;
+		hdr_append.s[hdr_append.len] = '\0';
+
+		if(add_lump_rpl(msg, hdr_append.s, hdr_append.len, LUMP_RPL_HDR) == 0) {
+			LM_ERR("unable to add lump_rl\n");
+			return -1;
+		}
+	} else if(reply_code == INTERVAL_TOO_BRIEF) {
+
+		hdr_append.s = buffer;
+		hdr_append.s[0] = '\0';
+		hdr_append.len = sprintf(hdr_append.s, "Min-Expires: %d", min_expires);
+		if(hdr_append.len < 0) {
+			LM_ERR("unsuccessful sprintf\n");
+			return -1;
 		}
-		memcpy(hdr_append.s+ hdr_append.len, CRLF, CRLF_LEN);
-		hdr_append.len+=  CRLF_LEN;
-		hdr_append.s[hdr_append.len]= '\0';
-		
-		if (add_lump_rpl( msg, hdr_append.s, hdr_append.len, LUMP_RPL_HDR)==0 )
-		{
+		memcpy(hdr_append.s + hdr_append.len, CRLF, CRLF_LEN);
+		hdr_append.len += CRLF_LEN;
+		hdr_append.s[hdr_append.len] = '\0';
+
+		if(add_lump_rpl(msg, hdr_append.s, hdr_append.len, LUMP_RPL_HDR) == 0) {
 			LM_ERR("unable to add lump_rl\n");
 			return -1;
 		}
-    } else if(reply_code== INTERVAL_TOO_BRIEF) {
-        
-        hdr_append.s = buffer;
-        hdr_append.s[0]='\0';
-        hdr_append.len = sprintf(hdr_append.s, "Min-Expires: %d", min_expires);
-        if(hdr_append.len < 0)
-        {
-            LM_ERR("unsuccessful sprintf\n");
-            return -1;
-        }
-        memcpy(hdr_append.s+ hdr_append.len, CRLF, CRLF_LEN);
-        hdr_append.len+=  CRLF_LEN;
-        hdr_append.s[hdr_append.len]= '\0';
-        
-        if (add_lump_rpl( msg, hdr_append.s, hdr_append.len, LUMP_RPL_HDR)==0 )
-        {
-            LM_ERR("unable to add lump_rl\n");
-            return -1;
-        }
-    }
-
-	if (slb.freply(msg, reply_code, &reply_str) < 0)
-	{
+	}
+
+	if(slb.freply(msg, reply_code, &reply_str) < 0) {
 		LM_ERR("sending %d %.*s reply\n", reply_code, reply_str.len,
 				reply_str.s);
 		return -1;
 	}
 	return 0;
-
 }
-

+ 38 - 51
src/modules/presence/utils_func.h

@@ -28,7 +28,6 @@
  */
 
 
-
 #ifndef UTILS_FUNC_H
 #define UTILS_FUNC_H
 #include <stdio.h>
@@ -45,32 +44,30 @@
 #define INTERVAL_TOO_BRIEF 423
 
 
-#define EVENT_DIALOG_SLA(ev) \
-	((ev)->type == EVENT_DIALOG \
-		&& ((ev)->params.hooks.event_dialog.sla \
-			|| (ev)->params.hooks.event_dialog.ma))
+#define EVENT_DIALOG_SLA(ev)                        \
+	((ev)->type == EVENT_DIALOG                     \
+			&& ((ev)->params.hooks.event_dialog.sla \
+					   || (ev)->params.hooks.event_dialog.ma))
 
 
-static inline int uandd_to_uri(str user,  str domain, str *out)
+static inline int uandd_to_uri(str user, str domain, str *out)
 {
 	int size;
 
-	if(out==0)
+	if(out == 0)
 		return -1;
 
-	size = user.len + domain.len+7;
-	out->s = (char*)pkg_malloc(size);
+	size = user.len + domain.len + 7;
+	out->s = (char *)pkg_malloc(size);
 
-	if(out->s == NULL)
-	{
+	if(out->s == NULL) {
 		LM_ERR("no more memory\n");
 		return -1;
 	}
-	strcpy(out->s,"sip:");
+	strcpy(out->s, "sip:");
 	out->len = 4;
-	if(user.s!=NULL && user.len>0)
-	{
-		memcpy(out->s+out->len, user.s, user.len);
+	if(user.s != NULL && user.len > 0) {
+		memcpy(out->s + out->len, user.s, user.len);
 		out->len += user.len;
 		out->s[out->len++] = '@';
 	}
@@ -81,69 +78,61 @@ static inline int uandd_to_uri(str user,  str domain, str *out)
 	return 0;
 }
 
-static inline int ps_fill_local_contact(struct sip_msg* msg, str *contact)
+static inline int ps_fill_local_contact(struct sip_msg *msg, str *contact)
 {
 	str ip;
-	char* proto;
+	char *proto;
 	int port;
 	int len;
 	int plen;
 	char *p;
 
-	contact->s= (char*)pkg_malloc(LCONTACT_BUF_SIZE);
-	if(contact->s== NULL)
-	{
+	contact->s = (char *)pkg_malloc(LCONTACT_BUF_SIZE);
+	if(contact->s == NULL) {
 		LM_ERR("No more memory\n");
 		goto error;
 	}
 
 	memset(contact->s, 0, LCONTACT_BUF_SIZE);
-	contact->len= 0;
+	contact->len = 0;
 
 	plen = 3;
-	if(msg->rcv.proto== PROTO_NONE || msg->rcv.proto==PROTO_UDP)
-		proto= "udp";
-	else
-	if(msg->rcv.proto== PROTO_TLS )
-			proto= "tls";
-	else
-	if(msg->rcv.proto== PROTO_TCP)
-		proto= "tcp";
-	else
-	if(msg->rcv.proto== PROTO_SCTP) {
-		proto= "sctp";
+	if(msg->rcv.proto == PROTO_NONE || msg->rcv.proto == PROTO_UDP)
+		proto = "udp";
+	else if(msg->rcv.proto == PROTO_TLS)
+		proto = "tls";
+	else if(msg->rcv.proto == PROTO_TCP)
+		proto = "tcp";
+	else if(msg->rcv.proto == PROTO_SCTP) {
+		proto = "sctp";
 		plen = 4;
-	}
-	else
-	if(msg->rcv.proto== PROTO_WS || msg->rcv.proto== PROTO_WSS) {
-		proto= "ws";
+	} else if(msg->rcv.proto == PROTO_WS || msg->rcv.proto == PROTO_WSS) {
+		proto = "ws";
 		plen = 2;
-	}
-	else
-	{
+	} else {
 		LM_ERR("unsupported proto\n");
 		goto error;
 	}
 
-	if(msg->rcv.bind_address->useinfo.name.len>0) {
+	if(msg->rcv.bind_address->useinfo.name.len > 0) {
 		ip = msg->rcv.bind_address->useinfo.name;
 	} else {
 		ip = msg->rcv.bind_address->address_str;
 	}
 
-	if(msg->rcv.bind_address->useinfo.port_no>0) {
+	if(msg->rcv.bind_address->useinfo.port_no > 0) {
 		port = msg->rcv.bind_address->useinfo.port_no;
 	} else {
 		port = msg->rcv.bind_address->port_no;
 	}
 
 	p = contact->s;
-	if(strncmp(ip.s, "sip:", 4)!=0) {
+	if(strncmp(ip.s, "sip:", 4) != 0) {
 		memcpy(p, "sip:", 4);
 		contact->len += 4;
 		p += 4;
 	}
-	if(msg->rcv.bind_address->address.af==AF_INET6) {
+	if(msg->rcv.bind_address->address.af == AF_INET6) {
 		*p = '[';
 		contact->len += 1;
 		p += 1;
@@ -151,7 +140,7 @@ static inline int ps_fill_local_contact(struct sip_msg* msg, str *contact)
 	strncpy(p, ip.s, ip.len);
 	contact->len += ip.len;
 	p += ip.len;
-	if(msg->rcv.bind_address->address.af==AF_INET6) {
+	if(msg->rcv.bind_address->address.af == AF_INET6) {
 		*p = ']';
 		contact->len += 1;
 		p += 1;
@@ -159,10 +148,9 @@ static inline int ps_fill_local_contact(struct sip_msg* msg, str *contact)
 	if(contact->len > LCONTACT_BUF_SIZE - 21) {
 		LM_ERR("buffer overflow\n");
 		goto error;
-
 	}
-	len= sprintf(p, ":%d;transport=" , port);
-	if(len< 0) {
+	len = sprintf(p, ":%d;transport=", port);
+	if(len < 0) {
 		LM_ERR("unsuccessful sprintf\n");
 		goto error;
 	}
@@ -173,7 +161,7 @@ static inline int ps_fill_local_contact(struct sip_msg* msg, str *contact)
 
 	return 0;
 error:
-	if(contact->s!=NULL)
+	if(contact->s != NULL)
 		pkg_free(contact->s);
 	contact->s = 0;
 	contact->len = 0;
@@ -182,11 +170,10 @@ error:
 
 //str* int_to_str(long int n);
 
-int a_to_i (char *s,int len);
+int a_to_i(char *s, int len);
 
 void to64frombits(unsigned char *out, const unsigned char *in, int inlen);
 
-int send_error_reply(struct sip_msg* msg, int reply_code, str reply_str);
+int send_error_reply(struct sip_msg *msg, int reply_code, str reply_str);
 
 #endif
-

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.