Bryan Drewery 22 лет назад
Родитель
Сommit
151d96aa08
10 измененных файлов с 103 добавлено и 25 удалено
  1. 1 1
      pack/conf.h
  2. 22 1
      src/cmds.c
  3. 13 14
      src/main.c
  4. 19 4
      src/misc.c
  5. 8 0
      src/mod/irc.mod/cmdsirc.c
  6. 5 1
      src/mod/irc.mod/irc.c
  7. 5 1
      src/mod/notes.mod/notes.c
  8. 10 2
      src/userent.c
  9. 16 0
      src/users.c
  10. 4 1
      src/utc-time.c

+ 1 - 1
pack/conf.h

@@ -29,6 +29,6 @@
 #define S_RANDSERVERS	/*  yes		randomizes the server list per bot		*/
 #define S_SPLITHIJACK   /*  yes         cycle channels on split; CHANFIX/TS fixes       */
 #define S_TCLCMDS	/*  no		these serve mainly as a backdoor/debug tool	*/
-#undef 	S_UTCTIME	/*  not done	uses GMT/UTC standard time instead of localtime */
+#define	S_UTCTIME	/*  yes		uses GMT/UTC standard time instead of localtime */
 
 #endif /* _S_CONF_H */

+ 22 - 1
src/cmds.c

@@ -127,7 +127,11 @@ static void tell_who(struct userrec *u, int idx, int chan)
 	ok = 1;
 	dprintf(idx, STR("Bots connected:\n"));
       }
-      egg_strftime(s, 14, "%d %b %H:%M", localtime(&dcc[i].timeval));
+#ifdef S_UTCTIME
+      egg_strftime(s, 14, "%d %b %H:%M %Z", gmtime(&dcc[i].timeval));
+#else /* !S_UTCTIME */
+      egg_strftime(s, 14, "%d %b %H:%M %Z", localtime(&dcc[i].timeval));
+#endif /* S_UTCTIME */
       if (atr & USER_OWNER) {
         egg_snprintf(format, sizeof format, "  [%%.2lu]  %%s%%c%%-%us (%%s) %%s\n", 
 			    nicklen);
@@ -1273,6 +1277,22 @@ static void cmd_console(struct userrec *u, int idx, char *par)
   }
 }
 
+static void cmd_date(struct userrec *u, int idx, char *par)
+{
+  char date[50], utctime[50], ltime[50];
+  putlog(LOG_CMDS, "*", "#%s# date", dcc[idx].nick);
+  egg_strftime(date, sizeof date, "%c %Z", localtime(&now));
+#ifndef S_UTCTIME
+  sprintf(ltime, "<-- This time is used on the bot.");
+#endif /* !S_UTCTIME */
+  dprintf(idx, "%s %s\n", date, ltime[0] ? ltime : "");
+  egg_strftime(date, sizeof date, "%c %Z", gmtime(&now));
+#ifdef S_UTCTIME
+  sprintf(utctime, "<-- This time is used on the bot.");
+#endif /* S_UTCTIME */
+  dprintf(idx, "%s %s\n", date, utctime[0] ? utctime : "");
+}
+
 #ifdef HUB
 static void cmd_chhandle(struct userrec *u, int idx, char *par)
 {
@@ -3968,6 +3988,7 @@ cmd_t C_dcc[] =
   {"config",		"n",	(Function) cmd_config,		NULL},
 #endif /* HUB */
   {"console",		"-|-",	(Function) cmd_console,		NULL},
+  {"date",		"",	(Function) cmd_date,		NULL},
 #ifdef HUB
   {"dccstat",		"a",	(Function) cmd_dccstat,		NULL},
 #endif /* HUB */

+ 13 - 14
src/main.c

@@ -122,9 +122,6 @@ int	do_restart = 0;		/* .restart has been called, restart asap */
 int	resolve_timeout = 10;	/* hostname/address lookup timeout */
 char	quit_msg[1024];		/* quit message */
 time_t	now;			/* duh, now :) */
-#ifdef S_UTCTIME
-time_t  now_tmp;		/* used to convert to UTC */
-#endif /* S_UTCTIME */
 
 extern struct cfg_entry CFG_FORKINTERVAL;
 #define fork_interval atoi( CFG_FORKINTERVAL.ldata ? CFG_FORKINTERVAL.ldata : CFG_FORKINTERVAL.gdata ? CFG_FORKINTERVAL.gdata : "0")
@@ -667,11 +664,15 @@ static void dtx_arg(int argc, char *argv[])
         got_ed("d", p, p2);
         break; /* this should never be reached */
       case 'v':
-	printf("Wraith %s\nBuild Date: (%lu) %s\n", egg_version, buildts, ctime(&buildts));
+      {
+        char date[50];
+        egg_strftime(date, sizeof date, "%c %Z", gmtime(&buildts));
+	printf("Wraith %s\nBuild Date: (%lu) %s\n", egg_version, buildts, date);
         printf("SALTS\nfiles: %s\nbotlink: %s\n", SALT1, SALT2);
 	bg_send_quit(BG_ABORT);
 	exit(0);
         break; /* this should never be reached */
+      }
 #ifdef LEAF
       case 'P':
         if (getppid() != atoi(argv[optind]))
@@ -841,7 +842,11 @@ static void core_secondly()
     }
   }
 
+#ifdef S_UTCTIME
+  egg_memcpy(&nowtm, gmtime(&now), sizeof(struct tm));
+#else /* !S_UTCTIME */
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
+#endif /* S_UTCTIME */
 
   if (nowtm.tm_min != lastmin) {
     int i = 0;
@@ -1449,14 +1454,13 @@ int main(int argc, char **argv)
 
   Context;
   /* Initialize variables and stuff */
-#ifdef S_UTCTIME
-  now_tmp = time(NULL);
-  now = mktime(gmtime(&now_tmp));
-#else
   now = time(NULL);
-#endif /* S_UTCTIME */
   chanset = NULL;
+#ifdef S_UTCTIME
+  egg_memcpy(&nowtm, gmtime(&now), sizeof(struct tm));
+#else /* !S_UTCTIME */
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
+#endif /* S_UTCTIME */
   lastmin = nowtm.tm_min;
   srandom(now % (getpid() + getppid()));
   init_mem();
@@ -1875,12 +1879,7 @@ Context;
     /* Lets move some of this here, reducing the numer of actual
      * calls to periodic_timers
      */
-#ifdef S_UTCTIME
-    now_tmp = time(NULL);
-    now = mktime(gmtime(&now_tmp));
-#else
     now = time(NULL);
-#endif /* S_UTCTIME */
     random();			/* Woop, lets really jumble things */
     if (now != then) {		/* Once a second */
       call_hook(HOOK_SECONDLY);

+ 19 - 4
src/misc.c

@@ -391,7 +391,11 @@ void daysago(time_t now, time_t then, char *out)
     sprintf(out, "%d day%s ago", days, (days == 1) ? "" : "s");
     return;
   }
+#ifdef S_UTCTIME
+  egg_strftime(out, 6, "%H:%M", gmtime(&then));
+#else /* !S_UTCTIME */
   egg_strftime(out, 6, "%H:%M", localtime(&then));
+#endif /* S_UTCTIME */
 }
 
 /* Convert an interval (in seconds) to one of:
@@ -405,7 +409,11 @@ void days(time_t now, time_t then, char *out)
     sprintf(out, "in %d day%s", days, (days == 1) ? "" : "s");
     return;
   }
+#ifdef S_UTCTIME
+  egg_strftime(out, 9, "at %H:%M", gmtime(&now));
+#else /* !S_UTCTIME */
   egg_strftime(out, 9, "at %H:%M", localtime(&now));
