Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_settime.c
index a75a3c00fc3ebc77438cc5774299f74497b74fb2..0847261f05131fd7dc51e9bcc30494a2e9d8a575 100644 (file)
@@ -79,6 +79,8 @@
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
+#include "config.h"
+
 #if 0
 /*
  * No need to include handlers.h here the signatures must match
@@ -90,7 +92,9 @@
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
+#include "ircd_features.h"
 #include "ircd_reply.h"
+#include "ircd_snprintf.h"
 #include "ircd_string.h"
 #include "list.h"
 #include "msg.h"
@@ -137,45 +141,45 @@ int ms_settime(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   if (IsServer(sptr))           /* send to unlagged servers */
   {
-#ifdef RELIABLE_CLOCK
-    sprintf_irc(tbuf, TIME_T_FMT, TStime());
-    parv[1] = tbuf;
-#endif
+    if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+      ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
+      parv[1] = tbuf;
+    }
+
     for (lp = cli_serv(&me)->down; lp; lp = lp->next)
       if (cptr != lp->value.cptr && MsgQLength(&(cli_sendQ(lp->value.cptr))) < 8000)
        sendcmdto_one(sptr, CMD_NOTICE, lp->value.cptr, "%s", parv[1]);
   }
   else
   {
-    sprintf_irc(tbuf, TIME_T_FMT, TStime());
+    ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
     parv[1] = tbuf;
     if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
         HUNTED_ISME)
       return 0;
   }
 
-#ifdef RELIABLE_CLOCK
-  if ((dt > 600) || (dt < -600))
-    sendcmdto_serv_butone(&me, CMD_WALLOPS, 0, ":Bad SETTIME from %s: %Tu",
-                         cli_name(sptr), t);
-  if (IsUser(sptr))
-  {
-    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is not set %ld seconds %s "
-                 ": RELIABLE_CLOCK is defined", sptr, (dt < 0) ? -dt : dt,
-                 (dt < 0) ? "forwards" : "backwards");
+  if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+    if ((dt > 600) || (dt < -600))
+      sendcmdto_serv_butone(&me, CMD_WALLOPS, 0, ":Bad SETTIME from %s: %Tu",
+                           cli_name(sptr), t);
+    if (IsUser(sptr)) {
+      sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is not set %ld "
+                   "seconds %s : RELIABLE_CLOCK is defined", sptr,
+                   (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
+    }
+  } else {
+    sendto_opmask_butone(0, SNO_OLDSNO, "SETTIME from %s, clock is set %ld "
+                        "seconds %s", cli_name(sptr), (dt < 0) ? -dt : dt,
+                        (dt < 0) ? "forwards" : "backwards");
+    TSoffset -= dt;
+    if (IsUser(sptr)) {
+      sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is set %ld seconds %s",
+                   sptr, (dt < 0) ? -dt : dt,
+                   (dt < 0) ? "forwards" : "backwards");
+    }
   }
-#else
-  sendto_opmask_butone(0, SNO_OLDSNO, "SETTIME from %s, clock is set %ld "
-                      "seconds %s", cli_name(sptr), (dt < 0) ? -dt : dt,
-                      (dt < 0) ? "forwards" : "backwards");
-  TSoffset -= dt;
-  if (IsUser(sptr))
-  {
-    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is set %ld seconds %s",
-                 sptr, (dt < 0) ? -dt : dt,
-                 (dt < 0) ? "forwards" : "backwards");
-  }
-#endif
+
   return 0;
 }
 
@@ -213,45 +217,45 @@ int mo_settime(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   if (IsServer(sptr))           /* send to unlagged servers */
   {
-#ifdef RELIABLE_CLOCK
-    sprintf_irc(tbuf, TIME_T_FMT, TStime());
-    parv[1] = tbuf;
-#endif
+    if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+      ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
+      parv[1] = tbuf;
+    }
+
     for (lp = cli_serv(&me)->down; lp; lp = lp->next)
       if (cptr != lp->value.cptr && MsgQLength(&(cli_sendQ(lp->value.cptr))) < 8000)
        sendcmdto_one(sptr, CMD_SETTIME, lp->value.cptr, "%s", parv[1]);
   }
   else
   {
-    sprintf_irc(tbuf, TIME_T_FMT, TStime());
+    ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
     parv[1] = tbuf;
     if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
         HUNTED_ISME)
       return 0;
   }
 
-#ifdef RELIABLE_CLOCK
-  if ((dt > 600) || (dt < -600))
-    sendcmdto_serv_butone(&me, CMD_WALLOPS, 0, ":Bad SETTIME from %s: %Tu",
-                         cli_name(sptr), t);
-  if (IsUser(sptr))
-  {
-    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is not set %ld seconds %s "
-                 ": RELIABLE_CLOCK is defined", sptr, (dt < 0) ? -dt : dt,
-                 (dt < 0) ? "forwards" : "backwards");
-  }
-#else
-  sendto_opmask_butone(0, SNO_OLDSNO, "SETTIME from %s, clock is set %ld "
-                      "seconds %s", cli_name(sptr), (dt < 0) ? -dt : dt,
-                      (dt < 0) ? "forwards" : "backwards");
-  TSoffset -= dt;
-  if (IsUser(sptr))
-  {
-    sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is set %ld seconds %s",
-                 sptr, (dt < 0) ? -dt : dt,
-                 (dt < 0) ? "forwards" : "backwards");
+  if (feature_bool(FEAT_RELIABLE_CLOCK)) {
+    if ((dt > 600) || (dt < -600))
+      sendcmdto_serv_butone(&me, CMD_WALLOPS, 0, ":Bad SETTIME from %s: %Tu",
+                           cli_name(sptr), t);
+    if (IsUser(sptr)) {
+      sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is not set %ld "
+                   "seconds %s : RELIABLE_CLOCK is defined", sptr,
+                   (dt < 0) ? -dt : dt, (dt < 0) ? "forwards" : "backwards");
+    }
+  } else {
+    sendto_opmask_butone(0, SNO_OLDSNO, "SETTIME from %s, clock is set %ld "
+                        "seconds %s", cli_name(sptr), (dt < 0) ? -dt : dt,
+                        (dt < 0) ? "forwards" : "backwards");
+    TSoffset -= dt;
+    if (IsUser(sptr)) {
+      sendcmdto_one(&me, CMD_NOTICE, sptr, "%C :clock is set %ld seconds %s",
+                   sptr, (dt < 0) ? -dt : dt,
+                   (dt < 0) ? "forwards" : "backwards");
+    }
   }
-#endif
+
   return 0;
 }