Module: sip-router
Branch: master
Commit: aafc8ea72a36be3ac9bd6115cd492a68e4166e85
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=aafc8ea…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Jul 15 22:46:07 2009 +0200
core: new debug core rpcs
- added core.printi that expects integer parameters and prints
them back in the reply (works with variable numbers of params.)
- added core.echo that echoes back its parameters (works with
variable number of parameters and with any type, it
auto-converts all of them to string).
- changed core.prints to work with variable number of parameters.
---
core_cmd.c | 41 +++++++++++++++++++++++++++++++++++++----
1 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/core_cmd.c b/core_cmd.c
index f2edc3d..bc2bd13 100644
--- a/core_cmd.c
+++ b/core_cmd.c
@@ -279,15 +279,43 @@ static void system_methodHelp(rpc_t* rpc, void* c)
static const char* core_prints_doc[] = {
- "Returns the string given as parameter.", /* Documentation string */
- 0 /* Method signature(s) */
+ "Returns the strings given as parameters.", /* Documentation string */
+ 0 /* Method signature(s) */
};
static void core_prints(rpc_t* rpc, void* c)
{
char* string = 0;
- if (rpc->scan(c, "s", &string)>0)
+ while((rpc->scan(c, "*s", &string)>0))
+ rpc->add(c, "s", string);
+}
+
+
+static const char* core_printi_doc[] = {
+ "Returns the integers given as parameters.", /* Documentation string */
+ 0 /* Method signature(s) */
+};
+
+
+static void core_printi(rpc_t* rpc, void* c)
+{
+ int i;
+ while((rpc->scan(c, "*d", &i)>0))
+ rpc->add(c, "d", i);
+}
+
+
+static const char* core_echo_doc[] = {
+ "Returns back its parameters.", /* Documentation string */
+ 0 /* Method signature(s) */
+};
+
+
+static void core_echo(rpc_t* rpc, void* c)
+{
+ char* string = 0;
+ while((rpc->scan(c, "*.s", &string)>0))
rpc->add(c, "s", string);
}
@@ -699,7 +727,12 @@ static rpc_export_t core_rpc_methods[] = {
{"system.listMethods", system_listMethods, system_listMethods_doc,
RET_ARRAY},
{"system.methodSignature", system_methodSignature, system_methodSignature_doc,
0 },
{"system.methodHelp", system_methodHelp, system_methodHelp_doc,
0 },
- {"core.prints", core_prints, core_prints_doc,
0 },
+ {"core.prints", core_prints, core_prints_doc,
+ RET_ARRAY},
+ {"core.printi", core_printi, core_printi_doc,
+ RET_ARRAY},
+ {"core.echo", core_echo, core_echo_doc,
+ RET_ARRAY},
{"core.version", core_version, core_version_doc,
0 },
{"core.uptime", core_uptime, core_uptime_doc,
0 },
{"core.ps", core_ps, core_ps_doc,
RET_ARRAY},