Ported PJSIP and PJSIP-SIMPLE to Symbian

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1241 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index 56fa8ea..326afa8 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -51,13 +51,13 @@
 
 const pjsip_method pjsip_subscribe_method = 
 {
-    PJSIP_SUBSCRIBE_METHOD,
+    (pjsip_method_e) PJSIP_SUBSCRIBE_METHOD,
     { "SUBSCRIBE", 9 }
 };
 
 const pjsip_method pjsip_notify_method = 
 {
-    PJSIP_NOTIFY_METHOD,
+    (pjsip_method_e) PJSIP_NOTIFY_METHOD,
     { "NOTIFY", 6 }
 };
 
@@ -327,7 +327,7 @@
  */
 PJ_DEF(pjsip_evsub*) pjsip_tsx_get_evsub(pjsip_transaction *tsx)
 {
-    return tsx->mod_data[mod_evsub.mod.id];
+    return (pjsip_evsub*) tsx->mod_data[mod_evsub.mod.id];
 }
 
 
@@ -395,7 +395,7 @@
 
     /* Create new event package: */
 
-    pkg = pj_pool_alloc(mod_evsub.pool, sizeof(struct evpkg));
+    pkg = PJ_POOL_ALLOC_T(mod_evsub.pool, struct evpkg);
     pkg->pkg_mod = pkg_mod;
     pkg->pkg_expires = expires;
     pj_strdup(mod_evsub.pool, &pkg->pkg_name, event_name);
@@ -508,8 +508,8 @@
     /* Kill timer */
     set_timer(sub, TIMER_TYPE_NONE, 0);
 
-    /* Remote this session from dialog's list of subscription */
-    dlgsub_head = sub->dlg->mod_data[mod_evsub.mod.id];
+    /* Remove this session from dialog's list of subscription */
+    dlgsub_head = (struct dlgsub *) sub->dlg->mod_data[mod_evsub.mod.id];
     dlgsub = dlgsub_head->next;
     while (dlgsub != dlgsub_head) {
 	
@@ -572,7 +572,7 @@
 
     PJ_UNUSED_ARG(timer_heap);
 
-    sub = entry->user_data;
+    sub = (pjsip_evsub*) entry->user_data;
 
     pjsip_dlg_inc_lock(sub->dlg);
 
@@ -673,7 +673,7 @@
 
     /* Init attributes: */
 
-    sub = pj_pool_zalloc(dlg->pool, sizeof(struct pjsip_evsub));
+    sub = PJ_POOL_ZALLOC_T(dlg->pool, struct pjsip_evsub);
     sub->pool = dlg->pool;
     sub->endpt = dlg->endpt;
     sub->dlg = dlg;
@@ -684,7 +684,8 @@
     sub->state = PJSIP_EVSUB_STATE_NULL;
     sub->state_str = evsub_state_names[sub->state];
     sub->expires = pjsip_expires_hdr_create(sub->pool, pkg->pkg_expires);
-    sub->accept = pjsip_hdr_clone(sub->pool, pkg->pkg_accept);
+    sub->accept = (pjsip_accept_hdr*) 
+    		  pjsip_hdr_clone(sub->pool, pkg->pkg_accept);
 
     sub->timer.user_data = sub;
     sub->timer.cb = &on_timer;
@@ -706,8 +707,8 @@
 
     /* Create subcription list: */
 
-    dlgsub_head = pj_pool_alloc(sub->pool, sizeof(struct dlgsub));
-    dlgsub = pj_pool_alloc(sub->pool, sizeof(struct dlgsub));
+    dlgsub_head = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub);
+    dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub);
     dlgsub->sub = sub;
 
     pj_list_init(dlgsub_head);
@@ -828,7 +829,7 @@
 	goto on_return;
 
     /* Just duplicate Event header from the request */
-    sub->event = pjsip_hdr_clone(sub->pool, event_hdr);
+    sub->event = (pjsip_event_hdr*) pjsip_hdr_clone(sub->pool, event_hdr);
 
     /* Set the method: */
     pjsip_method_copy(sub->pool, &sub->method, 
@@ -850,7 +851,7 @@
     accept_hdr = (pjsip_accept_hdr*)
 	pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_ACCEPT, NULL);
     if (accept_hdr)
