Răsfoiți Sursa

* Changed the order of some initialize functions in main.c to call majority after startup_checks()

svn: 1790
Bryan Drewery 21 ani în urmă
părinte
comite
b99e4fd7c4
16 a modificat fișierele cu 42 adăugiri și 49 ștergeri
  1. 7 12
      src/auth.c
  2. 1 1
      src/auth.h
  3. 1 0
      src/botcmd.h
  4. 1 1
      src/botnet.h
  5. 1 1
      src/cfg.c
  6. 1 0
      src/cfg.h
  7. 1 0
      src/core_binds.c
  8. 1 13
      src/dccutil.c
  9. 1 0
      src/dccutil.h
  10. 16 17
      src/main.c
  11. 8 1
      src/net.c
  12. 1 0
      src/net.h
  13. 0 0
      src/tclhash.c
  14. 0 1
      src/tclhash.h
  15. 1 2
      src/userent.c
  16. 1 0
      src/userent.h

+ 7 - 12
src/auth.c

@@ -35,17 +35,6 @@ int auth_total = 0;
 static int max_auth = 50;
 struct auth_t *auth = NULL;
 
-void
-init_auth_max()
-{
-  if (max_auth < 1)
-    max_auth = 1;
-  if (auth)
-    auth = (struct auth_t *) my_realloc(auth, sizeof(struct auth_t) * max_auth);
-  else
-    auth = (struct auth_t *) my_calloc(1, sizeof(struct auth_t) * max_auth);
-}
-
 static void
 expire_auths()
 {
@@ -67,7 +56,13 @@ expire_auths()
 void
 init_auth()
 {
-  init_auth_max();
+  if (max_auth < 1)
+    max_auth = 1;
+  if (auth)
+    auth = (struct auth_t *) my_realloc(auth, sizeof(struct auth_t) * max_auth);
+  else
+    auth = (struct auth_t *) my_calloc(1, sizeof(struct auth_t) * max_auth);
+
   timer_create_secs(60, "expire_auths", (Function) expire_auths);
 }
 

+ 1 - 1
src/auth.h

@@ -23,7 +23,7 @@ int findauth(char *);
 void removeauth(int);
 char *makebdhash(char *);
 void makehash(int, int, char *);
-
+void init_auth(void);
 
 extern int auth_total;
 extern struct auth_t *auth;

+ 1 - 0
src/botcmd.h

@@ -6,5 +6,6 @@ void send_remote_simul(int, char *, char *, char *);
 void bot_share(int, char *);
 void bot_shareupdate(int, char *);
 int base64_to_int(char *);
+void init_botcmd(void);
 
 #endif /* !_BOTCMD_H */

+ 1 - 1
src/botnet.h

@@ -40,5 +40,5 @@ void botnet_send_cmdpass(int, char *, char *);
 void zapfbot(int);
 void tandem_relay(int, char *, int);
 int getparty(char *, int);
-
+void init_party(void);
 #endif /* !_BOTNET_H */

+ 1 - 1
src/cfg.c

@@ -766,7 +766,7 @@ struct cfg_entry CFG_MOTD = {
 #endif /* HUB */
 };
 
-void init_config()
+void init_cfg()
 {
   add_cfg(&CFG_AUTHKEY);
   add_cfg(&CFG_BADPROCESS);

+ 1 - 0
src/cfg.h

@@ -39,6 +39,7 @@ void trigger_cfg_changed();
 int check_cmd_pass(const char *, char *);
 int has_cmd_pass(const char *);
 void set_cmd_pass(char *, int);
+void init_cfg(void);
 
 extern struct cmd_pass            *cmdpass;
 

+ 1 - 0
src/core_binds.c

@@ -28,6 +28,7 @@ void core_binds_init()
         BT_bot = bind_table_add("bot", 3, "sss", MATCH_EXACT, 0);
         BT_chon = bind_table_add("chon", 2, "si", MATCH_MASK | MATCH_FLAGS, BIND_STACKABLE);
         BT_dcc = bind_table_add("dcc", 2, "is", MATCH_PARTIAL | MATCH_FLAGS, 0);
+	egg_bzero(&cmdlist, 500);
         add_builtins("dcc", C_dcc);
         BT_nkch = bind_table_add("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE);
         BT_note = bind_table_add("note", 3 , "sss", MATCH_EXACT, 0);

+ 1 - 13
src/dccutil.c

@@ -36,26 +36,14 @@ int max_dcc = 200;
 static int dcc_flood_thr = 3;
 
 void
-init_dcc_max()
+init_dcc()
 {
-  int osock = MAXSOCKS;
-
   if (max_dcc < 1)
     max_dcc = 1;
   if (dcc)
     dcc = (struct dcc_t *) my_realloc(dcc, sizeof(struct dcc_t) * max_dcc);
   else
     dcc = (struct dcc_t *) my_calloc(1, sizeof(struct dcc_t) * max_dcc);
-
-  MAXSOCKS = max_dcc + 10;
-  if (socklist)
-    socklist = (sock_list *) my_realloc((void *) socklist, sizeof(sock_list) * MAXSOCKS);
-  else
-    socklist = (sock_list *) my_calloc(1, sizeof(sock_list) * MAXSOCKS);
-
-  for (; osock < MAXSOCKS; osock++)
-    socklist[osock].flags = SOCK_UNUSED;
-
 }
 
 /* Replace \n with \r\n */

+ 1 - 0
src/dccutil.h

@@ -27,6 +27,7 @@ struct portmap {
 #define DP_DUMP		0x8000
 
 
+void init_dcc(void);
 void dprintf(int, const char *, ...) __attribute__((format(printf, 2, 3)));
 void chatout(const char *, ...) __attribute__((format(printf, 1, 2)));
 void chanout_but(int, int, const char *, ...) __attribute__((format(printf, 3, 4)));

+ 16 - 17
src/main.c

@@ -8,7 +8,10 @@
 
 #include "common.h"
 #include "main.h"
+#include "userent.h"
+#include "auth.h"
 #include "adns.h"
+#include "botcmd.h"
 #include "color.h"
 #include "dcc.h"
 #include "misc.h"
@@ -656,9 +659,6 @@ static void startup_checks(int hack) {
 #endif /* LEAF */
 }
 
-int init_dcc_max(), init_userent(), init_auth(), init_config(), init_party(),
- init_net(), init_botcmd();
-
 static char *fake_md5 = "596a96cc7bf9108cd896f33c44aedc8a";
 
 void console_init();
@@ -749,20 +749,8 @@ printf("out: %s\n", out);
   egg_snprintf(tempdir, sizeof tempdir, "%s/tmp/", confdir());
 #endif /* CYGWIN_HACKS */
   clear_tmp();		/* clear out the tmp dir, no matter if we are localhub or not */
-  /* just load everything now, won't matter if it's loaded if the bot has to suicide on startup */
-  init_flags();
-  binds_init();
-  core_binds_init();
-  init_dcc_max();
-  init_userent();
-  init_party();
-  init_net();
-  init_auth();
-  init_config();
-  init_botcmd();
-  init_conf();
-  init_responses();
 
+  init_conf();			/* establishes conffile and sets to defaults */
   if (argc) {
     sdprintf("Calling dtx_arg with %d params.", argc);
     dtx_arg(argc, argv);
@@ -785,8 +773,19 @@ printf("out: %s\n", out);
     }
   }
 
-  egg_dns_init();
 
+  init_flags();			/* needed to establish FLAGS[] */
+  core_binds_init();
+  init_dcc();			/* needed if we are going to make any dcc */
+  init_net();			/* needed for socklist[] */
+  init_userent();		/* needed before loading userfile */
+  init_party();			/* creates party[] */
+  init_auth();			/* creates auth[] */
+  init_cfg();			/* needed for cfg */
+  init_botcmd();
+  init_responses();		/* zeros out response[] */
+
+  egg_dns_init();
   channels_init();
 #ifdef LEAF
   server_init();

+ 8 - 1
src/net.c

@@ -211,10 +211,17 @@ int seed_PRNG(void)
  */
 void init_net()
 {
+  MAXSOCKS = max_dcc + 10;
+
+  if (socklist)
+    socklist = (sock_list *) my_realloc((void *) socklist, sizeof(sock_list) * MAXSOCKS);
+  else
+    socklist = (sock_list *) my_calloc(1, sizeof(sock_list) * MAXSOCKS);
+
   for (int i = 0; i < MAXSOCKS; i++) {
     egg_bzero(&socklist[i], sizeof(socklist[i]));
 #ifdef HAVE_SSL
-    socklist[i].ssl=NULL;
+    socklist[i].ssl = NULL;
 #endif /* HAVE_SSL */
     socklist[i].flags = SOCK_UNUSED;
   }

+ 1 - 0
src/net.h

@@ -165,6 +165,7 @@ void tell_netdebug(int);
 char *iptostr(in_addr_t);
 bool sock_has_data(int, int);
 int sockoptions(int sock, int operation, int sock_options);
+void init_net(void);
 
 extern union sockaddr_union 		cached_myip4_so;
 #ifdef USE_IPV6

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
src/tclhash.c


+ 0 - 1
src/tclhash.h

@@ -64,7 +64,6 @@ typedef struct bind_table_b {
 
 
 void kill_binds(void);
-void binds_init();
 
 int check_bind(bind_table_t *table, const char *match, struct flag_record *flags, ...);
 int check_bind_hits(bind_table_t *table, const char *match, struct flag_record *flags, int *hits, ...);

+ 1 - 2
src/userent.c

@@ -17,11 +17,10 @@
 #include "crypt.h"
 #include "botmsg.h"
 
-static struct user_entry_type *entry_type_list;
+static struct user_entry_type *entry_type_list = NULL;
 
 void init_userent()
 {
-  entry_type_list = NULL;
   add_entry_type(&USERENTRY_COMMENT);
   add_entry_type(&USERENTRY_INFO);
   add_entry_type(&USERENTRY_LASTON);

+ 1 - 0
src/userent.h

@@ -6,5 +6,6 @@
 void update_mod(char *, char *, char *, char *);
 void list_type_kill(struct list_type *);
 void stats_add(struct userrec *, int, int);
+void init_userent(void);
 
 #endif /* !_USERENT_H */

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff