Module: sip-router Branch: master Commit: 059bd9c5576e7e14bc69506330990a165286d9c1 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=059bd9c5...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: Wed Feb 12 16:14:35 2014 -0500
htable: adding flags and expires fields to htable.get RPC command
---
modules/htable/htable.c | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/modules/htable/htable.c b/modules/htable/htable.c index ab2ecea..a5e110e 100644 --- a/modules/htable/htable.c +++ b/modules/htable/htable.c @@ -649,6 +649,8 @@ error: return 0; }
+#define RPC_DATE_BUF_LEN 21 + static const char* htable_dump_doc[2] = { "Dump the contents of hash table.", 0 @@ -710,6 +712,8 @@ static void htable_rpc_get(rpc_t* rpc, void* c) { ht_cell_t *htc; /*!< One HT cell */ void* th; void* vh; + struct tm *_expire_t; + char expire_buf[RPC_DATE_BUF_LEN]="NEVER";
if (rpc->scan(c, "SS", &htname, &keyname) < 2) { rpc->fault(c, 500, "Not enough parameters (htable name and key name)"); @@ -742,14 +746,27 @@ static void htable_rpc_get(rpc_t* rpc, void* c) { goto error; }
+ if (htc->expire) { + _expire_t = localtime(&htc->expire); + strftime(expire_buf, RPC_DATE_BUF_LEN - 1, + "%Y-%m-%d %H:%M:%S", _expire_t); + } + LM_NOTICE("got expire [%s]\n", expire_buf); + if(htc->flags&AVP_VAL_STR) { - if(rpc->struct_add(vh, "SS", "name", &htc->name.s, "value", &htc->value.s)<0) + if(rpc->struct_add(vh, "SSds", "name", &htc->name.s, + "value", &htc->value.s, + "flags", htc->flags, + "expire", expire_buf)<0) { rpc->fault(c, 500, "Internal error adding item"); goto error; } } else { - if(rpc->struct_add(vh, "Sd", "name", &htc->name.s, "value", (int)htc->value.n)) + if(rpc->struct_add(vh, "Sdds", "name", &htc->name.s, + "value", (int)htc->value.n, + "flags", htc->flags, + "expire", expire_buf)<0) { rpc->fault(c, 500, "Internal error adding item"); goto error; @@ -892,7 +909,7 @@ static void htable_rpc_dump(rpc_t* rpc, void* c) } else { if(rpc->struct_add(vh, "Sd", "name", &it->name.s, - "value", (int)it->value.n)) + "value", (int)it->value.n)<0) { rpc->fault(c, 500, "Internal error adding item"); goto error;