-	sub->accept = pjsip_hdr_clone(sub->pool, accept_hdr);
+	sub->accept = (pjsip_accept_hdr*)pjsip_hdr_clone(sub->pool,accept_hdr);
 
     /* We can start the session: */
 
@@ -941,22 +942,22 @@
 
 
     /* Add Event header: */
-    pjsip_msg_add_hdr( tdata->msg,
+    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 		       pjsip_hdr_shallow_clone(tdata->pool, sub->event));
 
     /* Update and add expires header: */
     if (expires >= 0)
 	sub->expires->ivalue = expires;
-    pjsip_msg_add_hdr( tdata->msg,
+    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 		       pjsip_hdr_shallow_clone(tdata->pool, sub->expires));
 
     /* Add Accept header: */
-    pjsip_msg_add_hdr( tdata->msg,
+    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 		       pjsip_hdr_shallow_clone(tdata->pool, sub->accept));
     
 
     /* Add Allow-Events header: */
-    pjsip_msg_add_hdr( tdata->msg,
+    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 		       pjsip_hdr_shallow_clone(tdata->pool, 
 					       mod_evsub.allow_events_hdr));
 
@@ -1011,14 +1012,14 @@
 
 
     /* Add expires header: */
-    pjsip_msg_add_hdr( tdata->msg,
+    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 		       pjsip_hdr_shallow_clone(tdata->pool, sub->expires));
 
     /* Add additional header, if any. */
     if (hdr_list) {
 	const pjsip_hdr *hdr = hdr_list->next;
 	while (hdr != hdr_list) {
-	    pjsip_msg_add_hdr( tdata->msg,
+	    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 			       pjsip_hdr_clone(tdata->pool, hdr));
 	    hdr = hdr->next;
 	}
@@ -1117,7 +1118,7 @@
 	goto on_return;
 
     /* Add Event header */
-    pjsip_msg_add_hdr(tdata->msg,
+    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)
 		      pjsip_hdr_shallow_clone(tdata->pool, sub->event));
 
     /* Add Subscription-State header */
@@ -1126,7 +1127,7 @@
     pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)sub_state);
 
     /* Add Allow-Events header */
-    pjsip_msg_add_hdr(tdata->msg,
+    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)
 		      pjsip_hdr_shallow_clone(tdata->pool, mod_evsub.allow_events_hdr));
 
     /* Add Authentication headers. */
@@ -1258,7 +1259,8 @@
 	return NULL;
     }
 
