Fixed minor warnings/mismatched comments mainly in pjlib++

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@122 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/build/pjlib++.dsp b/pjlib/build/pjlib++.dsp
index 77057fb..0b1baea 100644
--- a/pjlib/build/pjlib++.dsp
+++ b/pjlib/build/pjlib++.dsp
@@ -107,6 +107,10 @@
 # End Source File

 # Begin Source File

 

+SOURCE="..\include\pjlib++.hpp"

+# End Source File

+# Begin Source File

+

 SOURCE="..\include\pj++\pool.hpp"

 # End Source File

 # Begin Source File

diff --git a/pjlib/include/pj++/file.hpp b/pjlib/include/pj++/file.hpp
index 9efe53f..1c44a56 100644
--- a/pjlib/include/pj++/file.hpp
+++ b/pjlib/include/pj++/file.hpp
@@ -83,9 +83,9 @@
     //
     enum Offset_Type
     {
-        SEEK_SET = PJ_SEEK_SET,
-        SEEK_CUR = PJ_SEEK_CUR,
-        SEEK_END = PJ_SEEK_END,
+        PJ_SEEK_SET = PJ_SEEK_SET,
+        PJ_SEEK_CUR = PJ_SEEK_CUR,
+        PJ_SEEK_END = PJ_SEEK_END,
     };
 
     //
diff --git a/pjlib/include/pj++/os.hpp b/pjlib/include/pj++/os.hpp
index 2484e1b..07fd6e8 100644
--- a/pjlib/include/pj++/os.hpp
+++ b/pjlib/include/pj++/os.hpp
@@ -20,6 +20,7 @@
 #define __PJPP_OS_HPP__
 
 #include <pj/os.h>
+#include <pj/string.h>
 #include <pj++/types.hpp>
 #include <pj++/pool.hpp>
 
@@ -151,7 +152,7 @@
     {
         destroy();
         return Pj_Thread_API::create( pool, &thread_, &thread_proc, this,
-                                      flags, thread_name);
+                                      flags, thread_name, stack_size);
     }
 
     //
@@ -531,6 +532,7 @@
                  unsigned initial = 0, const char *name = NULL)
     : sem_(NULL)
     {
+	create(pool, max, initial, name);
     }
 
     //
@@ -722,6 +724,69 @@
 };
 
 //
+// Timestamp
+//
+class Pj_Timestamp
+{
+public:
+    pj_status_t get_timestamp()
+    {
+	return pj_get_timestamp(&ts_);
+    }
+
+    Pj_Timestamp& operator += (const Pj_Timestamp &rhs)
+    {
+	pj_add_timestamp(&ts_, &rhs.ts_);
+	return *this;
+    }
+
+    Pj_Timestamp& operator -= (const Pj_Timestamp &rhs)
+    {
+	pj_sub_timestamp(&ts_, &rhs.ts_);
+	return *this;
+    }
+
+    Pj_Time_Val to_time() const
+    {
+	Pj_Timestamp zero;
+	pj_memset(&zero, 0, sizeof(zero));
+	return Pj_Time_Val(pj_elapsed_time(&zero.ts_, &ts_));
+    }
+
+    pj_uint32_t to_msec() const
+    {
+	Pj_Timestamp zero;
+	pj_memset(&zero, 0, sizeof(zero));
+	return pj_elapsed_msec(&zero.ts_, &ts_);
+    }
+
+    pj_uint32_t to_usec() const
+    {
+	Pj_Timestamp zero;
+	pj_memset(&zero, 0, sizeof(zero));
+	return pj_elapsed_usec(&zero.ts_, &ts_);
+    }
+
+    pj_uint32_t to_nanosec() const
+    {
+	Pj_Timestamp zero;
+	pj_memset(&zero, 0, sizeof(zero));
+	return pj_elapsed_nanosec(&zero.ts_, &ts_);
+    }
+
+    pj_uint32_t to_cycle() const
+    {
+	Pj_Timestamp zero;
+	pj_memset(&zero, 0, sizeof(zero));
+	return pj_elapsed_cycle(&zero.ts_, &ts_);
+    }
+
+private:
+    pj_timestamp    ts_;
+};
+
+
+//
 // OS abstraction.
 //
 class Pj_OS_API
