pjlib - How do I enum all keys in a pjsip hashtable?

张超
Mon, May 23, 2011 10:12 AM

Hi, all:
How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?
Thanks a lot.

--
Best Regards
Super

Hi, all: How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this? Thanks a lot. -- Best Regards Super
P
peteryzwei
Mon, May 23, 2011 9:28 PM

Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input.

--- On Mon, 5/23/11, 张超 super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To: pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 6:12 AM

Hi, all:
    How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?
    
Thanks a lot.

--
Best RegardsSuper

-----Inline Attachment Follows-----


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input. --- On Mon, 5/23/11, 张超 <super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To: pjsip@lists.pjsip.org Date: Monday, May 23, 2011, 6:12 AM Hi, all:     How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?      Thanks a lot. -- Best RegardsSuper -----Inline Attachment Follows----- _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
张超
Tue, May 24, 2011 1:27 AM

Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions?

--
Best Regards
Super

At 2011-05-24 05:28:31,peteryzwei peteryzwei@yahoo.com wrote:

Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input.

--- OnMon, 5/23/11, 张超super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To:pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 6:12 AM

Hi, all:
How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?
Thanks a lot.

--
Best Regards
Super

-----Inline Attachment Follows-----


Visit our blog:http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions? -- Best Regards Super At 2011-05-24 05:28:31,peteryzwei <peteryzwei@yahoo.com> wrote: Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input. --- OnMon, 5/23/11, 张超<super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To:pjsip@lists.pjsip.org Date: Monday, May 23, 2011, 6:12 AM Hi, all: How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this? Thanks a lot. -- Best Regards Super -----Inline Attachment Follows----- _______________________________________________ Visit our blog:http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
P
peteryzwei
Tue, May 24, 2011 12:34 PM

Super,
  since pj_hash_entry is defined in hash.c, the key is opaque to the caller. To get around this, I suggest adding the following function to hash.c and updating hash.h.

//hash.c
//get the key from the iterator. keyBuf MUST be big enough to hold the key.
pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf) {
  memcpy(keyBuf, iterator->entry->key, iterator->entry->keylen);
  return iterator->entry->keylen;
}

//hash.h
pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf);

--- On Mon, 5/23/11, 张超 super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: Re: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To: "pjsip list" pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 9:27 PM

Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions?

Best RegardsSuper

At 2011-05-24 05:28:31,peteryzwei peteryzwei@yahoo.com wrote:
Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input.

--- On Mon, 5/23/11, 张超 super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To: pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 6:12 AM

Hi, all:
    How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?
    
Thanks a lot.

--
Best RegardsSuper

-----Inline Attachment Follows-----


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

-----Inline Attachment Follows-----


Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Super,   since pj_hash_entry is defined in hash.c, the key is opaque to the caller. To get around this, I suggest adding the following function to hash.c and updating hash.h. //hash.c //get the key from the iterator. keyBuf MUST be big enough to hold the key. pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf) {   memcpy(keyBuf, iterator->entry->key, iterator->entry->keylen);   return iterator->entry->keylen; } //hash.h pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf); --- On Mon, 5/23/11, 张超 <super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: Re: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To: "pjsip list" <pjsip@lists.pjsip.org> Date: Monday, May 23, 2011, 9:27 PM Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions? -- Best RegardsSuper At 2011-05-24 05:28:31,peteryzwei <peteryzwei@yahoo.com> wrote: Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input. --- On Mon, 5/23/11, 张超 <super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To: pjsip@lists.pjsip.org Date: Monday, May 23, 2011, 6:12 AM Hi, all:     How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?      Thanks a lot. -- Best RegardsSuper -----Inline Attachment Follows----- _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org -----Inline Attachment Follows----- _______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
张超
Wed, May 25, 2011 1:55 AM

Thanks, peteryzwei. I got it. I just wanna make sure whether there is some APIs I missed which can get the keys of pj hashtable. Actually, I don't wanna change the source codes of pjsip cause this brings additional code "merge" works while upgrading.
Anyway, thanks a lot.

--
Best Regards
Super

At 2011-05-24 20:34:55,peteryzwei peteryzwei@yahoo.com wrote:

Super,
since pj_hash_entry is defined in hash.c, the key is opaque to the caller. To get around this, I suggest adding the following function to hash.c and updating hash.h.

//hash.c
//get the key from the iterator. keyBuf MUST be big enough to hold the key.
pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf) {
memcpy(keyBuf, iterator->entry->key, iterator->entry->keylen);
return iterator->entry->keylen;
}

//hash.h
pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf);

--- OnMon, 5/23/11, 张超super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: Re: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To: "pjsip list" pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 9:27 PM

Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions?

--
Best Regards
Super

At 2011-05-24 05:28:31,peteryzwei peteryzwei@yahoo.com wrote:

Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input.

--- OnMon, 5/23/11, 张超super119@vip.126.com wrote:

From: 张超 super119@vip.126.com
Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable?
To:pjsip@lists.pjsip.org
Date: Monday, May 23, 2011, 6:12 AM

Hi, all:
How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this?
Thanks a lot.

--
Best Regards
Super

-----Inline Attachment Follows-----


Visit our blog:http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

-----Inline Attachment Follows-----


Visit our blog:http://blog.pjsip.org

pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

Thanks, peteryzwei. I got it. I just wanna make sure whether there is some APIs I missed which can get the keys of pj hashtable. Actually, I don't wanna change the source codes of pjsip cause this brings additional code "merge" works while upgrading. Anyway, thanks a lot. -- Best Regards Super At 2011-05-24 20:34:55,peteryzwei <peteryzwei@yahoo.com> wrote: Super, since pj_hash_entry is defined in hash.c, the key is opaque to the caller. To get around this, I suggest adding the following function to hash.c and updating hash.h. //hash.c //get the key from the iterator. keyBuf MUST be big enough to hold the key. pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf) { memcpy(keyBuf, iterator->entry->key, iterator->entry->keylen); return iterator->entry->keylen; } //hash.h pj_uint32 getKey(pj_hash_iterator_t *iterator, char *keyBuf); --- OnMon, 5/23/11, 张超<super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: Re: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To: "pjsip list" <pjsip@lists.pjsip.org> Date: Monday, May 23, 2011, 9:27 PM Thanks, peteryzwei. But pj_hash_first/pj_hash_next/pj_hash_this can only enum values in the hashtable. I wanna checkout all keys. Any other suggestions? -- Best Regards Super At 2011-05-24 05:28:31,peteryzwei <peteryzwei@yahoo.com> wrote: Use pj_hash_first() to get an iterator then use pj_hash_next() with iterator as input. --- OnMon, 5/23/11, 张超<super119@vip.126.com> wrote: From: 张超 <super119@vip.126.com> Subject: [pjsip] pjlib - How do I enum all keys in a pjsip hashtable? To:pjsip@lists.pjsip.org Date: Monday, May 23, 2011, 6:12 AM Hi, all: How can I enum all keys in a pjsip hashtable? I didn't find such functions in pjlib hashtable's manual. And I tried to get keys directly from pj_hash_entry, but the "keys" member is not open to the outside. So, how can I do this? Thanks a lot. -- Best Regards Super -----Inline Attachment Follows----- _______________________________________________ Visit our blog:http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org -----Inline Attachment Follows----- _______________________________________________ Visit our blog:http://blog.pjsip.org pjsip mailing list pjsip@lists.pjsip.org http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org