Index: /pjproject/trunk/pjsip/src/test-pjsip/main.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/main.c	(revision 60)
+++ /pjproject/trunk/pjsip/src/test-pjsip/main.c	(revision 61)
@@ -17,16 +17,2 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#include "test.h"
-#include <stdio.h>
-
-int main()
-{
-    test_uri();
-    test_msg();
-
-#if !IS_PROFILING
-    puts("Press <ENTER> to quit.");
-    fgets( s, sizeof(s), stdin);
-#endif
-    return 0;
-}
Index: /pjproject/trunk/pjsip/src/test-pjsip/parse_msg.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/parse_msg.c	(revision 61)
+++ /pjproject/trunk/pjsip/src/test-pjsip/parse_msg.c	(revision 61)
@@ -0,0 +1,440 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include <pjsip/sip_msg.h>
+#include <pjsip/sip_parser.h>
+#include <pj/os.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "test.h"
+
+#define ERR_SYNTAX_ERR	(-2)
+#define ERR_NOT_EQUAL	(-3)
+#define ERR_SYSTEM	(-4)
+
+
+static pjsip_msg *create_msg0(pj_pool_t *pool);
+
+struct test_msg
+{
+    char	 msg[1024];
+    pjsip_msg *(*creator)(pj_pool_t *pool);
+    pj_size_t	 len;
+} test_array[] = 
+{
+    {
+	/* 'Normal' message with all headers. */
+	"INVITE sip:user@foo SIP/2.0\n"
+	"From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r"
+	"To: Fellow User <sip:user@foo.bar.domain.com>\r\n"
+	"Call-ID: 12345678901234567890@bar\r\n"
+	"Content-Length: 0\r\n"
+	"CSeq: 123456 INVITE\n"
+	"Contact: <sip:joe@bar> ; q=0.5;expires=3600,sip:user@host;q=0.500\r"
+	"  ,sip:user2@host2\n"
+	"Content-Type: text/html ; charset=ISO-8859-4\r"
+	"Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n"
+	"  <sip:server10.biloxi.com;lr>\r"
+	"Record-Route: <sip:server10.biloxi.com>,\r\n"
+	"  <sip:bigbox3.site3.atlanta.com;lr>\n"
+	"Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n"
+	"Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n"
+	" ;received=192.0.2.1\r\n"
+	"Via: SIP/2.0/UDP 10.2.1.1, SIP/2.0/TCP 192.168.1.1\n"
+	"Organization: \r"
+	"Max-Forwards: 70\n"
+	"X-Header: \r\n"
+	"\r",
+	&create_msg0
+    }
+};
+
+static pj_caching_pool cp;
+static pj_pool_factory *pf = &cp.factory;
+static pj_uint32_t parse_len, parse_time, print_time;
+
+static void pool_error(pj_pool_t *pool, pj_size_t sz)
+{
+    PJ_UNUSED_ARG(pool)
+    PJ_UNUSED_ARG(sz)
+
+    pj_assert(0);
+    exit(1);
+}
+
+static const char *STATUS_STR(pj_status_t status)
+{
+    switch (status) {
+    case 0: return "OK";
+    case ERR_SYNTAX_ERR: return "Syntax Error";
+    case ERR_NOT_EQUAL: return "Not Equal";
+    case ERR_SYSTEM: return "System Error";
+    }
+    return "???";
+}
+
+static pj_status_t test_entry( struct test_msg *entry )
+{
+    pjsip_msg *parsed_msg, *ref_msg;
+    pj_pool_t *pool;
+    pj_status_t status = PJ_SUCCESS;
+    int len;
+    pj_str_t str1, str2;
+    pjsip_hdr *hdr1, *hdr2;
+    pj_hr_timestamp t1, t2;
+    char *msgbuf;
+
+    enum { BUFLEN = 512 };
+    
+    pool = pj_pool_create( pf, "", 
+			   PJSIP_POOL_LEN_RDATA*2, PJSIP_POOL_INC_RDATA, 
+			   &pool_error);
+
+    if (entry->len == 0) {
+	entry->len = strlen(entry->msg);
+    }
+
+    /* Parse message. */
+    parse_len += entry->len;
+    pj_hr_gettimestamp(&t1);
+    parsed_msg = pjsip_parse_msg(pool, entry->msg, entry->len, NULL);
+    if (parsed_msg == NULL) {
+	status = ERR_SYNTAX_ERR;
+	goto on_return;
+    }
+    pj_hr_gettimestamp(&t2);
+    parse_time += t2.u32.lo - t1.u32.lo;
+
+#if IS_PROFILING
+    goto print_msg;
+#endif
+
+    /* Create reference message. */
+    ref_msg = entry->creator(pool);
+
+    /* Create buffer for comparison. */
+    str1.ptr = pj_pool_alloc(pool, BUFLEN);
+    str2.ptr = pj_pool_alloc(pool, BUFLEN);
+
+    /* Compare message type. */
+    if (parsed_msg->type != ref_msg->type) {
+	status = ERR_NOT_EQUAL;
+	goto on_return;
+    }
+
+    /* Compare request or status line. */
+    if (parsed_msg->type == PJSIP_REQUEST_MSG) {
+	pjsip_method *m1 = &parsed_msg->line.req.method;
+	pjsip_method *m2 = &ref_msg->line.req.method;
+
+	if (m1->id != m2->id || pj_strcmp(&m1->name, &m2->name)) {
+	    status = ERR_NOT_EQUAL;
+	    goto on_return;
+	}
+    } else {
+
+    }
+
+    /* Compare headers. */
+    hdr1 = parsed_msg->hdr.next;
+    hdr2 = ref_msg->hdr.next;
+
+    while (hdr1 != &parsed_msg->hdr && hdr2 != &ref_msg->hdr) {
+	len = hdr1->vptr->print_on(hdr1, str1.ptr, BUFLEN);
+	if (len < 1) {
+	    status = ERR_SYSTEM;
+	    goto on_return;
+	}
+	str1.slen = len;
+
+	len = hdr2->vptr->print_on(hdr2, str2.ptr, BUFLEN);
+	if (len < 1) {
+	    status = ERR_SYSTEM;
+	    goto on_return;
+	}
+	str2.slen = len;
+
+	if (!SILENT) {
+	    printf("hdr1='%.*s'\n"
+		   "hdr2='%.*s'\n\n",
+		   str1.slen, str1.ptr,
+		   str2.slen, str2.ptr);
+	}
+	if (pj_strcmp(&str1, &str2) != 0) {
+	    status = ERR_NOT_EQUAL;
+	    goto on_return;
+	}
+
+	hdr1 = hdr1->next;
+	hdr2 = hdr2->next;
+    }
+
+    if (hdr1 != &parsed_msg->hdr || hdr2 != &ref_msg->hdr) {
+	status = ERR_NOT_EQUAL;
+	goto on_return;
+    }
+
+    /* Print message. */
+#if IS_PROFILING
+print_msg:
+#endif
+    msgbuf = pj_pool_alloc(pool, PJSIP_MAX_PKT_LEN);
+    if (msgbuf == NULL) {
+	status = ERR_SYSTEM;
+	goto on_return;
+    }
+    pj_hr_gettimestamp(&t1);
+    len = pjsip_msg_print(parsed_msg, msgbuf, PJSIP_MAX_PKT_LEN);
+    if (len < 1) {
+	status = ERR_SYSTEM;
+	goto on_return;
+    }
+    pj_hr_gettimestamp(&t2);
+    print_time += t2.u32.lo - t1.u32.lo;
+    status = PJ_SUCCESS;
+
+on_return:
+    pj_pool_release(pool);
+    return status;
+}
+
+static void warm_up()
+{
+    pj_pool_t *pool;
+    pool = pj_pool_create( pf, "", 
+			   PJSIP_POOL_LEN_RDATA*2, PJSIP_POOL_INC_RDATA, 
+			   &pool_error);
+    pj_pool_release(pool);
+}
+
+
+pj_status_t test_msg(void)
+{
+    pj_status_t status;
+    unsigned i;
+
+    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+    warm_up();
+
+    for (i=0; i<LOOP; ++i) {
+	status = test_entry( &test_array[0] );
+    }
+    printf("%s\n", STATUS_STR(status));
+
+    printf("Total bytes: %u, parse time=%f/char, print time=%f/char\n", 
+	   parse_len, 
+	   parse_time*1.0/parse_len,
+	   print_time*1.0/parse_len);
+    return PJ_SUCCESS;
+}
+
+/*****************************************************************************/
+
+static pjsip_msg *create_msg0(pj_pool_t *pool)
+{
+
+    pjsip_msg *msg;
+    pjsip_name_addr *name_addr;
+    pjsip_url *url;
+    pjsip_fromto_hdr *fromto;
+    pjsip_cid_hdr *cid;
+    pjsip_clen_hdr *clen;
+    pjsip_cseq_hdr *cseq;
+    pjsip_contact_hdr *contact;
+    pjsip_ctype_hdr *ctype;
+    pjsip_routing_hdr *routing;
+    pjsip_via_hdr *via;
+    pjsip_generic_string_hdr *generic;
+    pj_str_t str;
+
+    msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
+
+    /* "INVITE sip:user@foo SIP/2.0\n" */
+    pjsip_method_set(&msg->line.req.method, PJSIP_INVITE_METHOD);
+    url = pjsip_url_create(pool, 0);
+    msg->line.req.uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "user");
+    pj_strdup2(pool, &url->host, "foo");
+
+    /* "From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r" */
+    fromto = pjsip_from_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)fromto);
+    pj_strdup2(pool, &fromto->tag, "1234578901234567890");
+    name_addr = pjsip_name_addr_create(pool);
+    fromto->uri = (pjsip_uri*)name_addr;
+    pj_strdup2(pool, &name_addr->display, "Hi I'm Joe");
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "joe.user");
+    pj_strdup2(pool, &url->host, "bar.otherdomain.com");
+
+    /* "To: Fellow User <sip:user@foo.bar.domain.com>\r\n" */
+    fromto = pjsip_to_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)fromto);
+    name_addr = pjsip_name_addr_create(pool);
+    fromto->uri = (pjsip_uri*)name_addr;
+    pj_strdup2(pool, &name_addr->display, "Fellow User");
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "user");
+    pj_strdup2(pool, &url->host, "foo.bar.domain.com");
+
+    /* "Call-ID: 12345678901234567890@bar\r\n" */
+    cid = pjsip_cid_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)cid);
+    pj_strdup2(pool, &cid->id, "12345678901234567890@bar");
+
+    /* "Content-Length: 0\r\n" */
+    clen = pjsip_clen_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)clen);
+    clen->len = 0;
+
+    /* "CSeq: 123456 INVITE\n" */
+    cseq = pjsip_cseq_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)cseq);
+    cseq->cseq = 123456;
+    pjsip_method_set(&cseq->method, PJSIP_INVITE_METHOD);
+
+    /* "Contact: <sip:joe@bar>;q=0.5;expires=3600*/
+    contact = pjsip_contact_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
+    contact->q1000 = 500;
+    contact->expires = 3600;
+    name_addr = pjsip_name_addr_create(pool);
+    contact->uri = (pjsip_uri*)name_addr;
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "joe");
+    pj_strdup2(pool, &url->host, "bar");
+
+    /*, sip:user@host;q=0.500\r" */
+    contact = pjsip_contact_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
+    contact->q1000 = 500;
+    url = pjsip_url_create(pool, 0);
+    contact->uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "user");
+    pj_strdup2(pool, &url->host, "host");
+
+    /* "  ,sip:user2@host2\n" */
+    contact = pjsip_contact_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
+    url = pjsip_url_create(pool, 0);
+    contact->uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->user, "user2");
+    pj_strdup2(pool, &url->host, "host2");
+
+    /* "Content-Type: text/html; charset=ISO-8859-4\r" */
+    ctype = pjsip_ctype_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)ctype);
+    pj_strdup2(pool, &ctype->media.type, "text");
+    pj_strdup2(pool, &ctype->media.subtype, "html");
+    pj_strdup2(pool, &ctype->media.param, ";charset=ISO-8859-4");
+
+    /* "Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n" */
+    routing = pjsip_route_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
+    url = pjsip_url_create(pool, 0);
+    routing->name_addr.uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->host, "bigbox3.site3.atlanta.com");
+    url->lr_param = 1;
+
+    /* "  <sip:server10.biloxi.com;lr>\r" */
+    routing = pjsip_route_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
+    url = pjsip_url_create(pool, 0);
+    routing->name_addr.uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->host, "server10.biloxi.com");
+    url->lr_param = 1;
+
+    /* "Record-Route: <sip:server10.biloxi.com>,\r\n" */
+    routing = pjsip_rr_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
+    url = pjsip_url_create(pool, 0);
+    routing->name_addr.uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->host, "server10.biloxi.com");
+    url->lr_param = 0;
+
+    /* "  <sip:bigbox3.site3.atlanta.com;lr>\n" */
+    routing = pjsip_rr_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
+    url = pjsip_url_create(pool, 0);
+    routing->name_addr.uri = (pjsip_uri*)url;
+    pj_strdup2(pool, &url->host, "bigbox3.site3.atlanta.com");
+    url->lr_param = 1;
+
+    /* "Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n" */
+    via = pjsip_via_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
+    pj_strdup2(pool, &via->transport, "SCTP");
+    pj_strdup2(pool, &via->sent_by.host, "bigbox3.site3.atlanta.com");
+    pj_strdup2(pool, &via->branch_param, "z9hG4bK77ef4c2312983.1");
+
+    /* "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n"
+	" ;received=192.0.2.1\r\n" */
+    via = pjsip_via_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
+    pj_strdup2(pool, &via->transport, "UDP");
+    pj_strdup2(pool, &via->sent_by.host, "pc33.atlanta.com");
+    pj_strdup2(pool, &via->branch_param, "z9hG4bKnashds8");
+    pj_strdup2(pool, &via->recvd_param, "192.0.2.1");
+
+
+    /* "Via: SIP/2.0/UDP 10.2.1.1, */ 
+    via = pjsip_via_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
+    pj_strdup2(pool, &via->transport, "UDP");
+    pj_strdup2(pool, &via->sent_by.host, "10.2.1.1");
+    
+    
+    /*SIP/2.0/TCP 192.168.1.1\n" */
+    via = pjsip_via_hdr_create(pool);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
+    pj_strdup2(pool, &via->transport, "TCP");
+    pj_strdup2(pool, &via->sent_by.host, "192.168.1.1");
+
+    /* "Organization: \r" */
+    str.ptr = "Organization";
+    str.slen = 12;
+    generic = pjsip_generic_string_hdr_create(pool, &str);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
+    generic->hvalue.ptr = NULL;
+    generic->hvalue.slen = 0;
+
+    /* "Max-Forwards: 70\n" */
+    str.ptr = "Max-Forwards";
+    str.slen = 12;
+    generic = pjsip_generic_string_hdr_create(pool, &str);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
+    str.ptr = "70";
+    str.slen = 2;
+    generic->hvalue = str;
+
+    /* "X-Header: \r\n" */
+    str.ptr = "X-Header";
+    str.slen = 8;
+    generic = pjsip_generic_string_hdr_create(pool, &str);
+    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
+    str.ptr = NULL;
+    str.slen = 0;
+    generic->hvalue = str;
+
+    return msg;
+}
Index: /pjproject/trunk/pjsip/src/test-pjsip/parse_uri.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/parse_uri.c	(revision 61)
+++ /pjproject/trunk/pjsip/src/test-pjsip/parse_uri.c	(revision 61)
@@ -0,0 +1,660 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include <pjsip/sip_parser.h>
+#include <pjsip/sip_uri.h>
+#include <pj/os.h>
+#include <pj/pool.h>
+#include <pj/string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "test.h"
+
+#define ERR_SYNTAX_ERR	(-2)
+#define ERR_NOT_EQUAL	(-3)
+
+#define ALPHANUM    "abcdefghijklmnopqrstuvwxyz" \
+		    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+		    "0123456789"
+#define MARK	    "-_.!~*'()"
+#define USER	    "&=+$,;?/%"
+#define PASS	    "&=+$,%"
+#define PARAM_CHAR  "[]/:&+$" MARK "%"
+
+#define POOL_SIZE	4096
+
+static const char *STATUS_STR(pj_status_t status)
+{
+    switch (status) {
+    case 0: return "OK";
+    case ERR_SYNTAX_ERR: return "Syntax Error";
+    case ERR_NOT_EQUAL: return "Not Equal";
+    }
+    return "???";
+}
+
+static pj_uint32_t parse_len, parse_time, print_time;
+static pj_caching_pool cp;
+
+
+/* URI creator functions. */
+static pjsip_uri *create_uri1( pj_pool_t *pool );
+static pjsip_uri *create_uri2( pj_pool_t *pool );
+static pjsip_uri *create_uri3( pj_pool_t *pool );
+static pjsip_uri *create_uri4( pj_pool_t *pool );
+static pjsip_uri *create_uri5( pj_pool_t *pool );
+static pjsip_uri *create_uri6( pj_pool_t *pool );
+static pjsip_uri *create_uri7( pj_pool_t *pool );
+static pjsip_uri *create_uri8( pj_pool_t *pool );
+static pjsip_uri *create_uri9( pj_pool_t *pool );
+static pjsip_uri *create_uri10( pj_pool_t *pool );
+static pjsip_uri *create_uri11( pj_pool_t *pool );
+static pjsip_uri *create_uri12( pj_pool_t *pool );
+static pjsip_uri *create_uri13( pj_pool_t *pool );
+static pjsip_uri *create_uri14( pj_pool_t *pool );
+static pjsip_uri *create_uri15( pj_pool_t *pool );
+static pjsip_uri *create_uri16( pj_pool_t *pool );
+static pjsip_uri *create_uri17( pj_pool_t *pool );
+static pjsip_uri *create_uri18( pj_pool_t *pool );
+static pjsip_uri *create_uri19( pj_pool_t *pool );
+static pjsip_uri *create_dummy( pj_pool_t *pool );
+
+struct uri_test
+{
+    pj_status_t	     status;
+    char	     str[PJSIP_MAX_URL_SIZE];
+    pjsip_uri *(*creator)(pj_pool_t *pool);
+    pj_size_t	     len;
+} uri_test_array[] = 
+{
+    {
+	PJ_SUCCESS,
+	"sip:localhost",
+	&create_uri1
+    },
+    {
+	PJ_SUCCESS,
+	"sip:user@localhost",
+	&create_uri2
+    },
+    {
+	PJ_SUCCESS,
+	"sip:user:password@localhost:5060",
+	&create_uri3,
+    },
+    {
+	/* Port is specified should not match unspecified port. */
+	ERR_NOT_EQUAL,
+	"sip:localhost:5060",
+	&create_uri4
+    },
+    {
+	/* All recognized parameters. */
+	PJ_SUCCESS,
+	"sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK",
+	&create_uri5
+    },
+    {
+	/* Params mixed with other params and header params. */
+	PJ_SUCCESS,
+	"sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
+	"?Subject=Hello%20There&Server=SIP%20Server",
+	&create_uri6
+    },
+    {
+	/* SIPS. */
+	PJ_SUCCESS,
+	"sips:localhost",
+	&create_uri7,
+    },
+    {
+	/* Name address */
+	PJ_SUCCESS,
+	"<sip:localhost>",
+	&create_uri8
+    },
+    {
+	/* Name address with display name and SIPS scheme with some redundant
+	 * whitespaced.
+	 */
+	PJ_SUCCESS,
+	"  Power Administrator  <sips:localhost>",
+	&create_uri9
+    },
+    {
+	/* Name address. */
+	PJ_SUCCESS,
+	" \"User\" <sip:user@localhost:5071>",
+	&create_uri10
+    },
+    {
+	/* Escaped sequence in display name (display=Strange User\"\\\"). */
+	PJ_SUCCESS,
+	" \"Strange User\\\"\\\\\\\"\" <sip:localhost>",
+	&create_uri11,
+    },
+    {
+	/* Errorneous escaping in display name. */
+	ERR_SYNTAX_ERR,
+	" \"Rogue User\\\" <sip:localhost>",
+	&create_uri12,
+    },
+    {
+	/* Dangling quote in display name, but that should be OK. */
+	PJ_SUCCESS,
+	"Strange User\" <sip:localhost>",
+	&create_uri13,
+    },
+    {
+	/* Special characters in parameter value must be quoted. */
+	PJ_SUCCESS,
+	"sip:localhost;pvalue=\"hello world\"",
+	&create_uri14,
+    },
+    {
+	/* Excercise strange character sets allowed in display, user, password,
+	 * host, and port. 
+	 */
+	PJ_SUCCESS,
+	"This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%09a&Zz=+$,@"
+	"my_proxy09.MY-domain.com:9801>",
+	&create_uri15,
+    },
+    {
+	/* Another excercise to the allowed character sets to the hostname. */
+	PJ_SUCCESS,
+	"sip:" ALPHANUM "-_.com",
+	&create_uri16,
+    },
+    {
+	/* Another excercise to the allowed character sets to the username 
+	 * and password.
+	 */
+	PJ_SUCCESS,
+	"sip:" ALPHANUM USER ":" ALPHANUM PASS "@host",
+	&create_uri17,
+    },
+    {
+	/* Excercise to the pname and pvalue, and mixup of other-param
+	 * between 'recognized' params.
+	 */
+	PJ_SUCCESS,
+	"sip:host;user=ip;" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR 
+	";lr;other=1;transport=sctp;other2",
+	&create_uri18,
+    },
+    {
+	/* This should trigger syntax error. */
+	ERR_SYNTAX_ERR,
+	"sip:",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: whitespace after scheme. */
+	ERR_SYNTAX_ERR,
+	"sip :host",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: whitespace before hostname. */
+	ERR_SYNTAX_ERR,
+	"sip: host",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: invalid port. */
+	ERR_SYNTAX_ERR,
+	"sip:user:password",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: no host. */
+	ERR_SYNTAX_ERR,
+	"sip:user@",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: no user/host. */
+	ERR_SYNTAX_ERR,
+	"sip:@",
+	&create_dummy,
+    },
+    {
+	/* Syntax error: empty string. */
+	ERR_SYNTAX_ERR,
+	"",
+	&create_dummy,
+    },
+    {
+	PJ_SUCCESS,
+	"",
+	NULL,
+    },
+};
+
+static pjsip_uri *create_uri1(pj_pool_t *pool)
+{
+    /* "sip:localhost" */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri2(pj_pool_t *pool)
+{
+    /* "sip:user@localhost" */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2( pool, &url->user, "user");
+    pj_strdup2( pool, &url->host, "localhost");
+
+    return (pjsip_uri*) url;
+}
+
+static pjsip_uri *create_uri3(pj_pool_t *pool)
+{
+    /* "sip:user:password@localhost:5060" */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2( pool, &url->user, "user");
+    pj_strdup2( pool, &url->passwd, "password");
+    pj_strdup2( pool, &url->host, "localhost");
+    url->port = 5060;
+
+    return (pjsip_uri*) url;
+}
+
+static pjsip_uri *create_uri4(pj_pool_t *pool)
+{
+    /* Like: "sip:localhost:5060", but without the port. */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri5(pj_pool_t *pool)
+{
+    /* "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK" */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2(pool, &url->host, "localhost");
+    pj_strdup2(pool, &url->transport_param, "tcp");
+    pj_strdup2(pool, &url->user_param, "ip");
+    url->ttl_param = 255;
+    url->lr_param = 1;
+    pj_strdup2(pool, &url->maddr_param, "127.0.0.1");
+    pj_strdup2(pool, &url->method_param, "ACK");
+
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri6(pj_pool_t *pool)
+{
+    /* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
+       "?Subject=Hello%20There&Server=SIP%20Server" 
+     */
+    pjsip_url *url = pjsip_url_create(pool, 0);
+
+    pj_strdup2(pool, &url->host, "localhost");
+    pj_strdup2(pool, &url->user_param, "phone");
+    pj_strdup2(pool, &url->other_param, ";pickup=hurry;message=I%20am%20sorry");
+    pj_strdup2(pool, &url->header_param, "?Subject=Hello%20There&Server=SIP%20Server");
+    return (pjsip_uri*)url;
+
+}
+
+static pjsip_uri *create_uri7(pj_pool_t *pool)
+{
+    /* "sips:localhost" */
+    pjsip_url *url = pjsip_url_create(pool, 1);
+
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri8(pj_pool_t *pool)
+{
+    /* "<sip:localhost>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri9(pj_pool_t *pool)
+{
+    /* "  Power Administrator <sips:localhost>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 1);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "Power Administrator");
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri10(pj_pool_t *pool)
+{
+    /* " \"User\" <sip:user@localhost:5071>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "\"User\"");
+    pj_strdup2(pool, &url->user, "user");
+    pj_strdup2(pool, &url->host, "localhost");
+    url->port = 5071;
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri11(pj_pool_t *pool)
+{
+    /* " \"Strange User\\\"\\\\\\\"\" <sip:localhost>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "\"Strange User\\\"\\\\\\\"\"");
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri12(pj_pool_t *pool)
+{
+    /* " \"Rogue User\\\" <sip:localhost>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "\"Rogue User\\\"");
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri13(pj_pool_t *pool)
+{
+    /* "Strange User\" <sip:localhost>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "Strange User\"");
+    pj_strdup2(pool, &url->host, "localhost");
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri14(pj_pool_t *pool)
+{
+    /* "sip:localhost;pvalue=\"hello world\"" */
+    pjsip_url *url;
+    url = pjsip_url_create(pool, 0);
+    pj_strdup2(pool, &url->host, "localhost");
+    pj_strdup2(pool, &url->other_param, ";pvalue=\"hello world\"");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri15(pj_pool_t *pool)
+{
+    /* "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%09a&Zz=+$,@my_proxy09.my-domain.com:9801>" */
+    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
+    pjsip_url *url;
+
+    url = pjsip_url_create(pool, 0);
+    name_addr->uri = (pjsip_uri*) url;
+
+    pj_strdup2(pool, &name_addr->display, "This is -. !% *_+`'~ me");
+    pj_strdup2(pool, &url->user, "a19A&=+$,;?/%2c");
+    pj_strdup2(pool, &url->passwd, "%09a&Zz=+$,");
+    pj_strdup2(pool, &url->host, "my_proxy09.MY-domain.com");
+    url->port = 9801;
+    return (pjsip_uri*)name_addr;
+}
+
+static pjsip_uri *create_uri16(pj_pool_t *pool)
+{
+    /* "sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com" */
+    pjsip_url *url;
+    url = pjsip_url_create(pool, 0);
+    pj_strdup2(pool, &url->host, ALPHANUM "-_.com");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri17(pj_pool_t *pool)
+{
+    /* "sip:" ALPHANUM USER ":" ALPHANUM PASS "@host" */
+    pjsip_url *url;
+    url = pjsip_url_create(pool, 0);
+    pj_strdup2(pool, &url->user, ALPHANUM USER);
+    pj_strdup2(pool, &url->passwd, ALPHANUM PASS);
+    pj_strdup2(pool, &url->host, "host");
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_uri18(pj_pool_t *pool)
+{
+    /* "sip:host;user=ip;" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR ";lr;other=1;transport=sctp;other2" */
+    pjsip_url *url;
+    url = pjsip_url_create(pool, 0);
+    pj_strdup2(pool, &url->host, "host");
+    pj_strdup2(pool, &url->user_param, "ip");
+    pj_strdup2(pool, &url->transport_param, "sctp");
+    pj_strdup2(pool, &url->other_param, ";" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR ";other=1;other2");    
+    url->lr_param = 1;
+    return (pjsip_uri*)url;
+}
+
+static pjsip_uri *create_dummy(pj_pool_t *pool)
+{
+    PJ_UNUSED_ARG(pool)
+    return NULL;
+}
+
+/*****************************************************************************/
+
+static void pool_error(pj_pool_t *pool, pj_size_t sz)
+{
+    PJ_UNUSED_ARG(pool)
+    PJ_UNUSED_ARG(sz)
+
+    pj_assert(0);
+    exit(1);
+}
+
+/*
+ * Test one test entry.
+ */
+static pj_status_t test_entry(struct uri_test *entry)
+{
+    pj_status_t status;
+    pj_pool_t *pool;
+    int len;
+    pjsip_uri *parsed_uri, *ref_uri;
+    pj_str_t s1 = {NULL, 0}, s2 = {NULL, 0};
+    pj_hr_timestamp t1, t2;
+
+    pool = (*cp.factory.create_pool)( &cp.factory, "", POOL_SIZE, 0, &pool_error);
+
+    /* Parse URI text. */
+    pj_hr_gettimestamp(&t1);
+    parse_len += entry->len;
+    parsed_uri = pjsip_parse_uri(pool, entry->str, entry->len, 0);
+    if (!parsed_uri) {
+	/* Parsing failed. If the entry says that this is expected, then
+	 * return OK.
+	 */
+	status = entry->status==ERR_SYNTAX_ERR ? PJ_SUCCESS : ERR_SYNTAX_ERR;
+	goto on_return;
+    }
+    pj_hr_gettimestamp(&t2);
+    parse_time += t2.u32.lo - t1.u32.lo;
+
+    /* Create the reference URI. */
+    ref_uri = entry->creator(pool);
+
+    /* Print both URI. */
+    s1.ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
+    s2.ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
+
+    pj_hr_gettimestamp(&t1);
+    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, parsed_uri, s1.ptr, PJSIP_MAX_URL_SIZE);
+    if (len < 1) {
+	status = -1;
+	goto on_return;
+    }
+    s1.slen = len;
+
+    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, ref_uri, s2.ptr, PJSIP_MAX_URL_SIZE);
+    if (len < 1) {
+	status = -1;
+	goto on_return;
+    }
+    s2.slen = len;
+    pj_hr_gettimestamp(&t2);
+    print_time += t2.u32.lo - t1.u32.lo;
+
+    /* Full comparison of parsed URI with reference URI. */
+    if (pjsip_uri_cmp(PJSIP_URI_IN_OTHER, parsed_uri, ref_uri) != 0) {
+	/* Not equal. See if this is the expected status. */
+	status = entry->status==ERR_NOT_EQUAL ? PJ_SUCCESS : ERR_NOT_EQUAL;
+	goto on_return;
+
+    } else {
+	/* Equal. See if this is the expected status. */
+	status = entry->status==PJ_SUCCESS ? PJ_SUCCESS : -1;
+	if (status != PJ_SUCCESS) {
+	    goto on_return;
+	}
+    }
+
+    /* Compare text. */
+    if (pj_strcmp(&s1, &s2) != 0) {
+	/* Not equal. */
+	status = ERR_NOT_EQUAL;
+    }
+
+on_return:
+    if (!SILENT) {
+	printf("%.2d %s (expected status=%s)\n"
+	       "   str=%s\n"
+	       "   uri=%.*s\n"
+	       "   ref=%.*s\n\n", 
+	       entry-uri_test_array, 
+	       STATUS_STR(status), 
+	       STATUS_STR(entry->status), 
+	       entry->str, 
+	       (int)s1.slen, s1.ptr, (int)s2.slen, s2.ptr);
+    }
+
+    pj_pool_release(pool);
+    return status;
+}
+
+static void warm_up(pj_pool_factory *pf)
+{
+    pj_pool_t *pool;
+    struct uri_test *entry;
+
+    pool = pj_pool_create(pf, "", POOL_SIZE, 0, &pool_error);
+    pjsip_parse_uri(pool, "sip:host", 8, 0);
+    entry = &uri_test_array[0];
+    while (entry->creator) {
+	entry->len = strlen(entry->str);
+	++entry;
+    }
+    pj_pool_release(pool);
+}
+
+//#if !IS_PROFILING
+#if 1
+pj_status_t test_uri()
+{
+    struct uri_test *entry;
+    int i=0, err=0;
+    pj_status_t status;
+    pj_hr_timestamp t1, t2;
+    pj_uint32_t total_time;
+
+    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+    warm_up(&cp.factory);
+
+    pj_hr_gettimestamp(&t1);
+    for (i=0; i<LOOP; ++i) {
+	entry = &uri_test_array[0];
+	while (entry->creator) {
+	    status = test_entry(entry);
+	    if (status != PJ_SUCCESS) {
+		++err;
+	    }
+	    ++entry;
+	}
+    }
+    pj_hr_gettimestamp(&t2);
+    total_time = t2.u32.lo - t1.u32.lo;
+
+    printf("Error=%d\n", err);
+    printf("Total parse len:  %u bytes\n", parse_len);
+    printf("Total parse time: %u (%f/char), print time: %u (%f/char)\n", 
+	    parse_time, parse_time*1.0/parse_len,
+	    print_time, print_time*1.0/parse_len);
+    printf("Total time: %u (%f/char)\n", total_time, total_time*1.0/parse_len);
+    return err;
+}
+
+#else
+
+pj_status_t test_uri()
+{
+    struct uri_test *entry;
+    unsigned i;
+
+    warm_up();
+    pj_caching_pool_init(&cp, 1024*1024);
+
+    for (i=0; i<LOOP; ++i) {
+	entry = &uri_test_array[0];
+	while (entry->creator) {
+	    pj_pool_t *pool;
+	    pjsip_uri *uri1, *uri2;
+
+	    pool = pj_pool_create( &cp.factory, "", POOL_SIZE, 0, &pool_error);
+	    uri1 = pjsip_parse_uri(pool, entry->str, strlen(entry->str));
+	    pj_pool_release(pool);
+	    ++entry;
+	}
+    }
+
+    return 0;
+}
+
+#endif
Index: /pjproject/trunk/pjsip/src/test-pjsip/test.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/test.c	(revision 61)
+++ /pjproject/trunk/pjsip/src/test-pjsip/test.c	(revision 61)
@@ -0,0 +1,65 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+
+
+#include "test.h"
+#include <pjlib.h>
+#include <pjsip_core.h>
+
+#define DO_TEST(test)	do { \
+			    PJ_LOG(3, ("test", "Running %s...", #test));  \
+			    rc = test; \
+			    PJ_LOG(3, ("test",  \
+				       "%s(%d)",  \
+				       (rc ? "..ERROR" : "..success"), rc)); \
+			    if (rc!=0) goto on_return; \
+			} while (0)
+
+
+
+pjsip_endpoint *endpt;
+
+void app_perror(const char *msg, pj_status_t rc)
+{
+    char errbuf[256];
+
+    PJ_CHECK_STACK();
+
+    pjsip_strerror(rc, errbuf, sizeof(errbuf));
+    PJ_LOG(1,("test", "%s: [pj_status_t=%d] %s", msg, rc, errbuf));
+
+}
+
+
+
+int main()
+{
+    pj_status_t rc;
+
+    if ((rc=pj_init()) != PJ_SUCCESS) {
+	app_perror("pj_init", rc);
+    }
+
+    DO_TEST(parse_uri());
+    DO_TEST(parse_msg());
+
+on_return:
+    return 0;
+}
+
Index: /pjproject/trunk/pjsip/src/test-pjsip/test.h
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/test.h	(revision 60)
+++ /pjproject/trunk/pjsip/src/test-pjsip/test.h	(revision 61)
@@ -17,10 +17,20 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
  */
-#include <pj/types.h>
+#ifndef __TEST_H__
+#define __TEST_H__
 
-pj_status_t test_uri(void);
-pj_status_t test_msg(void);
+#include <pjsip/sip_types.h>
 
 #define SILENT		1
 #define IS_PROFILING	1
 #define LOOP		2000
+
+extern pjsip_endpoint *endpt;
+
+pj_status_t parse_uri(void);
+pj_status_t parse_msg(void);
+
+void app_perror(const char *msg, pj_status_t status);
+
+
+#endif	/* __TEST_H__ */
Index: project/trunk/pjsip/src/test-pjsip/test_msg.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/test_msg.c	(revision 60)
+++ 	(revision )
@@ -1,440 +1,0 @@
-/* $Id$ */
-/* 
- * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-#include <pjsip/sip_msg.h>
-#include <pjsip/sip_parser.h>
-#include <pj/os.h>
-#include <pj/pool.h>
-#include <pj/string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "test.h"
-
-#define ERR_SYNTAX_ERR	(-2)
-#define ERR_NOT_EQUAL	(-3)
-#define ERR_SYSTEM	(-4)
-
-
-static pjsip_msg *create_msg0(pj_pool_t *pool);
-
-struct test_msg
-{
-    char	 msg[1024];
-    pjsip_msg *(*creator)(pj_pool_t *pool);
-    pj_size_t	 len;
-} test_array[] = 
-{
-    {
-	/* 'Normal' message with all headers. */
-	"INVITE sip:user@foo SIP/2.0\n"
-	"From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r"
-	"To: Fellow User <sip:user@foo.bar.domain.com>\r\n"
-	"Call-ID: 12345678901234567890@bar\r\n"
-	"Content-Length: 0\r\n"
-	"CSeq: 123456 INVITE\n"
-	"Contact: <sip:joe@bar> ; q=0.5;expires=3600,sip:user@host;q=0.500\r"
-	"  ,sip:user2@host2\n"
-	"Content-Type: text/html ; charset=ISO-8859-4\r"
-	"Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n"
-	"  <sip:server10.biloxi.com;lr>\r"
-	"Record-Route: <sip:server10.biloxi.com>,\r\n"
-	"  <sip:bigbox3.site3.atlanta.com;lr>\n"
-	"Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n"
-	"Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n"
-	" ;received=192.0.2.1\r\n"
-	"Via: SIP/2.0/UDP 10.2.1.1, SIP/2.0/TCP 192.168.1.1\n"
-	"Organization: \r"
-	"Max-Forwards: 70\n"
-	"X-Header: \r\n"
-	"\r",
-	&create_msg0
-    }
-};
-
-static pj_caching_pool cp;
-static pj_pool_factory *pf = &cp.factory;
-static pj_uint32_t parse_len, parse_time, print_time;
-
-static void pool_error(pj_pool_t *pool, pj_size_t sz)
-{
-    PJ_UNUSED_ARG(pool)
-    PJ_UNUSED_ARG(sz)
-
-    pj_assert(0);
-    exit(1);
-}
-
-static const char *STATUS_STR(pj_status_t status)
-{
-    switch (status) {
-    case 0: return "OK";
-    case ERR_SYNTAX_ERR: return "Syntax Error";
-    case ERR_NOT_EQUAL: return "Not Equal";
-    case ERR_SYSTEM: return "System Error";
-    }
-    return "???";
-}
-
-static pj_status_t test_entry( struct test_msg *entry )
-{
-    pjsip_msg *parsed_msg, *ref_msg;
-    pj_pool_t *pool;
-    pj_status_t status = PJ_SUCCESS;
-    int len;
-    pj_str_t str1, str2;
-    pjsip_hdr *hdr1, *hdr2;
-    pj_hr_timestamp t1, t2;
-    char *msgbuf;
-
-    enum { BUFLEN = 512 };
-    
-    pool = pj_pool_create( pf, "", 
-			   PJSIP_POOL_LEN_RDATA*2, PJSIP_POOL_INC_RDATA, 
-			   &pool_error);
-
-    if (entry->len == 0) {
-	entry->len = strlen(entry->msg);
-    }
-
-    /* Parse message. */
-    parse_len += entry->len;
-    pj_hr_gettimestamp(&t1);
-    parsed_msg = pjsip_parse_msg(pool, entry->msg, entry->len, NULL);
-    if (parsed_msg == NULL) {
-	status = ERR_SYNTAX_ERR;
-	goto on_return;
-    }
-    pj_hr_gettimestamp(&t2);
-    parse_time += t2.u32.lo - t1.u32.lo;
-
-#if IS_PROFILING
-    goto print_msg;
-#endif
-
-    /* Create reference message. */
-    ref_msg = entry->creator(pool);
-
-    /* Create buffer for comparison. */
-    str1.ptr = pj_pool_alloc(pool, BUFLEN);
-    str2.ptr = pj_pool_alloc(pool, BUFLEN);
-
-    /* Compare message type. */
-    if (parsed_msg->type != ref_msg->type) {
-	status = ERR_NOT_EQUAL;
-	goto on_return;
-    }
-
-    /* Compare request or status line. */
-    if (parsed_msg->type == PJSIP_REQUEST_MSG) {
-	pjsip_method *m1 = &parsed_msg->line.req.method;
-	pjsip_method *m2 = &ref_msg->line.req.method;
-
-	if (m1->id != m2->id || pj_strcmp(&m1->name, &m2->name)) {
-	    status = ERR_NOT_EQUAL;
-	    goto on_return;
-	}
-    } else {
-
-    }
-
-    /* Compare headers. */
-    hdr1 = parsed_msg->hdr.next;
-    hdr2 = ref_msg->hdr.next;
-
-    while (hdr1 != &parsed_msg->hdr && hdr2 != &ref_msg->hdr) {
-	len = hdr1->vptr->print_on(hdr1, str1.ptr, BUFLEN);
-	if (len < 1) {
-	    status = ERR_SYSTEM;
-	    goto on_return;
-	}
-	str1.slen = len;
-
-	len = hdr2->vptr->print_on(hdr2, str2.ptr, BUFLEN);
-	if (len < 1) {
-	    status = ERR_SYSTEM;
-	    goto on_return;
-	}
-	str2.slen = len;
-
-	if (!SILENT) {
-	    printf("hdr1='%.*s'\n"
-		   "hdr2='%.*s'\n\n",
-		   str1.slen, str1.ptr,
-		   str2.slen, str2.ptr);
-	}
-	if (pj_strcmp(&str1, &str2) != 0) {
-	    status = ERR_NOT_EQUAL;
-	    goto on_return;
-	}
-
-	hdr1 = hdr1->next;
-	hdr2 = hdr2->next;
-    }
-
-    if (hdr1 != &parsed_msg->hdr || hdr2 != &ref_msg->hdr) {
-	status = ERR_NOT_EQUAL;
-	goto on_return;
-    }
-
-    /* Print message. */
-#if IS_PROFILING
-print_msg:
-#endif
-    msgbuf = pj_pool_alloc(pool, PJSIP_MAX_PKT_LEN);
-    if (msgbuf == NULL) {
-	status = ERR_SYSTEM;
-	goto on_return;
-    }
-    pj_hr_gettimestamp(&t1);
-    len = pjsip_msg_print(parsed_msg, msgbuf, PJSIP_MAX_PKT_LEN);
-    if (len < 1) {
-	status = ERR_SYSTEM;
-	goto on_return;
-    }
-    pj_hr_gettimestamp(&t2);
-    print_time += t2.u32.lo - t1.u32.lo;
-    status = PJ_SUCCESS;
-
-on_return:
-    pj_pool_release(pool);
-    return status;
-}
-
-static void warm_up()
-{
-    pj_pool_t *pool;
-    pool = pj_pool_create( pf, "", 
-			   PJSIP_POOL_LEN_RDATA*2, PJSIP_POOL_INC_RDATA, 
-			   &pool_error);
-    pj_pool_release(pool);
-}
-
-
-pj_status_t test_msg(void)
-{
-    pj_status_t status;
-    unsigned i;
-
-    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
-    warm_up();
-
-    for (i=0; i<LOOP; ++i) {
-	status = test_entry( &test_array[0] );
-    }
-    printf("%s\n", STATUS_STR(status));
-
-    printf("Total bytes: %u, parse time=%f/char, print time=%f/char\n", 
-	   parse_len, 
-	   parse_time*1.0/parse_len,
-	   print_time*1.0/parse_len);
-    return PJ_SUCCESS;
-}
-
-/*****************************************************************************/
-
-static pjsip_msg *create_msg0(pj_pool_t *pool)
-{
-
-    pjsip_msg *msg;
-    pjsip_name_addr *name_addr;
-    pjsip_url *url;
-    pjsip_fromto_hdr *fromto;
-    pjsip_cid_hdr *cid;
-    pjsip_clen_hdr *clen;
-    pjsip_cseq_hdr *cseq;
-    pjsip_contact_hdr *contact;
-    pjsip_ctype_hdr *ctype;
-    pjsip_routing_hdr *routing;
-    pjsip_via_hdr *via;
-    pjsip_generic_string_hdr *generic;
-    pj_str_t str;
-
-    msg = pjsip_msg_create(pool, PJSIP_REQUEST_MSG);
-
-    /* "INVITE sip:user@foo SIP/2.0\n" */
-    pjsip_method_set(&msg->line.req.method, PJSIP_INVITE_METHOD);
-    url = pjsip_url_create(pool, 0);
-    msg->line.req.uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "user");
-    pj_strdup2(pool, &url->host, "foo");
-
-    /* "From: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=1234578901234567890\r" */
-    fromto = pjsip_from_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)fromto);
-    pj_strdup2(pool, &fromto->tag, "1234578901234567890");
-    name_addr = pjsip_name_addr_create(pool);
-    fromto->uri = (pjsip_uri*)name_addr;
-    pj_strdup2(pool, &name_addr->display, "Hi I'm Joe");
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "joe.user");
-    pj_strdup2(pool, &url->host, "bar.otherdomain.com");
-
-    /* "To: Fellow User <sip:user@foo.bar.domain.com>\r\n" */
-    fromto = pjsip_to_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)fromto);
-    name_addr = pjsip_name_addr_create(pool);
-    fromto->uri = (pjsip_uri*)name_addr;
-    pj_strdup2(pool, &name_addr->display, "Fellow User");
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "user");
-    pj_strdup2(pool, &url->host, "foo.bar.domain.com");
-
-    /* "Call-ID: 12345678901234567890@bar\r\n" */
-    cid = pjsip_cid_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)cid);
-    pj_strdup2(pool, &cid->id, "12345678901234567890@bar");
-
-    /* "Content-Length: 0\r\n" */
-    clen = pjsip_clen_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)clen);
-    clen->len = 0;
-
-    /* "CSeq: 123456 INVITE\n" */
-    cseq = pjsip_cseq_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)cseq);
-    cseq->cseq = 123456;
-    pjsip_method_set(&cseq->method, PJSIP_INVITE_METHOD);
-
-    /* "Contact: <sip:joe@bar>;q=0.5;expires=3600*/
-    contact = pjsip_contact_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
-    contact->q1000 = 500;
-    contact->expires = 3600;
-    name_addr = pjsip_name_addr_create(pool);
-    contact->uri = (pjsip_uri*)name_addr;
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "joe");
-    pj_strdup2(pool, &url->host, "bar");
-
-    /*, sip:user@host;q=0.500\r" */
-    contact = pjsip_contact_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
-    contact->q1000 = 500;
-    url = pjsip_url_create(pool, 0);
-    contact->uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "user");
-    pj_strdup2(pool, &url->host, "host");
-
-    /* "  ,sip:user2@host2\n" */
-    contact = pjsip_contact_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)contact);
-    url = pjsip_url_create(pool, 0);
-    contact->uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->user, "user2");
-    pj_strdup2(pool, &url->host, "host2");
-
-    /* "Content-Type: text/html; charset=ISO-8859-4\r" */
-    ctype = pjsip_ctype_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)ctype);
-    pj_strdup2(pool, &ctype->media.type, "text");
-    pj_strdup2(pool, &ctype->media.subtype, "html");
-    pj_strdup2(pool, &ctype->media.param, ";charset=ISO-8859-4");
-
-    /* "Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n" */
-    routing = pjsip_route_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
-    url = pjsip_url_create(pool, 0);
-    routing->name_addr.uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->host, "bigbox3.site3.atlanta.com");
-    url->lr_param = 1;
-
-    /* "  <sip:server10.biloxi.com;lr>\r" */
-    routing = pjsip_route_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
-    url = pjsip_url_create(pool, 0);
-    routing->name_addr.uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->host, "server10.biloxi.com");
-    url->lr_param = 1;
-
-    /* "Record-Route: <sip:server10.biloxi.com>,\r\n" */
-    routing = pjsip_rr_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
-    url = pjsip_url_create(pool, 0);
-    routing->name_addr.uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->host, "server10.biloxi.com");
-    url->lr_param = 0;
-
-    /* "  <sip:bigbox3.site3.atlanta.com;lr>\n" */
-    routing = pjsip_rr_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)routing);
-    url = pjsip_url_create(pool, 0);
-    routing->name_addr.uri = (pjsip_uri*)url;
-    pj_strdup2(pool, &url->host, "bigbox3.site3.atlanta.com");
-    url->lr_param = 1;
-
-    /* "Via: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1\n" */
-    via = pjsip_via_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
-    pj_strdup2(pool, &via->transport, "SCTP");
-    pj_strdup2(pool, &via->sent_by.host, "bigbox3.site3.atlanta.com");
-    pj_strdup2(pool, &via->branch_param, "z9hG4bK77ef4c2312983.1");
-
-    /* "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n"
-	" ;received=192.0.2.1\r\n" */
-    via = pjsip_via_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
-    pj_strdup2(pool, &via->transport, "UDP");
-    pj_strdup2(pool, &via->sent_by.host, "pc33.atlanta.com");
-    pj_strdup2(pool, &via->branch_param, "z9hG4bKnashds8");
-    pj_strdup2(pool, &via->recvd_param, "192.0.2.1");
-
-
-    /* "Via: SIP/2.0/UDP 10.2.1.1, */ 
-    via = pjsip_via_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
-    pj_strdup2(pool, &via->transport, "UDP");
-    pj_strdup2(pool, &via->sent_by.host, "10.2.1.1");
-    
-    
-    /*SIP/2.0/TCP 192.168.1.1\n" */
-    via = pjsip_via_hdr_create(pool);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)via);
-    pj_strdup2(pool, &via->transport, "TCP");
-    pj_strdup2(pool, &via->sent_by.host, "192.168.1.1");
-
-    /* "Organization: \r" */
-    str.ptr = "Organization";
-    str.slen = 12;
-    generic = pjsip_generic_string_hdr_create(pool, &str);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
-    generic->hvalue.ptr = NULL;
-    generic->hvalue.slen = 0;
-
-    /* "Max-Forwards: 70\n" */
-    str.ptr = "Max-Forwards";
-    str.slen = 12;
-    generic = pjsip_generic_string_hdr_create(pool, &str);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
-    str.ptr = "70";
-    str.slen = 2;
-    generic->hvalue = str;
-
-    /* "X-Header: \r\n" */
-    str.ptr = "X-Header";
-    str.slen = 8;
-    generic = pjsip_generic_string_hdr_create(pool, &str);
-    pjsip_msg_add_hdr(msg, (pjsip_hdr*)generic);
-    str.ptr = NULL;
-    str.slen = 0;
-    generic->hvalue = str;
-
-    return msg;
-}
Index: project/trunk/pjsip/src/test-pjsip/test_uri.c
===================================================================
--- /pjproject/trunk/pjsip/src/test-pjsip/test_uri.c	(revision 60)
+++ 	(revision )
@@ -1,660 +1,0 @@
-/* $Id$ */
-/* 
- * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 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
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
- */
-#include <pjsip/sip_parser.h>
-#include <pjsip/sip_uri.h>
-#include <pj/os.h>
-#include <pj/pool.h>
-#include <pj/string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "test.h"
-
-#define ERR_SYNTAX_ERR	(-2)
-#define ERR_NOT_EQUAL	(-3)
-
-#define ALPHANUM    "abcdefghijklmnopqrstuvwxyz" \
-		    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
-		    "0123456789"
-#define MARK	    "-_.!~*'()"
-#define USER	    "&=+$,;?/%"
-#define PASS	    "&=+$,%"
-#define PARAM_CHAR  "[]/:&+$" MARK "%"
-
-#define POOL_SIZE	4096
-
-static const char *STATUS_STR(pj_status_t status)
-{
-    switch (status) {
-    case 0: return "OK";
-    case ERR_SYNTAX_ERR: return "Syntax Error";
-    case ERR_NOT_EQUAL: return "Not Equal";
-    }
-    return "???";
-}
-
-static pj_uint32_t parse_len, parse_time, print_time;
-static pj_caching_pool cp;
-
-
-/* URI creator functions. */
-static pjsip_uri *create_uri1( pj_pool_t *pool );
-static pjsip_uri *create_uri2( pj_pool_t *pool );
-static pjsip_uri *create_uri3( pj_pool_t *pool );
-static pjsip_uri *create_uri4( pj_pool_t *pool );
-static pjsip_uri *create_uri5( pj_pool_t *pool );
-static pjsip_uri *create_uri6( pj_pool_t *pool );
-static pjsip_uri *create_uri7( pj_pool_t *pool );
-static pjsip_uri *create_uri8( pj_pool_t *pool );
-static pjsip_uri *create_uri9( pj_pool_t *pool );
-static pjsip_uri *create_uri10( pj_pool_t *pool );
-static pjsip_uri *create_uri11( pj_pool_t *pool );
-static pjsip_uri *create_uri12( pj_pool_t *pool );
-static pjsip_uri *create_uri13( pj_pool_t *pool );
-static pjsip_uri *create_uri14( pj_pool_t *pool );
-static pjsip_uri *create_uri15( pj_pool_t *pool );
-static pjsip_uri *create_uri16( pj_pool_t *pool );
-static pjsip_uri *create_uri17( pj_pool_t *pool );
-static pjsip_uri *create_uri18( pj_pool_t *pool );
-static pjsip_uri *create_uri19( pj_pool_t *pool );
-static pjsip_uri *create_dummy( pj_pool_t *pool );
-
-struct uri_test
-{
-    pj_status_t	     status;
-    char	     str[PJSIP_MAX_URL_SIZE];
-    pjsip_uri *(*creator)(pj_pool_t *pool);
-    pj_size_t	     len;
-} uri_test_array[] = 
-{
-    {
-	PJ_SUCCESS,
-	"sip:localhost",
-	&create_uri1
-    },
-    {
-	PJ_SUCCESS,
-	"sip:user@localhost",
-	&create_uri2
-    },
-    {
-	PJ_SUCCESS,
-	"sip:user:password@localhost:5060",
-	&create_uri3,
-    },
-    {
-	/* Port is specified should not match unspecified port. */
-	ERR_NOT_EQUAL,
-	"sip:localhost:5060",
-	&create_uri4
-    },
-    {
-	/* All recognized parameters. */
-	PJ_SUCCESS,
-	"sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK",
-	&create_uri5
-    },
-    {
-	/* Params mixed with other params and header params. */
-	PJ_SUCCESS,
-	"sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
-	"?Subject=Hello%20There&Server=SIP%20Server",
-	&create_uri6
-    },
-    {
-	/* SIPS. */
-	PJ_SUCCESS,
-	"sips:localhost",
-	&create_uri7,
-    },
-    {
-	/* Name address */
-	PJ_SUCCESS,
-	"<sip:localhost>",
-	&create_uri8
-    },
-    {
-	/* Name address with display name and SIPS scheme with some redundant
-	 * whitespaced.
-	 */
-	PJ_SUCCESS,
-	"  Power Administrator  <sips:localhost>",
-	&create_uri9
-    },
-    {
-	/* Name address. */
-	PJ_SUCCESS,
-	" \"User\" <sip:user@localhost:5071>",
-	&create_uri10
-    },
-    {
-	/* Escaped sequence in display name (display=Strange User\"\\\"). */
-	PJ_SUCCESS,
-	" \"Strange User\\\"\\\\\\\"\" <sip:localhost>",
-	&create_uri11,
-    },
-    {
-	/* Errorneous escaping in display name. */
-	ERR_SYNTAX_ERR,
-	" \"Rogue User\\\" <sip:localhost>",
-	&create_uri12,
-    },
-    {
-	/* Dangling quote in display name, but that should be OK. */
-	PJ_SUCCESS,
-	"Strange User\" <sip:localhost>",
-	&create_uri13,
-    },
-    {
-	/* Special characters in parameter value must be quoted. */
-	PJ_SUCCESS,
-	"sip:localhost;pvalue=\"hello world\"",
-	&create_uri14,
-    },
-    {
-	/* Excercise strange character sets allowed in display, user, password,
-	 * host, and port. 
-	 */
-	PJ_SUCCESS,
-	"This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%09a&Zz=+$,@"
-	"my_proxy09.MY-domain.com:9801>",
-	&create_uri15,
-    },
-    {
-	/* Another excercise to the allowed character sets to the hostname. */
-	PJ_SUCCESS,
-	"sip:" ALPHANUM "-_.com",
-	&create_uri16,
-    },
-    {
-	/* Another excercise to the allowed character sets to the username 
-	 * and password.
-	 */
-	PJ_SUCCESS,
-	"sip:" ALPHANUM USER ":" ALPHANUM PASS "@host",
-	&create_uri17,
-    },
-    {
-	/* Excercise to the pname and pvalue, and mixup of other-param
-	 * between 'recognized' params.
-	 */
-	PJ_SUCCESS,
-	"sip:host;user=ip;" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR 
-	";lr;other=1;transport=sctp;other2",
-	&create_uri18,
-    },
-    {
-	/* This should trigger syntax error. */
-	ERR_SYNTAX_ERR,
-	"sip:",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: whitespace after scheme. */
-	ERR_SYNTAX_ERR,
-	"sip :host",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: whitespace before hostname. */
-	ERR_SYNTAX_ERR,
-	"sip: host",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: invalid port. */
-	ERR_SYNTAX_ERR,
-	"sip:user:password",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: no host. */
-	ERR_SYNTAX_ERR,
-	"sip:user@",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: no user/host. */
-	ERR_SYNTAX_ERR,
-	"sip:@",
-	&create_dummy,
-    },
-    {
-	/* Syntax error: empty string. */
-	ERR_SYNTAX_ERR,
-	"",
-	&create_dummy,
-    },
-    {
-	PJ_SUCCESS,
-	"",
-	NULL,
-    },
-};
-
-static pjsip_uri *create_uri1(pj_pool_t *pool)
-{
-    /* "sip:localhost" */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri2(pj_pool_t *pool)
-{
-    /* "sip:user@localhost" */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2( pool, &url->user, "user");
-    pj_strdup2( pool, &url->host, "localhost");
-
-    return (pjsip_uri*) url;
-}
-
-static pjsip_uri *create_uri3(pj_pool_t *pool)
-{
-    /* "sip:user:password@localhost:5060" */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2( pool, &url->user, "user");
-    pj_strdup2( pool, &url->passwd, "password");
-    pj_strdup2( pool, &url->host, "localhost");
-    url->port = 5060;
-
-    return (pjsip_uri*) url;
-}
-
-static pjsip_uri *create_uri4(pj_pool_t *pool)
-{
-    /* Like: "sip:localhost:5060", but without the port. */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri5(pj_pool_t *pool)
-{
-    /* "sip:localhost;transport=tcp;user=ip;ttl=255;lr;maddr=127.0.0.1;method=ACK" */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2(pool, &url->host, "localhost");
-    pj_strdup2(pool, &url->transport_param, "tcp");
-    pj_strdup2(pool, &url->user_param, "ip");
-    url->ttl_param = 255;
-    url->lr_param = 1;
-    pj_strdup2(pool, &url->maddr_param, "127.0.0.1");
-    pj_strdup2(pool, &url->method_param, "ACK");
-
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri6(pj_pool_t *pool)
-{
-    /* "sip:localhost;pickup=hurry;user=phone;message=I%20am%20sorry"
-       "?Subject=Hello%20There&Server=SIP%20Server" 
-     */
-    pjsip_url *url = pjsip_url_create(pool, 0);
-
-    pj_strdup2(pool, &url->host, "localhost");
-    pj_strdup2(pool, &url->user_param, "phone");
-    pj_strdup2(pool, &url->other_param, ";pickup=hurry;message=I%20am%20sorry");
-    pj_strdup2(pool, &url->header_param, "?Subject=Hello%20There&Server=SIP%20Server");
-    return (pjsip_uri*)url;
-
-}
-
-static pjsip_uri *create_uri7(pj_pool_t *pool)
-{
-    /* "sips:localhost" */
-    pjsip_url *url = pjsip_url_create(pool, 1);
-
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri8(pj_pool_t *pool)
-{
-    /* "<sip:localhost>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri9(pj_pool_t *pool)
-{
-    /* "  Power Administrator <sips:localhost>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 1);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "Power Administrator");
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri10(pj_pool_t *pool)
-{
-    /* " \"User\" <sip:user@localhost:5071>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "\"User\"");
-    pj_strdup2(pool, &url->user, "user");
-    pj_strdup2(pool, &url->host, "localhost");
-    url->port = 5071;
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri11(pj_pool_t *pool)
-{
-    /* " \"Strange User\\\"\\\\\\\"\" <sip:localhost>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "\"Strange User\\\"\\\\\\\"\"");
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri12(pj_pool_t *pool)
-{
-    /* " \"Rogue User\\\" <sip:localhost>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "\"Rogue User\\\"");
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri13(pj_pool_t *pool)
-{
-    /* "Strange User\" <sip:localhost>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "Strange User\"");
-    pj_strdup2(pool, &url->host, "localhost");
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri14(pj_pool_t *pool)
-{
-    /* "sip:localhost;pvalue=\"hello world\"" */
-    pjsip_url *url;
-    url = pjsip_url_create(pool, 0);
-    pj_strdup2(pool, &url->host, "localhost");
-    pj_strdup2(pool, &url->other_param, ";pvalue=\"hello world\"");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri15(pj_pool_t *pool)
-{
-    /* "This is -. !% *_+`'~ me <sip:a19A&=+$,;?/%2c:%09a&Zz=+$,@my_proxy09.my-domain.com:9801>" */
-    pjsip_name_addr *name_addr = pjsip_name_addr_create(pool);
-    pjsip_url *url;
-
-    url = pjsip_url_create(pool, 0);
-    name_addr->uri = (pjsip_uri*) url;
-
-    pj_strdup2(pool, &name_addr->display, "This is -. !% *_+`'~ me");
-    pj_strdup2(pool, &url->user, "a19A&=+$,;?/%2c");
-    pj_strdup2(pool, &url->passwd, "%09a&Zz=+$,");
-    pj_strdup2(pool, &url->host, "my_proxy09.MY-domain.com");
-    url->port = 9801;
-    return (pjsip_uri*)name_addr;
-}
-
-static pjsip_uri *create_uri16(pj_pool_t *pool)
-{
-    /* "sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com" */
-    pjsip_url *url;
-    url = pjsip_url_create(pool, 0);
-    pj_strdup2(pool, &url->host, ALPHANUM "-_.com");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri17(pj_pool_t *pool)
-{
-    /* "sip:" ALPHANUM USER ":" ALPHANUM PASS "@host" */
-    pjsip_url *url;
-    url = pjsip_url_create(pool, 0);
-    pj_strdup2(pool, &url->user, ALPHANUM USER);
-    pj_strdup2(pool, &url->passwd, ALPHANUM PASS);
-    pj_strdup2(pool, &url->host, "host");
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_uri18(pj_pool_t *pool)
-{
-    /* "sip:host;user=ip;" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR ";lr;other=1;transport=sctp;other2" */
-    pjsip_url *url;
-    url = pjsip_url_create(pool, 0);
-    pj_strdup2(pool, &url->host, "host");
-    pj_strdup2(pool, &url->user_param, "ip");
-    pj_strdup2(pool, &url->transport_param, "sctp");
-    pj_strdup2(pool, &url->other_param, ";" ALPHANUM PARAM_CHAR "=" ALPHANUM PARAM_CHAR ";other=1;other2");    
-    url->lr_param = 1;
-    return (pjsip_uri*)url;
-}
-
-static pjsip_uri *create_dummy(pj_pool_t *pool)
-{
-    PJ_UNUSED_ARG(pool)
-    return NULL;
-}
-
-/*****************************************************************************/
-
-static void pool_error(pj_pool_t *pool, pj_size_t sz)
-{
-    PJ_UNUSED_ARG(pool)
-    PJ_UNUSED_ARG(sz)
-
-    pj_assert(0);
-    exit(1);
-}
-
-/*
- * Test one test entry.
- */
-static pj_status_t test_entry(struct uri_test *entry)
-{
-    pj_status_t status;
-    pj_pool_t *pool;
-    int len;
-    pjsip_uri *parsed_uri, *ref_uri;
-    pj_str_t s1 = {NULL, 0}, s2 = {NULL, 0};
-    pj_hr_timestamp t1, t2;
-
-    pool = (*cp.factory.create_pool)( &cp.factory, "", POOL_SIZE, 0, &pool_error);
-
-    /* Parse URI text. */
-    pj_hr_gettimestamp(&t1);
-    parse_len += entry->len;
-    parsed_uri = pjsip_parse_uri(pool, entry->str, entry->len, 0);
-    if (!parsed_uri) {
-	/* Parsing failed. If the entry says that this is expected, then
-	 * return OK.
-	 */
-	status = entry->status==ERR_SYNTAX_ERR ? PJ_SUCCESS : ERR_SYNTAX_ERR;
-	goto on_return;
-    }
-    pj_hr_gettimestamp(&t2);
-    parse_time += t2.u32.lo - t1.u32.lo;
-
-    /* Create the reference URI. */
-    ref_uri = entry->creator(pool);
-
-    /* Print both URI. */
-    s1.ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
-    s2.ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
-
-    pj_hr_gettimestamp(&t1);
-    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, parsed_uri, s1.ptr, PJSIP_MAX_URL_SIZE);
-    if (len < 1) {
-	status = -1;
-	goto on_return;
-    }
-    s1.slen = len;
-
-    len = pjsip_uri_print( PJSIP_URI_IN_OTHER, ref_uri, s2.ptr, PJSIP_MAX_URL_SIZE);
-    if (len < 1) {
-	status = -1;
-	goto on_return;
-    }
-    s2.slen = len;
-    pj_hr_gettimestamp(&t2);
-    print_time += t2.u32.lo - t1.u32.lo;
-
-    /* Full comparison of parsed URI with reference URI. */
-    if (pjsip_uri_cmp(PJSIP_URI_IN_OTHER, parsed_uri, ref_uri) != 0) {
-	/* Not equal. See if this is the expected status. */
-	status = entry->status==ERR_NOT_EQUAL ? PJ_SUCCESS : ERR_NOT_EQUAL;
-	goto on_return;
-
-    } else {
-	/* Equal. See if this is the expected status. */
-	status = entry->status==PJ_SUCCESS ? PJ_SUCCESS : -1;
-	if (status != PJ_SUCCESS) {
-	    goto on_return;
-	}
-    }
-
-    /* Compare text. */
-    if (pj_strcmp(&s1, &s2) != 0) {
-	/* Not equal. */
-	status = ERR_NOT_EQUAL;
-    }
-
-on_return:
-    if (!SILENT) {
-	printf("%.2d %s (expected status=%s)\n"
-	       "   str=%s\n"
-	       "   uri=%.*s\n"
-	       "   ref=%.*s\n\n", 
-	       entry-uri_test_array, 
-	       STATUS_STR(status), 
-	       STATUS_STR(entry->status), 
-	       entry->str, 
-	       (int)s1.slen, s1.ptr, (int)s2.slen, s2.ptr);
-    }
-
-    pj_pool_release(pool);
-    return status;
-}
-
-static void warm_up(pj_pool_factory *pf)
-{
-    pj_pool_t *pool;
-    struct uri_test *entry;
-
-    pool = pj_pool_create(pf, "", POOL_SIZE, 0, &pool_error);
-    pjsip_parse_uri(pool, "sip:host", 8, 0);
-    entry = &uri_test_array[0];
-    while (entry->creator) {
-	entry->len = strlen(entry->str);
-	++entry;
-    }
-    pj_pool_release(pool);
-}
-
-//#if !IS_PROFILING
-#if 1
-pj_status_t test_uri()
-{
-    struct uri_test *entry;
-    int i=0, err=0;
-    pj_status_t status;
-    pj_hr_timestamp t1, t2;
-    pj_uint32_t total_time;
-
-    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
-    warm_up(&cp.factory);
-
-    pj_hr_gettimestamp(&t1);
-    for (i=0; i<LOOP; ++i) {
-	entry = &uri_test_array[0];
-	while (entry->creator) {
-	    status = test_entry(entry);
-	    if (status != PJ_SUCCESS) {
-		++err;
-	    }
-	    ++entry;
-	}
-    }
-    pj_hr_gettimestamp(&t2);
-    total_time = t2.u32.lo - t1.u32.lo;
-
-    printf("Error=%d\n", err);
-    printf("Total parse len:  %u bytes\n", parse_len);
-    printf("Total parse time: %u (%f/char), print time: %u (%f/char)\n", 
-	    parse_time, parse_time*1.0/parse_len,
-	    print_time, print_time*1.0/parse_len);
-    printf("Total time: %u (%f/char)\n", total_time, total_time*1.0/parse_len);
-    return err;
-}
-
-#else
-
-pj_status_t test_uri()
-{
-    struct uri_test *entry;
-    unsigned i;
-
-    warm_up();
-    pj_caching_pool_init(&cp, 1024*1024);
-
-    for (i=0; i<LOOP; ++i) {
-	entry = &uri_test_array[0];
-	while (entry->creator) {
-	    pj_pool_t *pool;
-	    pjsip_uri *uri1, *uri2;
-
-	    pool = pj_pool_create( &cp.factory, "", POOL_SIZE, 0, &pool_error);
-	    uri1 = pjsip_parse_uri(pool, entry->str, strlen(entry->str));
-	    pj_pool_release(pool);
-	    ++entry;
-	}
-    }
-
-    return 0;
-}
-
-#endif
