Index: /pjproject/branches/symbian/pjlib/build/pjlib.dsp
===================================================================
--- /pjproject/branches/symbian/pjlib/build/pjlib.dsp	(revision 691)
+++ /pjproject/branches/symbian/pjlib/build/pjlib.dsp	(revision 692)
@@ -111,4 +111,9 @@
 # Begin Source File
 
+SOURCE=..\src\pj\ioqueue_symbian.cpp
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
 SOURCE=..\src\pj\log_writer_printk.c
 # PROP Exclude_From_Build 1
@@ -162,4 +167,9 @@
 
 SOURCE=..\src\pj\sock_linux_kernel.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\src\pj\sock_select_symbian.cpp
 # PROP Exclude_From_Build 1
 # End Source File
Index: /pjproject/branches/symbian/pjlib/include/pj/compat/cc_codew.h
===================================================================
--- /pjproject/branches/symbian/pjlib/include/pj/compat/cc_codew.h	(revision 692)
+++ /pjproject/branches/symbian/pjlib/include/pj/compat/cc_codew.h	(revision 692)
@@ -0,0 +1,51 @@
+/* $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 
+ */
+#ifndef __PJ_COMPAT_CC_GCC_H__
+#define __PJ_COMPAT_CC_GCC_H__
+
+/**
+ * @file cc_codew.h
+ * @brief Describes MetroWerks Code Warrior compiler specifics.
+ */
+
+#ifndef __MWERKS__
+#  error "This file is only for Code Warrior!"
+#endif
+
+#define PJ_CC_NAME		"codewarrior"
+#define PJ_CC_VER_1		((__MWERKS__ & 0xF000) >> 12)
+#define PJ_CC_VER_2		((__MWERKS__ & 0x0F00) >> 8)
+#define PJ_CC_VER_3		((__MWERKS__ & 0xFF))
+
+
+#define PJ_INLINE_SPECIFIER	static inline
+#define PJ_THREAD_FUNC	
+#define PJ_NORETURN		
+#define PJ_ATTR_NORETURN	
+
+#define PJ_HAS_INT64		1
+
+typedef long long pj_int64_t;
+typedef unsigned long long pj_uint64_t;
+
+#define PJ_INT64_FMT		"L"
+
+
+#endif	/* __PJ_COMPAT_CC_GCC_H__ */
+
Index: /pjproject/branches/symbian/pjlib/include/pj/compat/os_symbian.h
===================================================================
--- /pjproject/branches/symbian/pjlib/include/pj/compat/os_symbian.h	(revision 691)
+++ /pjproject/branches/symbian/pjlib/include/pj/compat/os_symbian.h	(revision 692)
@@ -92,7 +92,8 @@
 #define PJ_BLOCKING_CONNECT_ERROR_VAL   EINPROGRESS
 
-#ifndef PJ_HAS_THREADS
-#  define PJ_HAS_THREADS	    (1)
-#endif
+/*
+ * We don't want to use threads in Symbian
+ */
+#define PJ_HAS_THREADS		    0
 
 
@@ -107,12 +108,10 @@
  * Override features.
  */
-#define PJ_HAS_FLOATING_POINT	    0
-#define PJ_HAS_MALLOC               0
-#define PJ_HAS_SEMAPHORE	    0
+#define PJ_HAS_FLOATING_POINT	    1
+#define PJ_HAS_MALLOC               1
+#define PJ_HAS_SEMAPHORE	    1
 #define PJ_HAS_EVENT_OBJ	    0
 #define PJ_HAS_HIGH_RES_TIMER	    1
-#ifndef PJ_OS_HAS_CHECK_STACK
-#   define PJ_OS_HAS_CHECK_STACK    0
-#endif
+#define PJ_OS_HAS_CHECK_STACK       0
 #define PJ_TERM_HAS_COLOR	    0
 #define PJ_NATIVE_STRING_IS_UNICODE 0
@@ -122,5 +121,5 @@
 
 /* If 1, use Read/Write mutex emulation for platforms that don't support it */
-#define PJ_EMULATE_RWMUTEX	    0
+#define PJ_EMULATE_RWMUTEX	    1
 
 /* If 1, pj_thread_create() should enforce the stack size when creating
Index: /pjproject/branches/symbian/pjlib/include/pj/config.h
===================================================================
--- /pjproject/branches/symbian/pjlib/include/pj/config.h	(revision 691)
+++ /pjproject/branches/symbian/pjlib/include/pj/config.h	(revision 692)
@@ -34,4 +34,6 @@
 #elif defined(__CW32__)
 #  include <pj/compat/cc_mwcc.h>
+#elif defined(__MWERKS__)
+#  include <pj/compat/cc_codew.h>
 #else
 #  error "Unknown compiler."
Index: project/branches/symbian/pjlib/src/pj/compat/string.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/compat/string.c	(revision 691)
+++ 	(revision )
@@ -1,69 +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 <pj/types.h>
-#include <pj/compat/string.h>
-#include <pj/ctype.h>
-
-#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
-/* Nothing to do */
-#else
-PJ_DEF(int) strcasecmp(const char *s1, const char *s2)
-{
-    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
-	if (!*s1++)
-	    return 0;
-	++s2;
-    }
-    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
-}
-
-PJ_DEF(int) strncasecmp(const char *s1, const char *s2, int len)
-{
-    if (!len) return 0;
-
-    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
-	if (!*s1++ || --len <= 0)
-	    return 0;
-	++s2;
-    }
-    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
-}
-#endif
-
-#if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
-
-PJ_DEF(int) snprintf(char *s1, pj_size_t len, const char *s2, ...)
-{
-    int ret;
-    
-    va_list arg;
-    va_start(arg, s2);
-    ret = vsprintf(s1, s2, arg);
-    va_end(arg);
-    
-    return ret;
-}
-
-PJ_DEF(int) vsnprintf(char *s1, pj_size_t len, const char *s2, va_list arg)
-{
-    return vsprintf(s1,s2,arg);
-}
-
-#endif
-
Index: /pjproject/branches/symbian/pjlib/src/pj/compat/string_compat.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/compat/string_compat.c	(revision 692)
+++ /pjproject/branches/symbian/pjlib/src/pj/compat/string_compat.c	(revision 692)
@@ -0,0 +1,69 @@
+/* $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 <pj/types.h>
+#include <pj/compat/string.h>
+#include <pj/ctype.h>
+
+#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0
+/* Nothing to do */
+#else
+PJ_DEF(int) strcasecmp(const char *s1, const char *s2)
+{
+    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
+	if (!*s1++)
+	    return 0;
+	++s2;
+    }
+    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
+}
+
+PJ_DEF(int) strncasecmp(const char *s1, const char *s2, int len)
+{
+    if (!len) return 0;
+
+    while ((*s1==*s2) || (pj_tolower(*s1)==pj_tolower(*s2))) {
+	if (!*s1++ || --len <= 0)
+	    return 0;
+	++s2;
+    }
+    return (pj_tolower(*s1) < pj_tolower(*s2)) ? -1 : 1;
+}
+#endif
+
+#if defined(PJ_HAS_NO_SNPRINTF) && PJ_HAS_NO_SNPRINTF != 0
+
+PJ_DEF(int) snprintf(char *s1, pj_size_t len, const char *s2, ...)
+{
+    int ret;
+    
+    va_list arg;
+    va_start(arg, s2);
+    ret = vsprintf(s1, s2, arg);
+    va_end(arg);
+    
+    return ret;
+}
+
+PJ_DEF(int) vsnprintf(char *s1, pj_size_t len, const char *s2, va_list arg)
+{
+    return vsprintf(s1,s2,arg);
+}
+
+#endif
+
Index: /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp	(revision 691)
+++ /pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp	(revision 692)
@@ -19,9 +19,4 @@
 
 #include <e32cmn.h>
