+
+static unsigned int
+uptime_hrs(time_t *now)
+{
+ return t_diff(now, 60 * 60);
+}
+
+
+static unsigned int
+uptime_mins(time_t *now)
+{
+ return t_diff(now, 60);
+}
+
+
+/**
+ * Handler for the IRC command "STATS".
+ * See RFC 2812 section 3.4.4.
+ */
+GLOBAL bool
+IRC_STATS( CLIENT *Client, REQUEST *Req )
+{
+ CLIENT *from, *target, *cl;
+ CONN_ID con;
+ char query;
+ COMMAND *cmd;
+ time_t time_now;
+ unsigned int days, hrs, mins;
+ struct list_head *list;
+ struct list_elem *list_item;
+
+ assert(Client != NULL);
+ assert(Req != NULL);
+
+ if (Req->argc > 2)
+ return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ Client_ID(Client), Req->command);
+
+ /* use prefix to determine "From" */
+ if (Client_Type(Client) == CLIENT_SERVER)
+ from = Client_Search(Req->prefix);
+ else
+ from = Client;
+
+ if (!from)
+ return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
+ Client_ID(Client), Req->prefix);
+
+ if (Req->argc == 2) {
+ /* forward to another server? */
+ target = Client_Search(Req->argv[1]);
+ if ((!target) || (Client_Type(target) != CLIENT_SERVER))
+ return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
+ Client_ID(from), Req->argv[1]);
+
+ if (target != Client_ThisServer()) {
+ /* forward to another server */
+ return IRC_WriteStrClientPrefix(target, from,
+ "STATS %s %s", Req->argv[0], Req->argv[1]);