summaryrefslogtreecommitdiff
path: root/pjlib
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-01-18 23:32:27 +0000
committerBenny Prijono <bennylp@teluu.com>2006-01-18 23:32:27 +0000
commitd192c694c8bf65798b042853a23932d08dc806a1 (patch)
treefa35c11eea5117ec5b3d1e1b5401b7431b6a21d9 /pjlib
parent5c43708955177778cac44eb56d98e16cbbecf438 (diff)
Fixed minor warnings/mismatched comments mainly in pjlib++
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@122 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib')
-rw-r--r--pjlib/build/pjlib++.dsp4
-rw-r--r--pjlib/include/pj++/file.hpp6
-rw-r--r--pjlib/include/pj++/os.hpp67
-rw-r--r--pjlib/include/pj++/proactor.hpp16
-rw-r--r--pjlib/include/pj++/scanner.hpp108
-rw-r--r--pjlib/include/pj++/sock.hpp4
-rw-r--r--pjlib/include/pj++/string.hpp22
-rw-r--r--pjlib/include/pj++/timer.hpp2
-rw-r--r--pjlib/include/pj/compat/cc_gcc.h2
-rw-r--r--pjlib/include/pj/compat/cc_msvc.h3
-rw-r--r--pjlib/include/pj/sock.h2
-rw-r--r--pjlib/include/pjlib++.hpp1
12 files changed, 189 insertions, 48 deletions
diff --git a/pjlib/build/pjlib++.dsp b/pjlib/build/pjlib++.dsp
index 77057fbf..0b1baea3 100644
--- a/pjlib/build/pjlib++.dsp
+++ b/pjlib/build/pjlib++.dsp
@@ -107,6 +107,10 @@ SOURCE="..\include\pj++\os.hpp"
# 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 9efe53f5..1c44a56d 100644
--- a/pjlib/include/pj++/file.hpp
+++ b/pjlib/include/pj++/file.hpp
@@ -83,9 +83,9 @@ public:
//
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 2484e1bd..07fd6e85 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 @@ public:
{
destroy();
return Pj_Thread_API::create( pool, &thread_, &thread_proc, this,
- flags, thread_name);
+ flags, thread_name, stack_size);
}
//
@@ -531,6 +532,7 @@ public:
unsigned initial = 0, const char *name = NULL)
: sem_(NULL)
{
+ create(pool, max, initial, name);
}
//
@@ -722,6 +724,69 @@ private:
};
//
+// 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 92309ea6..3f967b73 100644
--- a/pjlib/include/pj++/proactor.hpp
+++ b/pjlib/include/pj++/proactor.hpp
@@ -206,23 +206,21 @@ protected:
//
// 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 @@ protected:
//
// 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 @@ private:
//
// 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 e9ffe304..fb012056 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__); }
+ Pj_Cis_Buffer()
+ {
+ pj_cis_buf_init(&buf_);
+ }
+
+private:
+ 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 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); }
+ void add_alpha()
+ {
+ pj_cis_add_alpha(&cis_);
+ }
+
+ void add_num()
+ {
+ pj_cis_add_num(&cis_);
+ }
- pj_char_spec_element_t *cs_()
+ void add_str(const char *str)
{
- return cs__;
+ pj_cis_add_str(&cis_, str);
}
- const pj_char_spec_element_t *cs_() const
+ void add_cis(const Pj_Cis &rhs)
{
- return cs__;
+ 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_char_spec cs__;
+ pj_cis_t cis_;
};
+
+
class Pj_Scanner
{
public:
@@ -85,9 +141,9 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 ab86f77a..cb952c0c 100644
--- a/pjlib/include/pj++/sock.hpp
+++ b/pjlib/include/pj++/sock.hpp
@@ -235,7 +235,7 @@ public:
//
// 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 @@ public:
//
// 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 aa196c8f..1c868986 100644
--- a/pjlib/include/pj++/string.hpp
+++ b/pjlib/include/pj++/string.hpp
@@ -344,6 +344,24 @@ public:
}
//
+ // 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 @@ public:
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 927de13c..b547f6d4 100644
--- a/pjlib/include/pj++/timer.hpp
+++ b/pjlib/include/pj++/timer.hpp
@@ -62,7 +62,7 @@ public:
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 f49c8b0a..fa9c2aca 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 57f97a3d..291ecc82 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 89883495..cd15913a 100644
--- a/pjlib/include/pj/sock.h
+++ b/pjlib/include/pj/sock.h
@@ -663,7 +663,7 @@ PJ_DECL(pj_status_t) pj_sock_send(pj_sock_t sockfd,
* @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 59a3d611..078ff187 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>