Ver código fonte

* Fixed some compile/make issues
* Added delays for cycle/down
* Added lag to .netserver
* (more) code cleanup
* Fixed misc bugs/unfinished functions
* Added details to cmd_save [not tested]


svn: 314

Bryan Drewery 22 anos atrás
pai
commit
014da0be9d

+ 17 - 19
Makefile.in

@@ -33,7 +33,7 @@ TCLLIBFN = @TCLLIBFN@
 modconf = $(top_srcdir)/misc/modconfig --top_srcdir=$(top_srcdir)
 
 DEBCFLAGS = -DDEBUG_ASSERT -DDEBUG_MEM -g3 -ggdb3
-CFLGS = 
+CFLGS = -fno-strict-aliasing
 MAKEFLAGS = -s -j4
 
 MAKE_LEAF = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
@@ -59,8 +59,7 @@ MAKE_DHUB = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD) -g' \
 'EGGEXEC=$(HUBEXEC)' 'EGGBUILD=(debug hub)' 'MODOBJS=mod/*.o'
 
 MAKE_UTILS = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'STRIP=$(STRIP)' \
-'CFLGS=$(CFLGS)' 'XREQS=$(XREQS)' \
-'XLIBS=$(XLIBS)' 'LD=$(LD)'
+'CFLGS=$(CFLGS)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' 'LD=$(LD)'
 
 MAKE_DEPEND = $(MAKE) 'MAKE=$(MAKE)' 'CC=$(CC)' 'LD=$(LD)' \
 'STRIP=$(STRIP)' 'CFLGS=$(CFLGS)'
@@ -73,15 +72,15 @@ all:
 	@echo ""
 
 cleanutils:
-	@rm -f stringfix
+	@rm -f src/stringfix src/makesettings src/makesalt
 	@misc/dostrings l
 
 clean:  cleanutils
 	+@cd src && $(MAKE) clean
 	+@cd src/compat && $(MAKE) clean
 	+@cd src/mod && $(MAKE) distclean
-	@rm -f $(HUBEXEC) $(LEAFEXEC) *.stamp core DEBUG *~ key configure.temp makesalt makesettings .mangled
-	@rm -f $(HUBEXEC).* $(LEAFEXEC).* src/makesalt src/makesettings src/settings.c src/settings.tmp
+	@rm -f $(HUBEXEC) $(LEAFEXEC) *.stamp core DEBUG *~ key configure.temp .mangled
+	@rm -f $(HUBEXEC).* $(LEAFEXEC).* src/settings.c src/settings.tmp 
 
 distclean: clean clean-modconfig
 	@rm -f Makefile src/Makefile src/compat/Makefile src/mod/Makefile
@@ -119,14 +118,18 @@ eggautoconf:
 	@$(modconf) eggautoconf
 
 packconf: makesettings
-	@./makesettings pack/pack.cfg src/settings.tmp
-	@touch src/settings.c
+	@src/makesettings pack/pack.cfg src/settings.tmp
+	@(if [ ! -f src/settings.c ]; then \
+	touch src/settings.c; \
+	fi)
 	@(if test "x`diff -qurN src/settings.tmp src/settings.c`" != "x"; then \
 	cp -f src/settings.tmp src/settings.c; \
 	fi)
 
 salt:	makesalt
-	@./makesalt
+	@src/makesalt
+	@cp -f pack/salt.h src/salt.h
+	@src/stringfix src/salt.h
 
 config:
 	@$(modconf) modules-still-exist
@@ -142,21 +145,16 @@ clean-modconfig:
 reconfig: clean-modconfig config
 
 stringfix:
-	@echo -e "Compiling: \033[1mstringfix\033[0m"
-	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) src/stringfix.c -o stringfix
-	@$(STRIP) stringfix
+	+@cd src && ${MAKE_UTILS} stringfix
 
 makesalt:
-	@echo -e "Compiling: \033[1mmakesalt\033[0m"
-	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) src/makesalt.c -o makesalt
-	@$(STRIP) makesalt
+	+@cd src && ${MAKE_UTILS} makesalt
 
 makesettings:
-	@echo -e "Compiling: \033[1mmakesettings\033[0m"
-	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) src/makesettings.c -o makesettings
-	@$(STRIP) makesettings
+	+@cd src && ${MAKE_UTILS} makesettings
 
-utils:  stringfix makesalt makesettings
+utils:
+	+@cd src && ${MAKE_UTILS} utils
 
 dostrings: stringfix
 	@misc/dostrings

+ 24 - 7
src/Makefile.in

@@ -28,6 +28,23 @@ doofus:
 	@echo ""
 	@cd .. && $(MAKE)
 
+makesalt: makesalt.c
+	@echo -e "Compiling: \033[1mmakesalt\033[0m"
+	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) makesalt.c -o makesalt
+	@$(STRIP) makesalt
+
+makesettings: makesettings.c
+	@echo -e "Compiling: \033[1mmakesettings\033[0m"
+	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) makesettings.c -o makesettings
+	@$(STRIP) makesettings
+
+stringfix: stringfix.c
+	@echo -e "Compiling: \033[1mstringfix\033[0m"
+	@$(CC) $(CFLAGS) -I$(top_srcdir) -I$(top_srcdir)/pack $(CPPFLAGS) stringfix.c -o stringfix
+	@$(STRIP) stringfix
+
+utils: stringfix makesettings makesalt
+
 ../$(EGGEXEC): build_msg $(eggdrop_objs) $(XREQS) compatability
 	@echo ""
 	@echo "Linking wraith... $(EGGBUILD)"
@@ -38,7 +55,7 @@ doofus:
 	@echo "Successful compile: $(EGGEXEC)"
 	@echo ""
 
-$(EGGEXEC): ../stringfix ../$(EGGEXEC)
+$(EGGEXEC): stringfix ../$(EGGEXEC)
 
 clean:
 	@rm -f .depend *.o *.a *~ x*.c
@@ -54,10 +71,10 @@ build_msg:
 	@echo "[*] Compiling core components"
 
 
-main.o: ../stringfix
+main.o: stringfix
 	@cp -f main.c xmain.c
 	@echo -e "Compiling: \033[1mmain\033[0m"
-	@../stringfix xmain.c
+	@./stringfix xmain.c
 	@$(CC) $(CFLAGS) -I$(top_srcdir) $(CPPFLAGS) '-DCCFLAGS="$(CC) $(CFLAGS) $(CPPFLAGS)"' \
 	'-DLDFLAGS="$(LD)"' '-DSTRIPFLAGS="$(STRIP)"' -c $(srcdir)/xmain.c -o main.o
 
@@ -73,14 +90,14 @@ eggdrop.h:
 .SUFFIXES: .c .h .o .a
 
 
-.c.o:   ../stringfix
+.c.o:   stringfix
 	@cp -f $< x$<
 	@echo -e "Compiling: \033[1m`basename $< .c`\033[0m"
-	@../stringfix x$<
+	@./stringfix x$<
 	@$(CC) $(CFLAGS) $(CPPFLAGS) -c x$< -o `basename $< .c`.o
+	@${STRIP} `basename $< .c`.o
 
 #safety hash
-../stringfix: stringfix.c
 auth.o: auth.c main.h ../config.h ../pack/conf.h lang.h eggdrop.h flags.h proto.h \
  ../lush.h misc_file.h cmdt.h chan.h users.h compat/compat.h compat/inet_aton.h \
  compat/inet_ntop.h ../src/main.h compat/snprintf.h  compat/memset.h \
@@ -119,7 +136,7 @@ config.o: config.c main.h ../config.h ../pack/conf.h lang.h eggdrop.h flags.h pr
  ../lush.h misc_file.h cmdt.h chan.h users.h compat/compat.h compat/inet_aton.h \
  compat/inet_ntop.h ../src/main.h compat/snprintf.h  compat/memset.h \
  compat/memcpy.h compat/strcasecmp.h compat/strftime.h
-crypt.o: crypt.c main.h ../config.h ../pack/salt.h eggdrop.h proto.h \
+crypt.o: crypt.c main.h ../config.h salt.h eggdrop.h proto.h \
  ../lush.h misc_file.h compat/compat.h compat/inet_aton.h \
  compat/inet_ntop.h ../src/main.h compat/snprintf.h  compat/memset.h \
  compat/memcpy.h compat/strcasecmp.h compat/strftime.h

+ 3 - 2
src/chan.h

@@ -100,8 +100,9 @@ struct chan_t {
   int maxmembers;
   int members;
   int do_opreq;
-  int jointime;
-  int parttime;
+  time_t jointime;
+  time_t parttime;
+  time_t no_op;
 #ifdef S_AUTOLOCK
   int fighting;
 #endif /* S_AUTOLOCK */

+ 19 - 17
src/chanprog.c

@@ -872,23 +872,25 @@ void do_chanset(struct chanset_t *chan, char *options, int local)
   char *buf;
   module_entry *me;
 
+Context;
   /* send out over botnet. */
-  /* nmalloc(options,chan,'cset ',' ',+ 1) */
-  if (chan)
-    buf = nmalloc(strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
-  else
-    buf = nmalloc(strlen(options) + 1 + 5 + 1 + 1);
-  buf[0] = 0;
-  strcat(buf, "cset ");
-  if (chan)
-    strcat(buf, chan->dname);
-  else
-    strcat(buf, "*");
-  strcat(buf, " ");
-  strcat(buf, options);
-  putallbots(buf);
-  nfree(buf);
-
+  if (local != 2) {
+         /* nmalloc(options,chan,'cset ',' ',+ 1) */
+    if (chan)
+      buf = nmalloc(strlen(options) + strlen(chan->dname) + 5 + 1 + 1);
+    else
+      buf = nmalloc(strlen(options) + 1 + 5 + 1 + 1);
+    buf[0] = 0;
+    strcat(buf, "cset ");
+    if (chan)
+      strcat(buf, chan->dname);
+    else
+      strcat(buf, "*");
+    strcat(buf, " ");
+    strcat(buf, options);
+    putallbots(buf);
+    nfree(buf);
+  }
   /* now set locally, hopefully it works */
   if (local && (me = module_find("channels", 0, 0))) {
   /* tcl_channel_modify(0, chan, 1, options) */
@@ -922,7 +924,7 @@ void do_chanset(struct chanset_t *chan, char *options, int local)
           /* Par gets modified in tcl channel_modify under some
            * circumstances, so save it now.
            */
-           (func[38]) (0, ch, 2, list);
+           (func[38]) (0, ch, 2, list);			/* tcl_channel_modify() */
         }
       }
       if (all)

+ 30 - 12
src/cmds.c

@@ -23,7 +23,8 @@ extern struct userrec	 *userlist;
 extern tcl_timer_t	 *timer, *utimer;
 extern int		 dcc_total, remote_boots, backgrd, 
 			 do_restart, conmask, must_be_owner,
-			 strict_host, quiet_save, cfg_count;
+			 strict_host, quiet_save, cfg_count,
+			 server_lag;
 
 extern unsigned long	 otraffic_irc, otraffic_irc_today,
 			 itraffic_irc, itraffic_irc_today,
@@ -1842,9 +1843,22 @@ static void cmd_relay(struct userrec *u, int idx, char *par)
 #ifdef HUB
 static void cmd_save(struct userrec *u, int idx, char *par)
 {
+  char buf[100], i = 0;
   putlog(LOG_CMDS, "*", STR("#%s# save"), dcc[idx].nick);
-  dprintf(idx, STR("Saving user file...\n"));
-  write_userfile(-1);
+  sprintf(buf, "Saving user file...");
+  i = write_userfile(-1);
+  if (i == 0)
+    sprintf(buf, "success.");
+  else if (i == 1)
+    sprintf(buf, "failed: No userlist.");
+  else if (i == 2)
+    sprintf(buf, "failed: Cannot open userfile for writing.");
+  else if (i == 3)
+    sprintf(buf, "failed: Problem writing users/chans (see debug).");
+  else		/* This can't happen. */
+    sprintf(buf, "failed: Unforseen error");
+  buf[99] = 0;
+  dprintf(idx, "%s\n", buf);
 }
 
 static void cmd_backup(struct userrec *u, int idx, char *par)
@@ -3339,7 +3353,6 @@ static void cmd_mns_host(struct userrec *u, int idx, char *par)
 }
 
 /* netserver */
-
 static void cmd_netserver(struct userrec * u, int idx, char * par) {
   putlog(LOG_CMDS, "*", STR("#%s# netserver"), dcc[idx].nick);
   botnet_send_cmd_broad(-1, botnetnick, u->handle, idx, STR("cursrv"));
@@ -3370,11 +3383,13 @@ void rcmd_cursrv(char * fbot, char * fhand, char * fidx) {
     sprintf(cursrvname, "%s", ((char *)(func[41])));
   }
   if (server_online)
-    sprintf(tmp, STR("Currently: %s"), cursrvname);
+    sprintf(tmp, "Currently: %-40s Lag: %d", cursrvname, server_lag);
+//    sprintf(tmp, STR("%-20s %d)"), cursrvname, server_lag);
   else
-    sprintf(tmp, STR("Currently: none"));
+    sprintf(tmp, "Currently: none");
+//    sprintf(tmp, STR("%-20s"), "none");
   botnet_send_cmdreply(botnetnick, fbot, fhand, fidx, tmp);
-#endif
+#endif /* LEAF */
 }
 
 /* netversion */
@@ -3802,11 +3817,14 @@ void gotremotecmd (char * forbot, char * frombot, char * fromhand, char * fromid
     botnet_send_cmdreply(botnetnick, frombot, fromhand, fromidx, STR("Unrecognized remote command"));
   }
 }
