Module: sip-router
Branch: master
Commit: 40e9b5b3238e65c14ad6c4d1be0cb3e0c779c642
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=40e9b5b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Apr 22 16:06:32 2014 +0200
mtree: rpc mtree.summary can take as parameter the name of the tree
---
modules/mtree/mtree_mod.c | 62 +++++++++++++++++++++++++-------------------
1 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c
index f48e443..ea05005 100644
--- a/modules/mtree/mtree_mod.c
+++ b/modules/mtree/mtree_mod.c
@@ -1024,6 +1024,7 @@ error:
void rpc_mtree_summary(rpc_t* rpc, void* c)
{
+ str tname = {0, 0};
m_tree_t *pt;
void* th;
void* ih;
@@ -1034,6 +1035,9 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
return;
}
+ /* read optional tree name */
+ rpc->scan(c, "*S", &tname);
+
pt = mt_get_first_tree();
if(pt==NULL)
{
@@ -1043,34 +1047,38 @@ void rpc_mtree_summary(rpc_t* rpc, void* c)
while(pt!=NULL)
{
- if (rpc->add(c, "{", &th) < 0)
- {
- rpc->fault(c, 500, "Internal error creating rpc");
- return;
- }
- if(rpc->struct_add(th, "s{",
- "table", pt->tname.s,
- "item", &ih) < 0)
+ if(tname.s==NULL
+ || (tname.s!=NULL && pt->tname.len>=tname.len
+ && strncmp(pt->tname.s, tname.s, tname.len)==0))
{
- rpc->fault(c, 500, "Internal error creating rpc ih");
- return;
- }
-
- if(rpc->struct_add(ih, "d", "ttype", pt->type) < 0 ) {
- rpc->fault(c, 500, "Internal error adding type");
- return;
- }
- if(rpc->struct_add(ih, "d", "memsize", pt->memsize) < 0 )
{
- rpc->fault(c, 500, "Internal error adding memsize");
- return;
- }
- if(rpc->struct_add(ih, "d", "nrnodes", pt->nrnodes) < 0 )
{
- rpc->fault(c, 500, "Internal error adding nodes");
- return;
- }
- if(rpc->struct_add(ih, "d", "nritems", pt->nritems) < 0 )
{
- rpc->fault(c, 500, "Internal error adding items");
- return;
+ if (rpc->add(c, "{", &th) < 0)
+ {
+ rpc->fault(c, 500, "Internal error creating rpc");
+ return;
+ }
+ if(rpc->struct_add(th, "s{",
+ "table", pt->tname.s,
+ "item", &ih) < 0)
+ {
+ rpc->fault(c, 500, "Internal error creating rpc ih");
+ return;
+ }
+ if(rpc->struct_add(ih, "d", "ttype", pt->type) < 0 ) {
+ rpc->fault(c, 500, "Internal error adding type");
+ return;
+ }
+ if(rpc->struct_add(ih, "d", "memsize", pt->memsize) < 0 )
{
+ rpc->fault(c, 500, "Internal error adding memsize");
+ return;
+ }
+ if(rpc->struct_add(ih, "d", "nrnodes", pt->nrnodes) < 0 )
{
+ rpc->fault(c, 500, "Internal error adding nodes");
+ return;
+ }
+ if(rpc->struct_add(ih, "d", "nritems", pt->nritems) < 0 )
{
+ rpc->fault(c, 500, "Internal error adding items");
+ return;
+ }
}
pt = pt->next;
}