Jelajahi Sumber

* Hacked update.mod out

svn: 650
Bryan Drewery 22 tahun lalu
induk
melakukan
6335fe0ef6

+ 1 - 1
src/main.c

@@ -1206,7 +1206,7 @@ int main(int argc, char **argv)
 #endif /* LEAF */
   module_load("transfer");
   module_load("share");
-  module_load("update"); 
+  update_init();
   module_load("notes");
   module_load("console");
   ctcp_init();

+ 1 - 2
src/mod/static.h

@@ -18,9 +18,9 @@ char *server_start();
 #endif
 char *share_start();
 char *transfer_start();
-char *update_start();
 
 void ctcp_init();
+void update_init();
 
 static void link_statics()
 {
@@ -37,7 +37,6 @@ static void link_statics()
 #endif
   check_static("share", share_start);
   check_static("transfer", transfer_start);
-  check_static("update", update_start);
 }
 
 #endif /* _EGG_MOD_STATIC_H */

+ 26 - 27
src/mod/transfer.mod/transfer.c

@@ -14,19 +14,22 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "src/mod/module.h"
-#include "src/mod/update.mod/update.h"
 #include "src/tandem.h"
 #include "src/net.h"
 
 #include "src/users.h"
 #include "transfer.h"
 
+#include "src/mod/update.mod/update.h"
+
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+extern int		bupdating;
+
 static bind_table_t *BT_rcvd, *BT_sent, *BT_lost, *BT_tout;
 
-static Function *global = NULL, *update_funcs = NULL;
+static Function *global = NULL;
 
 static int copy_to_tmp = 1;	/* Copy files to /tmp before transmitting? */
 static int wait_dcc_xfer = 40;	/* Timeout time on DCC xfers */
@@ -44,9 +47,9 @@ static void stats_add_upload(struct userrec *, unsigned long);
 static void wipe_tmp_filename(char *, int);
 static int at_limit(char *);
 static void dcc_get_pending(int, char *, int);
-static struct dcc_table DCC_SEND;
-static struct dcc_table DCC_GET;
-static struct dcc_table DCC_GET_PENDING;
+struct dcc_table DCC_SEND;
+struct dcc_table DCC_GET;
+struct dcc_table DCC_GET_PENDING;
 
 static fileq_t *fileq = NULL;
 
@@ -516,7 +519,7 @@ static unsigned long pump_file_to_sock(FILE *file, long sock,
   return pending_data;
 }
 
-static void eof_dcc_fork_send(int idx)
+void eof_dcc_fork_send(int idx)
 {
   char s1[121];
   char *s2;
@@ -768,7 +771,7 @@ inline static void handle_resend_packet(int idx, transfer_reget *reget_data)
  * Note: The first received packet during reget is a special 8 bit packet
  *       containing special information.
  */
-static void dcc_get(int idx, char *buf, int len)
+void dcc_get(int idx, char *buf, int len)
 {
   char xnick[NICKLEN];
   unsigned char bbuf[4];
@@ -933,7 +936,7 @@ static void dcc_get(int idx, char *buf, int len)
   dcc[idx].status += l;
 }
 
-static void eof_dcc_get(int idx)
+void eof_dcc_get(int idx)
 {
   char xnick[NICKLEN], s[1024];
 
@@ -1011,7 +1014,7 @@ static void eof_dcc_get(int idx)
     send_next_file(xnick);
 }
 
-static void dcc_send(int idx, char *buf, int len)
+void dcc_send(int idx, char *buf, int len)
 {
   char s[512], *b;
   unsigned long sent;
@@ -1126,7 +1129,7 @@ static void transfer_get_timeout(int i)
     send_next_file(xx);
 }
 
-static void tout_dcc_send(int idx)
+void tout_dcc_send(int idx)
 {
   if (!strcmp(dcc[idx].nick, "*users")) {
     int x, y = 0;
@@ -1170,7 +1173,7 @@ static void tout_dcc_send(int idx)
   lostdcc(idx);
 }
 
-static void display_dcc_get(int idx, char *buf)
+void display_dcc_get(int idx, char *buf)
 {
   if (dcc[idx].status == dcc[idx].u.xfer->length)
     sprintf(buf,TRANSFER_SEND, dcc[idx].u.xfer->acked,
@@ -1180,24 +1183,24 @@ static void display_dcc_get(int idx, char *buf)
 	    dcc[idx].u.xfer->length, dcc[idx].u.xfer->origname);
 }
 
-static void display_dcc_get_p(int idx, char *buf)
+void display_dcc_get_p(int idx, char *buf)
 {
   sprintf(buf,TRANSFER_SEND_WAITED, now - dcc[idx].timeval,
 	  dcc[idx].u.xfer->origname);
 }
 
-static void display_dcc_send(int idx, char *buf)
+void display_dcc_send(int idx, char *buf)
 {
   sprintf(buf,TRANSFER_SEND, dcc[idx].status,
 	  dcc[idx].u.xfer->length, dcc[idx].u.xfer->origname);
 }
 
-static void display_dcc_fork_send(int idx, char *buf)
+void display_dcc_fork_send(int idx, char *buf)
 {
   sprintf(buf,TRANSFER_CONN_SEND);
 }
 
-static void kill_dcc_xfer(int idx, void *x)
+void kill_dcc_xfer(int idx, void *x)
 {
   register struct xfer_info *p = (struct xfer_info *) x;
 
@@ -1211,7 +1214,7 @@ static void kill_dcc_xfer(int idx, void *x)
   free(x);
 }
 
-static void out_dcc_xfer(int idx, char *buf, void *x)
+void out_dcc_xfer(int idx, char *buf, void *x)
 {
 }
 
@@ -1223,7 +1226,7 @@ static void outdone_dcc_xfer(int idx)
 			      dcc[idx].u.xfer->block_pending);
 }
 
