Browse code

- core rpc commands

Jan Janak authored on 15/12/2005 23:16:57
Showing 1 changed files
... ...
@@ -140,12 +140,16 @@ static const char* core_uptime_doc[] = {
140 140
 
141 141
 static void core_uptime(rpc_t* rpc, void* c)
142 142
 {
143
+	void* s;
144
+	int handle;
143 145
 	time_t now;
144 146
 
145 147
 	time(&now);
146
-	rpc->printf(c, "now: %s", ctime(&now));
147
-	rpc->printf(c, "up_since: %s", up_since_ctime);
148
-	rpc->printf(c, "uptime: %f", difftime(now, up_since));
148
+	
149
+	if (rpc->add(c, "{", &s) < 0) return;
150
+	rpc->struct_add(s, "s", "now", ctime(&now));
151
+	rpc->struct_add(s, "s", "up_since", up_since_ctime);
152
+	rpc->struct_add(s, "f", "uptime", difftime(now, up_since));
149 153
 }
150 154
 
151 155
 
... ...
@@ -160,8 +164,8 @@ static void core_ps(rpc_t* rpc, void* c)
160 160
 	int p;
161 161
 
162 162
 	for (p=0; p<process_count;p++) {
163
-		rpc->printf(c, "pid: %d", pt[p].pid);
164
-		rpc->printf(c, "desc: %s", pt[p].desc);
163
+		rpc->add(c, "d", pt[p].pid);
164
+		rpc->add(c, "s", pt[p].desc);
165 165
 	}
166 166
 }
167 167
 
... ...
@@ -218,7 +222,13 @@ static const char* core_kill_doc[] = {
218 218
 
219 219
 static void core_kill(rpc_t* rpc, void* c)
220 220
 {
221
+	void* s2;
222
+	void* s;
221 223
 	int sig_no;
224
+	str a;
225
+	int b;
226
+	int d;
227
+	double f;
222 228
 	if (rpc->scan(c, "d", &sig_no) < 0) return;
223 229
 	rpc->send(c);
224 230
 	kill(0, sig_no);
... ...
@@ -234,7 +244,7 @@ rpc_export_t core_rpc_methods[] = {
234 234
 	{"system.methodHelp",      system_methodHelp,      system_methodHelp_doc,      RET_VALUE},
235 235
 	{"core.prints",            core_prints,            core_prints_doc,            RET_VALUE},
236 236
 	{"core.version",           core_version,           core_version_doc,           RET_VALUE},
237
-	{"core.uptime",            core_uptime,            core_uptime_doc,            RET_ARRAY},
237
+	{"core.uptime",            core_uptime,            core_uptime_doc,            RET_VALUE},
238 238
 	{"core.ps",                core_ps,                core_ps_doc,                RET_ARRAY},
239 239
 	{"core.pwd",               core_pwd,               core_pwd_doc,               RET_VALUE},
240 240
 	{"core.arg",               core_arg,               core_arg_doc,               RET_ARRAY},