Browse code

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.

Andrei Pelinescu-Onciul authored on 15/07/2009 20:46:07
Showing 1 changed files
... ...
@@ -279,15 +279,43 @@ static void system_methodHelp(rpc_t* rpc, void* c)
279 279
 
280 280
 
281 281
 static const char* core_prints_doc[] = {
282
-	"Returns the string given as parameter.",   /* Documentation string */
283
-	0                                           /* Method signature(s) */
282
+	"Returns the strings given as parameters.",   /* Documentation string */
283
+	0                                             /* Method signature(s) */
284 284
 };
285 285
 
286 286
 
287 287
 static void core_prints(rpc_t* rpc, void* c)
288 288
 {
289 289
 	char* string = 0;
290
-	if (rpc->scan(c, "s", &string)>0)
290
+	while((rpc->scan(c, "*s", &string)>0))
291
+		rpc->add(c, "s", string);
292
+}
293
+
294
+
295
+static const char* core_printi_doc[] = {
296
+	"Returns the integers given as parameters.",  /* Documentation string */
297
+	0                                             /* Method signature(s) */
298
+};
299
+
300
+
301
+static void core_printi(rpc_t* rpc, void* c)
302
+{
303
+	int i;
304
+	while((rpc->scan(c, "*d", &i)>0))
305
+		rpc->add(c, "d", i);
306
+}
307
+
308
+
309
+static const char* core_echo_doc[] = {
310
+	"Returns back its parameters.",              /* Documentation string */
311
+	0                                             /* Method signature(s) */
312
+};
313
+
314
+
315
+static void core_echo(rpc_t* rpc, void* c)
316
+{
317
+	char* string = 0;
318
+	while((rpc->scan(c, "*.s", &string)>0))
291 319
 		rpc->add(c, "s", string);
292 320
 }
293 321
 
... ...
@@ -699,7 +727,12 @@ static rpc_export_t core_rpc_methods[] = {
699 699
 	{"system.listMethods",     system_listMethods,     system_listMethods_doc,     RET_ARRAY},
700 700
 	{"system.methodSignature", system_methodSignature, system_methodSignature_doc, 0        },
701 701
 	{"system.methodHelp",      system_methodHelp,      system_methodHelp_doc,      0        },
702
-	{"core.prints",            core_prints,            core_prints_doc,            0        },
702
+	{"core.prints",            core_prints,            core_prints_doc,
703
+	RET_ARRAY},
704
+	{"core.printi",            core_printi,            core_printi_doc,
705
+	RET_ARRAY},
706
+	{"core.echo",              core_echo,              core_echo_doc,
707
+	RET_ARRAY},
703 708
 	{"core.version",           core_version,           core_version_doc,           0        },
704 709
 	{"core.uptime",            core_uptime,            core_uptime_doc,            0        },
705 710
 	{"core.ps",                core_ps,                core_ps_doc,                RET_ARRAY},