diff --git a/pjlib/include/pj++/proactor.hpp b/pjlib/include/pj++/proactor.hpp
index 92309ea..3f967b7 100644
--- a/pjlib/include/pj++/proactor.hpp
+++ b/pjlib/include/pj++/proactor.hpp
@@ -206,23 +206,21 @@
     //
     // Timeout callback.
     //
-    virtual void on_timeout(int data) 
+    virtual void on_timeout(int) 
     {
     }
 
     //
     // On read complete callback.
     //
-    virtual void on_read_complete( Pj_Async_Op *op_key,
-                                   pj_ssize_t bytes_read) 
+    virtual void on_read_complete( Pj_Async_Op*, pj_ssize_t) 
     {
     }
 
     //
     // On write complete callback.
     //
-    virtual void on_write_complete( Pj_Async_Op *op_key, 
-                                    pj_ssize_t bytes_sent) 
+    virtual void on_write_complete( Pj_Async_Op *, pj_ssize_t) 
     {
     }
 
@@ -230,16 +228,14 @@
     //
     // On connect complete callback.
     //
-    virtual void on_connect_complete(pj_status_t status) 
+    virtual void on_connect_complete(pj_status_t) 
     {
     }
 
     //
     // On new connection callback.
     //
-    virtual void on_accept_complete( Pj_Async_Op *op_key,
-                                     pj_sock_t new_sock,
-                                     pj_status_t status) 
+    virtual void on_accept_complete( Pj_Async_Op*, pj_sock_t, pj_status_t) 
     {
     }
 
@@ -256,7 +252,7 @@
     //
     // Static timer callback.
     //
