[sr-dev] git:tirpi/cfg_framework_multivalue: cfg_rpc: group can be specified for cfg .list

Miklos Tirpak miklos at iptel.org
Wed Oct 27 12:53:30 CEST 2010


Module: sip-router
Branch: tirpi/cfg_framework_multivalue
Commit: f6f6e6c8134d5c995d1818890b6107790363410f
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f6f6e6c8134d5c995d1818890b6107790363410f

Author: Miklos Tirpak <miklos at iptel.org>
Committer: Miklos Tirpak <miklos at iptel.org>
Date:   Tue Oct  5 16:50:51 2010 +0200

cfg_rpc: group can be specified for cfg.list

- cfg.list without any parameter lists all the cfg variables.
- cfg.list <group name> lists only the variables of the specific group.

---

 modules/cfg_rpc/README      |    4 ++--
 modules/cfg_rpc/cfg_rpc.c   |   14 ++++++++++++--
 modules/cfg_rpc/doc/rpc.xml |    3 ++-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/modules/cfg_rpc/README b/modules/cfg_rpc/README
index 385ee8d..3bec8f0 100644
--- a/modules/cfg_rpc/README
+++ b/modules/cfg_rpc/README
@@ -60,8 +60,8 @@ Miklos Tirpak
        can optionally contain the group instance id, for example foo[5].
      * cfg.help - Print the description of a configuration variable. The
        function accepts two parameters: group name, variable name.
-     * cfg.list - List the configuration variables. The function does not
-       have any parameters.
+     * cfg.list - List the configuration variables. The function has one
+       optional parameter: group name.
      * cfg.diff - List the pending configuration changes that have not
        been committed yet. The function does not have any parameters.
      * cfg.add_group_inst - Add a new instance to an existing
diff --git a/modules/cfg_rpc/cfg_rpc.c b/modules/cfg_rpc/cfg_rpc.c
index 0ec588f..23cba03 100644
--- a/modules/cfg_rpc/cfg_rpc.c
+++ b/modules/cfg_rpc/cfg_rpc.c
@@ -353,11 +353,21 @@ static void rpc_list(rpc_t* rpc, void* c)
 	str		gname;
 	cfg_def_t	*def;
 	int		i;
+	str		group;
+
+	if (rpc->scan(c, "*S", &group) < 1) {
+		group.s = NULL;
+		group.len = 0;
+	}
 
 	cfg_get_group_init(&h);
 	while(cfg_get_group_next(&h, &gname, &def))
-		for (i=0; def[i].name; i++)
-			rpc->printf(c, "%.*s: %s", gname.len, gname.s, def[i].name);
+		if (!group.len
+			|| ((gname.len == group.len)
+				&& (memcmp(gname.s, group.s, group.len) == 0))
+		)
+			for (i=0; def[i].name; i++)
+				rpc->printf(c, "%.*s: %s", gname.len, gname.s, def[i].name);
 }
 
 static const char* rpc_diff_doc[2] = {
diff --git a/modules/cfg_rpc/doc/rpc.xml b/modules/cfg_rpc/doc/rpc.xml
index 24c5769..4491184 100644
--- a/modules/cfg_rpc/doc/rpc.xml
+++ b/modules/cfg_rpc/doc/rpc.xml
@@ -100,7 +100,8 @@
 	<listitem>
 	    <para>
 		<emphasis>cfg.list</emphasis> - List the configuration
-		variables. The function does not have any parameters.
+		variables. The function has one optional parameter:
+		group name.
 	    </para>
 	</listitem>
 	<listitem>




More information about the sr-dev mailing list