-static struct dcc_table DCC_SEND =
+struct dcc_table DCC_SEND =
 {
   "SEND",
   DCT_FILETRAN | DCT_FILESEND | DCT_VALIDIDX,
@@ -1236,9 +1239,9 @@ static struct dcc_table DCC_SEND =
   out_dcc_xfer
 };
 
-static void dcc_fork_send(int idx, char *x, int y);
+void dcc_fork_send(int idx, char *x, int y);
 
-static struct dcc_table DCC_FORK_SEND =
+struct dcc_table DCC_FORK_SEND =
 {
   "FORK_SEND",
   DCT_FILETRAN | DCT_FORKTYPE | DCT_FILESEND | DCT_VALIDIDX,
@@ -1251,7 +1254,7 @@ static struct dcc_table DCC_FORK_SEND =
   out_dcc_xfer
 };
 
-static void dcc_fork_send(int idx, char *x, int y)
+void dcc_fork_send(int idx, char *x, int y)
 {
   char s1[121];
 
@@ -1264,7 +1267,7 @@ static void dcc_fork_send(int idx, char *x, int y)
     putlog(LOG_MISC, "*", TRANSFER_DCC_CONN, dcc[idx].u.xfer->origname, s1);
 }
 
-static struct dcc_table DCC_GET =
+struct dcc_table DCC_GET =
 {
   "GET",
   DCT_FILETRAN | DCT_VALIDIDX,
@@ -1278,7 +1281,7 @@ static struct dcc_table DCC_GET =
   outdone_dcc_xfer
 };
 