-
-void gotremotereply (char * frombot, char * tohand, char * toidx, char * ln) {
-  int idx=atoi(toidx);
-  if ((idx>=0) && (idx<dcc_total) && (dcc[idx].type == &DCC_CHAT) && (!strcmp(dcc[idx].nick, tohand))) {
-    dprintf(idx, STR("(%s) %s\n"), frombot, ln);
+    
+void gotremotereply (char *frombot, char *tohand, char *toidx, char *ln) {
+  int idx = atoi(toidx);
+  if ((idx >= 0) && (idx < dcc_total) && (dcc[idx].type == &DCC_CHAT) && (!strcmp(dcc[idx].nick, tohand))) {
+    char *buf = nmalloc(strlen(frombot) + 2 + 1);
+    sprintf(buf, "(%s)", frombot);
+    dprintf(idx, STR("%-13s %s\n"), buf, ln);
+    nfree(buf);
   }
 }
 

+ 1 - 1
src/dcc.c

@@ -667,7 +667,7 @@ static void dcc_chat_pass(int idx, char *buf, int atr)
       send_timesync(idx);
     } else {
       /* Invalid password/digest on hub */
-      putlog(LOG_WARN, "*", "%s failed encrypted link handshake", dcc[idx].nick);
+      putlog(LOG_WARN, "*", "%s failed encrypted link handshake.", dcc[idx].nick);
       killsock(dcc[idx].sock);
       lostdcc(idx);
     }

+ 3 - 1
src/main.c

@@ -1722,7 +1722,9 @@ Context;
   module_load("console");
   module_load("ctcp");
   module_load("compress");
+Context;
   chanprog();
+Context;
 
 #ifdef LEAF
   if (localhub) {
@@ -1902,7 +1904,7 @@ Context;
     xx = sockgets(buf, &i); 
     if (xx >= 0) {		/* Non-error */
       int idx;
-
+printf("READ: %s\n", buf);
       for (idx = 0; idx < dcc_total; idx++)
 	if (dcc[idx].sock == xx) {
 	  if (dcc[idx].type && dcc[idx].type->activity) {

+ 1 - 1
src/main.h

@@ -13,7 +13,7 @@
 #endif
 
 #include "pack/conf.h"
-#include "pack/salt.h"
+#include "salt.h"
 
 #include "lush.h" /* We seem to need this everywhere... */
 

+ 5 - 6
src/makesalt.c

@@ -51,12 +51,11 @@ int main(void)
     printf("Cannot created Salt-File.. aborting\n");
     exit(1);
   }
-  fprintf(saltfd,"/* SALT1 is for local files */\n",saltlen1);
-  fprintf(saltfd,"#define SALT1 %c%s%c\n",34,randstring(saltlen1),34);
-  fprintf(saltfd,"\n");
-  fprintf(saltfd,"/* SALT2 is for botlink  */\n",saltlen2);
-  fprintf(saltfd,"#define SALT2 %c%s%c\n",34,randstring(saltlen2),34);
-  fprintf(saltfd,"\n");
+  fprintf(saltfd, "#define STR(x) x\n");
+  fprintf(saltfd, "/* SALT1 is for local files */\n");
+  fprintf(saltfd, "#define SALT1 STR(\"%s\")\n", randstring(saltlen1));
+  fprintf(saltfd, "/* SALT2 is for botlink  */\n");
+  fprintf(saltfd, "#define SALT2 STR(\"%s\")\n", randstring(saltlen2));
   fclose(saltfd);
   printf("Salt File created.\n");
   exit (0);

+ 15 - 8
src/makesettings.c

@@ -3,6 +3,12 @@
 #include <ctype.h>
 #include <stdlib.h>
 
+#define strncpyz(_target, _source, _len)        do {                    \
+        strncpy((_target), (_source), (_len) - 1);                      \
+        (_target)[(_len) - 1] = 0;                                      \
+} while (0)
+
+
 #define LISTSEPERATORS  ",=:; "
 #define BADNICKCHARS  ",+*=:!.@#;$%&"
 #define SWITCHMETA    "+-"
@@ -17,7 +23,7 @@ struct cfg_struct {
   char packname[PACKNAMELEN];
   char shellhash[33];
   char bdhash[33];
-  char dccprefix[1];
+  char dccprefix[2];
   char *owners;
   char *hubs;
   char *owneremail;
@@ -198,16 +204,16 @@ int loadconfig(char **argv) {
       if (p) {
         int size = strlen(trim(p)) + 2;
         if (!strcmp(lcase(buffer), "packname")) {
-          strncpy(cfg.packname, trim(p), sizeof cfg.packname - 1);
+          strncpyz(cfg.packname, trim(p), sizeof cfg.packname);
           printf(".");
         } else if (!strcmp(lcase(buffer), "shellhash")) {
-          strncpy(cfg.shellhash, trim(p), sizeof cfg.shellhash - 1);
+          strncpyz(cfg.shellhash, trim(p), sizeof cfg.shellhash);
           printf(".");
         } else if (!strcmp(lcase(buffer), "bdhash")) {
-          strncpy(cfg.bdhash, trim(p), sizeof cfg.bdhash - 1);
+          strncpyz(cfg.bdhash, trim(p), sizeof cfg.bdhash);
           printf(".");
         } else if (!strcmp(lcase(buffer), "dccprefix")) {
-          strncpy(cfg.dccprefix, trim(p), sizeof cfg.dccprefix);
+          strncpyz(cfg.dccprefix, trim(p), sizeof cfg.dccprefix);
           printf(".");
         } else if (!strcmp(lcase(buffer), "owner")) {
           if (cfg.owners && strlen(cfg.owners))
@@ -308,7 +314,7 @@ fprintf(f, " \
 #include <string.h> \n\
 #include \"main.h\"\n\
 \n\
-char packname[512], shellhash[33], bdhash[33], dcc_prefix[1], *owners, *hubs, *owneremail;\n\n\
+char packname[512], shellhash[33], bdhash[33], dcc_prefix[2], *owners, *hubs, *owneremail;\n\n\
 char *progname() {\n\
 #ifdef S_PSCLOAK\n");
 fprintf(f," \
@@ -325,7 +331,7 @@ fprintf(f, " \
 
 
   fprintf(f, "#define _PACKNAME STR(\"%s\")\n", cfg.packname);
-  fprintf(f, "#define _DCCPREFIX STR(\"%c\")\n", cfg.dccprefix[0]);
+  fprintf(f, "#define _DCCPREFIX STR(\"%s\")\n", cfg.dccprefix);
   fprintf(f, "#define _SHELLHASH STR(\"%s\")\n", cfg.shellhash);
   fprintf(f, "#define _BDHASH STR(\"%s\")\n", cfg.bdhash);
   fprintf(f, "#define _OWNERS STR(\"%s\")\n", cfg.owners);
@@ -345,7 +351,8 @@ int init_settings()\n\
   egg_snprintf(packname, sizeof packname, _PACKNAME);\n\
   egg_snprintf(bdhash, sizeof bdhash, _BDHASH);\n\
   egg_snprintf(shellhash, sizeof shellhash, _SHELLHASH);\n\
-  sprintf(dcc_prefix, _DCCPREFIX);\n\
+  egg_snprintf(dcc_prefix, sizeof dcc_prefix, _DCCPREFIX);\n\
+  dcc_prefix[1] = 0;\n\
   sdprintf(STR(\"owners: %%s\\nhubs: %%s\\nowneremail: %%s\"), owners, hubs, owneremail);\n\
   sdprintf(STR(\"dcc_prefix: %%s \\nbdhash: %%s \\nshellhash: %%s\"), dcc_prefix, bdhash, shellhash);\n\
   return 1;\n\

+ 1 - 0
src/misc.c

@@ -63,6 +63,7 @@ int	 shtime = 1;		/* Whether or not to display the time
 				   with console output */
 int	 conmask = LOG_MODES | LOG_CMDS | LOG_MISC; /* Console mask */
 int	 debug_output = 1;	/* Disply output to server to LOG_SERVEROUT */
+int 	 server_lag = 0;	/* GUESS! */
 
 
 /* Expected memory usage

+ 109 - 96
src/mod/channels.mod/channels.c

@@ -8,41 +8,40 @@
 #define MAKING_CHANNELS
 #include <sys/stat.h>
 #include "src/mod/module.h"
-#include "irc.mod/irc.h"
-
-static Function *global		= NULL, *irc_funcs = NULL;
-
-static int  use_info;
-static int  quiet_save;
-static char glob_chanmode[64];		/* Default chanmode (drummer,990731) */
-static char *lastdeletedmask;
-static struct udef_struct *udef;
-static int global_stopnethack_mode;
-static int global_revenge_mode;
-static int global_idle_kick;		/* Default idle-kick setting. */
-static int global_ban_time;
-static int global_exempt_time;
-static int global_invite_time;
+
+static Function *global		= NULL;
+
+static int 			use_info;
+static int			quiet_save;
+static char 			glob_chanmode[64];		/* Default chanmode (drummer,990731) */
+static char 			*lastdeletedmask;
+static struct udef_struct 	*udef;
+static int 			global_stopnethack_mode;
+static int 			global_revenge_mode;
+static int 			global_idle_kick;		/* Default idle-kick setting. */
+static int 			global_ban_time;
+static int 			global_exempt_time;
+static int 			global_invite_time;
 
 /* Global channel settings (drummer/dw) */
-static char glob_chanset[512];
+static char 			glob_chanset[512];
 
 /* Global flood settings */
-static int gfld_chan_thr;
-static int gfld_chan_time;
-static int gfld_deop_thr;
-static int gfld_deop_time;
-static int gfld_kick_thr;
-static int gfld_kick_time;
-static int gfld_join_thr;
-static int gfld_join_time;
-static int gfld_ctcp_thr;
-static int gfld_ctcp_time;
-static int gfld_nick_thr;
-static int gfld_nick_time;
+static int 			gfld_chan_thr;
+static int 			gfld_chan_time;
+static int 			gfld_deop_thr;
+static int 			gfld_deop_time;
+static int 			gfld_kick_thr;
+static int 			gfld_kick_time;
+static int 			gfld_join_thr;
+static int 			gfld_join_time;
+static int 			gfld_ctcp_thr;
+static int 			gfld_ctcp_time;
+static int 			gfld_nick_thr;
+static int 			gfld_nick_time;
 
 #ifdef S_AUTOLOCK
-int killed_bots = 0;
+int 				killed_bots = 0;
 #endif /* S_AUTOLOCK */
 
 #include "channels.h"
@@ -54,7 +53,6 @@ int killed_bots = 0;
 #ifdef S_AUTOLOCK
 #define kill_threshold (CFG_KILLTHRESHOLD.gdata ? atoi(CFG_KILLTHRESHOLD.gdata) : 0)
 #endif /* S_AUTOLOCK */
-
 #ifdef S_AUTOLOCK
 struct cfg_entry CFG_LOCKTHRESHOLD, CFG_KILLTHRESHOLD;
 #endif /* S_AUTOLOCK */
@@ -66,10 +64,7 @@ static void check_should_lock()
 #ifdef HUB
   char *p = CFG_LOCKTHRESHOLD.gdata;
   tand_t *bot;
-  int H,
-    L,
-    hc,
-    lc;
+  int H, L, hc, lc;
   struct chanset_t *chan;
 
   if (!p)
@@ -100,11 +95,10 @@ static void check_should_lock()
         do_chanset(chan, STR("+closed chanmode +stni"), 1);
 #ifdef G_BACKUP
         chan->channel.backup_time = now + 30;
-#endif
+#endif /* G_BACKUP */
       }
     }
   }
-
 #endif /* HUB */
 #endif /* S_AUTOLOCK */
 }
@@ -116,8 +110,6 @@ static void got_cset(char *botnick, char *code, char *par)
   char *chname = NULL, *list[2], *buf, *bak;
   struct chanset_t *chan = NULL;
 
-  module_entry *me;
-Context;
   if (!par[0])
    return;
   else {
@@ -134,7 +126,8 @@ Context;
   }
   if (all)
    chan = chanset;
-//blah - from cmd_chanset
+
+  /* copied from cmd_chanset */
   bak = par;
   buf = nmalloc(strlen(par) + 1);
   while (chan) {
@@ -147,8 +140,7 @@ Context;
           (!strcmp(list[0], "dont-idle-kick"))) {
         if (tcl_channel_modify(0, chan, 1, list) == TCL_OK) {
         } else if (!all || !chan->next)
-          putlog(LOG_BOTS, "@", "Error trying to set %s for %s, invalid mode.",
-                  list[0], all ? "all channels" : chname);
+          putlog(LOG_BOTS, "@", "Error trying to set %s for %s, invalid mode.", list[0], all ? "all channels" : chname);
         list[0] = newsplit(&par);
         continue;
       }
@@ -159,13 +151,12 @@ Context;
          */
         if (tcl_channel_modify(0, chan, 2, list) == TCL_OK) {
         } else if (!all || !chan->next)
-          putlog(LOG_BOTS, "@", "Error trying to set %s for %s, invalid option\n",
-                  list[0], all ? "all channels" : chname);
+          putlog(LOG_BOTS, "@", "Error trying to set %s for %s, invalid option\n", list[0], all ? "all channels" : chname);
       }
       break;
     }
     if (chan->status & CHAN_BITCH) {
-Context;
+      module_entry *me;
       if ((me = module_find("irc", 0, 0)))
         (me->funcs[IRC_RECHECK_CHANNEL])(chan, 0);
     }
@@ -192,7 +183,8 @@ static void got_cpart(char *botnick, char *code, char *par)
    return;
   remove_channel(chan);
 }
-static void got_cycle(char *botnick, char *code, char *par)
+
+static void got_cjoin(char *botnick, char *code, char *par)
 {
   char *chname;
   struct chanset_t *chan;
@@ -201,31 +193,43 @@ static void got_cycle(char *botnick, char *code, char *par)
    return;
 
   chname = newsplit(&par);
-  chan = findchan_by_dname(chname);
-  if (!chan)
+  if (findchan_by_dname(chname)) {
    return;
+  } else if ((chan = findchan(chname))) {
+   return;
+  }
 
-  dprintf(DP_SERVER, "PART %s\n", chname);
+  if (tcl_channel_add(0, chname, par) == TCL_ERROR) /* drummer */
+    putlog(LOG_BOTS, "@", "Invalid channel or channel options from %s for %s", botnick, chname);
+  else {
+#ifdef HUB
+    write_userfile(-1);
+#endif /* HUB */
+  }
 }
 
-static void got_down(char *botnick, char *code, char *par)
+#ifdef LEAF
+static void got_cycle(char *botnick, char *code, char *par)
 {
   char *chname;
   struct chanset_t *chan;
+  int delay = 10;
 
   if (!par[0])
    return;
 
   chname = newsplit(&par);
-  chan = findchan_by_dname(chname);
-  if (!chan)
+  if (!(chan = findchan_by_dname(chname)))
    return;
- 
-  add_mode(chan, '-', 'o', botname);
-
+  if (par[0])
+    delay = atoi(newsplit(&par));
+  
+  do_chanset(chan, "+inactive", 2);
+  dprintf(DP_SERVER, "PART %s\n", chan->name);
+  chan->channel.jointime = ((now + delay) - server_lag); 		/* rejoin in 10 seconds */
 }
 
-static void got_cjoin(char *botnick, char *code, char *par)
+static void got_down(char *botnick, char *code, char *par)
 {
   char *chname;
   struct chanset_t *chan;
@@ -234,24 +238,18 @@ static void got_cjoin(char *botnick, char *code, char *par)
    return;
 
   chname = newsplit(&par);
-  if (findchan_by_dname(chname)) {
-   return;
-  } else if ((chan = findchan(chname))) {
+  if (!(chan = findchan_by_dname(chname)))
    return;
-  }
-
-  if (tcl_channel_add(0, chname, par) == TCL_ERROR) /* drummer */
-    putlog(LOG_BOTS, "@", "Invalid channel or channel options from %s for %s", botnick, chname);
-  else {
-#ifdef HUB
-    write_userfile(-1);
-#endif
-  }
+ 
+  chan->channel.no_op = (now + 10);
+  add_mode(chan, '-', 'o', botname);
 }
+#endif /* LEAF */
 
 static void got_role(char *botnick, char *code, char *par)
 {
   char *tmp;
+
   tmp = newsplit(&par);
   role = atoi(tmp);
   tmp = newsplit(&par);
@@ -282,8 +280,6 @@ void rebalance_roles()
   struct userrec *u;
   char tmp[10];
 
-Context;
-ContextNote("rebalance_roles");
   for (u = userlist; u; u = u->next) {
     if ((u->flags & USER_BOT) && (nextbot(u->handle) >= 0)) {
       ba = get_user(&USERENTRY_BOTADDR, u);
@@ -328,58 +324,53 @@ ContextNote("rebalance_roles");
     }
   }
 }
-#endif
+#endif /* HUB */
 
+/* FIXME: needs more testing */
 static void channels_checkslowjoin() {
-  struct chanset_t * chan;
-Context;
-  for (chan=chanset;chan;chan=chan->next) {
-ContextNote(chan->dname);
+  struct chanset_t *chan;
+ContextNote("slowpart");
+  for (chan = chanset; chan ; chan = chan->next) {
     /* slowpart */
     if (channel_active(chan) && (chan->channel.parttime) && (chan->channel.parttime < now)) {
-Context;
       chan->channel.parttime = 0;
-Context;
 #ifdef LEAF
       dprintf(DP_MODE, "PART %s\n", chan->name);
 #endif /* LEAF */
-Context;
       if (chan) /* this should NOT be necesary, but some unforseen bug requires it.. */
         remove_channel(chan);
       break;    /* if we keep looping, we'll segfault. */
-Context;
     /* slowjoin */
     } else if ((chan->channel.jointime) && (chan->channel.jointime < now)) {
-Context;
         chan->status &= ~CHAN_INACTIVE;
-Context;
-        chan->channel.jointime=0;
-Context;
+        chan->channel.jointime = 0;
 #ifdef LEAF
       if (shouldjoin(chan) && !channel_active(chan))
         dprintf(DP_MODE, "JOIN %s %s\n", chan->name, chan->key_prot);
 #endif /* LEAF */
     }
   }
-Context;
 }
 
 static void got_sj(int idx, char * code, char * par) {
-  char * chname;
+  char *chname;
   time_t delay;
-  struct chanset_t * chan;
+  struct chanset_t *chan;
+
   chname = newsplit(&par);
-  delay=atoi(par) + now;
+  delay = atoi(par) + now;
   chan = findchan_by_dname(chname);
   if (chan)
     chan->channel.jointime = delay;
 }
+
 static void got_sp(int idx, char * code, char * par) {
-  char * chname;
+  char *chname;
   time_t delay;
-  struct chanset_t * chan;
+  struct chanset_t *chan;
+
   chname = newsplit(&par);
-  delay=atoi(par) + now;
+  delay = atoi(par) + now;
   chan = findchan_by_dname(chname);
   if (chan)
     chan->channel.parttime = delay;
@@ -723,10 +714,10 @@ static void channels_report(int idx, int details)
 #ifdef LEAF
 	  dprintf(idx, "    %-10s: (%s), enforcing \"%s\"  (%s)\n", chan->dname,
 		  channel_pending(chan) ? "pending" : "not on channel", s2, s);
-#else
+#else /* !LEAF */
 	  dprintf(idx, "    %-10s: (%s), enforcing \"%s\"  (%s)\n", chan->dname,
 		  "limbo", s2, s);
-#endif
+#endif /* LEAF */
 	}
       } else {
 	dprintf(idx, "    %-10s: channel is set +inactive\n",
@@ -904,8 +895,10 @@ cmd_t channels_bot[] = {
   {"cjoin",    "", (Function) got_cjoin, NULL},
   {"cpart",    "", (Function) got_cpart, NULL},
   {"cset",     "", (Function) got_cset,  NULL},
+#ifdef LEAF
   {"cycle",    "", (Function) got_cycle, NULL},
   {"down",     "", (Function) got_down,  NULL},
+#endif /* LEAF */
   {"rl",       "", (Function) got_role,  NULL},
   {"kl",       "", (Function) got_kl,    NULL},
   {"sj",       "", (Function) got_sj,    NULL},
@@ -1109,6 +1102,30 @@ struct cfg_entry CFG_KILLTHRESHOLD = {
 #endif /* S_AUTOLOCK */
 
 
+#ifdef LEAF
+int checklimit = 1;
+static void check_limitraise() {
+  int i = 0;
+  struct chanset_t *chan;
+  for (chan = chanset; chan; chan = chan->next, i++) {
+    if (i % 2 == checklimit) {
+      if (chan->limitraise) {
+        if (dolimit(chan)) {
+          module_entry *me;
+          if ((me = module_find("irc", 0, 0)))
+            (me->funcs[23])(chan);             /* raise_limit(chan) */
+        }
+      }
+    }
+  }
+  if (checklimit)
+    checklimit=0;
+  else
+    checklimit=1;
+}
+#endif /* LEAF */
+
+
 char *channels_start(Function * global_funcs)
 {
   global = global_funcs;
@@ -1159,11 +1176,6 @@ char *channels_start(Function * global_funcs)
          "-private "
 	 "-fastop ");
   module_register(MODULE_NAME, channels_table, 1, 0);
-  if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 0, 0))) {
-    module_undepend(MODULE_NAME);
-    return "This module requires channels module 0.0 or later.";
-  }
-
 #ifdef LEAF
   add_hook(HOOK_MINUTELY, (Function) check_limitraise);
 #endif /* LEAF */
@@ -1194,3 +1206,4 @@ char *channels_start(Function * global_funcs)
 #endif /* S_AUTOLOCK */
   return NULL;
 }
+

+ 59 - 47
src/mod/channels.mod/cmdschan.c

@@ -146,6 +146,7 @@ static void cmd_pls_ban(struct userrec *u, int idx, char *par)
     }
   }
 }
+
 #ifdef S_IRCNET
 static void cmd_pls_exempt(struct userrec *u, int idx, char *par)
 {
@@ -405,7 +406,7 @@ static void cmd_pls_invite(struct userrec *u, int idx, char *par)
     }
   }
 }
-#endif
+#endif /* S_IRCNET */
 
 static void cmd_mns_ban(struct userrec *u, int idx, char *par)
 {
@@ -520,7 +521,7 @@ static void cmd_mns_ban(struct userrec *u, int idx, char *par)
 }
 
 #ifdef S_IRCNET
-static void cmd_mns_exempt (struct userrec *u, int idx, char *par)
+static void cmd_mns_exempt(struct userrec *u, int idx, char *par)
 {
   int console = 0, i = 0, j;
   struct chanset_t *chan = NULL;
@@ -637,7 +638,7 @@ static void cmd_mns_exempt (struct userrec *u, int idx, char *par)
   dprintf(idx, "No such exemption.\n");
 }
 
-static void cmd_mns_invite (struct userrec *u, int idx, char *par)
+static void cmd_mns_invite(struct userrec *u, int idx, char *par)
 {
   int console = 0, i = 0, j;
   struct chanset_t *chan = NULL;
@@ -755,8 +756,8 @@ static void cmd_mns_invite (struct userrec *u, int idx, char *par)
   }
   dprintf(idx, "No such invite.\n");
 }
+#endif /* S_IRCNET */
 
-#endif
 static void cmd_bans(struct userrec *u, int idx, char *par)
 {
   if (!egg_strcasecmp(par, "all")) {
@@ -767,8 +768,9 @@ static void cmd_bans(struct userrec *u, int idx, char *par)
     tell_bans(idx, 0, par);
   }
 }
+
 #ifdef S_IRCNET
-static void cmd_exempts (struct userrec *u, int idx, char *par)
+static void cmd_exempts(struct userrec *u, int idx, char *par)
 {
   if (!use_exempts) {
     dprintf(idx, "This command can only be used with use-exempts enabled.\n");
@@ -783,7 +785,7 @@ static void cmd_exempts (struct userrec *u, int idx, char *par)
   }
 }
 
-static void cmd_invites (struct userrec *u, int idx, char *par)
+static void cmd_invites(struct userrec *u, int idx, char *par)
 {
   if (!use_invites) {
     dprintf(idx, "This command can only be used with use-invites enabled.\n");
@@ -797,7 +799,7 @@ static void cmd_invites (struct userrec *u, int idx, char *par)
     tell_invites(idx, 0, par);
   }
 }
-#endif
+#endif /* S_IRCNET */
 
 static void cmd_info(struct userrec *u, int idx, char *par)
 {
@@ -829,10 +831,10 @@ static void cmd_info(struct userrec *u, int idx, char *par)
     if (s1 && s1[0]) {
       if (chname) {
 	dprintf(idx, "Info on %s: %s\n", chname, s1);
-	dprintf(idx, "Use '.info %s none' to remove it.\n", chname);
+	dprintf(idx, "Use 'info %s none' to remove it.\n", chname);
       } else {
 	dprintf(idx, "Default info: %s\n", s1);
-	dprintf(idx, "Use '.info none' to remove it.\n");
+	dprintf(idx, "Use 'info none' to remove it.\n");
       }
     } else
       dprintf(idx, "No info has been set for you.\n");
@@ -939,27 +941,27 @@ static void cmd_chinfo(struct userrec *u, int idx, char *par)
 
 static void cmd_slowjoin(struct userrec *u, int idx, char *par)
 {
-  int intvl=0, delay=0, count=1;
+  int intvl = 0, delay = 0, count = 1;
   char *chname;
   char buf[2048], buf2[1048];
-  struct chanset_t * chan;
+  struct chanset_t *chan;
   tand_t *bot;
   char *p;
 
-  /* .slowjoin #chan 60 */
+  /* slowjoin #chan 60 */
   putlog(LOG_CMDS, "*", "#%s# slowjoin %s", dcc[idx].nick, par);
   chname = newsplit(&par);
   p = newsplit(&par);
-  intvl=atoi(p);
+  intvl = atoi(p);
   if (!chname[0] || !p[0]) {
     dprintf(idx, "Usage: slowjoin channel interval-seconds [channel options]\n");
     return;
   }
-  if (intvl<10) {
+  if (intvl < 10) {
     dprintf(idx, "Interval must be at least 10 seconds\n");
     return;
   }
-  if ((chan=findchan_by_dname(chname))) {
+  if ((chan = findchan_by_dname(chname))) {
     dprintf(idx, "Already on %s\n", chan->dname);
     return;
   }
@@ -981,13 +983,13 @@ static void cmd_slowjoin(struct userrec *u, int idx, char *par)
     return;
   }
   sprintf(buf2, "cjoin %s %s", chan->dname, buf);
-  botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+  putallbots(buf2);
 #ifdef HUB
   count=0;
-#else
+#else /* !HUB */
   count=1;
 #endif /* HUB */
-  for (bot=tandbot;bot;bot=bot->next) {
+  for (bot = tandbot; bot; bot = bot->next) {
     struct userrec *ubot;
     char tmp[100];
     
@@ -1002,39 +1004,39 @@ static void cmd_slowjoin(struct userrec *u, int idx, char *par)
 	sprintf(tmp, "sj %s %i\n", chan->dname, delay + v);
 	count++;
       }
-      botnet_send_zapf(nextbot(ubot->handle), botnetnick, ubot->handle, tmp);
+      putbot(ubot->handle, tmp);
     }
   }
   dprintf(idx, "%i bots joining %s during the next %i seconds\n", count, chan->dname, delay);
   chan->status &= ~CHAN_INACTIVE;
 #ifdef LEAF
   if (shouldjoin(chan)) 
-    dprintf(DP_MODE, "JOIN %s %s\n", chan->dname, chan->key_prot);
+    dprintf(DP_MODE, "JOIN %s %s\n", chan->name, chan->key_prot);
 #endif /* LEAF */
 }
 
 static void cmd_slowpart(struct userrec *u, int idx, char *par)
 {
-  int intvl=0, delay=0, count=1;
+  int intvl = 0, delay = 0, count = 1;
   char *chname;
-  struct chanset_t * chan;
+  struct chanset_t *chan;
   tand_t *bot;
   char *p;
 
-  /* .slowpart #chan 60 */
+  /* slowpart #chan 60 */
   putlog(LOG_CMDS, "*", "#%s# slowpart %s", dcc[idx].nick, par);
   chname = newsplit(&par);
   p = newsplit(&par);
-  intvl=atoi(p);
+  intvl = atoi(p);
   if (!chname[0] || !p[0]) {
     dprintf(idx, "Usage: slowpart channel interval-seconds\n");
     return;
   }
-  if (intvl<10) {
+  if (intvl < 10) {
     dprintf(idx, "Interval must be at least 10 seconds\n");
     return;
   }
-  if (!(chan=findchan_by_dname(chname))) {
+  if (!(chan = findchan_by_dname(chname))) {
     dprintf(idx, "Not on %s\n", chan->dname);
     return;
   }
@@ -1051,10 +1053,10 @@ static void cmd_slowpart(struct userrec *u, int idx, char *par)
   }
 #ifdef HUB
   count=0;
-#else
+#else /* !HUB */
   count=1;
 #endif /* HUB */
-  for (bot=tandbot;bot;bot=bot->next) {
+  for (bot = tandbot; bot; bot = bot->next) {
     char tmp[100];
     struct userrec *ubot;
 
@@ -1069,7 +1071,7 @@ static void cmd_slowpart(struct userrec *u, int idx, char *par)
   	  sprintf(tmp, "sp %s %i\n", chname, delay + v);
   	  count++;
         }
-        botnet_send_zapf(nextbot(ubot->handle), botnetnick, ubot->handle, tmp);
+        putbot(ubot->handle, tmp);
       }  
   }
   dprintf(idx, "%i bots parting %s during the next %i seconds\n", count, chname, delay);
@@ -1352,30 +1354,40 @@ static void cmd_cycle(struct userrec *u, int idx, char *par)
 {
   char *chname;
   char buf2[1024];
+  int delay = 10;
+  struct chanset_t *chan;
 
   putlog(LOG_CMDS, "*", "#%s# cycle %s", dcc[idx].nick, par);
 
   if (!par[0]) {
-    dprintf(idx, "Usage: cycle [%s]<channel>\n", CHANMETA);
+    dprintf(idx, "Usage: cycle [%s]<channel> [delay]\n", CHANMETA);
+    dprintf(idx, "rejoin delay defaults to '10'\n");
     return;
   }
 
   chname = newsplit(&par);
-  if (!findchan_by_dname(chname)) {
+  chan = findchan_by_dname(chname);
+  if (!chan) {
     dprintf(idx, "%s it not a valid channel.\n", chname);
     return;
   }
+  if (par[0])
+    delay = atoi(newsplit(&par));
 
-  sprintf(buf2, "cycle %s", chname); //this just makes the bot PART
-  botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+  sprintf(buf2, "cycle %s %d", chname, delay); //this just makes the bot PART
+  putallbots(buf2);
 #ifdef LEAF
-  dprintf(DP_SERVER, "PART %s\n", chname);
-#endif  
+  do_chanset(chan, "+inactive", 2);
+  dprintf(DP_SERVER, "PART %s\n", chan->name);
+  chan->channel.jointime = ((now + delay) - server_lag);
+#endif /* LEAF */
 }
+
 static void cmd_down(struct userrec *u, int idx, char *par)
 {
   char *chname;
   char buf2[1024];
+  struct chanset_t *chan;
 
   putlog(LOG_CMDS, "*", "#%s# down %s", dcc[idx].nick, par);
 
@@ -1385,17 +1397,18 @@ static void cmd_down(struct userrec *u, int idx, char *par)
   }
 
   chname = newsplit(&par);
-
-  if (!findchan_by_dname(chname)) {
+  chan = findchan_by_dname(chname);
+  if (!chan) {
     dprintf(idx, "%s it not a valid channel.\n", chname);
     return;
   }
   
-  sprintf(buf2, "down %s", chname);
-  botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+  sprintf(buf2, "down %s", chan->dname);
+  putallbots(buf2);
 #ifdef LEAF
-  add_mode(findchan_by_dname(chname), '-', 'o', botname);
-#endif
+  add_mode(chan, '-', 'o', botname);
+  chan->channel.no_op = (now + 10);
+#endif /* LEAF */
   
 }
 
@@ -1414,7 +1427,7 @@ static void cmd_pls_chan(struct userrec *u, int idx, char *par)
 
   chname = newsplit(&par);
   sprintf(buf2, "cjoin %s %s", chname, par);
-  botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+  putallbots(buf2);
   if (findchan_by_dname(chname)) {
     dprintf(idx, "That channel already exists!\n");
     return;
@@ -1431,7 +1444,7 @@ static void cmd_pls_chan(struct userrec *u, int idx, char *par)
   else {
 #ifdef HUB
     write_userfile(-1);
-#endif
+#endif /* HUB */
   }
 }
 
@@ -1451,7 +1464,7 @@ static void cmd_mns_chan(struct userrec *u, int idx, char *par)
   chname = newsplit(&par);
 
   sprintf(buf2, "cpart %s", chname);
-  botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+  putallbots(buf2);
 
   chan = findchan_by_dname(chname);
   if (!chan) {
@@ -1491,7 +1504,6 @@ void modesetting(int idx, char *work, int *cnt, char *name, int state)
   if (!work[0])
     sprintf(work, "  ");
   if (name && name[0]) {
-//    snprintf(tmp, sizeof tmp, "%s%-17s", state ? "\033[32m+\033[0m" : "\033[31m-\033[0m", name);
     snprintf(tmp, sizeof tmp, "%s%-17s", state ? "\002+\002" : "\002-\002", name);
     strcat(work, tmp);
   }
@@ -1771,7 +1783,7 @@ static void cmd_chanset(struct userrec *u, int idx, char *par)
 		answers, chname);
 #ifdef HUB
         write_userfile(-1);
-#endif
+#endif /* HUB */
       }
       if (!all)
         chan = NULL;
@@ -1784,7 +1796,7 @@ static void cmd_chanset(struct userrec *u, int idx, char *par)
 	      answers);
 #ifdef HUB
       write_userfile(-1);
-#endif
+#endif /* HUB */
     }
     nfree(buf);
   }