-    static void timer_callback( pj_timer_heap_t *timer_heap, 
+    static void timer_callback( pj_timer_heap_t*, 
                                 struct pj_timer_entry *entry)
     {
         Pj_Event_Handler *handler = 
diff --git a/pjlib/include/pj++/scanner.hpp b/pjlib/include/pj++/scanner.hpp
index e9ffe30..fb01205 100644
--- a/pjlib/include/pj++/scanner.hpp
+++ b/pjlib/include/pj++/scanner.hpp
@@ -22,35 +22,91 @@
 #include <pjlib-util/scanner.h>
 #include <pj++/string.hpp>
 
-class Pj_Char_Spec
+class Pj_Cis;
+class Pj_Cis_Buffer;
+class Pj_Scanner;
+
+class Pj_Cis_Buffer
 {
+    friend class Pj_Cis;
+
 public:
-    Pj_Char_Spec() { pj_cs_init(cs__); }
-
-    void set(int c) { pj_cs_set(cs__, c); }
-    void add_range(int begin, int end) { pj_cs_add_range(cs__, begin, end); }
-    void add_alpha() { pj_cs_add_alpha(cs__); }
-    void add_num() { pj_cs_add_num(cs__); }
-    void add_str(const char *str) { pj_cs_add_str(cs__, str); }
-    void del_range(int begin, int end) { pj_cs_del_range(cs__, begin, end); }
-    void del_str(const char *str) { pj_cs_del_str(cs__, str); }
-    void invert() { pj_cs_invert(cs__); }
-    int  match(int c) { return pj_cs_match(cs__, c); }
-
-    pj_char_spec_element_t *cs_()
-    {
-	return cs__;
-    }
-
-    const pj_char_spec_element_t *cs_() const
-    {
-	return cs__;
+    Pj_Cis_Buffer() 
+    { 
+	pj_cis_buf_init(&buf_); 
     }
 
 private:
-    pj_char_spec cs__;
+    pj_cis_buf_t buf_;
 };
 
+
+class Pj_Cis
+{
+    friend class Pj_Scanner;
+
+public:
+    Pj_Cis(Pj_Cis_Buffer *buf)
+    {
+	pj_cis_init(&buf->buf_, &cis_);
+    }
+
+    Pj_Cis(const Pj_Cis &rhs)
+    {
+	pj_cis_dup(&cis_, (pj_cis_t*)&rhs.cis_);
+    }
+
+    void add_range(int start, int end)
+    {
+	pj_cis_add_range(&cis_, start, end);
+    }
+
+    void add_alpha()
+    {
+	pj_cis_add_alpha(&cis_);
+    }
+
+    void add_num()
+    {
+	pj_cis_add_num(&cis_);
+    }
+
+    void add_str(const char *str)
+    {
+	pj_cis_add_str(&cis_, str);
+    }
+
+    void add_cis(const Pj_Cis &rhs)
+    {
+	pj_cis_add_cis(&cis_, &rhs.cis_);
+    }
+
+    void del_range(int start, int end)
+    {
+	pj_cis_del_range(&cis_, start, end);
+    }
+
+    void del_str(const char *str)
+    {
+	pj_cis_del_str(&cis_, str);
+    }
+
+    void invert()
+    {
+	pj_cis_invert(&cis_);
+    }
+
+    bool match(int c) const
+    {
+	return pj_cis_match(&cis_, c) != 0;
+    }
+
+private:
+    pj_cis_t cis_;
+};
+
+
+
 class Pj_Scanner
 {
 public:
@@ -85,9 +141,9 @@
 	return *scanner_.curptr;
     }
 
-    int peek(const Pj_Char_Spec *cs, Pj_String *out)
+    int peek(const Pj_Cis *cis, Pj_String *out)
     {
-	return pj_scan_peek(&scanner_,  cs->cs_(), out);
+	return pj_scan_peek(&scanner_,  &cis->cis_, out);
     }
 
     int peek_n(pj_size_t len, Pj_String *out)
@@ -95,14 +151,14 @@
 	return pj_scan_peek_n(&scanner_, len, out);
     }
 
-    int peek_until(const Pj_Char_Spec *cs, Pj_String *out)
+    int peek_until(const Pj_Cis *cis, Pj_String *out)
     {
-	return pj_scan_peek_until(&scanner_, cs->cs_(), out);
+	return pj_scan_peek_until(&scanner_, &cis->cis_, out);
     }
 
-    void get(const Pj_Char_Spec *cs, Pj_String *out)
+    void get(const Pj_Cis *cis, Pj_String *out)
     {
-	pj_scan_get(&scanner_, cs->cs_(), out);
+	pj_scan_get(&scanner_, &cis->cis_, out);
     }
 
     void get_n(unsigned N, Pj_String *out)
@@ -125,9 +181,9 @@
 	pj_scan_get_newline(&scanner_);
     }
 
-    void get_until(const Pj_Char_Spec *cs, Pj_String *out)
+    void get_until(const Pj_Cis *cis, Pj_String *out)
     {
-	pj_scan_get_until(&scanner_, cs->cs_(), out);
+	pj_scan_get_until(&scanner_, &cis->cis_, out);
     }
 
     void get_until_ch(int until_ch, Pj_String *out)
@@ -160,7 +216,7 @@
 	pj_scan_skip_whitespace(&scanner_);
     }
 
-    void save_state(State *state)
+    void save_state(State *state) const
     {
 	pj_scan_save_state(&scanner_, state);
     }
@@ -177,7 +233,7 @@
 
     int get_pos_col() const
     {
-	return scanner_.col;
+	return pj_scan_get_col(&scanner_);
     }
 
 
diff --git a/pjlib/include/pj++/sock.hpp b/pjlib/include/pj++/sock.hpp
index ab86f77..cb952c0 100644
--- a/pjlib/include/pj++/sock.hpp
+++ b/pjlib/include/pj++/sock.hpp
@@ -235,7 +235,7 @@
     //
     // getsockopt.
     //
