Module: sip-router
Branch: mariusbucur/dmq
Commit: 959e8630cb1780e75c42952719e611f7b52e21b7
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=959e863…
Author: Marius Bucur <marius(a)marius-bucur.ro>
Committer: Marius Bucur <marius(a)marius-bucur.ro>
Date: Sat Jun 4 00:53:46 2011 +0300
some minor modification in the serialization library
---
modules_k/htable/ht_serialize.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/modules_k/htable/ht_serialize.c b/modules_k/htable/ht_serialize.c
index 8365be9..7f47223 100644
--- a/modules_k/htable/ht_serialize.c
+++ b/modules_k/htable/ht_serialize.c
@@ -1,6 +1,8 @@
#include "ht_serialize.h"
-/* snprintf - pretty ugly, but cds/serialize is unusable for the moment */
+/* snprintf - pretty ugly, but cds/serialize is unusable for the moment
+ * TODO using tpl is probably a very good solution
+ */
int serialize_ht_pair(str* key, pv_value_t* val, str* htname, str* s) {
str encoded_key = {0, 0};
str encoded_val = {0, 0};
@@ -42,7 +44,7 @@ int serialize_ht_pair(str* key, pv_value_t* val, str* htname, str* s) {
}
encoded_key.len = len;
- s->len = snprintf(s->s, s->len, "%d %d %.*s %.*s %.*s",
val->flags, val->ri, STR_FMT(&encoded_htname), STR_FMT(&encoded_key),
STR_FMT(&encoded_val));
+ s->len = snprintf(s->s, s->len, "%d|%d|%.*s|%.*s|%.*s",
val->flags, val->ri, STR_FMT(&encoded_htname), STR_FMT(&encoded_key),
STR_FMT(&encoded_val));
if(s->len < 0) {
LM_ERR("cannot serialize data - probably an small buffer\n");
goto error;
@@ -76,7 +78,7 @@ int deserialize_ht_pair(str* key, pv_value_t* val, str* htname, str*
src) {
encoded_key.s = pkg_malloc(src->len);
memset(encoded_key.s, 0, src->len);
- sscanf(src->s, "%d %d %s %s %s", &val->flags, &val->ri,
encoded_htname.s, encoded_key.s, encoded_val.s);
+ sscanf(src->s, "%d|%d|%s|%s|%s", &val->flags, &val->ri,
encoded_htname.s, encoded_key.s, encoded_val.s);
encoded_htname.len = strlen(encoded_htname.s);
encoded_key.len = strlen(encoded_key.s);
encoded_val.len = strlen(encoded_val.s);