+ 13 - 13
src/mod/channels.mod/tclchan.c

@@ -226,13 +226,13 @@ static int tcl_channel_get(Tcl_Interp * irp, struct chanset_t *chan, char *setti
   else if CHKFLAG_POS(CHAN_DYNAMICINVITES, "dynamicinvites", chan->ircnet_status)
   else if CHKFLAG_NEG(CHAN_NOUSERINVITES,  "userinvites",    chan->ircnet_status)
 #endif
-  else if CHKFLAG_POS(CHAN_CLOSED,          "closed",          chan->status)
-  else if CHKFLAG_POS(CHAN_TAKE,          "take",          chan->status)
-  else if CHKFLAG_POS(CHAN_NOMOP,          "nomop",          chan->status)
+  else if CHKFLAG_POS(CHAN_CLOSED,	   "closed",         chan->status)
+  else if CHKFLAG_POS(CHAN_TAKE,	   "take",           chan->status)
+  else if CHKFLAG_POS(CHAN_NOMOP,	   "nomop",          chan->status)
   else if CHKFLAG_POS(CHAN_MANOP,          "manop",          chan->status)
   else if CHKFLAG_POS(CHAN_VOICE,          "voice",          chan->status)
-  else if CHKFLAG_POS(CHAN_FASTOP,          "fastop",          chan->status)
-  else if CHKFLAG_POS(CHAN_PRIVATE,          "private",          chan->status)
+  else if CHKFLAG_POS(CHAN_FASTOP,         "fastop",         chan->status)
+  else if CHKFLAG_POS(CHAN_PRIVATE,        "private",        chan->status)
 /* Chanflag template
  *else if CHKFLAG_POS(CHAN_TEMP,	   "temp",		chan->status)
  */
@@ -270,12 +270,12 @@ static int tcl_channel STDVAR
       
       snprintf(buf2, sizeof buf2, "cjoin %s", argv[2]);
       if (!loading)
-        botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+        putallbots(buf2);
       return tcl_channel_add(irp, argv[2], "");
     }
     snprintf(buf2, sizeof buf2, "cjoin %s %s", argv[2], argv[3]);
     if (!loading)
-      botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+      putallbots(buf2);
     return tcl_channel_add(irp, argv[2], argv[3]);
   }
   if (!strcmp(argv[1], "set")) {
@@ -289,7 +289,9 @@ static int tcl_channel STDVAR
       Tcl_AppendResult(irp, "no such channel record", NULL);
       return TCL_ERROR;
     }
+Context;
     do_chanset(chan, argv[3], 0);
+Context;
     return tcl_channel_modify(irp, chan, argc - 3, &argv[3]);
   }
   if (!strcmp(argv[1], "get")) {
@@ -319,7 +321,7 @@ static int tcl_channel STDVAR
       return TCL_ERROR;
     }
     snprintf(buf2, sizeof buf2, "cpart %s", argv[2]);
-    botnet_send_zapf_broad(-1, botnetnick, NULL, buf2);
+    putallbots(buf2);
     remove_channel(chan);
     return TCL_OK;
   }
@@ -338,12 +340,10 @@ static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
   int old_status = chan->status,
       old_mode_mns_prot = chan->mode_mns_prot,
       old_mode_pls_prot = chan->mode_pls_prot;
-#endif
+  module_entry *me;
+#endif /* LEAF */
   struct udef_struct *ul = udef;
   char s[121];
-#ifdef LEAF
-  module_entry *me;
-#endif
 Context;
   for (i = 0; i < items; i++) {
     if (!strcmp(item[i], "chanmode")) {
@@ -688,7 +688,7 @@ Context;
       (me->funcs[IRC_RECHECK_CHANNEL_MODES])(chan);
   }
 Context;
-#endif
+#endif /* LEAF */
   if (x > 0)
     return TCL_ERROR;
   return TCL_OK;

+ 7 - 32
src/mod/channels.mod/userchan.c

@@ -1292,8 +1292,6 @@ static int write_chans(FILE *f, int idx)
     return 0;
 
   for (chan = chanset; chan; chan = chan->next) {
-
-
     if ((idx < 0) || (1)) {
       struct flag_record fr = {FR_CHAN | FR_GLOBAL | FR_BOT, 0, 0, 0, 0, 0};
       if (idx >= 0)
@@ -1301,8 +1299,6 @@ static int write_chans(FILE *f, int idx)
       else
         fr.chan = BOT_SHARE;
 
-//    if ((fr.chan & BOT_SHARE) || (fr.bot & BOT_GLOBAL)) {
-
      putlog(LOG_DEBUG, "*", "writing channel %s to userfile..", chan->dname);
 
      egg_memset(udefs,'\0',2048);
@@ -1331,15 +1327,13 @@ static int write_chans(FILE *f, int idx)
 revenge-mode %d \
 flood-chan %d:%d flood-ctcp %d:%d flood-join %d:%d \
 flood-kick %d:%d flood-deop %d:%d flood-nick %d:%d \
-ban-time %d \
-exempt-time %d invite-time %d \
+ban-time %d exempt-time %d invite-time %d \
 %cenforcebans %cdynamicbans %cuserbans %cbitch \
-%cprotectops %cdontkickops \
-%crevenge %crevengebot %cprivate \
-%ccycle %cinactive \
-%cdynamicexempts %cuserexempts %cdynamicinvites %cuserinvites \
-%cnodesynch \
-%cclosed %ctake %cmanop %cvoice %cfastop %s %s",
+%cprotectops %cdontkickops %crevenge %crevengebot \
+%cprivate %ccycle %cinactive %cdynamicexempts \
+%cuserexempts %cdynamicinvites %cuserinvites \
+%cnodesynch %cclosed %ctake %cmanop %cvoice \
+%cfastop %s %s",
 	"add",
 	name,
 	" { ",
@@ -1433,7 +1427,7 @@ static void channels_writeuserfile(void)
 #endif
     putlog(LOG_MISC, "*", USERF_ERRWRITE);
   //old .chan write_channels();
-#endif
+#endif /* HUB */
 }
 
 /* Expire mask originally set by `who' on `chan'?
@@ -1491,25 +1485,6 @@ static int expired_mask(struct chanset_t *chan, char *who)
     return 1;
 }
 
-#ifdef LEAF
-int checklimit = 1;
-void check_limitraise() {
-  int i=0;
-  struct chanset_t * chan;
-  for (chan=chanset;chan;chan=chan->next,i++) {
-    if (i % 2 == checklimit) {
-      if (chan->limitraise) {
-        if (dolimit(chan)) 
-          raise_limit(chan);
-      }
-    }
-  }
-  if (checklimit)
-    checklimit=0;
-  else
-    checklimit=1;
-}
-#endif
 /* Check for expired timed-bans.
  */
 

+ 12 - 12
src/mod/ctcp.mod/ctcp.c

@@ -15,14 +15,14 @@
 #include <arpa/inet.h>
 #ifdef HAVE_UNAME
 #include <sys/utsname.h>
-#endif
+#endif /* HAVE_UNAME */
 #include <pwd.h>
 #include <ctype.h>
 
 static Function *global = NULL, *server_funcs = NULL;
-#else
+#else /* !LEAF */
 static Function *global = NULL;
-#endif
+#endif /* LEAF */
 
 #define CLOAK_COUNT             10 /* The number of scripts currently existing */
 #define CLOAK_PLAIN             1 /* This is your plain bitchx client behaviour */
@@ -41,7 +41,7 @@ int cloak_script = CLOAK_PLAIN;
 #ifdef S_AUTOAWAY
 #define AVGAWAYTIME             60
 #define AVGHERETIME             5
-#endif
+#endif /* S_AUTOAWAY */
 int cloak_awaytime = 0;
 int cloak_heretime = 0;
 int listen_time = 0;
@@ -390,7 +390,7 @@ void sendaway()
     break;
   }
 }
-#endif
+#endif /* S_AUTOAWAY */
 
 static void ctcp_minutely()
 {
@@ -419,7 +419,7 @@ static void ctcp_minutely()
     } else
       sendaway();
   }
-#endif
+#endif /* S_AUTOAWAY */
 
 
   if (listen_time <= 0) {
@@ -455,7 +455,7 @@ static int ctcp_FINGER(char *nick, char *uhost, char *handle, char *object, char
 #endif
   if ((p = strchr(pwd->pw_gecos, GECOS_DELIMITER)) != NULL)
     *p = 0;
-  dprintf(DP_HELP, STR("NOTICE %s :\001%s %s (%s@%s) Idle %ld second%c\001\n"), nick, keyword, pwd->pw_gecos, pwd->pw_name, (char *) (strchr(botuserhost, '@') + 1), idletime, (idletime == 1) ? "" : "s");
+  dprintf(DP_HELP, STR("NOTICE %s :\001%s %s (%s@%s) Idle %ld second%s\001\n"), nick, keyword, pwd->pw_gecos, pwd->pw_name, (char *) (strchr(botuserhost, '@') + 1), idletime, (idletime == 1) ? "" : "s");
   return 1;
 }
 
@@ -713,12 +713,12 @@ void cloak_changed(struct cfg_entry *cfgent, char *oldval, int *valid)
 #ifdef LEAF
   if (i == 0)
     i = (random() % CLOAK_COUNT) + 1;
-#endif
+#endif /* LEAF */
   if ((*valid = ((i >= 0) && (i <= CLOAK_COUNT))))
     cloak_script = i;
 #ifdef LEAF
   scriptchanged();
-#endif
+#endif /* LEAF */
 }
 
 struct cfg_entry CFG_CLOAK_SCRIPT = {
@@ -743,8 +743,8 @@ char *ctcp_start(Function * global_funcs)
   char *p;
 #ifdef HAVE_UNAME
   struct utsname un;
-#endif
-#endif
+#endif /* HAVE_UNAME */
+#endif /* LEAF */
   global = global_funcs;
 
   module_register(MODULE_NAME, ctcp_table, 1, 0);
@@ -797,7 +797,7 @@ char *ctcp_start(Function * global_funcs)
 
   add_builtins(H_ctcp, myctcp);
   add_hook(HOOK_MINUTELY, (Function) ctcp_minutely);
-#endif
+#endif /* LEAF */
   add_cfg(&CFG_CLOAK_SCRIPT);
   return NULL;
 }

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

@@ -1206,11 +1206,12 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
     if (maxnicklen < 9) maxnicklen = 9;
     if (maxhandlen < 9) maxhandlen = 9;
     