-    pj_status_t getsockopt(int level, int optname, 
+    pj_status_t getsockopt(pj_uint16_t level, pj_uint16_t optname, 
                            void *optval, int *optlen)
     {
 	return pj_sock_getsockopt(sock_, level, optname, optval, optlen);
@@ -244,7 +244,7 @@
     //
     // setsockopt
     // 
-    pj_status_t setsockopt(int level, int optname, 
+    pj_status_t setsockopt(pj_uint16_t level, pj_uint16_t optname, 
                            const void *optval, int optlen)
     {
 	return pj_sock_setsockopt(sock_, level, optname, optval, optlen);
diff --git a/pjlib/include/pj++/string.hpp b/pjlib/include/pj++/string.hpp
index aa196c8..1c86898 100644
--- a/pjlib/include/pj++/string.hpp
+++ b/pjlib/include/pj++/string.hpp
@@ -344,6 +344,24 @@
     }
 
     //
+    // Assign from char*
+    //
+    Pj_String& operator=(char *s)
+    {
+	set(s);
+	return *this;
+    }
+
+    ///
+    // Assign from another Pj_String
+    //
+    Pj_String& operator=(Pj_String &rhs)
+    {
+	set(rhs);
+	return *this;
+    }
+
+    //
     // Find a character in the string.
     //
     char *strchr(int chr)
@@ -415,10 +433,6 @@
         slen = pj_utoa_pad(value, ptr, min_dig, pad);
     }
 
-
-private:
-    //Pj_String(const Pj_String &rhs) {}
-    void operator=(const Pj_String &rhs) { pj_assert(false); }
 };
 
 #endif	/* __PJPP_STRING_HPP__ */
diff --git a/pjlib/include/pj++/timer.hpp b/pjlib/include/pj++/timer.hpp
index 927de13..b547f6d 100644
--- a/pjlib/include/pj++/timer.hpp
+++ b/pjlib/include/pj++/timer.hpp
@@ -62,7 +62,7 @@
 private:
     pj_timer_entry entry_;
 
-    static void timer_heap_callback(pj_timer_heap_t *th, pj_timer_entry *e)
+    static void timer_heap_callback(pj_timer_heap_t*, pj_timer_entry *e)
     {
         Pj_Timer_Entry *entry = (Pj_Timer_Entry*) e->user_data;
         entry->on_timeout(e->id);
diff --git a/pjlib/include/pj/compat/cc_gcc.h b/pjlib/include/pj/compat/cc_gcc.h
index f49c8b0..fa9c2ac 100644
--- a/pjlib/include/pj/compat/cc_gcc.h
+++ b/pjlib/include/pj/compat/cc_gcc.h
@@ -44,6 +44,8 @@
 typedef long long pj_int64_t;
 typedef unsigned long long pj_uint64_t;
 
+#define PJ_INT64_FMT		"L"
+
 
 #endif	/* __PJ_COMPAT_CC_GCC_H__ */
 
diff --git a/pjlib/include/pj/compat/cc_msvc.h b/pjlib/include/pj/compat/cc_msvc.h
index 57f97a3..291ecc8 100644
--- a/pjlib/include/pj/compat/cc_msvc.h
+++ b/pjlib/include/pj/compat/cc_msvc.h
@@ -57,4 +57,7 @@
 typedef __int64 pj_int64_t;
 typedef unsigned __int64 pj_uint64_t;
 
+#define PJ_INT64_FMT	"I64"
+
+
 #endif	/* __PJ_COMPAT_CC_MSVC_H__ */
diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h
index 8988349..cd15913 100644
--- a/pjlib/include/pj/sock.h
+++ b/pjlib/include/pj/sock.h
@@ -663,7 +663,7 @@
  * @param to		The address to send.
  * @param tolen		The length of the address in bytes.
  *
- * @return		The length of data successfully sent.
+ * @return		PJ_SUCCESS or the status code.
  */
 PJ_DECL(pj_status_t) pj_sock_sendto(pj_sock_t sockfd,
 				    const void *buf,
diff --git a/pjlib/include/pjlib++.hpp b/pjlib/include/pjlib++.hpp
index 59a3d61..078ff18 100644
--- a/pjlib/include/pjlib++.hpp
+++ b/pjlib/include/pjlib++.hpp
@@ -19,6 +19,7 @@
 #ifndef __PJLIBPP_H__
 #define __PJLIBPP_H__
 
+#include <pj++/file.hpp>
 #include <pj++/pool.hpp>
 #include <pj++/hash.hpp>
 #include <pj++/list.hpp>