-#pragma data_seg(".SYMBIAN")
-__EMULATOR_IMAGE_HEADER2 (0x10000079,0x1000008d,0x1000425b,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x70000001,0x00000000,0)
-#pragma data_seg()
-
-
 #include <e32std.h>
 
@@ -36,23 +31,26 @@
 #include <pj/errno.h>
 
-#if defined(PJ_HAS_SEMAPHORE) && PJ_HAS_SEMAPHORE != 0
-#  include <semaphore.h>
-#endif
-
-#include <unistd.h>	    // getpid()
-#include <errno.h>	    // errno
-
-
-#define PJ_MAX_TLS  32
-
+
+#define PJ_MAX_TLS	    32
+#define DUMMY_MUTEX	    ((pj_mutex_t*)101)
+#define DUMMY_SEMAPHORE	    ((pj_sem_t*)102)
+
+
+/*
+ * Note:
+ *
+ * The Symbian implementation does not support threading!
+ */ 
 
 struct pj_thread_t
 {
     char	    obj_name[PJ_MAX_OBJ_NAME];
-    RThread	   *thread;
-    pj_thread_proc *proc;
-    void	   *arg;
-    unsigned	    flags;
     void	   *tls_values[PJ_MAX_TLS];
+
+} main_thread;
+
+struct pj_atomic_t
+{
+    pj_atomic_value_t	value;
 };
 
@@ -75,36 +73,8 @@
 PJ_DEF(pj_status_t) pj_init(void)
 {
-
-  return PJ_SUCCESS;
-}
-
-
-/*
- * thread_main()
- *
- * This is the main entry for all threads.
- */
-static TInt thread_main(TAny *param)
-{
-    pj_thread_t *rec = (pj_thread_t *) param;
-    TInt result;
-
-    /* Save thread record to Symbian TLS */
-    Dll::SetTls(rec);
-
-    /* Suspend thread if PJ_THREAD_SUSPENDED is specified */
-    if (rec->flags & PJ_THREAD_SUSPENDED)
-	rec->thread->Suspend();
-
-    PJ_LOG(6,(rec->obj_name, "Thread started"));
-
-    /* Call user's entry! */
-    result = (TInt)(*rec->proc)(rec->arg);
-
-    /* Done. */
-    PJ_LOG(6,(rec->obj_name, "Thread quitting"));
-
-    return result;
-}
+    pj_ansi_strcpy(main_thread.obj_name, "pjthread");
+    return PJ_SUCCESS;
+}
+
 
 /*
@@ -119,45 +89,14 @@
 				      pj_thread_t **ptr_thread)
 {
-    pj_thread_t *rec;
-    void *p;
-    int rc;
-
-
-    PJ_ASSERT_RETURN(pool && proc && ptr_thread, PJ_EINVAL);
-
-    /* Create thread record and assign name for the thread */
-    rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t));
-    PJ_ASSERT_RETURN(rec, PJ_ENOMEM);
-    
-    /* Set name. */
-    if (!thread_name) 
-	thread_name = "thr%p";
-    
-    if (strchr(thread_name, '%')) {
-	pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec);
-    } else {
-	strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME);
-	rec->obj_name[PJ_MAX_OBJ_NAME-1] = '\0';
-    }
-
-    /* Create Symbian RThread object */
-    p = pj_pool_alloc(pool, sizeof(RThread));
-    rec->thread = new (p) RThread;
-
-    /* Create the thread. */
-    rec->proc = proc;
-    rec->arg = arg;
-    rec->flags = flags;
-    _LIT( KThreadName, "Athread");
-    rc = rec->thread->Create(KThreadName, &thread_main, stack_size, 
-			     KMinHeapSize, KMinHeapSize, rec);
-    if (rc != 0) {
-	return PJ_RETURN_OS_ERROR(rc);
-    }
-
-    *ptr_thread = rec;
-
-    PJ_LOG(6, (rec->obj_name, "Thread created"));
-    return PJ_SUCCESS;
+    PJ_UNUSED_ARG(pool);
+    PJ_UNUSED_ARG(thread_name);
+    PJ_UNUSED_ARG(proc);
+    PJ_UNUSED_ARG(arg);
+    PJ_UNUSED_ARG(stack_size);
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(ptr_thread);
+
+    /* Sorry mate, we don't support threading */
+    return PJ_ENOTSUP;
 }
 
@@ -167,4 +106,5 @@
 PJ_DEF(const char*) pj_thread_get_name(pj_thread_t *p)
 {
+    pj_assert(p == &main_thread);
     return p->obj_name;
 }
@@ -175,6 +115,6 @@
 PJ_DEF(pj_status_t) pj_thread_resume(pj_thread_t *p)
 {
-    p->thread->Resume();
-    return PJ_SUCCESS;
+    PJ_UNUSED_ARG(p);
+    return PJ_EINVALIDOP;
 }
 
@@ -184,5 +124,5 @@
 PJ_DEF(pj_thread_t*) pj_thread_this(void)
 {
-    return (pj_thread_t*)Dll::Tls();
+    return &main_thread;
 }
 
@@ -192,11 +132,6 @@
 PJ_DEF(pj_status_t) pj_thread_join(pj_thread_t *rec)
 {
-    TRequestStatus result;
-
-    PJ_LOG(6, (rec->obj_name, "Joining thread %s", rec->obj_name));
-
-    rec->thread->Rendezvous(result);
-
-    return PJ_SUCCESS;
+    PJ_UNUSED_ARG(rec);
+    return PJ_EINVALIDOP;
 }
 
@@ -206,6 +141,6 @@
 PJ_DEF(pj_status_t) pj_thread_destroy(pj_thread_t *rec)
 {
-    rec->thread->Kill(1);
-    return PJ_SUCCESS;
+    PJ_UNUSED_ARG(rec);
+    return PJ_EINVALIDOP;
 }
 
@@ -215,10 +150,8 @@
 PJ_DEF(pj_status_t) pj_thread_sleep(unsigned msec)
 {
-    PJ_TODO(MSEC_RESOLUTION_SLEEP);
-
-    if (sleep(msec * 1000) == 0)
-	return PJ_SUCCESS;
-	
-    return PJ_SUCCESS;
+    PJ_UNUSED_ARG(msec);
+
+    /* Not supported either */
+    return PJ_EINVALIDOP;
 }
 