-    dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot)\n");
-    egg_snprintf(format, sizeof format, " %%-%us %%-%us %%-6s %%-5s %%s\n", 
+    dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot) CAP:global\n");
+    egg_snprintf(format, sizeof format, " %%-%us %%-%us %%-6s %%-4s %%-5s %%s\n", 
 			maxnicklen, maxhandlen);
-    dprintf(idx, format, "NICKNAME", "HANDLE", " JOIN", "IDLE", "USER@HOST");
+    dprintf(idx, format, "NICKNAME", "HANDLE", " JOIN", "  HOPS", "IDLE", "USER@HOST");
     for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
+      int hops = m->hops;
       if (m->joined > 0) {
 	if ((now - (m->joined)) > 86400)
 	  egg_strftime(s, 6, "%d%b", localtime(&(m->joined)));
@@ -1284,9 +1285,9 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
 
       if (chan_issplit(m)) {
         egg_snprintf(format, sizeof format, 
-			"%%c%%c%%-%us %%-%us %%s %%c     <- netsplit, %%lus\n", 
+			"%%c%%c%%-%us %%-%us   %%d %%s %%c     <- netsplit, %%lus\n", 
 			maxnicklen, maxhandlen);
-	dprintf(idx, format, chanflag[0],chanflag[1], m->nick, handle, s, atrflag,
+	dprintf(idx, format, chanflag[0],chanflag[1], m->nick, handle, s, hops, atrflag,
 		now - (m->split));
       } else if (!rfc_casecmp(m->nick, botname)) {
         egg_snprintf(format, sizeof format, 
@@ -1303,10 +1304,10 @@ static void cmd_channel(struct userrec *u, int idx, char *par)
 	  egg_snprintf(s1, sizeof s1, "%2lum", ((now - (m->last)) / 60));
 	else
 	  strncpyz(s1, "   ", sizeof s1);
-	egg_snprintf(format, sizeof format, "%%c%%c%%-%us %%-%us %%s %%c %%s  %%s\n", 
+	egg_snprintf(format, sizeof format, "%%c%%c%%-%us %%-%us %%s %%c   %%d %%s  %%s\n", 
 			maxnicklen, maxhandlen);
-	dprintf(idx, format, chanflag[0], chanflag[1], m->nick,	handle, s, atrflag, s1, 
-		    m->userhost);
+	dprintf(idx, format, chanflag[0], chanflag[1], m->nick,	handle, s, atrflag, hops,
+                     s1, m->userhost);
       }
       if (chan_fakeop(m))
 	dprintf(idx, "    (%s)\n", IRC_FAKECHANOP);

+ 45 - 41
src/mod/irc.mod/irc.c

@@ -17,12 +17,12 @@
 #endif
 
 
-#define op_bots (CFG_OPBOTS.gdata ? atoi(CFG_OPBOTS.gdata) : 1)
-#define in_bots (CFG_INBOTS.gdata ? atoi(CFG_INBOTS.gdata) : 1)
-#define lag_threshold (CFG_LAGTHRESHOLD.gdata ? atoi(CFG_LAGTHRESHOLD.gdata) : 15)
-#define opreq_count (CFG_OPREQUESTS.gdata ? atoi( CFG_OPREQUESTS.gdata ) : 2)
-#define opreq_seconds (CFG_OPREQUESTS.gdata ? atoi( strchr(CFG_OPREQUESTS.gdata, ':') + 1 ) : 5)
-#define op_time_slack (CFG_OPTIMESLACK.gdata ? atoi(CFG_OPTIMESLACK.gdata) : 60)
+#define OP_BOTS (CFG_OPBOTS.gdata ? atoi(CFG_OPBOTS.gdata) : 1)
+#define IN_BOTS (CFG_INBOTS.gdata ? atoi(CFG_INBOTS.gdata) : 1)
+#define LAG_THRESHOLD (CFG_LAGTHRESHOLD.gdata ? atoi(CFG_LAGTHRESHOLD.gdata) : 15)
+#define OPREQ_COUNT (CFG_OPREQUESTS.gdata ? atoi( CFG_OPREQUESTS.gdata ) : 2)
+#define OPREQ_SECONDS (CFG_OPREQUESTS.gdata ? atoi( strchr(CFG_OPREQUESTS.gdata, ':') + 1 ) : 5)
+#define OP_TIME_SLACK (CFG_OPTIMESLACK.gdata ? atoi(CFG_OPTIMESLACK.gdata) : 60)
 
 #define PRIO_DEOP 1
 #define PRIO_KICK 2
@@ -184,6 +184,11 @@ void getin_request(char *botnick, char *code, char *par)
   if (!chname[0] || !chname)
     return;
 
+  if (!(chan = findchan_by_dname(chname))) {
+    putlog(LOG_GETIN, "*", STR("getin req from %s for %s which is not a valid channel!"), botnick, chname);
+    return;
+  }
+
   nck = newsplit(&par);
   if (!nck[0])
     return;
@@ -201,10 +206,10 @@ void getin_request(char *botnick, char *code, char *par)
     if (ip4[0]) {
       char *tmp2;
 
-      tmp = nmalloc(strlen(host)+1);
+      tmp = nmalloc(strlen(host) + 1);
       strcpy(tmp, host);
       tmp2 = strtok(tmp, "@");
-      snprintf(ip4host, sizeof ip4host, "%s@%s", strtok(tmp2,"@") , ip4);
+      snprintf(ip4host, sizeof ip4host, "%s@%s", strtok(tmp2, "@") ,ip4);
       nfree(tmp);
     } else {
       ip4host[0] = 0;
@@ -213,10 +218,10 @@ void getin_request(char *botnick, char *code, char *par)
     if (ip6[0]) {
       char *tmp2;
 
-      tmp = nmalloc(strlen(host)+1);
+      tmp = nmalloc(strlen(host) + 1);
       strcpy(tmp, host);
       tmp2 = strtok(tmp, "@");
-      snprintf(ip6host, sizeof ip6host, "%s@%s", strtok(tmp2,"@") , ip6);
+      snprintf(ip6host, sizeof ip6host, "%s@%s", strtok(tmp2, "@") ,ip6);
       nfree(tmp);
     } else {
       ip6host[0] = 0;
@@ -226,13 +231,7 @@ void getin_request(char *botnick, char *code, char *par)
 
 
 Context;
-  if (!(chan = findchan_by_dname(chname)))
-    return;
 
-  if (!chan) {
-    putlog(LOG_GETIN, "*", STR("getin req from %s for %s which is not a valid channel!"), botnick, chname);
-    return;
-  }
 /*
   if (!ismember(chan, botname)) {
     putlog(LOG_GETIN, "*", STR("getin req from %s for %s - I'm not on %s!"), botnick, chname, chname);
@@ -287,7 +286,7 @@ Context;
       putlog(LOG_GETIN, "*", STR("opreq from %s/%s on %s - Already sent a +o"), botnick, nick, chan->dname);
       return;
     }
-    if (server_lag > lag_threshold) {
+    if (server_lag > LAG_THRESHOLD) {
       putlog(LOG_GETIN, "*", STR("opreq from %s/%s on %s - I'm too lagged"), botnick, nick, chan->dname);
       return;
     }
@@ -295,7 +294,12 @@ Context;
       putlog(LOG_GETIN, "*", STR("opreq from %s/%s on %s - I'm getting userlist right now"), botnick, nick, chan->dname);
       return;
     }
-
+    if (chan->channel.no_op) {
+      if (chan->channel.no_op > now)                      /* dont op until this time has passed */
+        return;
+      else
+        chan->channel.no_op = 0;
+    }
     do_op(nick, chan, 1);
     mem->flags |= SENTOP;
 
@@ -327,7 +331,7 @@ Context;
       putlog(LOG_GETIN, "*", STR("inreq from %s/%s for %s - %s doesn't have acces for chan."), botnick, nick, chan->dname, botnick);
       return;
     }
-    if (server_lag > lag_threshold) {
+    if (server_lag > LAG_THRESHOLD) {
       putlog(LOG_GETIN, "*", STR("inreq from %s/%s for %s - I'm too lagged"), botnick, nick, chan->dname);
       return;
     }
@@ -444,7 +448,6 @@ void check_hostmask()
   struct userrec *u = get_user_by_handle(userlist, botnetnick);
   struct list_type *q;
 
-Context;
   if (!server_online || !botuserhost[0])
     return;
   tmp = botuserhost;
@@ -467,19 +470,12 @@ Context;
 
 static void request_op(struct chanset_t *chan)
 {
-  int i = 0,
-    exp = 0,
-    first = 100,
-    n,
-    cnt,
-    i2;
+  int i = 0, exp = 0, first = 100, n, cnt, i2;
   memberlist *ml;
   memberlist *botops[MAX_BOTS];
-  char s[100],
-   *l,
-    myserv[SERVLEN];
+  char s[100], *l, myserv[SERVLEN];
   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0 };
-
+  
 Context;
   if (channel_pending(chan) || !shouldjoin(chan) || !channel_active(chan))
     return;
@@ -487,14 +483,14 @@ Context;
   if (me_op(chan))
     return;
   /* check server lag */
-  if (server_lag > lag_threshold) {
+  if (server_lag > LAG_THRESHOLD) {
     putlog(LOG_GETIN, "*", STR("Not asking for ops on %s - I'm too lagged"), chan->dname);
     return;
   }
-  /* max opreq_count requests per opreq_seconds sec */
+  /* max OPREQ_COUNT requests per OPREQ_SECONDS sec */
   n = time(NULL);
   while (i < 5) {
-    if (n - chan->opreqtime[i] > opreq_seconds) {
+    if (n - chan->opreqtime[i] > OPREQ_SECONDS) {
       if (first > i)
 	first = i;
       exp++;
@@ -502,8 +498,8 @@ Context;
     }
     i++;
   }
-  if ((5 - exp) >= opreq_count) {
-    putlog(LOG_GETIN, "*", STR("Delaying opreq for %s - Maximum of %d:%d reached"), chan->dname, opreq_count, opreq_seconds);
+  if ((5 - exp) >= OPREQ_COUNT) {
+    putlog(LOG_GETIN, "*", STR("Delaying opreq for %s - Maximum of %d:%d reached"), chan->dname, OPREQ_COUNT, OPREQ_SECONDS);
     return;
   }
   check_hostmask();		/* check, and update hostmask */
@@ -529,14 +525,21 @@ Context;
     putlog(LOG_GETIN, "@", STR("No one to ask for ops on %s"), chan->dname);
     return;
   }
+  if (chan->channel.no_op) {
+    if (chan->channel.no_op > now) 			/* dont op until this time has passed */
+      return;
+    else 
+      chan->channel.no_op = 0;
+  }
+
   /* first scan for bots on my server, ask first found for ops */
-  cnt = op_bots;
+  cnt = OP_BOTS;
   sprintf(s, STR("gi o %s %s"), chan->dname, botname);
   l = nmalloc(cnt * 50);
   l[0] = 0;
   for (i2 = 0; i2 < i; i2++) {
     if (botops[i2]->server && (!strcmp(botops[i2]->server, myserv))) {
-      botnet_send_zapf(nextbot(botops[i2]->user->handle), botnetnick, botops[i2]->user->handle, s);
+      putbot(botops[i2]->user->handle, s);
       chan->opreqtime[first] = n;
       if (l[0]) {
 	strcat(l, ", ");
@@ -551,11 +554,12 @@ Context;
       break;
     }
   }
+
   /* Pick random op and ask for ops */
   while (cnt) {
     i2 = random() % i;
     if (botops[i2]) {
-      botnet_send_zapf(nextbot(botops[i2]->user->handle), botnetnick, botops[i2]->user->handle, s);
+      putbot(botops[i2]->user->handle, s);
       chan->opreqtime[first] = n;
       if (l[0]) {
 	strcat(l, ", ");
@@ -568,7 +572,7 @@ Context;
       cnt--;
       botops[i2] = NULL;
     } else {
-      if (i < op_bots)
+      if (i < OP_BOTS)
 	cnt--;
     }
   }
@@ -601,7 +605,7 @@ static void request_in(struct chanset_t *chan)
     return;
   }
   check_hostmask();		/* check, and update hostmask */
-  cnt = in_bots;
+  cnt = IN_BOTS;
   sprintf(s, STR("gi i %s %s %s!%s %s %s"), chan->dname, botname, botname, botuserhost, myipstr(4) ? myipstr(4) : "."
                                           , myipstr(6) ? myipstr(6) : ".");
   l = nmalloc(cnt * 30);
@@ -619,7 +623,7 @@ static void request_in(struct chanset_t *chan)
       botops[n] = NULL;
       cnt--;
     } else {
-      if (i < in_bots)
+      if (i < IN_BOTS)
 	cnt--;
     }
   }

+ 1 - 1
src/mod/irc.mod/irc.h

@@ -49,7 +49,7 @@ static void got_op(struct chanset_t *chan, char *nick, char *from, char *who,
 static int killmember(struct chanset_t *chan, char *nick);
 static void check_lonely_channel(struct chanset_t *chan);
 static int gotmode(char *, char *);
-
+void raise_limit(struct chanset_t *);
 #define newban(chan, mask, who)         newmask((chan)->channel.ban, mask, who)
 #define newexempt(chan, mask, who)      newmask((chan)->channel.exempt, mask, \
 						who)

+ 24 - 28
src/mod/irc.mod/mode.c

@@ -182,11 +182,11 @@ void dequeue_op_deop(struct chanset_t * chan) {
   char lines[4096];
   char modechars[10];
   char nicks[128];
-  int i=0, cnt=0;
-  lines[0]=0;
-  modechars[0]=0;
-  nicks[0]=0;
-  while ((i<20) && (chan->opqueue[i].target)) {
+  int i = 0, cnt = 0;
+  lines[0] = 0;
+  modechars[0] = 0;
+  nicks[0] = 0;
+  while ((i < 20) && (chan->opqueue[i].target)) {
     strcat(nicks, " ");
     strcat(nicks, chan->opqueue[i].target);
     if (!modechars[0])
@@ -199,8 +199,8 @@ void dequeue_op_deop(struct chanset_t * chan) {
       strcat(lines, modechars);
       strcat(lines, nicks);
       strcat(lines, "\n");
-      modechars[0]=0;
-      nicks[0]=0;
+      modechars[0] = 0;
+      nicks[0] = 0;
     }
     nfree(chan->opqueue[i].target);
     chan->opqueue[i].target = NULL;
@@ -208,8 +208,8 @@ void dequeue_op_deop(struct chanset_t * chan) {
   }
   if (modechars[0] && chan->deopqueue[0].target)
     strcat(modechars, "-");
-  i=0;
-  while ((i<20) && (chan->deopqueue[i].target)) {
+  i = 0;
+  while ((i < 20) && (chan->deopqueue[i].target)) {
     strcat(nicks, " ");
     strcat(nicks, chan->deopqueue[i].target);
     if (!modechars[0])
@@ -222,10 +222,10 @@ void dequeue_op_deop(struct chanset_t * chan) {
       strcat(lines, modechars);
       strcat(lines, nicks);
       strcat(lines, "\n");
-      modechars[0]=0;
-      nicks[0]=0;
-      if (cnt>=24) {
-        dprintf(DP_MODE, lines);
+      modechars[0] = 0;
+      nicks[0] = 0;
+      if (cnt >= 24) {
+        dprintf(DP_SERVER, lines);
         lines[0]=0;
       }
     }
@@ -241,36 +241,36 @@ void dequeue_op_deop(struct chanset_t * chan) {
     strcat(lines, "\n");
   }
   if (lines[0])
-    dprintf(DP_MODE, lines);
+    dprintf(DP_SERVER, lines);
 }
-void queue_op(struct chanset_t * chan, char * op) {
+void queue_op(struct chanset_t *chan, char *op) {
   int n;
-  memberlist * m;
-  for (n=0;n<20;n++) {
+  memberlist *m;
+  for (n = 0; n < 20; n++) {
     if (!chan->opqueue[n].target) {
-      chan->opqueue[n].target = nmalloc(strlen(op)+1);
+      chan->opqueue[n].target = nmalloc(strlen(op) + 1);
       strcpy(chan->opqueue[n].target, op);
       m = ismember(chan, op);
       if (m)
         m->flags |= SENTOP;
-      if (n==19)
+      if (n == 19)
         dequeue_op_deop(chan);
       return;
     }
   }
 }
 
-void queue_deop(struct chanset_t * chan, char * op) {
+void queue_deop(struct chanset_t *chan, char *op) {
   int n;
-  memberlist * m;
-  for (n=0;n<20;n++) {
+  memberlist *m;
+  for (n = 0; n<20; n++) {
     if (!chan->deopqueue[n].target) {
       chan->deopqueue[n].target = nmalloc(strlen(op)+1);
       strcpy(chan->deopqueue[n].target, op);
       m = ismember(chan, op);
       if (m)
         m->flags |= SENTDEOP;
-      if (n==19)
+      if (n == 19)
         dequeue_op_deop(chan);
       return;
     }
@@ -290,8 +290,6 @@ static void real_add_mode(struct chanset_t *chan,
   if (!me_op(chan))
     return;			/* No point in queueing the mode */
 
-putlog(LOG_DEBUG, "@", "add_mode for %s, %c%c %s", chan->dname, plus, mode, op);
-
   if (mode == 'o') {
     if (plus=='+')
       queue_op(chan, op);
@@ -456,7 +454,6 @@ static void flush_mode(struct chanset_t *chan, int pri)
   char *p, out[512], post[512];
   size_t postsize = sizeof(post);
   int i, plus = 2;              /* 0 = '-', 1 = '+', 2 = none */
-putlog(LOG_DEBUG, "@", "DEBUG: flushing modes for %s", chan->dname);
   p = out;
   post[0] = 0, postsize--;
 
@@ -595,7 +592,6 @@ static void real_add_mode(struct chanset_t *chan,
    * are not allowed to set can be changed in chan.h. */
   if (!me_op(chan))
     return;
-putlog(LOG_DEBUG, "@", "add_mode for %s, %c%c %s", chan->dname, plus, mode, op);
 
   if (mode == 'o' || mode == 'h' || mode == 'v') {
     mx = ismember(chan, op);
@@ -1354,7 +1350,7 @@ static int gotmode(char *from, char *msg)
             optime = atol(ltmp);
             off = (now + timesync - optime);
 
-            if (abs(off) > op_time_slack) {
+            if (abs(off) > OP_TIME_SLACK) {
 /*            isbadop = 4; */
               putlog(LOG_ERRORS, "*", "%s opped with bad ts (not punishing.): %li was off by %li", nfrom, optime, off);
             }

+ 0 - 104
src/mod/irc.mod/tclirc.c

@@ -20,30 +20,6 @@ static int tcl_flushmode STDVAR
   return TCL_OK;
 }
 
-static int tcl_pushmode STDVAR
-{
-  struct chanset_t *chan;
-  char plus, mode;
-
-  BADARGS(3, 4, " channel mode ?arg?");
-  chan = findchan_by_dname(argv[1]);
-  if (chan == NULL) {
-    Tcl_AppendResult(irp, "invalid channel: ", argv[1], NULL);
-    return TCL_ERROR;
-  }
-  plus = argv[2][0];
-  mode = argv[2][1];
-  if ((plus != '+') && (plus != '-')) {
-    mode = plus;
-    plus = '+';
-  }
-  if (argc == 4)
-    add_mode(chan, plus, mode, argv[3]);
-  else
-    add_mode(chan, plus, mode, "");
-  return TCL_OK;
-}
-
 static int tcl_resetbans STDVAR
 {
   struct chanset_t *chan;
@@ -100,93 +76,13 @@ static int tcl_resetchan STDVAR
   return TCL_OK;
 }
 
-static int tcl_topic STDVAR
-{
-  struct chanset_t *chan;
-
-  BADARGS(2, 2, " channel");
-  chan = findchan_by_dname(argv[1]);
-  if (chan == NULL) {
-    Tcl_AppendResult(irp, "invalid channel ", argv[1], NULL);
-    return TCL_ERROR;
-  }
-  Tcl_AppendResult(irp, chan->channel.topic, NULL);
-  return TCL_OK;
-}
-
-/* Sends an optimal number of kicks per command (as defined by kick_method)
- * to the server, simialer to kick_all.
- */
-static int tcl_putkick STDVAR
-{
-  struct chanset_t *chan;
-  int k = 0, l;
-  char kicknick[512], *nick, *p, *comment = NULL;
-  memberlist *m;
-
-  BADARGS(3, 4, " channel nick?s? ?comment?");
-  chan = findchan_by_dname(argv[1]);
-  if (chan == NULL) {
-    Tcl_AppendResult(irp, "illegal channel: ", argv[1], NULL);
-    return TCL_ERROR;
-  }
-  if (argc == 4)
-    comment = argv[3];
-  else
-    comment = "";
-  if (!me_op(chan)) {
-    Tcl_AppendResult(irp, "need op", NULL);
-    return TCL_ERROR;
-  }
-
-  kicknick[0] = 0;
-  p = argv[2];
-  /* Loop through all given nicks */
-  while(p) {
-    nick = p;
-    p = strchr(nick, ',');	/* Search for beginning of next nick */
-    if (p) {
-      *p = 0;
-      p++;
-    }
-
-    m = ismember(chan, nick);
-    if (!me_op(chan) && !chan_hasop(m)) {
-      Tcl_AppendResult(irp, "need op", NULL);
-      return TCL_ERROR;
-    }
-    if (!m)
-      continue;			/* Skip non-existant nicks */
-    m->flags |= SENTKICK;	/* Mark as pending kick */
-    if (kicknick[0])
-      strcat(kicknick, ",");
-    strcat(kicknick, nick);	/* Add to local queue */
-    k++;
-
-    /* Check if we should send the kick command yet */
-    l = strlen(chan->name) + strlen(kicknick) + strlen(comment);
-    if (((kick_method != 0) && (k == kick_method)) || (l > 480)) {
-      dprintf(DP_SERVER, "KICK %s %s :%s%s\n", chan->name, kicknick, kickprefix, comment);
-      k = 0;
-      kicknick[0] = 0;
-    }
-  }
-  /* Clear out all pending kicks in our local kick queue */
-  if (k > 0)
-    dprintf(DP_SERVER, "KICK %s %s :%s%s\n", chan->name, kicknick, kickprefix, comment);
-  return TCL_OK;
-}
-
 static tcl_cmds tclchan_cmds[] =
 {
   {"flushmode",		tcl_flushmode},
-  {"pushmode",		tcl_pushmode},
   {"resetbans",		tcl_resetbans},
   {"resetexempts",	tcl_resetexempts},
   {"resetinvites",	tcl_resetinvites},
   {"resetchan",		tcl_resetchan},
-  {"topic",		tcl_topic},
-  {"putkick",		tcl_putkick},
   {NULL,		NULL}
 };
 

+ 1 - 1
src/mod/module.h

@@ -135,7 +135,7 @@
 #define botnet_send_bye ((void(*)(void))global[27])
 /* 28 - 31 */
 #define botnet_send_chat ((void(*)(int,char*,char*))global[28])
-/* UNUSED 29 */
+#define server_lag (*(int *)global[29])
 /* UNUSED 30 */
 /* UNUSED 31 */
 /* 32 - 35 */

+ 3 - 4
src/mod/server.mod/cmdsserv.c

@@ -34,6 +34,7 @@ static void cmd_servers(struct userrec *u, int idx, char *par)
 
 static void cmd_dump(struct userrec *u, int idx, char *par)
 {
+  putlog(LOG_CMDS, "*", "#%s# dump %s", dcc[idx].nick, par);
   if (!(isowner(dcc[idx].nick)) && (must_be_owner == 2)) {
     dprintf(idx, "What?  You need '%shelp'\n", dcc_prefix);
     return;
@@ -42,7 +43,6 @@ static void cmd_dump(struct userrec *u, int idx, char *par)
     dprintf(idx, "Usage: dump <server stuff>\n");
     return;
   }
-  putlog(LOG_CMDS, "*", "#%s# dump %s", dcc[idx].nick, par);
   dprintf(DP_SERVER, "%s\n", par);
 }
 
@@ -56,8 +56,7 @@ static void cmd_jump(struct userrec *u, int idx, char *par)
     port = atoi(newsplit(&par));
     if (!port)
       port = default_port;
-    putlog(LOG_CMDS, "*", "#%s# jump %s %d %s", dcc[idx].nick, other,
-	   port, par);
+    putlog(LOG_CMDS, "*", "#%s# jump %s %d %s", dcc[idx].nick, other, port, par);
     strncpyz(newserver, other, sizeof newserver);
     newserverport = port;
     strncpyz(newserverpass, par, sizeof newserverpass);
@@ -72,6 +71,7 @@ static void cmd_clearqueue(struct userrec *u, int idx, char *par)
 {
   int	msgs;
 
+  putlog(LOG_CMDS, "*", "#%s# clearqueue %s", dcc[idx].nick, par);
   if (!par[0]) {
     dprintf(idx, "Usage: clearqueue <mode|server|help|all>\n");
     return;
@@ -110,7 +110,6 @@ static void cmd_clearqueue(struct userrec *u, int idx, char *par)
     dprintf(idx, "Usage: clearqueue <mode|server|help|all>\n");
     return;
   }
-  putlog(LOG_CMDS, "*", "#%s# clearqueue %s", dcc[idx].nick, par);
 }
 /* Function call should be:
  *   int cmd_whatever(idx,"parameters");

+ 41 - 57
src/mod/server.mod/server.c

@@ -19,7 +19,6 @@ static char newserver[121];	/* new server? */
 static int newserverport;	/* new server port? */
 static char newserverpass[121];	/* new server password? */
 static time_t trying_server;	/* trying to connect to a server right now? */
-static int server_lag;		/* how lagged (in seconds) is the server? */
 static int curserv;		/* current position in server list: */
 static int flud_thr;		/* msg flood threshold */
 static int flud_time;		/* msg flood time */
@@ -999,49 +998,50 @@ static void clearq(struct server_list *xx)
     xx = x;
   }
 }
+
 void servers_describe(struct cfg_entry * entry, int idx) {
 }
 void servers6_describe(struct cfg_entry * entry, int idx) {
 }
 
-int count(const char *s)
+int count(const char *s, const char *delim)
 {
   char *ele;
   int i = 0;
-  char count[1000];
+  char work[2000];
   
-  strcpy(count,s);
-  ele=strtok(count,",");
+  strncpyz(work, s, sizeof work);
+  ele = strtok(work, delim);
   while(ele && *ele)
   {
     i++;
-    ele=strtok((char*)NULL,",");
+    ele = strtok((char*) NULL, delim);
   }
-  return i-1;
+  return (i - 1);
 }
 
 int rrand(int a, int b)
 {
   b++;
-  return ((random()%(b-a))+a);
+  return ((random()%(b - a))+a);
 }
 
 char *randomize(char *line, char **new)
 {
-  char *str, *words[1000], *bak;
-  int i,o,b,r,u = 0;
-  bak = nmalloc(strlen(line)+1);
+  char *str, *words[2000], *bak;
+  int i, o, b, r, u = 0;
+  bak = nmalloc(strlen(line) + 1);
   strcpy(bak, line);
-  i=count(line);
+  i = count(line, ",");
 
-  b=i+1;
-  str=strtok(line,",");
-  o=0;
+  b = i + 1;
+  str = strtok(line, ",");
+  o = 0;
   while(str && *str)
   {
     words[o] = str;
     o++;
-    str=strtok((char*)NULL,",");
+    str=strtok((char*)NULL, ",");
   }
 
   while (b) {
@@ -1055,7 +1055,7 @@ char *randomize(char *line, char **new)
     r = rrand(0,i);
 
     if (strstr(*new,words[r]) == NULL) {
-      if (b == i+1) sprintf(*new,"%s",words[r]);
+      if (b == i + 1) sprintf(*new,"%s",words[r]);
       else sprintf(*new,"%s,%s", *new, words[r]);
       b--;
     } else 
@@ -1065,6 +1065,7 @@ char *randomize(char *line, char **new)
   nfree(bak);
   return *new;
 }
+
 void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   char *slist, *p;
@@ -1073,7 +1074,7 @@ void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 
   if (hostname6[0] || myip6[0]) //we want to use the servers6 entry.
     return;
-#endif
+#endif /* S_RANDSERVERS */
 
   slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
   if (serverlist) {
@@ -1087,13 +1088,13 @@ void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
   randomize(p,&new);
   strcpy(p, new);
  
-#endif
+#endif /* S_RANDSERVERS */
   add_server(p);
   nfree(p);
 #ifdef S_RANDSERVERS
   nfree(new);
-#endif
-#endif
+#endif /* S_RANDSERVERS */
+#endif /* LEAF */
 }
 
 void servers6_changed(struct cfg_entry * entry, char * olddata, int * valid) {
@@ -1104,7 +1105,7 @@ void servers6_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 
   if (!hostname6[0] && !myip6[0]) //we probably want to use the normal server list..
     return;
-#endif
+#endif /* S_RANDSERVERS */
   slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
   if (serverlist) {
     clearq(serverlist);
@@ -1117,13 +1118,13 @@ void servers6_changed(struct cfg_entry * entry, char * olddata, int * valid) {
   randomize(p,&new);
   strcpy(p, new);
  
-#endif
+#endif /* S_RANDSERVERS */
   add_server(p);
   nfree(p);
 #ifdef S_RANDSERVERS
   nfree(new);
-#endif
-#endif
+#endif /* S_RANDSERVERS */
+#endif /* LEAF */
 }
 
 void nick_describe(struct cfg_entry * entry, int idx) {
@@ -1133,18 +1134,19 @@ void nick_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   char * p;
   if (entry->ldata)
-    p=entry->ldata;
+    p = entry->ldata;
   else if (entry->gdata)
-    p=entry->gdata;
+    p = entry->gdata;
   else
-    p=NULL;
+    p = NULL;
   if (p && p[0]) {
-        strncpyz(origbotname, p, NICKMAX+1);
-//        dprintf(DP_MODE, STR("NICK %s\n"), p);
+    strncpyz(origbotname, p, NICKLEN + 1);
+    if (server_online)
+      dprintf(DP_SERVER, "ISON :%s %s\n", botname, origbotname);
   } else {
-    strncpyz(origbotname, botnetnick, NICKMAX+1);
+    strncpyz(origbotname, botnetnick, NICKLEN + 1);
   }
-#endif
+#endif /* LEAF */
 }
 void realname_describe(struct cfg_entry * entry, int idx) {
 }
@@ -1152,17 +1154,18 @@ void realname_describe(struct cfg_entry * entry, int idx) {
 void realname_changed(struct cfg_entry * entry, char * olddata, int * valid) {
 #ifdef LEAF
   if (entry->ldata) {
-    strncpyz(botrealname, (char *) entry->ldata, 120);
+    strncpyz(botrealname, (char *) entry->ldata, 121);
   } else if (entry->gdata) {
-    strncpyz(botrealname, (char *) entry->gdata, 120);
+    strncpyz(botrealname, (char *) entry->gdata, 121);
   }
-#endif
+#endif /* LEAF */
 }
 
 struct cfg_entry CFG_SERVERS = {
   "servers", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
   servers_changed, servers_changed, servers_describe
 };
+
 struct cfg_entry CFG_SERVERS6 = {
   "servers6", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
   servers6_changed, servers6_changed, servers6_describe
@@ -1471,22 +1474,6 @@ Context;
   return NULL;
 }
 
-static tcl_strings my_tcl_strings[] =
-{
-  {"botnick",			NULL,		0,		STR_PROTECT},
-  {"realname",			botrealname,	80,		0},
-  {"stackable-commands",	stackablecmds,	510,		0},
-  {"stackable2-commands",	stackable2cmds,	510,		0},
-  {NULL,			NULL,		0,		0}
-};
-
-static tcl_coups my_tcl_coups[] =
-{
-  {"flood-msg",		&flud_thr,		&flud_time},
-  {"flood-ctcp",	&flud_ctcp_thr, 	&flud_ctcp_time},
-  {NULL,		NULL,			NULL}
-};
-
 static tcl_ints my_tcl_ints[] =
 {
   {"use-console-r",		NULL,				1},
@@ -1893,7 +1880,7 @@ static Function server_table[] =
   (Function) 0,	
   (Function) & nick_len,	/* int					*/
   (Function) 0,
-  (Function) & server_lag, /* int */
+  (Function) 0,
   (Function) & curserv,
   (Function) cursrvname,
   (Function) botrealname,
@@ -2001,12 +1988,9 @@ char *server_start(Function *global_funcs)
   add_builtins(H_raw, my_raw_binds);
   add_builtins(H_dcc, C_dcc_serv);
   add_builtins(H_ctcp, my_ctcps);
-  my_tcl_strings[0].buf = botname;
-  add_tcl_strings(my_tcl_strings);
   my_tcl_ints[0].val = &use_console_r;
   add_tcl_ints(my_tcl_ints);
   add_tcl_commands(my_tcl_cmds);
-  add_tcl_coups(my_tcl_coups);
   add_hook(HOOK_SECONDLY, (Function) server_secondly);
   add_hook(HOOK_10SECONDLY, (Function) server_10secondly);
   add_hook(HOOK_5MINUTELY, (Function) server_5minutely);
@@ -2028,7 +2012,7 @@ char *server_start(Function *global_funcs)
   add_cfg(&CFG_SERVERS);
   add_cfg(&CFG_SERVERS6);
   add_cfg(&CFG_REALNAME);
-  set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders");
+  set_cfg_str(NULL, STR("realname"), "A deranged product of evil coders.");
   return NULL;
 }
-#endif
+#endif /* LEAF */

+ 2 - 1
src/mod/server.mod/server.h

@@ -50,7 +50,8 @@
 #define ctcp_reply ((char *)(server_funcs[35]))
 /* 36 UNUSED */
 #define nick_len (*(int *)(server_funcs[37]))
-#define server_lag (*(int *)(server_funcs[39]))
+/* 38 UNUSED */
+/* 39 UNUSED */
 #define curserv (*(int *)(server_funcs[40))
 #define cursrvname ((char *)(server_funcs[41]))
 #define botrealname ((char *)(server_funcs[42]))

+ 3 - 6
src/mod/server.mod/servmsg.c

@@ -85,7 +85,7 @@ static int gotfake433(char *from)
   }
 
   putlog(LOG_SERV, "*", IRC_BOTNICKINUSE, botname);
-  dprintf(DP_MODE, "NICK %s\n", botname);
+  dprintf(DP_SERVER, "NICK %s\n", botname);
   return 0;
 }
 
@@ -1256,11 +1256,8 @@ static void connect_server(void)
     struct chanset_t *chan;
     struct server_list *x = serverlist;
 
-    if (!x) {
-//      putlog(LOG_SERV, "*", "No servers in server list");
-//      cycle_time = 10;
+    if (!x)
       return;
-    }
  
     servidx = new_dcc(&DCC_DNSWAIT, sizeof(struct dns_info));
     if (servidx < 0) {
@@ -1376,4 +1373,4 @@ static void server_resolve_success(int servidx)
     /* Wait for async result now */
   }
 }
-#endif
+#endif /* LEAF */

+ 12 - 65
src/mod/share.mod/share.c

@@ -363,7 +363,7 @@ static void share_chattr(int idx, char *par)
 #ifndef LEAF
 	  if (!(dcc[idx].status & STAT_GETTING))
 	    putlog(LOG_CMDS, "@", "%s: chattr %s %s", dcc[idx].nick, hand, s);
-#endif
+#endif /* LEAF */
 	  if ((me = module_find("irc", 0, 0))) {
 	    Function *func = me->funcs;
 
@@ -483,7 +483,7 @@ static void share_newuser(int idx, char *par)
 	noshare = 0;
 #ifndef LEAF
 	putlog(LOG_CMDS, "@", "%s: newuser %s %s", dcc[idx].nick, nick, s);
-#endif
+#endif /* LEAF */
       }
     }
   }
@@ -503,7 +503,7 @@ static void share_killuser(int idx, char *par)
       shareout_but(NULL, idx, "k %s\n", par);
 #ifndef LEAF
       putlog(LOG_CMDS, "@", "%s: killuser %s", dcc[idx].nick, par);
-#endif
+#endif /* LEAF */
     }
     noshare = 0;
   }
@@ -522,10 +522,9 @@ static void share_pls_host(int idx, char *par)
       set_user(&USERENTRY_HOSTS, u, par);
 #ifdef LEAF
       check_this_user(u->handle, 0, NULL);
-#endif /* LEAF */
-#ifndef LEAF
+#else /* !LEAF */
       putlog(LOG_CMDS, "@", "%s: +host %s %s", dcc[idx].nick, hand, par);
-#endif
+#endif /* LEAF */
     }
   }
 }
@@ -553,7 +552,7 @@ static void share_pls_bothost(int idx, char *par)
 #ifndef LEAF
       if (!(dcc[idx].status & STAT_GETTING))
 	putlog(LOG_CMDS, "@", "%s: +host %s %s", dcc[idx].nick, hand, par);
-#endif
+#endif /* LEAF */
     }
   }
 }
@@ -573,10 +572,9 @@ static void share_mns_host(int idx, char *par)
       noshare = 0;
 #ifdef LEAF
       check_this_user(hand, 2, par);
-#endif /* LEAF */
-#ifndef LEAF
+#else /* !LEAF */
       putlog(LOG_CMDS, "@", "%s: -host %s %s", dcc[idx].nick, hand, par);
-#endif
+#endif /* LEAF */
     }
   }
 }
@@ -1087,11 +1085,9 @@ static void share_ufyes(int idx, char *par)
 static void share_userfileq(int idx, char *par)
 {
   int ok = 1, i;
-//  int bfl = bot_flags(dcc[idx].user);
 
   flush_tbuf(dcc[idx].nick);
 
-//  if (bfl & BOT_AGGRESSIVE)
   if (bot_aggressive_to(dcc[idx].user)) {
     putlog(LOG_ERRORS, "*", STR("%s offered user transfer - I'm supposed to be aggressive to it"), dcc[idx].nick);
     dprintf(idx, STR("s un I have you marked for Agressive sharing.\n"));
@@ -1117,9 +1113,9 @@ static void share_userfileq(int idx, char *par)
       dcc[idx].status |= STAT_SHARE | STAT_GETTING | STAT_AGGRESSIVE;
 #ifdef HUB
       putlog(LOG_BOTS, "@", "Downloading user file from %s", dcc[idx].nick);
-#else
+#else /* !HUB */
       putlog(LOG_BOTS, "@", "Downloading user file via uplink.");
-#endif
+#endif /* HUB */
     }
   }
 }
@@ -1224,8 +1220,6 @@ static void share_version(int idx, char *par)
   dcc[idx].status &= ~(STAT_SHARE | STAT_GETTING | STAT_SENDING |
 		       STAT_OFFERED | STAT_AGGRESSIVE);
   dcc[idx].u.bot->uff_flags = 0;
-//printf("idx: %d them: %d me: %d a? %d\n", idx, dcc[idx].u.bot->numver, egg_numver, bot_aggressive_to(dcc[idx].user));
-//  if ((dcc[idx].u.bot->numver == egg_numver) && //only share with same VER bots.
   if (1 && //only share with same VER bots.
       (bot_aggressive_to(dcc[idx].user))) {
     if (can_resync(dcc[idx].nick))
@@ -1245,7 +1239,6 @@ static void hook_read_userfile()
     for (i = 0; i < dcc_total; i++)
       if ((dcc[i].type->flags & DCT_BOT) && (dcc[i].status & STAT_SHARE) &&
 	  !(dcc[i].status & STAT_AGGRESSIVE) &&
-//          (dcc[i].u.bot->numver == egg_numver)) { 
           (1)) { 
 	/* Cancel any existing transfers */
 	if (dcc[i].status & STAT_SENDING)
@@ -1286,7 +1279,6 @@ static botcmd_t C_share[] =
   {"+bc",	(Function) share_pls_banchan},
   {"+bh",	(Function) share_pls_bothost},
   {"+cr",	(Function) share_pls_chrec},
-//  {"+c",	(Function) share_pls_chan},
   {"+e",	(Function) share_pls_exempt},
   {"+ec",	(Function) share_pls_exemptchan},
   {"+h",	(Function) share_pls_host},
@@ -1304,7 +1296,6 @@ static botcmd_t C_share[] =
   {"-invc",	(Function) share_mns_invitechan},
   {"a",		(Function) share_chattr},
   {"c",		(Function) share_change},
-//  {"chan",	(Function) share_chan},
   {"chchinfo",	(Function) share_chchinfo},
   {"e",		(Function) share_end},
   {"feats",	(Function) share_feats},
@@ -1484,17 +1475,13 @@ static void check_expired_tbufs()
     if (dcc[i].type->flags & DCT_BOT) {
       if (dcc[i].status & STAT_OFFERED) {
 	if (now - dcc[i].timeval > 120) {
-	  if (dcc[i].user && (bot_aggressive_to(dcc[i].user)) &&
-             (1))
-//             (dcc[i].u.bot->numver == egg_numver))
+	  if (dcc[i].user && bot_aggressive_to(dcc[i].user))
 	    dprintf(i, "s u?\n");
 	  /* ^ send it again in case they missed it */
 	}
 	/* If it's a share bot that hasnt been sharing, ask again */
       } else if (!(dcc[i].status & STAT_SHARE)) {
-	if (dcc[i].user && (bot_aggressive_to(dcc[i].user)) &&
-           (1))
-//           (dcc[i].u.bot->numver == egg_numver))
+	if (dcc[i].user && bot_aggressive_to(dcc[i].user))
 	  dprintf(i, "s u?\n");
 	dcc[i].status |= STAT_OFFERED;
       }
@@ -1632,8 +1619,6 @@ static int write_tmp_userfile(char *fn, struct userrec *bu, int idx)
     chmod(fn, 0600);		/* make it -rw------- */
     lfprintf(f, "#4v: %s -- %s -- transmit\n", ver, botnetnick);
     ok = 1;
-//need chanhack for no support    
-    Context;
     if (!write_chans(f, idx))
      ok = 0;
     if (!write_bans(f, idx))
@@ -1659,13 +1644,10 @@ static int write_tmp_userfile(char *fn, struct userrec *bu, int idx)
     } else
       putlog(LOG_BOTS, "@", "%s is too old: not sharing exempts and invites.",
              dcc[idx].nick);
-    Context;
     for (u = bu; u && ok; u = u->next)
     if (!write_user(u, f, idx))
      ok = 0;
-    Context;
     lfprintf(f, "#DONT DELETE THIS LINE");
-    Context;
     fclose(f);
   }
   if (!ok)
@@ -2090,38 +2072,6 @@ static void cancel_user_xfer(int idx, void *x)
     def_dcc_bot_kill(idx, x);
 }
 
-static tcl_ints my_ints[] =
-{
-  {"allow-resync",	&allow_resync},
-  {"resync-time",	&resync_time},
-  {"private-global",	&private_global},
-  {"private-user",	&private_user},
-  {"override-bots",	&overr_local_bots},
-  {NULL,		NULL}
-};
-
-static tcl_strings my_strings[] =
-{
-  {"private-globals",	private_globals,	50,	0},
-  {NULL,		NULL,			0,	0}
-};
-
-static void cmd_flush(struct userrec *u, int idx, char *par)
-{
-  if (!par[0])
-    dprintf(idx, "Usage: flush <botname>\n");
-  else if (flush_tbuf(par))
-    dprintf(idx, "Flushed resync buffer for %s\n", par);
-  else
-    dprintf(idx, "There is no resync buffer for that bot.\n");
-}
-
-static cmd_t my_cmds[] =
-{
-  {"flush",	"n",	(Function) cmd_flush,		NULL},
-  {NULL,	NULL,	NULL,				NULL}
-};
-
 static int share_expmem()
 {
   int tot = 0;
@@ -2238,9 +2188,6 @@ char *share_start(Function *global_funcs)
   add_hook(HOOK_SECONDLY, (Function) check_delay);
   def_dcc_bot_kill = DCC_BOT.kill;
   DCC_BOT.kill = cancel_user_xfer;
-  add_tcl_ints(my_ints);
-  add_tcl_strings(my_strings);
-  add_builtins(H_dcc, my_cmds);
   uff_init();
   uff_addtable(internal_uff_table);
   return NULL;

+ 4 - 2
src/modules.c

@@ -28,7 +28,7 @@ extern char		 tempdir[], botnetnick[], botname[], natip[], cmdprefix[],
                          authkey[], 
 #endif /* S_AUTH */
 			 myip[], myip6[];
-extern int	 noshare, loading, role, 
+extern int	 	 noshare, loading, role, server_lag, 
 #ifdef S_AUTH
 			 auth_total, 
 #endif /* S_AUTH */
@@ -191,7 +191,7 @@ Function global_table[] =
   (Function) botnet_send_bye,
   /* 28 - 31 */
   (Function) botnet_send_chat,
-  (Function) 0,
+  (Function) & server_lag, /* int					*/
   (Function) 0,
   (Function) 0,
   /* 32 - 35 */
@@ -673,6 +673,8 @@ const char *module_load(char *name)
   Function f;
   struct static_list *sl;
 
+  sdprintf("module_load(\"%s\")", name);
+
   if (module_find(name, 0, 0) != NULL)
     return MOD_ALREADYLOAD;
   for (sl = static_modules; sl && egg_strcasecmp(sl->name, name); sl = sl->next);

+ 50 - 70
src/net.c

@@ -1251,29 +1251,30 @@ char *botlink_decrypt(int snum, char *src)
   int i;
 
   line = decrypt_string(socklist[snum].ikey, src);
+  strcpy(src, line);
+  nfree(line);
   if (socklist[snum].iseed) {
     for (i = 0; i <= 3; i++)
       *(dword *) & socklist[snum].ikey[i * 4] = prand(&socklist[snum].iseed, 0xFFFFFFFF);
     if (!socklist[snum].iseed)
       socklist[snum].iseed++;
   }
-  strcpy(src, line);
-  nfree(line);
   return src;
 }
 
 char *botlink_encrypt(int snum, char *src)
 {
   char *srcbuf = NULL, *buf = NULL, *line = NULL, *eol = NULL, *eline = NULL;
-  int bufpos = 0, i;
+  int bufpos = 0, i = 0;
   
-  srcbuf = nmalloc(strlen(src) + 10);
+  srcbuf = nmalloc(strlen(src) + 9 + 1);
   strcpy(srcbuf, src);
   line = srcbuf;
-  if (!line)
+  if (!line) {
+    nfree(srcbuf);
     return NULL;
+  }
   eol = strchr(line, '\n');
-  i = 0;
   while (eol) {
     *eol++ = 0;
     eline = encrypt_string(socklist[snum].okey, line);
@@ -1285,23 +1286,24 @@ char *botlink_encrypt(int snum, char *src)
     }
     buf = nrealloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
+    nfree(eline);
     strcat(buf, "\n");
     bufpos = strlen(buf);
     line = eol;
     eol = strchr(line, '\n');
-    nfree(eline);
   }
   if (line[0]) {
     eline = encrypt_string(socklist[snum].okey, line);
     if (socklist[snum].oseed) {
-       *(dword *) & socklist[snum].okey[i * 4] = prand(&socklist[snum].oseed, 0xFFFFFFFF);
+      for (i = 0; i <= 3; i++)
+        *(dword *) & socklist[snum].okey[i * 4] = prand(&socklist[snum].oseed, 0xFFFFFFFF);
       if (!socklist[snum].oseed)
-       socklist[snum].oseed++;
+        socklist[snum].oseed++;
     }
     buf = nrealloc(buf, bufpos + strlen(eline) + 1 + 9);
     strcpy((char *) &buf[bufpos], eline);
-    strcat(buf, "\n");
     nfree(eline);
+    strcat(buf, "\n");
   }
   nfree(srcbuf);
   return buf;
@@ -1360,7 +1362,7 @@ int sockgets(char *s, int *len)
 	  /* Strip CR if this was CR/LF combo */
 	  if (s[strlen(s) - 1] == '\r')
 	    s[strlen(s) - 1] = 0;
-          if (socklist[i].encstatus)
+          if (socklist[i].encstatus && (strlen(s) > 0))
             botlink_decrypt(i, s);
 	  *len = strlen(s);
 	  return socklist[i].sock;
@@ -1375,12 +1377,11 @@ int sockgets(char *s, int *len)
 	  socklist[i].inbuflen = 0;
 	} else {
 	  /* Split up into chunks of grab bytes. */
-	  *len = grab - 2;
+	  *len = (grab - 2);
 	  egg_memcpy(s, socklist[i].inbuf, *len);
 	  egg_memcpy(socklist[i].inbuf, socklist[i].inbuf + *len, *len);
 	  socklist[i].inbuflen -= *len;
-	  socklist[i].inbuf = nrealloc(socklist[i].inbuf,
-				       socklist[i].inbuflen);
+	  socklist[i].inbuf = nrealloc(socklist[i].inbuf, socklist[i].inbuflen);
 	}
 	return socklist[i].sock;
       }
@@ -1419,8 +1420,7 @@ int sockgets(char *s, int *len)
     egg_memcpy(s, xx, *len);
     return socklist[ret].sock;
   }
-  if ((socklist[ret].flags & SOCK_LISTEN) ||
-      (socklist[ret].flags & SOCK_PASS))
+  if ((socklist[ret].flags & SOCK_LISTEN) || (socklist[ret].flags & SOCK_PASS))
     return socklist[ret].sock;
   if (socklist[ret].flags & SOCK_BUFFER) {
     socklist[ret].inbuf = (char *) nrealloc(socklist[ret].inbuf,
@@ -1430,7 +1430,7 @@ int sockgets(char *s, int *len)
     /* We don't know whether it's binary data. Make sure normal strings
        will be handled properly later on too. */
     socklist[ret].inbuf[socklist[ret].inbuflen] = 0;
-    return -4;	/* Ignore this one. */
+    return -4;			/* Ignore this one. */
   }
   /* Might be necessary to prepend stored-up data! */
   if (socklist[ret].inbuf != NULL) {
@@ -1446,9 +1446,8 @@ int sockgets(char *s, int *len)
       socklist[ret].inbuflen = 0;
     } else {
       p = socklist[ret].inbuf;
-    socklist[ret].inbuflen = strlen(p) - (grab - 2);
+      socklist[ret].inbuflen = strlen(p) - (grab - 2);
       socklist[ret].inbuf = (char *) nmalloc(socklist[ret].inbuflen + 1); 
-//      socklist[ret].inbuf = (char *) nmalloc(strlen(p) - (grab - 3));
       strcpy(socklist[ret].inbuf, p + (grab - 2));
       *(p + (grab - 2)) = 0;
       strcpy(xx, p);
@@ -1466,11 +1465,8 @@ int sockgets(char *s, int *len)
     strcpy(xx, p + 1);
     if (s[strlen(s) - 1] == '\r')
       s[strlen(s) - 1] = 0;
-    data = 1;			/* DCC_CHAT may now need to process a
-				   blank line */
-
+    data = 1;			/* DCC_CHAT may now need to process a blank line */
 /* NO! */
-
 /* if (!s[0]) strcpy(s," ");  */
   } else {
     s[0] = 0;
@@ -1481,7 +1477,7 @@ int sockgets(char *s, int *len)
       data = 1;
     }
   }
-  if (socklist[ret].encstatus)
+  if (socklist[ret].encstatus && (strlen(s) > 0))
     botlink_decrypt(ret, s);
   *len = strlen(s);
   /* Anything left that needs to be saved? */
@@ -1519,56 +1515,40 @@ void tputs(register int z, char *s, unsigned int len)
   register int i, x, idx;
   char *p;
   static int inhere = 0;
-  if (z < 0)
-    return;			/* um... HELLO?!  sanity check please! */
+
+  if (z < 0)			/* um... HELLO?!  sanity check please! */
+    return;			
+
   if (((z == STDOUT) || (z == STDERR)) && (!backgrd || use_stderr)) {
-#ifdef EUSE_COLORPUTS
-     colorputs(s);
-     x = len;
-#else /* !EUSE_COLORPUTS */
     write(z, s, len);
-#endif /* EUSE_COLORPUTS */
     return;
   }
+
   for (i = 0; i < MAXSOCKS; i++) {
     if (!(socklist[i].flags & SOCK_UNUSED) && (socklist[i].sock == z)) {
       for (idx = 0; idx < dcc_total; idx++) {
-        if (dcc[idx].sock == z) {
-          if (dcc[idx].type) {
-            if (dcc[idx].type->name) {
-              if (!strncmp(dcc[idx].type->name, "BOT", 3)) {
-                otraffic_bn_today += len;
-                break;
-              } else if (!strcmp(dcc[idx].type->name, "SERVER")) {
-                otraffic_irc_today += len;
-                break;
-              } else if (!strncmp(dcc[idx].type->name, "CHAT", 4)) {
-                otraffic_dcc_today += len;
-                break;
-              } else if (!strncmp(dcc[idx].type->name, "FILES", 5)) {
-                otraffic_filesys_today += len;
-                break;
-              } else if (!strcmp(dcc[idx].type->name, "SEND")) {
-                otraffic_trans_today += len;
-                break;
-              } else if (!strncmp(dcc[idx].type->name, "GET", 3)) {
-                otraffic_trans_today += len;
-                break;
-              } else {
-                otraffic_unknown_today += len;
-                break;
-              }
-            }
-          }
+        if ((dcc[idx].sock == z) && dcc[idx].type && dcc[idx].type->name) {
+          if (!strncmp(dcc[idx].type->name, "BOT", 3))
+            otraffic_bn_today += len;
+          else if (!strcmp(dcc[idx].type->name, "SERVER"))
+            otraffic_irc_today += len;
+          else if (!strncmp(dcc[idx].type->name, "CHAT", 4))
+            otraffic_dcc_today += len;
+          else if (!strncmp(dcc[idx].type->name, "FILES", 5))
+            otraffic_filesys_today += len;
+          else if (!strcmp(dcc[idx].type->name, "SEND"))
+            otraffic_trans_today += len;
+          else if (!strncmp(dcc[idx].type->name, "GET", 3))
+            otraffic_trans_today += len;
+          else
+            otraffic_unknown_today += len;
+          break;
         }
       }
-      if (socklist[i].encstatus) {
-        if ((!s) || (!s[0])) {
-         s = botlink_encrypt(i, s);
-         len = strlen(s);
-       }
-       s = botlink_encrypt(i, s);
-       len = strlen(s);
+
+      if (socklist[i].encstatus && (strlen(s) > 0)) {
+        s = botlink_encrypt(i, s);
+        len = strlen(s);
       }
       
       if (socklist[i].outbuf != NULL) {
@@ -1577,8 +1557,8 @@ void tputs(register int z, char *s, unsigned int len)
 	egg_memcpy(p + socklist[i].outbuflen, s, len);
 	socklist[i].outbuf = p;
 	socklist[i].outbuflen += len;
-        if (socklist[i].encstatus)
-         nfree(s);
+        if (socklist[i].encstatus && s)
+          nfree(s);
 	return;
       }
       /* Try. */
@@ -1611,7 +1591,7 @@ void tputs(register int z, char *s, unsigned int len)
 //      } else
 //#endif /* HAVE_ZLIB_H */
         x = write(z, s, len);
-      if (x == (-1))
+      if (x == -1)
 	x = 0;
       if (x < len) {
 	/* Socket is full, queue it */
@@ -1619,8 +1599,8 @@ void tputs(register int z, char *s, unsigned int len)
 	egg_memcpy(socklist[i].outbuf, &s[x], len - x);
 	socklist[i].outbuflen = len - x;
       }
-      if (socklist[i].encstatus)
-       nfree(s);
+      if (socklist[i].encstatus && s)
+        nfree(s);
       return;
     }
   }

+ 1 - 1
src/proto.h

@@ -365,7 +365,7 @@ void freeuser(struct userrec *);
 int change_handle(struct userrec *, char *);
 void correct_handle(char *);
 int write_user(struct userrec *u, FILE * f, int shr);
-void write_userfile(int);
+int write_userfile(int);
 struct userrec *check_dcclist_hand(char *);
 void touch_laston(struct userrec *, char *, time_t);
 void user_del_chan(char *);

+ 5 - 4
src/userrec.c

@@ -500,7 +500,7 @@ void sort_userlist()
 /* Rewrite the entire user file. Call USERFILE hook as well, probably
  * causing the channel file to be rewritten as well.
  */
-void write_userfile(int idx)
+int write_userfile(int idx)
 {
   FILE *f;
   char *new_userfile;
@@ -510,7 +510,7 @@ void write_userfile(int idx)
   int ok;
 
   if (userlist == NULL)
-    return;			/* No point in saving userfile */
+    return 1;			/* No point in saving userfile */
 
   new_userfile = nmalloc(strlen(userfile) + 5);
   sprintf(new_userfile, "%s~new", userfile);
@@ -520,7 +520,7 @@ void write_userfile(int idx)
   if (f == NULL) {
     putlog(LOG_MISC, "*", USERF_ERRWRITE);
     nfree(new_userfile);
-    return;
+    return 2;
   }
   if (!quiet_save)
     putlog(LOG_MISC, "*", USERF_WRITING);
@@ -540,7 +540,7 @@ void write_userfile(int idx)
     putlog(LOG_MISC, "*", "%s (%s)", USERF_ERRWRITE, strerror(ferror(f)));
     fclose(f);
     nfree(new_userfile);
-    return;
+    return 3;
   }
   lfprintf(f, "#DONT DELETE THIS LINE.");
   fclose(f);
@@ -549,6 +549,7 @@ void write_userfile(int idx)
   copyfile(userfile, backup);
   movefile(new_userfile, userfile);
   nfree(new_userfile);
+  return 0;
 }
 int change_handle(struct userrec *u, char *newh)
 {