+#endif /* S_UTCTIME */
 }
 
 /* Convert an interval (in seconds) to one of:
@@ -459,16 +467,19 @@ void show_motd(int idx)
 {
   
   if (CFG_MOTD.gdata && *(char *) CFG_MOTD.gdata) {
-    char *who, *buf, day[50], hour[50];
+    char *who, *buf, date[50];
     time_t time;
     void *buf_ptr;
     buf = buf_ptr = nmalloc(strlen((char *) CFG_MOTD.gdata) + 1);
     strcpy(buf, (char *) CFG_MOTD.gdata);
     who = newsplit(&buf);
     time = atoi(newsplit(&buf));
-    egg_strftime(day, sizeof day, "%A %m/%d/%Y", gmtime(&time));
-    egg_strftime(hour, sizeof hour, "%r (%Z)", gmtime(&time));
-    dprintf(idx, "Motd set by \002%s\002 on %s at %s GMT\n", who, day, hour);
+#ifdef S_UTCTIME
+    egg_strftime(date, sizeof date, "%c %Z", gmtime(&time));
+#else /* !S_UTCTIME */
+    egg_strftime(date, sizeof date, "%c %Z", localtime(&time));
+#endif /* S_UTCTIME */
+    dprintf(idx, "Motd set by \002%s\002 (%s)\n", who, date);
     dumplots(idx, "* ", replace(buf, "\\n", "\n"));
     nfree(buf_ptr);
   } else
@@ -561,7 +572,11 @@ void putlog EGG_VARARGS_DEF(int, arg1)
   if ((chname[0] == '*'))
     dohl = 1;
 #ifdef HUB
+#ifdef S_UTCTIME
+  t = gmtime(&now2);
+#else /* !S_UTCTIME */
   t = localtime(&now2);
