Index: ChangeLog
===================================================================
RCS file: /cvsroot/silky/silky/ChangeLog,v
retrieving revision 1.16
diff -u -3 -p -u -r1.16 ChangeLog
--- ChangeLog	16 Nov 2003 11:16:26 -0000	1.16
+++ ChangeLog	16 Nov 2003 13:51:32 -0000
@@ -1,6 +1,7 @@
 2003-11-16 Michele Baldessari <michele@pupazzo.org>
 
 	* Made the message of not finding the silc toolkit a bit clearer
+	* Added support for the STATS command (taken straight from the SILC client)
 
 2003-11-13 Andrej Kacian <andrej@kacian.sk>
 	* Hopefully fixed inputbox focus issue
Index: src/callbacks.c
===================================================================
RCS file: /cvsroot/silky/silky/src/callbacks.c,v
retrieving revision 1.100
diff -u -3 -p -u -r1.100 callbacks.c
--- src/callbacks.c	14 Nov 2003 22:08:15 -0000	1.100
+++ src/callbacks.c	16 Nov 2003 13:51:34 -0000
@@ -2077,6 +2077,17 @@ cmd_server (char *tbuf, char *word[], ch
 
   return 2;
 }
+
+static int
+cmd_stats (char *tbuf, char *word[], char *word_eol[])
+{
+  int i = 0, longfmt = 0;
+  debug("cmd_stats()\n");
+  printconsole (_("\nSTATS Command\n\n"));
+  silc_client_command_call(silky->client, silky->conn, NULL, "STATS", silky->conn->local_entry->server, NULL);
+  return TRUE;
+}
+
 /* *MUST* be kept perfectly sorted for the bsearch to work */
 const struct commands xc_cmds[] = {
 	/*{"ALIAS", cmd_alias, 0, 0, ("ALIAS [<name> [<body>]]")},
@@ -2125,7 +2136,9 @@ const struct commands xc_cmds[] = {
 	{"SERVCHAN", cmd_servchan, 0, 0,
 	 N_("SERVCHAN <host> <port> <channel>, connects and joins a channel")},*/
 	{"SERVER", cmd_server, 0, 0,
-	 ("SERVER <host> [<port>] [<password>], connects to a server, the default port is 706")},/*
+	 ("SERVER <host> [<port>] [<password>], connects to a server, the default port is 706")},
+	{"STATS", cmd_stats, 0, 0,
+	 ("STATS shows some server statistics")},/*
 	{"TOPIC", cmd_topic, 1, 1,
 	 N_("TOPIC [<topic>], sets the topic if one is given, else shows the current topic")},
 	{"UNBAN", cmd_unban, 1, 1,
Index: src/silccallbacks.c
===================================================================
RCS file: /cvsroot/silky/silky/src/silccallbacks.c,v
retrieving revision 1.85
diff -u -3 -p -u -r1.85 silccallbacks.c
--- src/silccallbacks.c	14 Nov 2003 22:08:15 -0000	1.85
+++ src/silccallbacks.c	16 Nov 2003 13:51:34 -0000
@@ -867,15 +867,77 @@ static void silc_command_reply(SilcClien
 
     /* STATS */
   case SILC_COMMAND_STATS:
-    debug("SILC_COMMAND_STATS\n");
-    if (!success) {
-      debug("ERROR !success\n");
-      return;
-    }
+    {
+      SilcUInt32 starttime, uptime, my_clients, my_channels, my_server_ops,
+	         my_router_ops, cell_clients, cell_channels, cell_servers,
+	         clients, channels, servers, routers, server_ops, router_ops;
+      SilcUInt32 buf_len;
+      SilcBufferStruct buf;
+      unsigned char *tmp_buf;
+      char tmp[40];
+      const char *tmptime;
+      int days, hours, mins, secs;
+
+      debug("SILC_COMMAND_STATS\n");
+      if (!success) {
+	debug("ERROR !success\n");
+        return;
+      }
+
+      tmp_buf = va_arg(va, unsigned char *);
+      buf_len = va_arg(va, SilcUInt32);
 
-    printconsole(_("*** got STATS reply, can't yet show it (unimplemented)\n"));
+      if (!tmp_buf || !buf_len) {
+	printconsole(_("No statistics available\n"));
+	return;
+      }
 
-    break;
+      /* Get statistics structure */
+      silc_buffer_set(&buf, tmp_buf, buf_len);
+      silc_buffer_unformat(&buf,
+			   SILC_STR_UI_INT(&starttime),
+			   SILC_STR_UI_INT(&uptime),
+			   SILC_STR_UI_INT(&my_clients),
+			   SILC_STR_UI_INT(&my_channels),
+			   SILC_STR_UI_INT(&my_server_ops),
+			   SILC_STR_UI_INT(&my_router_ops),
+			   SILC_STR_UI_INT(&cell_clients),
+			   SILC_STR_UI_INT(&cell_channels),
+			   SILC_STR_UI_INT(&cell_servers),
+			   SILC_STR_UI_INT(&clients),
+			   SILC_STR_UI_INT(&channels),
+			   SILC_STR_UI_INT(&servers),
+			   SILC_STR_UI_INT(&routers),
+			   SILC_STR_UI_INT(&server_ops),
+			   SILC_STR_UI_INT(&router_ops),
+			   SILC_STR_END);
+
+      tmptime = silc_get_time(starttime);
+      printconsole(g_strdup_printf(_("Local server start time %s\n"), tmptime));
+
+      days = uptime / (24 * 60 * 60);
+      uptime -= days * (24 * 60 * 60);
+      hours = uptime / (60 * 60);
+      uptime -= hours * (60 * 60);
+      mins = uptime / 60;
+      uptime -= mins * 60;
+      secs = uptime;
+      printconsole(g_strdup_printf(_("Local server uptime %d days %d hours %d mins %d secs\n"), days, hours, mins, secs));
+      printconsole(g_strdup_printf(_("Local server clients %d\n"), (int)my_clients));
+      printconsole(g_strdup_printf(_("Local server channels %d\n"), (int)my_channels));
+      printconsole(g_strdup_printf(_("Local server operators %d\n"), (int)my_server_ops));
+      printconsole(g_strdup_printf(_("Local router operators %d\n"), (int)my_router_ops));
+      printconsole(g_strdup_printf(_("Local cell clients %d\n"), (int)cell_clients));
+      printconsole(g_strdup_printf(_("Local cell channels %d\n"), (int)cell_channels));
+      printconsole(g_strdup_printf(_("Local cell servers %d\n"), (int)cell_servers));
+      printconsole(g_strdup_printf(_("Total clients %d\n"), (int)clients));
+      printconsole(g_strdup_printf(_("Total channels %d\n"), (int)channels));
+      printconsole(g_strdup_printf(_("Total servers %d\n"), (int)servers));
+      printconsole(g_strdup_printf(_("Total routers %d\n"), (int)routers));
+      printconsole(g_strdup_printf(_("Total server operators %d\n"), (int)server_ops));
+      printconsole(g_strdup_printf(_("Total router operators %d\n"), (int)router_ops));
+    }
+      break;
 
     /* TOPIC */
   case SILC_COMMAND_TOPIC:
