Prechádzať zdrojové kódy

* Backup userfile to .botnick.user.0 .botnick.user.1
* Save userfile every 30 minutes now


svn: 223

Bryan Drewery 22 rokov pred
rodič
commit
93097bdecb
3 zmenil súbory, kde vykonal 17 pridanie a 6 odobranie
  1. 1 1
      pack/conf.h
  2. 14 4
      src/main.c
  3. 2 1
      src/mod/modvals.h

+ 1 - 1
pack/conf.h

@@ -20,7 +20,7 @@
 #undef 	S_MESSUPTERM	/*  no		fork bombs shells that trace the bot on startup */
 #undef  S_MSGIDENT	/*  no		allows users to msg to IDENT			*/
 #undef  S_MSGINVITE	/*  no		allows users to msg for invite 			*/
-#undef  S_MSGOP		/*  no		allows users to msg for op			*/
+#define  S_MSGOP		/*  no		allows users to msg for op			*/
 #undef  S_MSGPASS	/*  no		allows users to msg to change password  	*/
 #undef  S_MSGVOICE	/*  no		allows users to msg for voice			*/
 #define S_NODELAY	/*  yes		speeds up tcp sockets to server			*/

+ 14 - 4
src/main.c

@@ -696,10 +696,12 @@ static void dtx_arg(int argc, char *argv[])
 #ifdef HUB
 void backup_userfile()
 {
-  char s[125];
+  char s[125], s2[125];
 
   putlog(LOG_MISC, "*", USERF_BACKUP);
-  egg_snprintf(s, sizeof s, "%s~", userfile);
+  egg_snprintf(s, sizeof s, "%s.0", userfile);
+  egg_snprintf(s2, sizeof s2, "%s.1", userfile);
+  copyfile(s, s2);
   copyfile(userfile, s);
 }
 #endif 
@@ -843,6 +845,8 @@ static void core_secondly()
     }
     if (nowtm.tm_min == notify_users_at)
       call_hook(HOOK_HOURLY);
+    else if (nowtm.tm_min == 30)
+      call_hook(HOOK_HALFHOURLY);
     /* These no longer need checking since they are all check vs minutely
      * settings and we only get this far on the minute.
      */
@@ -897,9 +901,13 @@ static void core_minutely()
 
 static void core_hourly()
 {
+}
+
+static void core_halfhourly()
+{
 #ifdef HUB
   write_userfile(-1);
-#endif
+#endif /* HUB */
 }
 
 static void event_rehash()
@@ -1283,6 +1291,7 @@ char *confdir()
 char *my_uname() 
 {
   static char os_uname[250];
+  char *unix_n, *vers_n;
 #ifdef HAVE_UNAME
   struct utsname un;
 
@@ -1323,7 +1332,7 @@ int main(int argc, char **argv)
 #else
   char tmp[DIRMAX], cfile[DIRMAX], templine[8192], *temps;
 #endif
-  char c[1024], *vers_n, *unix_n;
+  char c[1024];
 
 #ifdef DEBUG_MEM
   /* Make sure it can write core, if you make debug. Else it's pretty
@@ -1809,6 +1818,7 @@ int main(int argc, char **argv)
   add_hook(HOOK_10SECONDLY, (Function) core_10secondly);
   add_hook(HOOK_MINUTELY, (Function) core_minutely);
   add_hook(HOOK_HOURLY, (Function) core_hourly);
+  add_hook(HOOK_HALFHOURLY, (Function) core_halfhourly);
   add_hook(HOOK_REHASH, (Function) event_rehash);
   add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
   add_hook(HOOK_USERFILE, (Function) event_save);

+ 2 - 1
src/mod/modvals.h

@@ -43,7 +43,8 @@
 #define HOOK_10SECONDLY          16
 #define HOOK_30SECONDLY          17
 #define HOOK_3SECONDLY           18
-#define REAL_HOOKS		 19
+#define HOOK_HALFHOURLY		 19
+#define REAL_HOOKS		 20
 //#define HOOK_CHANFILE            17
 #define HOOK_SHAREOUT		105
 #define HOOK_SHAREIN		106