-    event_hdr = pjsip_msg_find_hdr_by_name(msg, &STR_EVENT, NULL);
+    event_hdr = (pjsip_event_hdr*)
+    		pjsip_msg_find_hdr_by_name(msg, &STR_EVENT, NULL);
     if (!event_hdr) {
 	/* Not subscription related message */
 	return NULL;
@@ -1268,9 +1270,9 @@
      * of Event header: 
      */
 
-    dlgsub_head = dlg->mod_data[mod_evsub.mod.id];
+    dlgsub_head = (struct dlgsub*) dlg->mod_data[mod_evsub.mod.id];
     if (dlgsub_head == NULL) {
-	dlgsub_head = pj_pool_alloc(dlg->pool, sizeof(struct dlgsub));
+	dlgsub_head = PJ_POOL_ALLOC_T(dlg->pool, struct dlgsub);
 	pj_list_init(dlgsub_head);
 	dlg->mod_data[mod_evsub.mod.id] = dlgsub_head;
     }
@@ -1416,7 +1418,7 @@
     /* Add response headers. */
     hdr = res_hdr->next;
     while (hdr != res_hdr) {
-	pjsip_msg_add_hdr( tdata->msg, 
+	pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 			   pjsip_hdr_clone(tdata->pool, hdr));
 	hdr = hdr->next;
     }
@@ -1549,7 +1551,8 @@
 		pjsip_expires_hdr *expires;
 
 		msg = event->body.tsx_state.src.rdata->msg_info.msg;
-		expires = pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
+		expires = (pjsip_expires_hdr*)
+			  pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
 		if (expires) {
 		    sub->expires->ivalue = expires->ivalue;
 		}
@@ -1655,7 +1658,8 @@
 	pj_list_init(&res_hdr);
 
 	/* Get subscription state header. */
-	sub_state = pjsip_msg_find_hdr_by_name(msg, &STR_SUB_STATE, NULL);
+	sub_state = (pjsip_sub_state_hdr*)
+		    pjsip_msg_find_hdr_by_name(msg, &STR_SUB_STATE, NULL);
 	if (sub_state == NULL) {
 
 	    pjsip_warning_hdr *warn_hdr;
@@ -1803,8 +1807,10 @@
 	/* Set expiration time based on client request (in Expires header),
 	 * or package default expiration time.
 	 */
-	event_hdr = pjsip_msg_find_hdr_by_name(msg, &STR_EVENT, NULL);
-	expires = pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
+	event_hdr = (pjsip_event_hdr*)
+		    pjsip_msg_find_hdr_by_name(msg, &STR_EVENT, NULL);
+	expires = (pjsip_expires_hdr*)
+		  pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
 	if (event_hdr && expires) {
 	    struct evpkg *evpkg;
 
@@ -1859,7 +1865,7 @@
 				 body, &tdata);
 	if (status == PJ_SUCCESS) {
 	    /* Add expires header: */
-	    pjsip_msg_add_hdr( tdata->msg,
+	    pjsip_msg_add_hdr( tdata->msg, (pjsip_hdr*)
 			       pjsip_hdr_shallow_clone(tdata->pool, 
 						       sub->expires));
 
diff --git a/pjsip/src/pjsip-simple/evsub_msg.c b/pjsip/src/pjsip-simple/evsub_msg.c
index ead1c26..467345d 100644
--- a/pjsip/src/pjsip-simple/evsub_msg.c
+++ b/pjsip/src/pjsip-simple/evsub_msg.c
@@ -43,7 +43,7 @@
 
 PJ_DEF(pjsip_event_hdr*) pjsip_event_hdr_create(pj_pool_t *pool)
 {
-    pjsip_event_hdr *hdr = pj_pool_zalloc(pool, sizeof(*hdr));
+    pjsip_event_hdr *hdr = PJ_POOL_ZALLOC_T(pool, pjsip_event_hdr);
     hdr->type = PJSIP_H_OTHER;
     hdr->name.ptr = "Event";
     hdr->name.slen = 5;
@@ -93,7 +93,7 @@
 pjsip_event_hdr_shallow_clone( pj_pool_t *pool,
 			       const pjsip_event_hdr *rhs )
 {
-    pjsip_event_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+    pjsip_event_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_event_hdr);
     pj_memcpy(hdr, rhs, sizeof(*hdr));
     pjsip_param_shallow_clone(pool, &hdr->other_param, &rhs->other_param);
     return hdr;
@@ -142,7 +142,7 @@
 PJ_DEF(pjsip_sub_state_hdr*) pjsip_sub_state_hdr_create(pj_pool_t *pool)
 {
     pj_str_t sub_state = { "Subscription-State", 18 };
-    pjsip_sub_state_hdr *hdr = pj_pool_zalloc(pool, sizeof(*hdr));
+    pjsip_sub_state_hdr *hdr = PJ_POOL_ZALLOC_T(pool, pjsip_sub_state_hdr);
     hdr->type = PJSIP_H_OTHER;
     hdr->name = hdr->sname = sub_state;
     hdr->vptr = &sub_state_hdr_vptr;
@@ -208,7 +208,7 @@
 pjsip_sub_state_hdr_shallow_clone(pj_pool_t *pool,
 				  const pjsip_sub_state_hdr *rhs)
 {
-    pjsip_sub_state_hdr *hdr = pj_pool_alloc(pool, sizeof(*hdr));
+    pjsip_sub_state_hdr *hdr = PJ_POOL_ALLOC_T(pool, pjsip_sub_state_hdr);
     pj_memcpy(hdr, rhs, sizeof(*hdr));
     pjsip_param_shallow_clone(pool, &hdr->other_param, &rhs->other_param);
     return hdr;
@@ -234,7 +234,7 @@
 	if (pj_stricmp(&pname, &id_param)==0) {
 	    hdr->id_param = pvalue;
 	} else {
-	    pjsip_param *param = pj_pool_alloc(ctx->pool, sizeof(pjsip_param));
+	    pjsip_param *param = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param);
 	    param->name = pname;
 	    param->value = pvalue;
 	    pj_list_push_back(&hdr->other_param, param);
@@ -271,7 +271,7 @@
 	    hdr->retry_after = pj_strtoul(&pvalue);
 
 	} else {
-	    pjsip_param *param = pj_pool_alloc(ctx->pool, sizeof(pjsip_param));
+	    pjsip_param *param = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param);
 	    param->name = pname;
 	    param->value = pvalue;
 	    pj_list_push_back(&hdr->other_param, param);
diff --git a/pjsip/src/pjsip-simple/iscomposing.c b/pjsip/src/pjsip-simple/iscomposing.c
index 7db421e..d49fae4 100644
--- a/pjsip/src/pjsip-simple/iscomposing.c
+++ b/pjsip/src/pjsip-simple/iscomposing.c
@@ -95,7 +95,7 @@
     /* Add refresh, if any. */
     if (is_composing && refresh > 1 && refresh < 3601) {
 	node = pj_xml_node_new(pool, &STR_REFRESH);
-	node->content.ptr = pj_pool_alloc(pool, 10);
+	node->content.ptr = (char*) pj_pool_alloc(pool, 10);
 	node->content.slen = pj_utoa(refresh, node->content.ptr);
 	pj_xml_add_node(doc, node);
     }
@@ -113,7 +113,8 @@
 static int xml_print_body( struct pjsip_msg_body *msg_body, 
 			   char *buf, pj_size_t size)
 {
-    return pj_xml_print(msg_body->data, buf, size, PJ_TRUE);
+    return pj_xml_print((const pj_xml_node*)msg_body->data, buf, size, 
+    			PJ_TRUE);
 }
 
 
@@ -123,7 +124,7 @@
 static void* xml_clone_data(pj_pool_t *pool, const void *data, unsigned len)
 {
     PJ_UNUSED_ARG(len);
-    return pj_xml_clone( pool, data);
+    return pj_xml_clone( pool, (const pj_xml_node*)data);
 }
 
 
@@ -143,7 +144,7 @@
 	return NULL;
 
 
-    body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body));
+    body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
     body->content_type.type = STR_MIME_TYPE;
     body->content_type.subtype = STR_MIME_SUBTYPE;
 
diff --git a/pjsip/src/pjsip-simple/pidf.c b/pjsip/src/pjsip-simple/pidf.c
index 1064f37..730194c 100644
--- a/pjsip/src/pjsip-simple/pidf.c
+++ b/pjsip/src/pjsip-simple/pidf.c
@@ -88,7 +88,7 @@
 static pj_xml_attr* xml_create_attr(pj_pool_t *pool, pj_str_t *name,
 				    const pj_str_t *value)
 {
-    pj_xml_attr *attr = pj_pool_alloc(pool, sizeof(*attr));
+    pj_xml_attr *attr = PJ_POOL_ALLOC_T(pool, pj_xml_attr);
     attr->name = *name;
     pj_strdup(pool, &attr->value, value);
     return attr;
@@ -110,7 +110,7 @@
 PJ_DEF(pjpidf_tuple*) pjpidf_pres_add_tuple(pj_pool_t *pool, pjpidf_pres *pres,
 					    const pj_str_t *id)
 {
-    pjpidf_tuple *t = pj_pool_alloc(pool, sizeof(*t));
+    pjpidf_tuple *t = PJ_POOL_ALLOC_T(pool, pjpidf_tuple);
     pjpidf_tuple_construct(pool, t, id);
     pj_xml_add_node(pres, t);
     return t;
@@ -129,7 +129,7 @@
 
 static pj_bool_t find_tuple_by_id(pj_xml_node *node, const void *id)
 {
-    return pj_xml_find_attr(node, &ID, id) != NULL;
+    return pj_xml_find_attr(node, &ID, (const pj_str_t*)id) != NULL;
 }
 
 PJ_DEF(pjpidf_tuple*) pjpidf_pres_find_tuple(pjpidf_pres *pres, const pj_str_t *id)
@@ -146,7 +146,7 @@
 PJ_DEF(pjpidf_note*) pjpidf_pres_add_note(pj_pool_t *pool, pjpidf_pres *pres, 
 					  const pj_str_t *text)
 {
-    pjpidf_note *note = pj_pool_alloc(pool, sizeof(*note));
+    pjpidf_note *note = PJ_POOL_ALLOC_T(pool, pjpidf_note);
     xml_init_node(pool, note, &NOTE, text);
     pj_xml_add_node(pres, note);
     return note;
@@ -173,7 +173,7 @@
     xml_init_node(pool, t, &TUPLE, NULL);
     attr = xml_create_attr(pool, &ID, id);
     pj_xml_add_attr(t, attr);
-    st = pj_pool_alloc(pool, sizeof(*st));
+    st = PJ_POOL_ALLOC_T(pool, pjpidf_status);
     pjpidf_status_construct(pool, st);
     pj_xml_add_node(t, st);
 }
@@ -214,7 +214,7 @@
 {
     pj_xml_node *node = pj_xml_find_node(t, &CONTACT);
     if (!node) {
-	node = pj_pool_alloc(pool, sizeof(*node));
+	node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
 	xml_init_node(pool, node, &CONTACT, contact);
 	pj_xml_add_node(t, node);
     } else {
@@ -229,7 +229,7 @@
     pj_xml_attr *attr;
 
     if (!node) {
-	node = pj_pool_alloc(pool, sizeof(*node));
+	node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
 	xml_init_node(pool, node, &CONTACT, NULL);
 	pj_xml_add_node(t, node);
     }
@@ -259,7 +259,7 @@
 PJ_DEF(pjpidf_note*) pjpidf_tuple_add_note(pj_pool_t *pool, pjpidf_tuple *t,
 					   const pj_str_t *text)
 {
-    pjpidf_note *note = pj_pool_alloc(pool, sizeof(*note));
+    pjpidf_note *note = PJ_POOL_ALLOC_T(pool, pjpidf_note);
     xml_init_node(pool, note, &NOTE, text);
     pj_xml_add_node(t, note);
     return note;
@@ -287,7 +287,7 @@
 {
     pj_xml_node *node = pj_xml_find_node(t, &TIMESTAMP);
     if (!node) {
-	node = pj_pool_alloc(pool, sizeof(*node));
+	node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
 	xml_init_node(pool, node, &TIMESTAMP, ts);
     } else {
 	pj_strdup(pool, &node->content, ts);
@@ -300,7 +300,7 @@
 {
     pj_xml_node *node = pj_xml_find_node(t, &TIMESTAMP);
     if (!node) {
-	node = pj_pool_alloc(pool, sizeof(*node));
+	node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
 	xml_init_node(pool, node, &TIMESTAMP, ts);
     } else {
 	node->content = *ts;
@@ -314,7 +314,7 @@
     pj_xml_node *node;
 
     xml_init_node(pool, st, &STATUS, NULL);
-    node = pj_pool_alloc(pool, sizeof(*node));
+    node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
     xml_init_node(pool, node, &BASIC, &CLOSED);
     pj_xml_add_node(st, node);
 }
@@ -335,7 +335,7 @@
 
 PJ_DEF(pjpidf_pres*) pjpidf_create(pj_pool_t *pool, const pj_str_t *entity)
 {
-    pjpidf_pres *pres = pj_pool_alloc(pool, sizeof(*pres));
+    pjpidf_pres *pres = PJ_POOL_ALLOC_T(pool, pjpidf_pres);
     pjpidf_pres_construct(pool, pres, entity);
     return pres;
 }
diff --git a/pjsip/src/pjsip-simple/presence.c b/pjsip/src/pjsip-simple/presence.c
index d341162..9f04c64 100644
--- a/pjsip/src/pjsip-simple/presence.c
+++ b/pjsip/src/pjsip-simple/presence.c
@@ -197,7 +197,7 @@
 	goto on_return;
 
     /* Create presence */
-    pres = pj_pool_zalloc(dlg->pool, sizeof(pjsip_pres));
+    pres = PJ_POOL_ZALLOC_T(dlg->pool, pjsip_pres);
     pres->dlg = dlg;
     pres->sub = sub;
     if (user_cb)
@@ -244,7 +244,8 @@
 		     PJSIP_SIMPLE_ENOTSUBSCRIBE);
 
     /* Check that Event header contains "presence" */
-    event = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &STR_EVENT, NULL);
+    event = (pjsip_event_hdr*)
+    	    pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &STR_EVENT, NULL);
     if (!event) {
 	return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_BAD_REQUEST);
     }
@@ -253,7 +254,8 @@
     }
 
     /* Check that request contains compatible Accept header. */
-    accept = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_ACCEPT, NULL);
+    accept = (pjsip_accept_hdr*)
+    	     pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_ACCEPT, NULL);
     if (accept) {
 	unsigned i;
 	for (i=0; i<accept->count; ++i) {
@@ -280,7 +282,8 @@
     }
 
     /* Check that expires is not too short. */
-    expires_hdr=pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);
+    expires_hdr=(pjsip_expires_hdr*)
+    		pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);
     if (expires_hdr) {
 	if (expires_hdr->ivalue < 5) {
 	    return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_INTERVAL_TOO_BRIEF);
@@ -304,7 +307,7 @@
 	goto on_return;
 
     /* Create server presence subscription */
-    pres = pj_pool_zalloc(dlg->pool, sizeof(pjsip_pres));
+    pres = PJ_POOL_ZALLOC_T(dlg->pool, pjsip_pres);
     pres->dlg = dlg;
     pres->sub = sub;
     pres->content_type = content_type;
@@ -366,7 +369,7 @@
 
     PJ_ASSERT_RETURN(sub && status, PJ_EINVAL);
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_RETURN(pres!=NULL, PJSIP_SIMPLE_ENOPRESENCE);
 
     if (pres->tmp_status._is_valid)
@@ -389,7 +392,7 @@
 
     PJ_ASSERT_RETURN(sub && status, PJ_EINVAL);
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_RETURN(pres!=NULL, PJSIP_SIMPLE_ENOPRESENCE);
 
     for (i=0; i<status->info_cnt; ++i) {
@@ -422,7 +425,7 @@
     pj_str_t entity;
 
     /* Get publisher URI */
-    entity.ptr = pj_pool_alloc(tdata->pool, PJSIP_MAX_URL_SIZE);
+    entity.ptr = (char*) pj_pool_alloc(tdata->pool, PJSIP_MAX_URL_SIZE);
     entity.slen = pjsip_uri_print(PJSIP_URI_IN_REQ_URI,
 				  pres->dlg->local.info->uri,
 				  entity.ptr, PJSIP_MAX_URL_SIZE);
@@ -462,7 +465,7 @@
     PJ_ASSERT_RETURN(sub, PJ_EINVAL);
 
     /* Get the presence object. */
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_RETURN(pres != NULL, PJSIP_SIMPLE_ENOPRESENCE);
 
     /* Must have at least one presence info. */
@@ -508,7 +511,7 @@
     PJ_ASSERT_RETURN(sub, PJ_EINVAL);
 
     /* Get the presence object. */
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_RETURN(pres != NULL, PJSIP_SIMPLE_ENOPRESENCE);
 
     /* Must have at least one presence info. */
@@ -558,7 +561,7 @@
 {
     pjsip_pres *pres;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (pres->user_cb.on_evsub_state)
@@ -573,7 +576,7 @@
 {
     pjsip_pres *pres;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (pres->user_cb.on_tsx_state)
@@ -593,7 +596,7 @@
 {
     pjsip_pres *pres;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (pres->user_cb.on_rx_refresh) {
@@ -721,7 +724,7 @@
     pjsip_pres *pres;
     pj_status_t status;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (rdata->msg_info.msg->body) {
@@ -773,7 +776,7 @@
 {
     pjsip_pres *pres;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (pres->user_cb.on_client_refresh) {
@@ -795,7 +798,7 @@
 {
     pjsip_pres *pres;
 
-    pres = pjsip_evsub_get_mod_data(sub, mod_presence.id);
+    pres = (pjsip_pres*) pjsip_evsub_get_mod_data(sub, mod_presence.id);
     PJ_ASSERT_ON_FAIL(pres!=NULL, {return;});
 
     if (pres->user_cb.on_server_timeout) {
diff --git a/pjsip/src/pjsip-simple/presence_body.c b/pjsip/src/pjsip-simple/presence_body.c
index 04edf9c..c57e427 100644
--- a/pjsip/src/pjsip-simple/presence_body.c
+++ b/pjsip/src/pjsip-simple/presence_body.c
@@ -42,7 +42,8 @@
 static int pres_print_body(struct pjsip_msg_body *msg_body, 
 			   char *buf, pj_size_t size)
 {
-    return pj_xml_print(msg_body->data, buf, size, PJ_TRUE);
+    return pj_xml_print((const pj_xml_node*)msg_body->data, buf, size, 
+    			PJ_TRUE);
 }
 
 
@@ -52,7 +53,7 @@
 static void* xml_clone_data(pj_pool_t *pool, const void *data, unsigned len)
 {
     PJ_UNUSED_ARG(len);
-    return pj_xml_clone( pool, data);
+    return pj_xml_clone( pool, (const pj_xml_node*) data);
 }
 
 
@@ -100,7 +101,7 @@
 				     status->info[i].basic_open);
     }
 
-    body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body));
+    body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
     body->data = pidf;
     body->content_type.type = STR_APPLICATION;
     body->content_type.subtype = STR_PIDF_XML;
@@ -139,7 +140,7 @@
     else
 	pjxpidf_set_status( xpidf, PJ_FALSE);
 
-    body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body));
+    body = PJ_POOL_ZALLOC_T(pool, pjsip_msg_body);
     body->data = xpidf;
     body->content_type.type = STR_APPLICATION;
     body->content_type.subtype = STR_XPIDF_XML;
@@ -164,7 +165,7 @@
     pjpidf_tuple *pidf_tuple;
 
     pidf = pjpidf_parse(rdata->tp_info.pool, 
-			rdata->msg_info.msg->body->data,
+			(char*)rdata->msg_info.msg->body->data,
 			rdata->msg_info.msg->body->len);
     if (pidf == NULL)
 	return PJSIP_SIMPLE_EBADPIDF;
@@ -209,7 +210,7 @@
     pjxpidf_pres *xpidf;
 
     xpidf = pjxpidf_parse(rdata->tp_info.pool, 
-			  rdata->msg_info.msg->body->data,
+			  (char*)rdata->msg_info.msg->body->data,
 			  rdata->msg_info.msg->body->len);
     if (xpidf == NULL)
 	return PJSIP_SIMPLE_EBADXPIDF;
diff --git a/pjsip/src/pjsip-simple/publishc.c b/pjsip/src/pjsip-simple/publishc.c
index 1b10c74..0cb15a7 100644
--- a/pjsip/src/pjsip-simple/publishc.c
+++ b/pjsip/src/pjsip-simple/publishc.c
@@ -50,7 +50,7 @@
 
 const pjsip_method pjsip_publish_method = 
 {
-    PJSIP_PUBLISH_METHOD,
+    (pjsip_method_e)PJSIP_PUBLISH_METHOD,
     { "PUBLISH", 7 }
 };
 
@@ -122,7 +122,7 @@
     pool = pjsip_endpt_create_pool(endpt, "pubc%p", 1024, 1024);
     PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
 
-    pubc = pj_pool_zalloc(pool, sizeof(struct pjsip_publishc));
+    pubc = PJ_POOL_ZALLOC_T(pool, pjsip_publishc);
 
     pubc->pool = pool;
     pubc->endpt = endpt;
@@ -291,13 +291,15 @@
 	pjsip_hdr *route_pos;
 	const pjsip_route_hdr *route;
 
-	route_pos = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
+	route_pos = (pjsip_hdr*)
+		    pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
 	if (!route_pos)
 	    route_pos = &tdata->msg->hdr;
 
 	route = pubc->route_set.next;
 	while (route != &pubc->route_set) {
-	    pjsip_hdr *new_hdr = pjsip_hdr_shallow_clone(tdata->pool, route);
+	    pjsip_hdr *new_hdr = (pjsip_hdr*)
+	    			 pjsip_hdr_shallow_clone(tdata->pool, route);
 	    pj_list_insert_after(route_pos, new_hdr);
 	    route_pos = new_hdr;
 	    route = route->next;
@@ -345,7 +347,8 @@
     if (pubc->expires_hdr) {
 	pjsip_hdr *dup;
 
-	dup = pjsip_hdr_shallow_clone(tdata->pool, pubc->expires_hdr);
+	dup = (pjsip_hdr*)
+	      pjsip_hdr_shallow_clone(tdata->pool, pubc->expires_hdr);
 	if (dup)
 	    pjsip_msg_add_hdr(tdata->msg, dup);
     }
@@ -424,7 +427,7 @@
 static void pubc_refresh_timer_cb( pj_timer_heap_t *timer_heap,
 				   struct pj_timer_entry *entry)
 {
-    pjsip_publishc *pubc = entry->user_data;
+    pjsip_publishc *pubc = (pjsip_publishc*) entry->user_data;
     pjsip_tx_data *tdata;
     pj_status_t status;
     
@@ -446,7 +449,7 @@
 static void tsx_callback(void *token, pjsip_event *event)
 {
     pj_status_t status;
-    pjsip_publishc *pubc = token;
+    pjsip_publishc *pubc = (pjsip_publishc*) token;
     pjsip_transaction *tsx = event->body.tsx_state.tsx;
     
     /* Decrement pending transaction counter. */
@@ -507,7 +510,8 @@
 	    }
 
 	    /* Update expires value */
-	    expires = pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
+	    expires = (pjsip_expires_hdr*)
+	    	      pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
 
 	    if (expires)
 		expiration = expires->ivalue;
@@ -574,7 +578,8 @@
 
     /* Increment CSeq */
     cseq = ++pubc->cseq_hdr->cseq;
-    cseq_hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
+    cseq_hdr = (pjsip_cseq_hdr*)
+    	       pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
     cseq_hdr->cseq = cseq;
 
     /* Increment pending transaction first, since transaction callback
diff --git a/pjsip/src/pjsip-simple/xpidf.c b/pjsip/src/pjsip-simple/xpidf.c
index d0dcbf4..30698a0 100644
--- a/pjsip/src/pjsip-simple/xpidf.c
+++ b/pjsip/src/pjsip-simple/xpidf.c
@@ -40,7 +40,7 @@
 {
     pj_xml_node *node;
 
-    node = pj_pool_alloc(pool, sizeof(pj_xml_node));
+    node = PJ_POOL_ALLOC_T(pool, pj_xml_node);
     pj_list_init(&node->attr_head);
     pj_list_init(&node->node_head);
     node->name = *name;
@@ -53,7 +53,7 @@
 static pj_xml_attr* xml_create_attr(pj_pool_t *pool, pj_str_t *name,
 				    const pj_str_t *value)
 {
-    pj_xml_attr *attr = pj_pool_alloc(pool, sizeof(*attr));
+    pj_xml_attr *attr = PJ_POOL_ALLOC_T(pool, pj_xml_attr);
     attr->name = *name;
     pj_strdup(pool, &attr->value, value);
     return attr;
@@ -79,7 +79,8 @@
     pj_xml_add_node(pres, presentity);
 
     /* uri attribute */
-    uri.ptr = pj_pool_alloc(pool, uri_cstr->slen + STR_SUBSCRIBE_PARAM.slen);
+    uri.ptr = (char*) pj_pool_alloc(pool, uri_cstr->slen + 
+    					   STR_SUBSCRIBE_PARAM.slen);
     pj_strcpy( &uri, uri_cstr);
     pj_strcat( &uri, &STR_SUBSCRIBE_PARAM);
     attr = xml_create_attr(pool, &STR_URI, &uri);