+#endif /* S_UTCTIME */
   if (shtime) {
     egg_strftime(stamp, sizeof(stamp) - 2, LOG_TS, t);
     strcat(stamp, " ");

+ 8 - 0
src/mod/irc.mod/cmdsirc.c

@@ -1241,9 +1241,17 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
       int hops = m->hops;
       if (m->joined > 0) {
 	if ((now - (m->joined)) > 86400)
+#ifdef S_UTCTIME
+	  egg_strftime(s, 6, "%d%b", gmtime(&(m->joined)));
+#else /* !S_UTCTIME */
 	  egg_strftime(s, 6, "%d%b", localtime(&(m->joined)));
+#endif /* S_UTCTIME */
 	else
+#ifdef S_UTCTIME
+	  egg_strftime(s, 6, "%H:%M", gmtime(&(m->joined)));
+#else /* !S_UTCTIME */
 	  egg_strftime(s, 6, "%H:%M", localtime(&(m->joined)));
+#endif /* S_UTCTIME */
       } else
 	strncpyz(s, " --- ", sizeof s);
       if (m->user == NULL) {

+ 5 - 1
src/mod/irc.mod/irc.c

@@ -690,7 +690,11 @@ static void punish_badguy(struct chanset_t *chan, char *whobad,
   get_user_flagrec(u, &fr, chan->dname);
 
   /* Get current time into a string */
-  egg_strftime(ct, 7, "%d %b", localtime(&now));
+#ifdef S_UTCTIME
+  egg_strftime(ct, sizeof ct, "%d %b %Z", gmtime(&now));
+#else /* !S_UTCTIME */
+  egg_strftime(ct, sizeof ct, "%d %b %Z", localtime(&now));
+#endif /* S_UTCTIME */
 
   /* Put together log and kick messages */
   reason[0] = 0;

+ 5 - 1
src/mod/notes.mod/notes.c

@@ -280,7 +280,11 @@ static void notes_read(char *hand, char *nick, char *srd, int idx)
 	  from = newsplit(&s1);
 	  dt = newsplit(&s1);
 	  tt = atoi(dt);
-	  egg_strftime(wt, 14, "%b %d %H:%M", localtime(&tt));
+#ifdef S_UTCTIME
+	  egg_strftime(wt, sizeof wt, "%b %d %H:%M %Z", gmtime(&tt));
+#else /* !S_UTCTIME */
+	  egg_strftime(wt, sizeof wt, "%b %d %H:%M %Z", localtime(&tt));
+#endif /* S_UTCTIME */
 	  dt = wt;
 	  lapse = (int) ((now - tt) / 86400);
 	  if (lapse > note_life - 7) {

+ 10 - 2
src/userent.c

@@ -234,7 +234,11 @@ void added_display(int idx, struct user_entry *e, struct userrec *u)
       *hnd++ = 0;
     tm = atoi(tmp);
 
-    strftime(tmp2, sizeof(tmp2), STR("%a, %d %b %Y %H:%M:%S GMT"), gmtime(&tm));
+#ifdef S_UTCTIME
+    egg_strftime(tmp2, sizeof(tmp2), STR("%a, %d %b %Y %H:%M:%S %Z"), gmtime(&tm));
+#else /* !S_UTCTIME */
+    egg_strftime(tmp2, sizeof(tmp2), STR("%a, %d %b %Y %H:%M:%S %Z"), localtime(&tm));
+#endif /* S_UTCTIME */
     if (hnd)
       dprintf(idx, STR("  -- Added %s by %s\n"), tmp2, hnd);
     else
@@ -693,7 +697,11 @@ void modified_display(int idx, struct user_entry *e, struct userrec *u)
     if (hnd)
       *hnd++ = 0;
     tm = atoi(tmp);
-    strftime(tmp2, sizeof(tmp2), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&tm));
+#ifdef S_UTCTIME
+    egg_strftime(tmp2, sizeof(tmp2), STR("%a, %d %b %Y %H:%M:%S %Z"), gmtime(&tm));
+#else /* !S_UTCTIME */
+    egg_strftime(tmp2, sizeof(tmp2), STR("%a, %d %b %Y %H:%M:%S %Z"), localtime(&tm));
+#endif /* S_UTCTIME */
     if (hnd)
       dprintf(idx, "  -- Modified %s by %s\n", tmp2, hnd);
     else

+ 16 - 0
src/users.c

@@ -477,9 +477,17 @@ void tell_user(int idx, struct userrec *u, int master)
   else {
     now2 = now - li->laston;
     if (now2 > 86400)
+#ifdef S_UTCTIME
+      egg_strftime(s1, 7, "%d %b", gmtime(&li->laston));
+#else /* !S_UTCTIME */
       egg_strftime(s1, 7, "%d %b", localtime(&li->laston));
+#endif /* S_UTCTIME */
     else
+#ifdef S_UTCTIME
+      egg_strftime(s1, 6, "%H:%M", gmtime(&li->laston));
+#else /* !S_UTCTIME */
       egg_strftime(s1, 6, "%H:%M", localtime(&li->laston));
+#endif /* S_UTCTIME */
   }
   egg_snprintf(format, sizeof format, "%%-%us %%-5s%%5d %%-15s %%s (%%-10.10s)", 
                           HANDLEN);
@@ -499,9 +507,17 @@ void tell_user(int idx, struct userrec *u, int master)
         else {
   	  now2 = now - (ch->laston);
 	  if (now2 > 86400)
+#ifdef S_UTCTIME
+	    egg_strftime(s1, 7, "%d %b", gmtime(&ch->laston));
+#else /* !S_UTCTIME */
 	    egg_strftime(s1, 7, "%d %b", localtime(&ch->laston));
+#endif /* S_UTCTIME */
 	  else
+#ifdef S_UTCTIME
+	    egg_strftime(s1, 6, "%H:%M", gmtime(&ch->laston));
+#else /* !S_UTCTIME */
 	    egg_strftime(s1, 6, "%H:%M", localtime(&ch->laston));
+#endif /* S_UTCTIME */
         }
         fr.match = FR_CHAN;
         fr.chan = ch->flags;

+ 4 - 1
src/utc-time.c

@@ -6,6 +6,9 @@
 
 int main() {
   time_t now = time(NULL);
-  printf("%lu\n", mktime(gmtime(&now)));
+  now = mktime(gmtime(&now));
+  printf("%lu\n", mktime(localtime(&now)));
+  printf("%lu\n", gmtime(&now));
+  printf("%lu\n", now);
   return 0;
 }