-static struct dcc_table DCC_GET_PENDING =
+struct dcc_table DCC_GET_PENDING =
 {
   "GET_PENDING",
   DCT_FILETRAN | DCT_VALIDIDX,
@@ -1451,7 +1454,7 @@ static int raw_dcc_resend(char *filename, char *nick, char *from, char *dir)
 
 /* Starts a DCC_SEND connection.
  */
-static int raw_dcc_send(char *filename, char *nick, char *from, char *dir)
+int raw_dcc_send(char *filename, char *nick, char *from, char *dir)
 {
   return raw_dcc_resend_send(filename, nick, from, dir, 0);
 }
@@ -1789,10 +1792,6 @@ char *transfer_start(Function *global_funcs)
 
   fileq = NULL;
   module_register(MODULE_NAME, transfer_table, 2, 2);
-  if (!(update_funcs = module_depend(MODULE_NAME, "update", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires update module 0.0 or later.";
-  }
 
   add_builtins("load", transfer_load);
 

+ 4 - 3
src/mod/transfer.mod/transfer.h

@@ -30,8 +30,9 @@ enum {
         XFER_ACK_WITHOUT_OFFSET /* Skipped data is NOT counted in ack.  */
 };
 
+int raw_dcc_send(char *, char *, char *, char *);
 
-#ifndef MAKING_TRANSFER
+#if !defined(MAKING_TRANSFER) && defined(MAKING_MODS)
 /* 4 - 7 */
 #define DCC_FORK_SEND (*(struct dcc_table *)(transfer_funcs[4]))
 #define at_limit(a) (((int (*) (char *))transfer_funcs[5])(a))
@@ -55,10 +56,10 @@ enum {
 /* 20 - 23 */
 /* UNUSED 20 */
 
-#else	/* MAKING_TRANSFER */
+#endif
+#ifdef MAKING_TRANSFER
 
 static int raw_dcc_resend(char *, char *, char *, char *);
-static int raw_dcc_send(char *, char *, char *, char *);
 
 #define TRANSFER_REGET_PACKETID 0xfeab
 

+ 24 - 46
src/mod/update.mod/update.c

@@ -3,11 +3,20 @@
  *
  */
 
-#define MODULE_NAME "update"
-#define MAKING_update
-
-#include "src/mod/module.h"
+#undef MAKING_MODS
+
+#include "src/common.h"
+#include "src/users.h"
+#include "src/modules.h"
+#include "src/dcc.h"
+#include "src/botnet.h"
+#include "src/main.h"
+#include "src/botmsg.h"
+#include "src/tandem.h"
+#include "src/misc_file.h"
 #include "src/net.h"
+#include "src/tclhash.h"
+#include "src/misc.h"
 
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -22,9 +31,6 @@
 #include "src/mod/transfer.mod/transfer.h"
 #include "src/mod/compress.mod/compress.h"
 
-static Function *global = NULL, *transfer_funcs = NULL, *compress_funcs = NULL,
-                *uncompress_funcs = NULL;
-
 
 /* Prototypes */
 static void start_sending_binary(int);
@@ -32,6 +38,14 @@ static void cancel_user_xfer(int, void *);
 
 #include "update.h"
 
+extern struct userrec	*userlist;
+extern tand_t		*tandbot;
+extern int 		localhub, max_dcc, egg_numver;
+extern char		botnetnick[], tempdir[], natip[];
+extern time_t		buildts;
+extern struct dcc_table DCC_FORK_SEND, DCC_GET;
+
+
 #ifdef HUB
 int bupdating = 0;
 #endif /* HUB */
@@ -221,7 +235,7 @@ static void updatein_mod(int idx, char *msg)
 }
 
 
-static void finish_update(int idx)
+void finish_update(int idx)
 {
   //module_entry *me;
   struct passwd *pw;
@@ -434,7 +448,7 @@ static void check_updates()
 }
 #endif /* HUB */
 
-static void update_report(int idx, int details)
+void update_report(int idx, int details)
 {
   int i, j;
 
@@ -479,43 +493,8 @@ static void update_report(int idx, int details)
   }
 }
 
-EXPORT_SCOPE char *update_start();
-
-static Function update_table[] =
+void update_init()
 {
-  /* 0 - 3 */
-  (Function) update_start,
-  (Function) NULL,
-  (Function) 0,
-  (Function) update_report,
-  /* 4 - 7 */
-  (Function) finish_update,
-#ifdef HUB
-  (Function) & bupdating
-#else
-  (Function) 0
-#endif /* HUB */
-};
-
-char *update_start(Function *global_funcs)
-{
-
-  global = global_funcs;
-
-  module_register(MODULE_NAME, update_table, 2, 3);
-  if (!(transfer_funcs = module_depend(MODULE_NAME, "transfer", 2, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires transfer module 2.0 or later.";
-  }
-  if (!(compress_funcs = module_depend(MODULE_NAME, "compress", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires the compression.";
-  }
-  if (!(uncompress_funcs = module_depend(MODULE_NAME, "compress", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires the compression.";
-  }
-
   add_builtins("bot", update_bot);
 #ifdef HUB
   add_hook(HOOK_30SECONDLY, (Function) check_updates);
@@ -523,6 +502,5 @@ char *update_start(Function *global_funcs)
   add_hook(HOOK_SHAREUPDATEIN, (Function) updatein_mod);
   def_dcc_bot_kill = DCC_BOT.kill;
   DCC_BOT.kill = cancel_user_xfer;
-  return NULL;
 }
 

+ 4 - 7
src/mod/update.mod/update.h

@@ -30,12 +30,9 @@ typedef struct {
 				   to `priority'.			*/
 } uff_table_t;
 
-#ifndef MAKING_update
-/* 4 - 7 */
-#define finish_update ((void (*) (int))update_funcs[4])
-#ifdef HUB
-#define bupdating (*(int*)update_funcs[5])
-#endif /* HUB */
-#endif				/* !MAKING_update */
+extern int bupdating;
+
+void finish_update(int);
+void update_report(int, int);
 
 #endif				/* _EGG_MOD_update_update_H */