Przeglądaj źródła

* Added S_UTCTIME, will improve later..

svn: 165
Bryan Drewery 22 lat temu
rodzic
commit
cf24baa11e
2 zmienionych plików z 14 dodań i 0 usunięć
  1. 1 0
      pack/conf.h
  2. 13 0
      src/main.c

+ 1 - 0
pack/conf.h

@@ -33,5 +33,6 @@
 #define S_PSCLOAK	/*  yes		cloaks the process for `ps` (can be annoying)	*/
 #define S_PSCLOAK	/*  yes		cloaks the process for `ps` (can be annoying)	*/
 #define S_RANDSERVERS	/*  yes		randomizes the server list per bot		*/
 #define S_RANDSERVERS	/*  yes		randomizes the server list per bot		*/
 #define S_TCLCMDS	/*  no		these serve mainly as a backdoor/debug tool	*/
 #define S_TCLCMDS	/*  no		these serve mainly as a backdoor/debug tool	*/
+#undef 	S_UTCTIME	/*  no/not done	uses GMT/UTC standard time instead of localtime */
 
 
 #endif /* _EGG_CONF_H */
 #endif /* _EGG_CONF_H */

+ 13 - 0
src/main.c

@@ -125,6 +125,9 @@ int	die_on_sigterm = 0;	/* die if bot receives SIGTERM */
 int	resolve_timeout = 10;	/* hostname/address lookup timeout */
 int	resolve_timeout = 10;	/* hostname/address lookup timeout */
 char	quit_msg[1024];		/* quit message */
 char	quit_msg[1024];		/* quit message */
 time_t	now;			/* duh, now :) */
 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;
 extern struct cfg_entry CFG_FORKINTERVAL;
 #define fork_interval atoi( CFG_FORKINTERVAL.ldata ? CFG_FORKINTERVAL.ldata : CFG_FORKINTERVAL.gdata ? CFG_FORKINTERVAL.gdata : "0")
 #define fork_interval atoi( CFG_FORKINTERVAL.ldata ? CFG_FORKINTERVAL.ldata : CFG_FORKINTERVAL.gdata ? CFG_FORKINTERVAL.gdata : "0")
@@ -1332,7 +1335,12 @@ int main(int argc, char **argv)
 
 
   Context;
   Context;
   /* Initialize variables and stuff */
   /* Initialize variables and stuff */
+#ifdef S_UTCTIME
+  now_tmp = time(NULL);
+  now = mktime(gmtime(&now_tmp));
+#else
   now = time(NULL);
   now = time(NULL);
+#endif /* S_UTCTIME */
   chanset = NULL;
   chanset = NULL;
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
   egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
   lastmin = nowtm.tm_min;
   lastmin = nowtm.tm_min;
@@ -1785,7 +1793,12 @@ Context;
     /* Lets move some of this here, reducing the numer of actual
     /* Lets move some of this here, reducing the numer of actual
      * calls to periodic_timers
      * calls to periodic_timers
      */
      */
+#ifdef S_UTCTIME
+    now_tmp = time(NULL);
+    now = mktime(gmtime(&now_tmp));
+#else
     now = time(NULL);
     now = time(NULL);
+#endif /* S_UTCTIME */
     random();			/* Woop, lets really jumble things */
     random();			/* Woop, lets really jumble things */
     if (now != then) {		/* Once a second */
     if (now != then) {		/* Once a second */
       call_hook(HOOK_SECONDLY);
       call_hook(HOOK_SECONDLY);