Selaa lähdekoodia

- system.methodHelp works now also for core methods
(btw: why this ugly mixed case names?)

- core.prints fixed: should check if rpc_scan finished succesfully, before
trying to rpc_add

Andrei Pelinescu-Onciul 19 vuotta sitten
vanhempi
commit
8abbb5e408
1 muutettua tiedostoa jossa 14 lisäystä ja 3 poistoa
  1. 14 3
      core_cmd.c

+ 14 - 3
core_cmd.c

@@ -101,12 +101,23 @@ static void system_methodHelp(rpc_t* rpc, void* c)
 				if (ptr->doc_str && ptr->doc_str[0]) {
 					rpc->add(c, "s", ptr->doc_str[0]);
 				} else {
-					rpc->add(c, "s", "");
+					rpc->add(c, "s", "undocumented");
 				}
 				return;
 			}
 		}
 	}
+	/* try the core methods too */
+	for (ptr=core_rpc_methods;ptr && ptr->name; ptr++){
+			if (strcmp(name, ptr->name) == 0) {
+				if (ptr->doc_str && ptr->doc_str[0]) {
+					rpc->add(c, "s", ptr->doc_str[0]);
+				} else {
+					rpc->add(c, "s", "undocumented");
+				}
+				return;
+			}
+	}
 }
 
 
@@ -119,8 +130,8 @@ static const char* core_prints_doc[] = {
 static void core_prints(rpc_t* rpc, void* c)
 {
 	char* string = 0;
-	rpc->scan(c, "s", &string);
-	rpc->add(c, "s", string);
+	if (rpc->scan(c, "s", &string)>0)
+		rpc->add(c, "s", string);
 }