@@ -288,4 +221,107 @@
 
 
+///////////////////////////////////////////////////////////////////////////////
+/*
+ * Create atomic variable.
+ */
+PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool, 
+				      pj_atomic_value_t initial,
+				      pj_atomic_t **atomic )
+{
+    *atomic = (pj_atomic_t*)pj_pool_alloc(pool, sizeof(struct pj_atomic_t));
+    (*atomic)->value = initial;
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Destroy atomic variable.
+ */
+PJ_DEF(pj_status_t) pj_atomic_destroy( pj_atomic_t *atomic_var )
+{
+    PJ_UNUSED_ARG(atomic_var);
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Set the value of an atomic type, and return the previous value.
+ */
+PJ_DEF(void) pj_atomic_set( pj_atomic_t *atomic_var, 
+			    pj_atomic_value_t value)
+{
+    atomic_var->value = value;
+}
+
+
+/*
+ * Get the value of an atomic type.
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_get(pj_atomic_t *atomic_var)
+{
+    return atomic_var->value;
+}
+
+
+/*
+ * Increment the value of an atomic type.
+ */
+PJ_DEF(void) pj_atomic_inc(pj_atomic_t *atomic_var)
+{
+    ++atomic_var->value;
+}
+
+
+/*
+ * Increment the value of an atomic type and get the result.
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_inc_and_get(pj_atomic_t *atomic_var)
+{
+    return ++atomic_var->value;
+}
+
+
+/*
+ * Decrement the value of an atomic type.
+ */
+PJ_DEF(void) pj_atomic_dec(pj_atomic_t *atomic_var)
+{
+    --atomic_var->value;
+}	
+
+
+/*
+ * Decrement the value of an atomic type and get the result.
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_dec_and_get(pj_atomic_t *atomic_var)
+{
+    return --atomic_var->value;
+}
+
+
+/*
+ * Add a value to an atomic type.
+ */
+PJ_DEF(void) pj_atomic_add( pj_atomic_t *atomic_var,
+			    pj_atomic_value_t value)
+{
+    atomic_var->value += value;
+}
+
+
+/*
+ * Add a value to an atomic type and get the result.
+ */
+PJ_DEF(pj_atomic_value_t) pj_atomic_add_and_get( pj_atomic_t *atomic_var,
+			                         pj_atomic_value_t value)
+{
+    atomic_var->value += value;
+    return atomic_var->value;
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+
 PJ_DEF(pj_status_t) pj_mutex_create( pj_pool_t *pool, 
                                      const char *name,
@@ -293,6 +329,9 @@
                                      pj_mutex_t **mutex)
 {
-    PJ_TODO(pj_mutex_create);
-    *mutex = (pj_mutex_t*)1;
+    PJ_UNUSED_ARG(pool);
+    PJ_UNUSED_ARG(name);
+    PJ_UNUSED_ARG(type);
+
+    *mutex = DUMMY_MUTEX;
     return PJ_SUCCESS;
 }
@@ -322,5 +361,5 @@
 PJ_DEF(pj_status_t) pj_mutex_lock(pj_mutex_t *mutex)
 {
-    PJ_TODO(pj_mutex_lock);
+    pj_assert(mutex == DUMMY_MUTEX);
     return PJ_SUCCESS;
 }
@@ -331,5 +370,5 @@
 PJ_DEF(pj_status_t) pj_mutex_trylock(pj_mutex_t *mutex)
 {
-    PJ_TODO(pj_mutex_trylock);
+    pj_assert(mutex == DUMMY_MUTEX);
     return PJ_SUCCESS;
 }
@@ -340,5 +379,5 @@
 PJ_DEF(pj_status_t) pj_mutex_unlock(pj_mutex_t *mutex)
 {
-    PJ_TODO(pj_mutex_unlock);
+    pj_assert(mutex == DUMMY_MUTEX);
     return PJ_SUCCESS;
 }
@@ -349,9 +388,17 @@
 PJ_DEF(pj_status_t) pj_mutex_destroy(pj_mutex_t *mutex)
 {
-    PJ_TODO(pj_mutex_destroy);
-    return PJ_SUCCESS;
-}
+    pj_assert(mutex == DUMMY_MUTEX);
+    return PJ_SUCCESS;
+}
+
 
 /////////////////////////////////////////////////////////////////////////////
+/*
+ * RW Mutex
+ */
+#include "os_rwmutex.c"
+
+
+/////////////////////////////////////////////////////////////////////////////
 
 /*
@@ -360,5 +407,5 @@
 PJ_DEF(void) pj_enter_critical_section(void)
 {
-    PJ_TODO(pj_enter_critical_section);
+    /* Nothing to do */
 }
 
@@ -369,8 +416,68 @@
 PJ_DEF(void) pj_leave_critical_section(void)
 {
-    PJ_TODO(pj_leave_critical_section);
-}
-
-
-
-
+    /* Nothing to do */
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+/*
+ * Create semaphore.
+ */
+PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool, 
+                                   const char *name,
+				   unsigned initial, 
+                                   unsigned max,
+				   pj_sem_t **sem)
+{
+    PJ_UNUSED_ARG(pool);
+    PJ_UNUSED_ARG(name);
+    PJ_UNUSED_ARG(initial);
+    PJ_UNUSED_ARG(max);
+    PJ_UNUSED_ARG(sem);
+
+    /* Unsupported */
+    return PJ_ENOTSUP;
+}
+
+
+/*
+ * Wait for semaphore.
+ */
+PJ_DEF(pj_status_t) pj_sem_wait(pj_sem_t *sem)
+{
+    PJ_UNUSED_ARG(sem);
+    return PJ_EINVALIDOP;
+}
+
+
+/*
+ * Try wait for semaphore.
+ */
+PJ_DEF(pj_status_t) pj_sem_trywait(pj_sem_t *sem)
+{
+    PJ_UNUSED_ARG(sem);
+    return PJ_EINVALIDOP;
+}
+
+
+/*
+ * Release semaphore.
+ */
+PJ_DEF(pj_status_t) pj_sem_post(pj_sem_t *sem)
+{
+    PJ_UNUSED_ARG(sem);
+    return PJ_EINVALIDOP;
+}
+
+
+/*
+ * Destroy semaphore.
+ */
+PJ_DEF(pj_status_t) pj_sem_destroy(pj_sem_t *sem)
+{
+    PJ_UNUSED_ARG(sem);
+    return PJ_EINVALIDOP;
+}
+
+
Index: /pjproject/branches/symbian/pjlib/src/pj/os_rwmutex.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pj/os_rwmutex.c	(revision 691)
+++ /pjproject/branches/symbian/pjlib/src/pj/os_rwmutex.c	(revision 692)
@@ -57,5 +57,5 @@
 
     *p_mutex = NULL;
-    rwmutex = pj_pool_alloc(pool, sizeof(struct pj_rwmutex_t));
+    rwmutex = (pj_rwmutex_t*)pj_pool_alloc(pool, sizeof(struct pj_rwmutex_t));
 
     status = pj_mutex_create_simple(pool, name, &rwmutex ->read_lock);
Index: /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 691)
+++ /pjproject/branches/symbian/pjlib/src/pjlib-test/main_symbian.cpp	(revision 692)
@@ -1,7 +1,8 @@
 //Auto-generated file. Please do not modify.
-#include <e32cmn.h>
-#pragma data_seg(".SYMBIAN")
-__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0)
-#pragma data_seg()
+//#include <e32cmn.h>
+
+//#pragma data_seg(".SYMBIAN")
+//__EMULATOR_IMAGE_HEADER2 (0x1000007a,0x00000000,0x00000000,EPriorityForeground,0x00000000u,0x00000000u,0x00000000,0x00000000,0x00000000,0)
+//#pragma data_seg()
 
 #include "test.h"
@@ -69,6 +70,4 @@
     console->Printf(KTextPressAnyKey);
     console->Getch();
-    console->Printf(KTextPressAnyKey);
-    console->Getch();
     
     delete console;
Index: project/branches/symbian/pjlib/src/pjlib-test/string.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pjlib-test/string.c	(revision 691)
+++ 	(revision )
@@ -1,403 +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 <pj/string.h>
-#include <pj/pool.h>
-#include <pj/log.h>
-#include <pj/os.h>
-#include "test.h"
-
-#define THIS_FILE	"string.c"
-
-/**
- * \page page_pjlib_string_test Test: String
- *
- * This file provides implementation of \b string_test(). It tests the
- * functionality of the string API.
- *
- * \section sleep_test_sec Scope of the Test
- *
- * API tested:
- *  - pj_str()
- *  - pj_strcmp()
- *  - pj_strcmp2()
- *  - pj_stricmp()
- *  - pj_strlen()
- *  - pj_strncmp()
- *  - pj_strnicmp()
- *  - pj_strchr()
- *  - pj_strdup()
- *  - pj_strdup2()
- *  - pj_strcpy()
- *  - pj_strcat()
- *  - pj_strtrim()
- *  - pj_utoa()
- *  - pj_strtoul()
- *  - pj_create_random_string()
- *  - ... and mode..
- *
- * This file is <b>pjlib-test/string.c</b>
- *
- * \include pjlib-test/string.c
- */
-
-#if INCLUDE_STRING_TEST
-
-#ifdef _MSC_VER
-#   pragma warning(disable: 4204)
-#endif
-
-#define HELLO_WORLD	"Hello World"
-#define JUST_HELLO	"Hello"
-#define UL_VALUE	3456789012UL
-
-#if 1
-/* See if both integers have the same sign */
-PJ_INLINE(int) cmp(const char *expr, int i, int j)
-{
-    i = !((i>0 && j>0) || (i<0 && j<0) || (i==0 && j==0));
-    if (i) {
-	PJ_LOG(3,(THIS_FILE,"   error: %s: expecting %d, got %d", expr, j, i));
-    }
-    return i;
-}
-#else
-/* For strict comparison, must be equal */
-PJ_INLINE(int) cmp(const char *expr, int i, int j)
-{
-    PJ_UNUSED_ARG(expr);
-    return i!=j;
-}
-#endif
-
-#define C(expr, res)	cmp(#expr, expr, res)
-
-static int stricmp_test(void)
-{
-/* This specificly tests and benchmark pj_stricmp(), pj_stricmp_alnum().
- * In addition, it also tests pj_stricmp2(), pj_strnicmp(), and 
- * pj_strnicmp2().
- */
-#define STRTEST(res,S1,S2,code)	\
-	    do { \
-		s1.ptr=S1; s1.slen=S1?len:0; \
-		s2.ptr=S2; s2.slen=S2?len:0; \
-		pj_get_timestamp(&t1); \
-	        if (C(pj_stricmp(&s1,&s2),res)) return code; \
-		pj_get_timestamp(&t2); \
-		pj_sub_timestamp(&t2, &t1); \
-		pj_add_timestamp(&e1, &t2); \
-		pj_get_timestamp(&t1); \
-	        if (C(pj_stricmp_alnum(&s1,&s2),res)) return code-1; \
-		pj_get_timestamp(&t2); \
-		pj_sub_timestamp(&t2, &t1); \
-		pj_add_timestamp(&e2, &t2); \
-		if (C(pj_stricmp2(&s1,S2),res)) return code*10; \
-		if (C(pj_strnicmp(&s1,&s2,len),res)) return code*100; \
-		if (C(pj_strnicmp2(&s1,S2,len),res)) return code*1000; \
-	    } while (0)
-
-    char *buf;
-    pj_str_t s1, s2;
-    pj_timestamp t1, t2, e1, e2, zero;
-    pj_uint32_t c1, c2;
-    int len;
-
-    e1.u32.hi = e1.u32.lo = e2.u32.hi = e2.u32.lo = 0;
-
-    pj_thread_sleep(0);
-
-    /* Compare empty strings. */
-    len=0;
-    STRTEST( 0, "","",-500);
-    STRTEST( 0, NULL,"",-502);
-    STRTEST( 0, "",NULL,-504);
-    STRTEST( 0, NULL,NULL,-506);
-    STRTEST( 0, "hello","world",-508);
-
-    /* equal, length=1 
-     * use buffer to simulate non-aligned string.
-     */
-    buf = "a""A";
-    len=1;
-    STRTEST( 0, "a",buf+0,-510);
-    STRTEST( 0, "a",buf+1,-512);
-    STRTEST( -1, "O", "P", -514);
-    STRTEST(-1, NULL, "a", -516);
-    STRTEST(1, "a", NULL, -518);
-
-    /* equal, length=2 
-     * use buffer to simulate non-aligned string.
-     */
-    buf = "aa""Aa""aA""AA";
-    len=2;
-    STRTEST( 0, "aa",buf+0,-520);
-    STRTEST( 0, "aa",buf+2,-522);
-    STRTEST( 0, "aa",buf+4,-524);
-    STRTEST( 0, "aa",buf+6,-524);
-
-    /* equal, length=3 
-     * use buffer to simulate non-aligned string.
-     */
-    buf = "aaa""Aaa""aAa""aaA""AAa""aAA""AaA""AAA";
-    len=3;
-    STRTEST( 0, "aaa",buf+0,-530);
-    STRTEST( 0, "aaa",buf+3,-532);
-    STRTEST( 0, "aaa",buf+6,-534);
-    STRTEST( 0, "aaa",buf+9,-536);
-    STRTEST( 0, "aaa",buf+12,-538);
-    STRTEST( 0, "aaa",buf+15,-540);
-    STRTEST( 0, "aaa",buf+18,-542);
-    STRTEST( 0, "aaa",buf+21,-534);
-
-    /* equal, length=4 */
-    len=4;
-    STRTEST( 0, "aaaa","aaaa",-540);
-    STRTEST( 0, "aaaa","Aaaa",-542);
-    STRTEST( 0, "aaaa","aAaa",-544);
-    STRTEST( 0, "aaaa","aaAa",-546);
-    STRTEST( 0, "aaaa","aaaA",-548);
-    STRTEST( 0, "aaaa","AAaa",-550);
-    STRTEST( 0, "aaaa","aAAa",-552);
-    STRTEST( 0, "aaaa","aaAA",-554);
-    STRTEST( 0, "aaaa","AaAa",-556);
-    STRTEST( 0, "aaaa","aAaA",-558);
-    STRTEST( 0, "aaaa","AaaA",-560);
-    STRTEST( 0, "aaaa","AAAa",-562);
-    STRTEST( 0, "aaaa","aAAA",-564);
-    STRTEST( 0, "aaaa","AAaA",-566);
-    STRTEST( 0, "aaaa","AaAA",-568);
-    STRTEST( 0, "aaaa","AAAA",-570);
-
-    /* equal, length=5 */
-    buf = "aaaAa""AaaaA""AaAaA""AAAAA";
-    len=5;
-    STRTEST( 0, "aaaaa",buf+0,-580);
-    STRTEST( 0, "aaaaa",buf+5,-582);
-    STRTEST( 0, "aaaaa",buf+10,-584);
-    STRTEST( 0, "aaaaa",buf+15,-586);
-
-    /* not equal, length=1 */
-    len=1;
-    STRTEST( -1, "a", "b", -600);
-
-    /* not equal, length=2 */
-    buf = "ab""ba";
-    len=2;
-    STRTEST( -1, "aa", buf+0, -610);
-    STRTEST( -1, "aa", buf+2, -612);
-
-    /* not equal, length=3 */
-    buf = "aab""aba""baa";
-    len=3;
-    STRTEST( -1, "aaa", buf+0, -620);
-    STRTEST( -1, "aaa", buf+3, -622);
-    STRTEST( -1, "aaa", buf+6, -624);
-
-    /* not equal, length=4 */
-    buf = "aaab""aaba""abaa""baaa";
-    len=4;
-    STRTEST( -1, "aaaa", buf+0, -630);
-    STRTEST( -1, "aaaa", buf+4, -632);
-    STRTEST( -1, "aaaa", buf+8, -634);
-    STRTEST( -1, "aaaa", buf+12, -636);
-
-    /* not equal, length=5 */
-    buf="aaaab""aaaba""aabaa""abaaa""baaaa";
-    len=5;
-    STRTEST( -1, "aaaaa", buf+0, -640);
-    STRTEST( -1, "aaaaa", buf+5, -642);
-    STRTEST( -1, "aaaaa", buf+10, -644);
-    STRTEST( -1, "aaaaa", buf+15, -646);
-    STRTEST( -1, "aaaaa", buf+20, -648);
-
-    zero.u32.hi = zero.u32.lo = 0;
-    c1 = pj_elapsed_cycle(&zero, &e1);
-    c2 = pj_elapsed_cycle(&zero, &e2);
-
-    if (c1 < c2) {
-	PJ_LOG(3,("", "  info: pj_stricmp_alnum is slower than pj_stricmp!"));
-	//return -700;
-    }
-
-    PJ_LOG(3, ("", "  time: stricmp=%u, stricmp_alnum=%u (speedup=%d.%02dx)", 
-		   c1, c2,
-		   (c1 * 100 / c2) / 100,
-		   (c1 * 100 / c2) % 100));
-    return 0;
-#undef STRTEST
-}
-
-/* This tests pj_strcmp(), pj_strcmp2(), pj_strncmp(), pj_strncmp2() */
-static int strcmp_test(void)
-{
-#define STR_TEST(res,S1,S2,code)    \
-	    do { \
-		s1.ptr=S1; s1.slen=S1?len:0; \
-		s2.ptr=S2; s2.slen=S2?len:0; \
-	        if (C(pj_strcmp(&s1,&s2),res)) return code; \
-		if (C(pj_strcmp2(&s1,S2),res)) return code-1; \
-		if (C(pj_strncmp(&s1,&s2,len),res)) return code-2; \
-		if (C(pj_strncmp2(&s1,S2,len),res)) return code-3; \
-	    } while (0)
-
-    pj_str_t s1, s2;
-    int len;
-    
-    /* Test with length == 0 */
-    len=0;
-    STR_TEST(0, "", "", -400);
-    STR_TEST(0, NULL, "", -405);
-    STR_TEST(0, "", NULL, -410);
-    STR_TEST(0, NULL, NULL, -415);
-    STR_TEST(0, "hello", "", -420);
-    STR_TEST(0, "hello", NULL, -425);
-
-    /* Test with length != 0 */
-    len = 2;
-    STR_TEST(0, "12", "12", -430);
-    STR_TEST(1, "12", "1", -435);
-    STR_TEST(-1, "1", "12", -440);
-    STR_TEST(-1, NULL, "12", -445);
-    STR_TEST(1, "12", NULL, -450);
-
-    return 0;
-
-#undef STR_TEST
-}
-
-int string_test(void)
-{
-    const pj_str_t hello_world = { HELLO_WORLD, strlen(HELLO_WORLD) };
-    const pj_str_t just_hello = { JUST_HELLO, strlen(JUST_HELLO) };
-    pj_str_t s1, s2, s3, s4, s5;
-    enum { RCOUNT = 10, RLEN = 16 };
-    pj_str_t random[RCOUNT];
-    pj_pool_t *pool;
-    int i;
-
-    pool = pj_pool_create(mem, NULL, 4096, 0, NULL);
-    if (!pool) return -5;
-    
-    /* 
-     * pj_str(), pj_strcmp(), pj_stricmp(), pj_strlen(), 
-     * pj_strncmp(), pj_strchr() 
-     */
-    s1 = pj_str(HELLO_WORLD);
-    if (pj_strcmp(&s1, &hello_world) != 0)
-	return -10;
-    if (pj_stricmp(&s1, &hello_world) != 0)
-	return -20;
-    if (pj_strcmp(&s1, &just_hello) <= 0)
-	return -30;
-    if (pj_stricmp(&s1, &just_hello) <= 0)
-	return -40;
-    if (pj_strlen(&s1) != strlen(HELLO_WORLD))
-	return -50;
-    if (pj_strncmp(&s1, &hello_world, 5) != 0)
-	return -60;
-    if (pj_strnicmp(&s1, &hello_world, 5) != 0)
-	return -70;
-    if (pj_strchr(&s1, HELLO_WORLD[1]) != s1.ptr+1)
-	return -80;
-
-    /* 
-     * pj_strdup() 
-     */
-    if (!pj_strdup(pool, &s2, &s1))
-	return -100;
-    if (pj_strcmp(&s1, &s2) != 0)
-	return -110;
-    
-    /* 
-     * pj_strcpy(), pj_strcat() 
-     */
-    s3.ptr = pj_pool_alloc(pool, 256);
-    if (!s3.ptr) 
-	return -200;
-    pj_strcpy(&s3, &s2);
-    pj_strcat(&s3, &just_hello);
-
-    if (pj_strcmp2(&s3, HELLO_WORLD JUST_HELLO) != 0)
-	return -210;
-
-    /* 
-     * pj_strdup2(), pj_strtrim(). 
-     */
-    pj_strdup2(pool, &s4, " " HELLO_WORLD "\t ");
-    pj_strtrim(&s4);
-    if (pj_strcmp2(&s4, HELLO_WORLD) != 0)
-	return -250;
-
-    /* 
-     * pj_utoa() 
-     */
-    s5.ptr = pj_pool_alloc(pool, 16);
-    if (!s5.ptr)
-	return -270;
-    s5.slen = pj_utoa(UL_VALUE, s5.ptr);
-
-    /* 
-     * pj_strtoul() 
-     */
-    if (pj_strtoul(&s5) != UL_VALUE)
-	return -280;
-
-    /* 
-     * pj_create_random_string() 
-     * Check that no duplicate strings are returned.
-     */
-    for (i=0; i<RCOUNT; ++i) {
-	int j;
-	
-	random[i].ptr = pj_pool_alloc(pool, RLEN);
-	if (!random[i].ptr)
-	    return -320;
-
-        random[i].slen = RLEN;
-	pj_create_random_string(random[i].ptr, RLEN);
-
-	for (j=0; j<i; ++j) {
-	    if (pj_strcmp(&random[i], &random[j])==0)
-		return -330;
-	}
-    }
-
-    /* Done. */
-    pj_pool_release(pool);
-
-    /* Case sensitive comparison test. */
-    i = strcmp_test();
-    if (i != 0)
-	return i;
-
-    /* Caseless comparison test. */
-    i = stricmp_test();
-    if (i != 0)
-	return i;
-
-    return 0;
-}
-
-#else
-/* To prevent warning about "translation unit is empty"
- * when this test is disabled. 
- */
-int dummy_string_test;
-#endif	/* INCLUDE_STRING_TEST */
-
Index: /pjproject/branches/symbian/pjlib/src/pjlib-test/string_test.c
===================================================================
--- /pjproject/branches/symbian/pjlib/src/pjlib-test/string_test.c	(revision 692)
+++ /pjproject/branches/symbian/pjlib/src/pjlib-test/string_test.c	(revision 692)
@@ -0,0 +1,403 @@
+/* $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 <pj/string.h>
+#include <pj/pool.h>
+#include <pj/log.h>
+#include <pj/os.h>
+#include "test.h"
+
+#define THIS_FILE	"string.c"
+
+/**
+ * \page page_pjlib_string_test Test: String
+ *
+ * This file provides implementation of \b string_test(). It tests the
+ * functionality of the string API.
+ *
+ * \section sleep_test_sec Scope of the Test
+ *
+ * API tested:
+ *  - pj_str()
+ *  - pj_strcmp()
+ *  - pj_strcmp2()
+ *  - pj_stricmp()
+ *  - pj_strlen()
+ *  - pj_strncmp()
+ *  - pj_strnicmp()
+ *  - pj_strchr()
+ *  - pj_strdup()
+ *  - pj_strdup2()
+ *  - pj_strcpy()
+ *  - pj_strcat()
+ *  - pj_strtrim()
+ *  - pj_utoa()
+ *  - pj_strtoul()
+ *  - pj_create_random_string()
+ *  - ... and mode..
+ *
+ * This file is <b>pjlib-test/string.c</b>
+ *
+ * \include pjlib-test/string.c
+ */
+
+#if INCLUDE_STRING_TEST
+
+#ifdef _MSC_VER
+#   pragma warning(disable: 4204)
+#endif
+
+#define HELLO_WORLD	"Hello World"
+#define JUST_HELLO	"Hello"
+#define UL_VALUE	3456789012UL
+
+#if 1
+/* See if both integers have the same sign */
+PJ_INLINE(int) cmp(const char *expr, int i, int j)
+{
+    i = !((i>0 && j>0) || (i<0 && j<0) || (i==0 && j==0));
+    if (i) {
+	PJ_LOG(3,(THIS_FILE,"   error: %s: expecting %d, got %d", expr, j, i));
+    }
+    return i;
+}
+#else
+/* For strict comparison, must be equal */
+PJ_INLINE(int) cmp(const char *expr, int i, int j)
+{
+    PJ_UNUSED_ARG(expr);
+    return i!=j;
+}
+#endif
+
+#define C(expr, res)	cmp(#expr, expr, res)
+
+static int stricmp_test(void)
+{
+/* This specificly tests and benchmark pj_stricmp(), pj_stricmp_alnum().
+ * In addition, it also tests pj_stricmp2(), pj_strnicmp(), and 
+ * pj_strnicmp2().
+ */
+#define STRTEST(res,S1,S2,code)	\
+	    do { \
+		s1.ptr=S1; s1.slen=S1?len:0; \
+		s2.ptr=S2; s2.slen=S2?len:0; \
+		pj_get_timestamp(&t1); \
+	        if (C(pj_stricmp(&s1,&s2),res)) return code; \
+		pj_get_timestamp(&t2); \
+		pj_sub_timestamp(&t2, &t1); \
+		pj_add_timestamp(&e1, &t2); \
+		pj_get_timestamp(&t1); \
+	        if (C(pj_stricmp_alnum(&s1,&s2),res)) return code-1; \
+		pj_get_timestamp(&t2); \
+		pj_sub_timestamp(&t2, &t1); \
+		pj_add_timestamp(&e2, &t2); \
+		if (C(pj_stricmp2(&s1,S2),res)) return code*10; \
+		if (C(pj_strnicmp(&s1,&s2,len),res)) return code*100; \
+		if (C(pj_strnicmp2(&s1,S2,len),res)) return code*1000; \
+	    } while (0)
+
+    char *buf;
+    pj_str_t s1, s2;
+    pj_timestamp t1, t2, e1, e2, zero;
+    pj_uint32_t c1, c2;
+    int len;
+
+    e1.u32.hi = e1.u32.lo = e2.u32.hi = e2.u32.lo = 0;
+
+    pj_thread_sleep(0);
+
+    /* Compare empty strings. */
+    len=0;
+    STRTEST( 0, "","",-500);
+    STRTEST( 0, NULL,"",-502);
+    STRTEST( 0, "",NULL,-504);
+    STRTEST( 0, NULL,NULL,-506);
+    STRTEST( 0, "hello","world",-508);
+
+    /* equal, length=1 
+     * use buffer to simulate non-aligned string.
+     */
+    buf = "a""A";
+    len=1;
+    STRTEST( 0, "a",buf+0,-510);
+    STRTEST( 0, "a",buf+1,-512);
+    STRTEST( -1, "O", "P", -514);
+    STRTEST(-1, NULL, "a", -516);
+    STRTEST(1, "a", NULL, -518);
+
+    /* equal, length=2 
+     * use buffer to simulate non-aligned string.
+     */
+    buf = "aa""Aa""aA""AA";
+    len=2;
+    STRTEST( 0, "aa",buf+0,-520);
+    STRTEST( 0, "aa",buf+2,-522);
+    STRTEST( 0, "aa",buf+4,-524);
+    STRTEST( 0, "aa",buf+6,-524);
+
+    /* equal, length=3 
+     * use buffer to simulate non-aligned string.
+     */
+    buf = "aaa""Aaa""aAa""aaA""AAa""aAA""AaA""AAA";
+    len=3;
+    STRTEST( 0, "aaa",buf+0,-530);
+    STRTEST( 0, "aaa",buf+3,-532);
+    STRTEST( 0, "aaa",buf+6,-534);
+    STRTEST( 0, "aaa",buf+9,-536);
+    STRTEST( 0, "aaa",buf+12,-538);
+    STRTEST( 0, "aaa",buf+15,-540);
+    STRTEST( 0, "aaa",buf+18,-542);
+    STRTEST( 0, "aaa",buf+21,-534);
+
+    /* equal, length=4 */
+    len=4;
+    STRTEST( 0, "aaaa","aaaa",-540);
+    STRTEST( 0, "aaaa","Aaaa",-542);
+    STRTEST( 0, "aaaa","aAaa",-544);
+    STRTEST( 0, "aaaa","aaAa",-546);
+    STRTEST( 0, "aaaa","aaaA",-548);
+    STRTEST( 0, "aaaa","AAaa",-550);
+    STRTEST( 0, "aaaa","aAAa",-552);
+    STRTEST( 0, "aaaa","aaAA",-554);
+    STRTEST( 0, "aaaa","AaAa",-556);
+    STRTEST( 0, "aaaa","aAaA",-558);
+    STRTEST( 0, "aaaa","AaaA",-560);
+    STRTEST( 0, "aaaa","AAAa",-562);
+    STRTEST( 0, "aaaa","aAAA",-564);
+    STRTEST( 0, "aaaa","AAaA",-566);
+    STRTEST( 0, "aaaa","AaAA",-568);
+    STRTEST( 0, "aaaa","AAAA",-570);
+
+    /* equal, length=5 */
+    buf = "aaaAa""AaaaA""AaAaA""AAAAA";
+    len=5;
+    STRTEST( 0, "aaaaa",buf+0,-580);
+    STRTEST( 0, "aaaaa",buf+5,-582);
+    STRTEST( 0, "aaaaa",buf+10,-584);
+    STRTEST( 0, "aaaaa",buf+15,-586);
+
+    /* not equal, length=1 */
+    len=1;
+    STRTEST( -1, "a", "b", -600);
+
+    /* not equal, length=2 */
+    buf = "ab""ba";
+    len=2;
+    STRTEST( -1, "aa", buf+0, -610);
+    STRTEST( -1, "aa", buf+2, -612);
+
+    /* not equal, length=3 */
+    buf = "aab""aba""baa";
+    len=3;
+    STRTEST( -1, "aaa", buf+0, -620);
+    STRTEST( -1, "aaa", buf+3, -622);
+    STRTEST( -1, "aaa", buf+6, -624);
+
+    /* not equal, length=4 */
+    buf = "aaab""aaba""abaa""baaa";
+    len=4;
+    STRTEST( -1, "aaaa", buf+0, -630);
+    STRTEST( -1, "aaaa", buf+4, -632);
+    STRTEST( -1, "aaaa", buf+8, -634);
+    STRTEST( -1, "aaaa", buf+12, -636);
+
+    /* not equal, length=5 */
+    buf="aaaab""aaaba""aabaa""abaaa""baaaa";
+    len=5;
+    STRTEST( -1, "aaaaa", buf+0, -640);
+    STRTEST( -1, "aaaaa", buf+5, -642);
+    STRTEST( -1, "aaaaa", buf+10, -644);
+    STRTEST( -1, "aaaaa", buf+15, -646);
+    STRTEST( -1, "aaaaa", buf+20, -648);
+
+    zero.u32.hi = zero.u32.lo = 0;
+    c1 = pj_elapsed_cycle(&zero, &e1);
+    c2 = pj_elapsed_cycle(&zero, &e2);
+
+    if (c1 < c2) {
+	PJ_LOG(3,("", "  info: pj_stricmp_alnum is slower than pj_stricmp!"));
+	//return -700;
+    }
+
+    PJ_LOG(3, ("", "  time: stricmp=%u, stricmp_alnum=%u (speedup=%d.%02dx)", 
+		   c1, c2,
+		   (c1 * 100 / c2) / 100,
+		   (c1 * 100 / c2) % 100));
+    return 0;
+#undef STRTEST
+}
+
+/* This tests pj_strcmp(), pj_strcmp2(), pj_strncmp(), pj_strncmp2() */
+static int strcmp_test(void)
+{
+#define STR_TEST(res,S1,S2,code)    \
+	    do { \
+		s1.ptr=S1; s1.slen=S1?len:0; \
+		s2.ptr=S2; s2.slen=S2?len:0; \
+	        if (C(pj_strcmp(&s1,&s2),res)) return code; \
+		if (C(pj_strcmp2(&s1,S2),res)) return code-1; \
+		if (C(pj_strncmp(&s1,&s2,len),res)) return code-2; \
+		if (C(pj_strncmp2(&s1,S2,len),res)) return code-3; \
+	    } while (0)
+
+    pj_str_t s1, s2;
+    int len;
+    
+    /* Test with length == 0 */
+    len=0;
+    STR_TEST(0, "", "", -400);
+    STR_TEST(0, NULL, "", -405);
+    STR_TEST(0, "", NULL, -410);
+    STR_TEST(0, NULL, NULL, -415);
+    STR_TEST(0, "hello", "", -420);
+    STR_TEST(0, "hello", NULL, -425);
+
+    /* Test with length != 0 */
+    len = 2;
+    STR_TEST(0, "12", "12", -430);
+    STR_TEST(1, "12", "1", -435);
+    STR_TEST(-1, "1", "12", -440);
+    STR_TEST(-1, NULL, "12", -445);
+    STR_TEST(1, "12", NULL, -450);
+
+    return 0;
+
+#undef STR_TEST
+}
+
+int string_test(void)
+{
+    const pj_str_t hello_world = { HELLO_WORLD, strlen(HELLO_WORLD) };
+    const pj_str_t just_hello = { JUST_HELLO, strlen(JUST_HELLO) };
+    pj_str_t s1, s2, s3, s4, s5;
+    enum { RCOUNT = 10, RLEN = 16 };
+    pj_str_t random[RCOUNT];
+    pj_pool_t *pool;
+    int i;
+
+    pool = pj_pool_create(mem, NULL, 4096, 0, NULL);
+    if (!pool) return -5;
+    
+    /* 
+     * pj_str(), pj_strcmp(), pj_stricmp(), pj_strlen(), 
+     * pj_strncmp(), pj_strchr() 
+     */
+    s1 = pj_str(HELLO_WORLD);
+    if (pj_strcmp(&s1, &hello_world) != 0)
+	return -10;
+    if (pj_stricmp(&s1, &hello_world) != 0)
+	return -20;
+    if (pj_strcmp(&s1, &just_hello) <= 0)
+	return -30;
+    if (pj_stricmp(&s1, &just_hello) <= 0)
+	return -40;
+    if (pj_strlen(&s1) != strlen(HELLO_WORLD))
+	return -50;
+    if (pj_strncmp(&s1, &hello_world, 5) != 0)
+	return -60;
+    if (pj_strnicmp(&s1, &hello_world, 5) != 0)
+	return -70;
+    if (pj_strchr(&s1, HELLO_WORLD[1]) != s1.ptr+1)
+	return -80;
+
+    /* 
+     * pj_strdup() 
+     */
+    if (!pj_strdup(pool, &s2, &s1))
+	return -100;
+    if (pj_strcmp(&s1, &s2) != 0)
+	return -110;
+    
+    /* 
+     * pj_strcpy(), pj_strcat() 
+     */
+    s3.ptr = pj_pool_alloc(pool, 256);
+    if (!s3.ptr) 
+	return -200;
+    pj_strcpy(&s3, &s2);
+    pj_strcat(&s3, &just_hello);
+
+    if (pj_strcmp2(&s3, HELLO_WORLD JUST_HELLO) != 0)
+	return -210;
+
+    /* 
+     * pj_strdup2(), pj_strtrim(). 
+     */
+    pj_strdup2(pool, &s4, " " HELLO_WORLD "\t ");
+    pj_strtrim(&s4);
+    if (pj_strcmp2(&s4, HELLO_WORLD) != 0)
+	return -250;
+
+    /* 
+     * pj_utoa() 
+     */
+    s5.ptr = pj_pool_alloc(pool, 16);
+    if (!s5.ptr)
+	return -270;
+    s5.slen = pj_utoa(UL_VALUE, s5.ptr);
+
+    /* 
+     * pj_strtoul() 
+     */
+    if (pj_strtoul(&s5) != UL_VALUE)
+	return -280;
+
+    /* 
+     * pj_create_random_string() 
+     * Check that no duplicate strings are returned.
+     */
+    for (i=0; i<RCOUNT; ++i) {
+	int j;
+	
+	random[i].ptr = pj_pool_alloc(pool, RLEN);
+	if (!random[i].ptr)
+	    return -320;
+
+        random[i].slen = RLEN;
+	pj_create_random_string(random[i].ptr, RLEN);
+
+	for (j=0; j<i; ++j) {
+	    if (pj_strcmp(&random[i], &random[j])==0)
+		return -330;
+	}
+    }
+
+    /* Done. */
+    pj_pool_release(pool);
+
+    /* Case sensitive comparison test. */
+    i = strcmp_test();
+    if (i != 0)
+	return i;
+
+    /* Caseless comparison test. */
+    i = stricmp_test();
+    if (i != 0)
+	return i;
+
+    return 0;
+}
+
+#else
+/* To prevent warning about "translation unit is empty"
+ * when this test is disabled. 
+ */
+int dummy_string_test;
+#endif	/* INCLUDE_STRING_TEST */
+
Index: /pjproject/branches/symbian/symbian/ABLD.BAT
===================================================================
--- /pjproject/branches/symbian/symbian/ABLD.BAT	(revision 692)
+++ /pjproject/branches/symbian/symbian/ABLD.BAT	(revision 692)
@@ -0,0 +1,15 @@
+@ECHO OFF
+
+REM Bldmake-generated batch file - ABLD.BAT
+REM ** DO NOT EDIT **
+
+perl -S ABLD.PL "\Project\symbian\symbian\\" %1 %2 %3 %4 %5 %6 %7 %8 %9
+if errorlevel==1 goto CheckPerl
+goto End
+
+:CheckPerl
+perl -v >NUL
+if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed?
+goto End
+
+:End
Index: /pjproject/branches/symbian/symbian/b.bat
===================================================================
--- /pjproject/branches/symbian/symbian/b.bat	(revision 692)
+++ /pjproject/branches/symbian/symbian/b.bat	(revision 692)
@@ -0,0 +1,4 @@
+rem set MWSym2Libraries=1
+rem set MWSym2Libraries=\Symbian\9.1\S60_3rd\Epoc32\release\winscw\udeb
+set EPOCROOT=\Symbian\9.1\S60_3rd\
+abld build -v winscw udeb
Index: /pjproject/branches/symbian/symbian/bld.inf
===================================================================
--- /pjproject/branches/symbian/symbian/bld.inf	(revision 692)
+++ /pjproject/branches/symbian/symbian/bld.inf	(revision 692)
@@ -0,0 +1,3 @@
+prj_mmpfiles
+pjlib.mmp
+pjlib-test.mmp
Index: /pjproject/branches/symbian/symbian/pjlib-test.mmp
===================================================================
--- /pjproject/branches/symbian/symbian/pjlib-test.mmp	(revision 692)
+++ /pjproject/branches/symbian/symbian/pjlib-test.mmp	(revision 692)
@@ -0,0 +1,57 @@
+TARGET 		pjlib-test-symbian.exe
+TARGETTYPE 	exe
+UID		0x100039CE 0x10004299
+VENDORID	0x70000001
+
+SOURCEPATH	..\pjlib\src\pjlib-test
+
+MACRO		PJ_M_I386=1
+MACRO		PJ_SYMBIAN=1
+MACRO		PJ_IMPORTING
+
+
+// Test files
+
+SOURCE	atomic.c
+SOURCE	echo_clt.c
+SOURCE	errno.c
+SOURCE	exception.c
+SOURCE	fifobuf.c
+SOURCE	file.c
+SOURCE	ioq_perf.c
+SOURCE	ioq_tcp.c
+SOURCE	ioq_udp.c
+SOURCE	ioq_unreg.c
+SOURCE	list.c
+SOURCE	mutex.c
+SOURCE	os.c
+SOURCE	pool.c
+SOURCE	pool_perf.c
+SOURCE	rand.c
+SOURCE	rbtree.c
+SOURCE	select.c
+SOURCE	sleep.c
+SOURCE	sock.c
+SOURCE	sock_perf.c
+SOURCE	string_test.c
+SOURCE	test.c
+SOURCE	thread.c
+SOURCE	timer.c
+SOURCE	timestamp.c
+SOURCE	udp_echo_srv_ioqueue.c
+SOURCE	udp_echo_srv_sync.c
+SOURCE	util.c
+
+SOURCE	main_symbian.cpp
+
+
+SYSTEMINCLUDE	..\pjlib\include
+SYSTEMINCLUDE	\symbian\9.1\S60_3rd\epoc32\include
+SYSTEMINCLUDE	\symbian\9.1\S60_3rd\epoc32\include\libc
+//SYSTEMINCLUDE	\symbian\9.1\S60_3rd_MR\epoc32\include
+//SYSTEMINCLUDE	\symbian\9.1\S60_3rd_MR\epoc32\include\libc
+
+LIBRARY		pjlib-symbian.lib euser.lib estlib.lib eexe.lib
+		//eexe.lib 
+CAPABILITY	None
+
Index: /pjproject/branches/symbian/symbian/pjlib.mmp
===================================================================
--- /pjproject/branches/symbian/symbian/pjlib.mmp	(revision 692)
+++ /pjproject/branches/symbian/symbian/pjlib.mmp	(revision 692)
@@ -0,0 +1,60 @@
+TARGET 		pjlib-symbian.lib
+TARGETTYPE 	lib
+UID		0x100039CE 0x10004299
+VENDORID	0x70000001
+
+SOURCEPATH	..\pjlib\src\pj
+
+MACRO		PJ_M_I386=1
+MACRO		PJ_SYMBIAN=1
+MACRO		PJ_EXPORTING
+
+//
+// Platform independent source
+//
+SOURCE		array.c
+SOURCE		config.c
+SOURCE		ctype.c
+SOURCE		errno.c
+SOURCE		except.c
+SOURCE		fifobuf.c
+SOURCE		guid.c
+SOURCE		hash.c
+SOURCE		list.c
+SOURCE		lock.c
+SOURCE		string.c
+SOURCE		log.c
+SOURCE		os_time_common.c
+SOURCE		pool.c
+SOURCE		pool_caching.c
+SOURCE		rand.c
+SOURCE		rbtree.c
+SOURCE		timer.c
+SOURCE		types.c
+
+
+//
+// Platform dependent source
+//
+SOURCE		addr_resolv_sock.c
+SOURCE		file_access_unistd.c
+SOURCE		file_io_ansi.c
+SOURCE		guid_simple.c
+SOURCE		log_writer_stdout.c
+SOURCE		os_core_symbian.cpp
+SOURCE		os_error_unix.c
+SOURCE		os_time_unix.c
+SOURCE		os_timestamp_common.c
+SOURCE		os_timestamp_posix.c
+SOURCE		pool_policy_malloc.c
+SOURCE		compat\string_compat.c
+SOURCE		sock_bsd.c
+SOURCE		sock_select_symbian.cpp
+SOURCE		ioqueue_symbian.cpp
+
+
+SYSTEMINCLUDE	..\pjlib\include
+//SYSTEMINCLUDE	\symbian\9.1\S60_3rd_MR\epoc32\include
+//SYSTEMINCLUDE	\symbian\9.1\S60_3rd_MR\epoc32\include\libc
+SYSTEMINCLUDE	\symbian\9.1\S60_3rd\epoc32\include
+SYSTEMINCLUDE	\symbian\9.1\S60_3rd\epoc32\include\libc
Index: /pjproject/branches/symbian/symbian/s.bat
===================================================================
--- /pjproject/branches/symbian/symbian/s.bat	(revision 692)
+++ /pjproject/branches/symbian/symbian/s.bat	(revision 692)
@@ -0,0 +1,4 @@
+rem set MWSym2Libraries=1
+set EPOCROOT=\Symbian\9.1\S60_3rd\
+bldmake bldfiles
+call b.bat
