Просмотр исходного кода

* Recoded/reorganized a lot of the 'first thing' checks (mdop/mop/cookieops)
* Removed a ton of useless check_tcl functions
* Fixed a user_malloc flaw
* Removed language.c references in mem.c


svn: 252

Bryan Drewery 22 лет назад
Родитель
Сommit
93810a8572

+ 1 - 1
src/botcmd.c

@@ -335,7 +335,7 @@ static void remote_tell_who(int idx, char *nick, int chan)
   putlog(LOG_BOTS, "*", "#%s# who", realnick);
   strcpy(s, "Channels: ");
   for (c = chanset; c; c = c->next)
-    if (!channel_secret(c) && !channel_inactive(c)) {
+    if (!channel_secret(c) && shouldjoin(c)) {
       l = strlen(c->name);
       if (i + l < 1021) {
 	if (i > 10)

+ 17 - 0
src/chanprog.c

@@ -858,3 +858,20 @@ int isowner(char *name)
   }
 }
 
+int shouldjoin(struct chanset_t *chan)
+{
+  if (!strcmp(chan->dname, "#wtest"))
+    return 1;
+  else
+    return 0;
+#ifdef G_BACKUP
+  struct flag_record fr = { FR_CHAN | FR_ANYWH | FR_GLOBAL, 0, 0, 0, 0 };
+
+  get_user_flagrec(get_user_by_handle(userlist, botnetnick), &fr, chan->name);
+  return (!channel_inactive(chan)
+          && (channel_backup(chan) || !glob_backupbot(fr)));
+#else
+  return !channel_inactive(chan);
+#endif
+}
+

+ 4 - 14
src/mem.c

@@ -48,10 +48,6 @@ int expmem_net();
 int expmem_modules();
 int expmem_config();
 int expmem_auth();
-int expmem_language() 
-{
-  return 0;
-}
 int expmem_tcldcc();
 int expmem_dns();
 
@@ -105,14 +101,14 @@ void tell_mem_status_dcc(int idx)
 void debug_mem_to_dcc(int idx)
 {
 #ifdef DEBUG_MEM
-#define MAX_MEM 15
+#define MAX_MEM 14
   unsigned long exp[MAX_MEM], use[MAX_MEM], l;
   int i, j;
   char fn[20], sofar[81];
   module_entry *me;
   char *p;
 
-  exp[0] = expmem_language();
+  exp[0] = expmem_auth();
   exp[1] = expmem_chanprog();
   exp[2] = expmem_misc();
   exp[3] = expmem_users();
@@ -126,7 +122,6 @@ void debug_mem_to_dcc(int idx)
   exp[11] = expmem_tcldcc();
   exp[12] = expmem_dns();
   exp[13] = expmem_config();
-  exp[14] = expmem_auth();
   for (me = module_list; me; me = me->next)
     me->mem_work = 0;
   for (i = 0; i < MAX_MEM; i++)
@@ -142,7 +137,7 @@ void debug_mem_to_dcc(int idx)
       *p = 0;
 */
     l = memtbl[i].size;
-    if (!strcmp(fn, "language.c"))
+    if (!strcmp(fn, "xauth.c"))
       use[0] += l;
     else if (!strcmp(fn, "xchanprog.c"))
       use[1] += l;
@@ -170,8 +165,6 @@ void debug_mem_to_dcc(int idx)
       use[12] += l;
     else if (!strcmp(fn, "xconfig.c"))
       use[13] += l;
-    else if (!strcmp(fn, "xauth.c"))
-      use[14] += l;
     else if (p) {
       for (me = module_list; me; me = me->next)
 	if (!strcmp(fn, me->name))
@@ -182,7 +175,7 @@ void debug_mem_to_dcc(int idx)
   for (i = 0; i < MAX_MEM; i++) {
     switch (i) {
     case 0:
-      strcpy(fn, "xlanguage.c");
+      strcpy(fn, "xauth.c");
       break;
     case 1:
       strcpy(fn, "xchanprog.c");
@@ -223,9 +216,6 @@ void debug_mem_to_dcc(int idx)
     case 13:
       strcpy(fn, "xconfig.c");
       break;
-    case 14:
-      strcpy(fn, "xauth.c");
-      break;
     }
     if (use[i] == exp[i]) {
       dprintf(idx, STR("File '%-10s' accounted for %lu/%lu (ok)\n"), fn, exp[i],

+ 16 - 2
src/misc.c

@@ -500,7 +500,7 @@ void show_channels(int idx, char *handle)
           
           first = 1;
         }
-        dprintf(idx, format, chan->dname, channel_inactive(chan) ? "(inactive) " : "", 
+        dprintf(idx, format, chan->dname, !shouldjoin(chan) ? "(inactive) " : "", 
            channel_private(chan) ? "(private)  " : "", !channel_manop(chan) ? "(no manop) " : "", 
            channel_bitch(chan) ? "(bitch)    " : "", channel_closed(chan) ?  "(closed)" : "");
     }
@@ -803,6 +803,20 @@ int dovoice(struct chanset_t *chan)
   return 0;
 }
 
+int dolimit(struct chanset_t *chan)
+{
+  struct userrec *user = NULL;
+  struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0 };
+
+  if (!chan) return 0;
+
+  user = get_user_by_handle(userlist, botnetnick);
+  get_user_flagrec(user, &fr, chan->dname);
+  if (glob_dolimit(fr) || chan_dolimit(fr))
+    return 1;
+  return 0;
+}
+
 #ifdef S_LASTCHECK
 char last_buf[128]="";
 #endif /* S_LASTCHECK */
@@ -1218,7 +1232,7 @@ int shell_exec(char *cmdline, char *input, char **output, char **erroutput)
     if (dup2(errd, STDERR_FILENO) == (-1)) {
       exit(1);
     }
-    argv[0] = STR("/bin/sh");
+    argv[0] = STR("sh"); 		/* it should find it no problem, according to man (/bin,/usr/bin)*/
     argv[1] = STR("-c");
     argv[2] = cmdline;
     argv[3] = NULL;

+ 4 - 4
src/mod/channels.mod/channels.c

@@ -259,7 +259,7 @@ Context;
       chan->parttime = 0;
 Context;
 #ifdef LEAF
-      if (channel_active(chan) && !channel_inactive(chan))
+      if (channel_active(chan) && shouldjoin(chan))
         dprintf(DP_MODE, "PART %s\n", chan->name);
 #endif /* LEAF */
 Context;
@@ -274,7 +274,7 @@ Context;
         chan->jointime=0;
 Context;
 #ifdef LEAF
-      if (!channel_inactive(chan) && !channel_active(chan))
+      if (shouldjoin(chan) && !channel_active(chan))
         dprintf(DP_MODE, "JOIN %s %s\n", chan->name, chan->key_prot);
 #endif /* LEAF */
     }
@@ -624,7 +624,7 @@ static void channels_report(int idx, int details)
       if (!s[0])
 	strcpy(s, MISC_LURKING);
       get_mode_protect(chan, s2);
-      if (!channel_inactive(chan)) {
+      if (shouldjoin(chan)) {
 	if (channel_active(chan)) {
 	  /* If it's a !chan, we want to display it's unique name too <cybah> */
 	  if (chan->dname[0]=='!') {
@@ -683,7 +683,7 @@ static void channels_report(int idx, int details)
 	if (!channel_nouserinvites(chan))
 	  i += my_strcpy(s + i, "userinvites ");
 #endif
-	if (channel_inactive(chan))
+	if (!shouldjoin(chan))
 	  i += my_strcpy(s + i, "inactive ");
 	if (channel_nodesynch(chan))
 	  i += my_strcpy(s + i, "nodesynch ");

+ 2 - 1
src/mod/channels.mod/cmdschan.c

@@ -1007,7 +1007,8 @@ static void cmd_slowjoin(struct userrec *u, int idx, char *par)
   dprintf(idx, "%i bots joining %s during the next %i seconds\n", count, chan->dname, delay);
   chan->status &= ~CHAN_INACTIVE;
 #ifdef LEAF
-  dprintf(DP_MODE, "JOIN %s %s\n", chan->dname, chan->key_prot);
+  if (shouldjoin(chan)) 
+    dprintf(DP_MODE, "JOIN %s %s\n", chan->dname, chan->key_prot);
 #endif /* LEAF */
 }
 

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

@@ -77,7 +77,7 @@ static int tcl_channel_info(Tcl_Interp * irp, struct chanset_t *chan)
     Tcl_AppendElement(irp, "+dontkickops");
   else
     Tcl_AppendElement(irp, "-dontkickops");
-  if (chan->status& CHAN_INACTIVE)
+  if (chan->status & CHAN_INACTIVE)
     Tcl_AppendElement(irp, "+inactive");
   else
     Tcl_AppendElement(irp, "-inactive");
@@ -723,10 +723,10 @@ static int tcl_channel_modify(Tcl_Interp * irp, struct chanset_t *chan,
   if (protect_readonly || loading) {
     if (((old_status ^ chan->status) & CHAN_INACTIVE) &&
 	module_find("irc", 0, 0)) {
-      if (channel_inactive(chan) &&
+      if (!shouldjoin(chan) &&
 	  (chan->status & (CHAN_ACTIVE | CHAN_PEND)))
 	dprintf(DP_SERVER, "PART %s\n", chan->name);
-      if (!channel_inactive(chan) &&
+      if (shouldjoin(chan) &&
 	  !(chan->status & (CHAN_ACTIVE | CHAN_PEND)))
 	dprintf(DP_SERVER, "JOIN %s %s\n", (chan->name[0]) ?
 					   chan->name : chan->dname,
@@ -1050,7 +1050,7 @@ static int tcl_channel_add(Tcl_Interp *irp, char *newname, char *options)
   }
   Tcl_Free((char *) item);
 #ifdef LEAF
-  if (join && !channel_inactive(chan) && module_find("irc", 0, 0))
+  if (join && shouldjoin(chan) && module_find("irc", 0, 0))
     dprintf(DP_SERVER, "JOIN %s %s\n", chan->dname, chan->key_prot);
 #endif
   return ret;

+ 1 - 4
src/mod/channels.mod/userchan.c

@@ -1490,13 +1490,10 @@ int checklimit = 1;
 void check_limitraise() {
   int i=0;
   struct chanset_t * chan;
-  struct userrec *u;
-  u=get_user_by_handle(userlist, botnetnick);
   for (chan=chanset;chan;chan=chan->next,i++) {
     if (i % 2 == checklimit) {
       if (chan->limitraise) {
-        get_user_flagrec(u, &user, chan->dname);
-        if (glob_dolimit(user) || (chan_dolimit(user)))
+        if (dolimit(chan)) 
           raise_limit(chan);
       }
     }

+ 1 - 1
src/mod/irc.mod/cmdsirc.c

@@ -554,7 +554,7 @@ Context;
     get_user_flagrec(dcc[idx].user, &user, chan->dname);
 
 Context;
-    if (channel_inactive(chan) || !channel_active(chan))  {
+    if (!shouldjoin(chan) || !channel_active(chan))  {
       dprintf(idx, "I'm not on %s\n", chan->dname);
       return;
     }

+ 28 - 174
src/mod/irc.mod/irc.c

@@ -42,8 +42,6 @@ struct cfg_entry CFG_OPBOTS,
 
   CFG_OPREQUESTS;
 
-static p_tcl_bind_list H_topc, H_splt, H_sign, H_rejn, H_part, H_pub, H_pubm;
-static p_tcl_bind_list H_nick, H_mode, H_kick, H_join, H_need;
 static Function *global = NULL, *channels_funcs = NULL, *server_funcs = NULL,
                 *encryption_funcs = NULL;
 
@@ -180,20 +178,24 @@ void getin_request(char *botnick, char *code, char *par)
     ip4 = newsplit(&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);
+      nfree(tmp);
     } else {
       ip4host[0] = 0;
     }
     ip6 = newsplit(&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);
+      nfree(tmp);
     } else {
       ip6host[0] = 0;
     }
@@ -406,7 +408,7 @@ Context;
       putlog(LOG_GETIN, "*", STR("Got key for nonexistant channel %s from %s"), chname, botnick);
       return;
     }
-    if (channel_inactive(chan)) {
+    if (!shouldjoin(chan)) {
       putlog(LOG_GETIN, "*", STR("Got key for %s from %s - I shouldn't be on that chan?!?"), chan->dname, botnick);
     } else {
       if (!(channel_pending(chan) || channel_active(chan))) {
@@ -462,7 +464,7 @@ static void request_op(struct chanset_t *chan)
   struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0 };
 
 Context;
-  if (channel_pending(chan) || channel_inactive(chan) || !channel_active(chan))
+  if (channel_pending(chan) || !shouldjoin(chan) || !channel_active(chan))
     return;
   chan->channel.do_opreq = 0;
   if (me_op(chan))
@@ -924,7 +926,7 @@ static void reset_chan_info(struct chanset_t *chan)
 {
   int opped = 0;
   /* Don't reset the channel if we're already resetting it */
-  if (channel_inactive(chan)) {
+  if (!shouldjoin(chan)) {
     dprintf(DP_MODE,"PART %s\n", chan->name);
     return;
   }
@@ -973,13 +975,12 @@ putlog(LOG_DEBUG, "@", "I AM NOW CHECKING +e for %s", chan->dname);
  */
 static void do_channel_part(struct chanset_t *chan)
 {
-  if (!channel_inactive(chan) && chan->name[0]) {
+  if (shouldjoin(chan) && chan->name[0]) {
     /* Using chan->name is important here, especially for !chans <cybah> */
     dprintf(DP_SERVER, "PART %s\n", chan->name);
 
     /* As we don't know of this channel anymore when we receive the server's
        ack for the above PART, we have to notify about it _now_. */
-    check_tcl_part(botname, botuserhost, NULL, chan->dname, NULL);
   }
 }
 
@@ -996,7 +997,7 @@ static void check_lonely_channel(struct chanset_t *chan)
   static int whined = 0;
 
   if (channel_pending(chan) || !channel_active(chan) || me_op(chan) ||
-      channel_inactive(chan) || (chan->channel.mode & CHANANON))
+      !shouldjoin(chan) || (chan->channel.mode & CHANANON))
     return;
   /* Count non-split channel members */
   for (m = chan->channel.member; m && m->nick[0]; m = m->next)
@@ -1014,11 +1015,7 @@ static void check_lonely_channel(struct chanset_t *chan)
   } else if (any_ops(chan)) {
     whined = 0;
     request_op(chan);
-/* need
-    check_tcl_need(chan->dname, "op");
-    if (chan->need_op[0])
-      do_tcl("need-op", chan->need_op);
-*/
+/* need: op */
   } else {
     /* Other people here, but none are ops. If there are other bots make
      * them LEAVE!
@@ -1052,11 +1049,7 @@ static void check_lonely_channel(struct chanset_t *chan)
     } else {
       /* Some humans on channel, but still op-less */
       request_op(chan);
-/* need
-      check_tcl_need(chan->dname, "op");
-      if (chan->need_op[0])
-	do_tcl("need-op", chan->need_op);
-*/
+/* need: op */
     }
   }
 }
@@ -1199,9 +1192,6 @@ static void check_expired_chanstuff()
 	n = m->next;
 	if (m->split && now - m->split > wait_split) {
 	  sprintf(s, "%s!%s", m->nick, m->userhost);
-	  check_tcl_sign(m->nick, m->userhost,
-			 m->user ? m->user : get_user_by_host(s),
-			 chan->dname, "lost in the netsplit");
 	  putlog(LOG_JOIN, chan->dname,
 		 "%s (%s) got lost in the net-split.",
 		 m->nick, m->userhost);
@@ -1242,7 +1232,7 @@ static void check_expired_chanstuff()
       }
       check_lonely_channel(chan);
     }
-    else if (!channel_inactive(chan) && !channel_pending(chan))
+    else if (shouldjoin(chan) && !channel_pending(chan))
       dprintf(DP_MODE, "JOIN %s %s\n",
               (chan->name[0]) ? chan->name : chan->dname,
               chan->channel.key[0] ? chan->channel.key : chan->key_prot);
@@ -1291,111 +1281,6 @@ static int channels_2char STDVAR
   return TCL_OK;
 }
 
-static void check_tcl_joinspltrejn(char *nick, char *uhost, struct userrec *u,
-			       char *chname, p_tcl_bind_list table)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char args[1024];
-
-  simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
-  get_user_flagrec(u, &fr, chname);
-  Tcl_SetVar(interp, "_jp1", nick, 0);
-  Tcl_SetVar(interp, "_jp2", uhost, 0);
-  Tcl_SetVar(interp, "_jp3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_jp4", chname, 0);
-  check_tcl_bind(table, args, &fr, " $_jp1 $_jp2 $_jp3 $_jp4",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
-/* we handle part messages now *sigh* (guppy 27Jan2000) */
-
-static void check_tcl_part(char *nick, char *uhost, struct userrec *u,
-			       char *chname, char *text)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char args[1024];
-
-  simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
-  get_user_flagrec(u, &fr, chname);
-  Tcl_SetVar(interp, "_p1", nick, 0);
-  Tcl_SetVar(interp, "_p2", uhost, 0);
-  Tcl_SetVar(interp, "_p3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_p4", chname, 0);
-  Tcl_SetVar(interp, "_p5", text ? text : "", 0);
-  check_tcl_bind(H_part, args, &fr, " $_p1 $_p2 $_p3 $_p4 $_p5",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
-static void check_tcl_signtopcnick(char *nick, char *uhost, struct userrec *u,
-				   char *chname, char *reason,
-				   p_tcl_bind_list table)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char args[1024];
-
-  if (table == H_sign)
-    simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
-  else
-    simple_sprintf(args, "%s %s", chname, reason);
-  get_user_flagrec(u, &fr, chname);
-  Tcl_SetVar(interp, "_stnm1", nick, 0);
-  Tcl_SetVar(interp, "_stnm2", uhost, 0);
-  Tcl_SetVar(interp, "_stnm3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_stnm4", chname, 0);
-  Tcl_SetVar(interp, "_stnm5", reason, 0);
-  check_tcl_bind(table, args, &fr, " $_stnm1 $_stnm2 $_stnm3 $_stnm4 $_stnm5",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
-static void check_tcl_kickmode(char *nick, char *uhost, struct userrec *u,
-			       char *chname, char *dest, char *reason,
-			       p_tcl_bind_list table)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char args[512];
-
-  get_user_flagrec(u, &fr, chname);
-  if (table == H_mode)
-    simple_sprintf(args, "%s %s", chname, dest);
-  else
-    simple_sprintf(args, "%s %s %s", chname, dest, reason);
-  Tcl_SetVar(interp, "_kick1", nick, 0);
-  Tcl_SetVar(interp, "_kick2", uhost, 0);
-  Tcl_SetVar(interp, "_kick3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_kick4", chname, 0);
-  Tcl_SetVar(interp, "_kick5", dest, 0);
-  Tcl_SetVar(interp, "_kick6", reason, 0);
-  check_tcl_bind(table, args, &fr, " $_kick1 $_kick2 $_kick3 $_kick4 $_kick5 $_kick6",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
-static int check_tcl_pub(char *nick, char *from, char *chname, char *msg)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  int x;
-  char buf[512], *args = buf, *cmd, host[161], *hand;
-  struct userrec *u;
-
-  strcpy(args, msg);
-  cmd = newsplit(&args);
-  simple_sprintf(host, "%s!%s", nick, from);
-  u = get_user_by_host(host);
-  hand = u ? u->handle : "*";
-  get_user_flagrec(u, &fr, chname);
-  Tcl_SetVar(interp, "_pub1", nick, 0);
-  Tcl_SetVar(interp, "_pub2", from, 0);
-  Tcl_SetVar(interp, "_pub3", hand, 0);
-  Tcl_SetVar(interp, "_pub4", chname, 0);
-  Tcl_SetVar(interp, "_pub5", args, 0);
-  x = check_tcl_bind(H_pub, cmd, &fr, " $_pub1 $_pub2 $_pub3 $_pub4 $_pub5",
-		     MATCH_EXACT | BIND_USE_ATTR | BIND_HAS_BUILTINS);
-  if (x == BIND_NOMATCH)
-    return 0;
-  if (x == BIND_EXEC_LOG)
-    putlog(LOG_CMDS, chname, "<<%s>> !%s! %s %s", nick, hand, cmd, args);
-  return 1;
-}
-
 #ifdef S_AUTH
 static int check_tcl_pubc(char *cmd, char *nick, char *uhost,
                          struct userrec *u, char *args, char *chan)
@@ -1420,25 +1305,6 @@ static int check_tcl_pubc(char *cmd, char *nick, char *uhost,
 }
 #endif /* S_AUTH */
 
-static void check_tcl_pubm(char *nick, char *from, char *chname, char *msg)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
-  char buf[1024], host[161];
-  struct userrec *u;
-
-  simple_sprintf(buf, "%s %s", chname, msg);
-  simple_sprintf(host, "%s!%s", nick, from);
-  u = get_user_by_host(host);
-  get_user_flagrec(u, &fr, chname);
-  Tcl_SetVar(interp, "_pubm1", nick, 0);
-  Tcl_SetVar(interp, "_pubm2", from, 0);
-  Tcl_SetVar(interp, "_pubm3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_pubm4", chname, 0);
-  Tcl_SetVar(interp, "_pubm5", msg, 0);
-  check_tcl_bind(H_pubm, buf, &fr, " $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
 static tcl_ints myints[] =
 {
   {"learn-users",		&learn_users,		0},	/* arthur2 */
@@ -1514,7 +1380,7 @@ static void irc_report(int idx, int details)
     if (!private(fr, chan, PRIV_OP) &&
         (idx == DP_STDOUT || glob_master(fr) || chan_master(fr))) {
       p = NULL;
-      if (!channel_inactive(chan)) {
+      if (shouldjoin(chan)) {
 	if (chan->status & CHAN_JUPED)
 	  p = MISC_JUPED;
 	else if (!(chan->status & CHAN_ACTIVE))
@@ -1687,24 +1553,24 @@ static Function irc_table[] =
   (Function) irc_expmem,
   (Function) irc_report,
   /* 4 - 7 */
-  (Function) & H_splt,		/* p_tcl_bind_list		*/
-  (Function) & H_rejn,		/* p_tcl_bind_list		*/
-  (Function) & H_nick,		/* p_tcl_bind_list		*/
-  (Function) & H_sign,		/* p_tcl_bind_list		*/
+  (Function) 0,		
+  (Function) 0,		
+  (Function) 0,
+  (Function) 0,
   /* 8 - 11 */
-  (Function) & H_join,		/* p_tcl_bind_list		*/
-  (Function) & H_part,		/* p_tcl_bind_list		*/
-  (Function) & H_mode,		/* p_tcl_bind_list		*/
-  (Function) & H_kick,		/* p_tcl_bind_list		*/
+  (Function) 0,		
+  (Function) 0,		
+  (Function) 0,		
+  (Function) 0,		
   /* 12 - 15 */
-  (Function) & H_pubm,		/* p_tcl_bind_list		*/
-  (Function) & H_pub,		/* p_tcl_bind_list		*/
-  (Function) & H_topc,		/* p_tcl_bind_list		*/
+  (Function) 0,
+  (Function) 0,
+  (Function) 0,
   (Function) recheck_channel,
   /* 16 - 19 */
   (Function) me_op,
   (Function) recheck_channel_modes,
-  (Function) & H_need,		/* p_tcl_bind_list		*/
+  (Function) 0,
   (Function) do_channel_part,
   /* 20 - 23 */
   (Function) check_this_ban,
@@ -1863,7 +1729,7 @@ char *irc_start(Function * global_funcs)
 #endif
 
   for (chan = chanset; chan; chan = chan->next) {
-    if (!channel_inactive(chan))
+    if (shouldjoin(chan))
       dprintf(DP_MODE, "JOIN %s %s\n",
               (chan->name[0]) ? chan->name : chan->dname, chan->key_prot);
     chan->status &= ~(CHAN_ACTIVE | CHAN_PEND | CHAN_ASKEDBANS);
@@ -1896,18 +1762,6 @@ char *irc_start(Function * global_funcs)
 #endif /* S_AUTH */
   add_builtins(H_raw, irc_raw);
   add_tcl_commands(tclchan_cmds);
-  H_topc = add_bind_table("topc", HT_STACKABLE, channels_5char);
-  H_splt = add_bind_table("splt", HT_STACKABLE, channels_4char);
-  H_sign = add_bind_table("sign", HT_STACKABLE, channels_5char);
-  H_rejn = add_bind_table("rejn", HT_STACKABLE, channels_4char);
-  H_part = add_bind_table("part", HT_STACKABLE, channels_5char);
-  H_nick = add_bind_table("nick", HT_STACKABLE, channels_5char);
-  H_mode = add_bind_table("mode", HT_STACKABLE, channels_6char);
-  H_kick = add_bind_table("kick", HT_STACKABLE, channels_6char);
-  H_join = add_bind_table("join", HT_STACKABLE, channels_4char);
-  H_pubm = add_bind_table("pubm", HT_STACKABLE, channels_5char);
-  H_pub = add_bind_table("pub", 0, channels_5char);
-  H_need = add_bind_table("need", HT_STACKABLE, channels_2char);
   do_nettype();
   return NULL;
 }

+ 0 - 30
src/mod/irc.mod/irc.h

@@ -7,28 +7,10 @@
 #ifndef _EGG_MOD_IRC_IRC_H
 #define _EGG_MOD_IRC_IRC_H
 
-#define check_tcl_join(a,b,c,d) check_tcl_joinspltrejn(a,b,c,d,H_join)
-#define check_tcl_splt(a,b,c,d) check_tcl_joinspltrejn(a,b,c,d,H_splt)
-#define check_tcl_rejn(a,b,c,d) check_tcl_joinspltrejn(a,b,c,d,H_rejn)
-#define check_tcl_sign(a,b,c,d,e) check_tcl_signtopcnick(a,b,c,d,e,H_sign)
-#define check_tcl_topc(a,b,c,d,e) check_tcl_signtopcnick(a,b,c,d,e,H_topc)
-#define check_tcl_nick(a,b,c,d,e) check_tcl_signtopcnick(a,b,c,d,e,H_nick)
-#define check_tcl_mode(a,b,c,d,e,f) check_tcl_kickmode(a,b,c,d,e,f,H_mode)
-#define check_tcl_kick(a,b,c,d,e,f) check_tcl_kickmode(a,b,c,d,e,f,H_kick)
-
 #define REVENGE_KICK 1		/* Kicked victim	*/
 #define REVENGE_DEOP 2		/* Took op		*/
 
 #ifdef MAKING_IRC
-static void check_tcl_kickmode(char *, char *, struct userrec *, char *,
-			       char *, char *, p_tcl_bind_list);
-static void check_tcl_joinspltrejn(char *, char *, struct userrec *, char *,
-			       p_tcl_bind_list);
-static void check_tcl_part(char *, char *, struct userrec *, char *, char *);
-static void check_tcl_signtopcnick(char *, char *, struct userrec *u, char *,
-				   char *, p_tcl_bind_list);
-static void check_tcl_pubm(char *, char *, char *, char *);
-static int check_tcl_pub(char *, char *, char *, char *);
 #ifdef S_AUTH
 static int check_tcl_pubc(char *, char *, char *, struct userrec *, char *, char *);
 #endif /* S_AUTH */
@@ -74,24 +56,12 @@ static int gotmode(char *, char *);
 
 #else
 /* 4 - 7 */
-#define H_splt (*(p_tcl_bind_list*)(irc_funcs[4]))
-#define H_rejn (*(p_tcl_bind_list*)(irc_funcs[5]))
-#define H_nick (*(p_tcl_bind_list*)(irc_funcs[6]))
-#define H_sign (*(p_tcl_bind_list*)(irc_funcs[7]))
 /* 8 - 11 */
-#define H_join (*(p_tcl_bind_list*)(irc_funcs[8]))
-#define H_part (*(p_tcl_bind_list*)(irc_funcs[9]))
-#define H_mode (*(p_tcl_bind_list*)(irc_funcs[10]))
-#define H_kick (*(p_tcl_bind_list*)(irc_funcs[11]))
 /* 12 - 15 */
-#define H_pubm (*(p_tcl_bind_list*)(irc_funcs[12]))
-#define H_pub (*(p_tcl_bind_list*)(irc_funcs[13]))
-#define H_topc (*(p_tcl_bind_list*)(irc_funcs[14]))
 /* recheck_channel is here */
 /* 16 - 19 */
 #define me_op ((int(*)(struct chanset_t *))irc_funcs[16])
 /* recheck_channel_modes is here */
-#define H_need (*(p_tcl_bind_list*)(irc_funcs[18]))
 /* do_channel_part is here. */
 /* 20 - 23 */
 /* check_this_ban is here. */

+ 265 - 42
src/mod/irc.mod/mode.c

@@ -266,10 +266,11 @@ static void real_add_mode(struct chanset_t *chan,
   memberlist *mx;
   char s[21];
 
-Context;
   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);
@@ -458,7 +459,6 @@ static void got_op(struct chanset_t *chan, char *nick, char *from,
   int check_chan = 0;
   int snm = chan->stopnethack_mode;
 
-Context;
   m = ismember(chan, who);
   if (!m) {
     if (channel_pending(chan))
@@ -482,7 +482,6 @@ Context;
    * add_mode() doesn't get irritated.
    */
   m->flags |= CHANOP;
-  check_tcl_mode(nick, from, opu, chan->dname, "+o", who);
   /* Added new meaning of WASOP:
    * in mode binds it means: was he op before get (de)opped
    * (stupid IrcNet allows opped users to be opped again and
@@ -512,8 +511,6 @@ Context;
   } else if (reversing && !match_my_nick(who))
     add_mode(chan, '-', 'o', who);
   if (!nick[0] && me_op(chan) && !match_my_nick(who)) {
-
-Context;
     if (chk_deop(victim, chan)) {
       m->flags |= FAKEOP;
       add_mode(chan, '-', 'o', who);
@@ -570,7 +567,6 @@ static void got_deop(struct chanset_t *chan, char *nick, char *from,
    * add_mode() doesn't get irritated.
    */
   m->flags &= ~(CHANOP | SENTDEOP | FAKEOP);
-  check_tcl_mode(nick, from, opu, chan->dname, "-o", who);
   /* Check comments in got_op()  (drummer) */
   m->flags &= ~WASOP;
 
@@ -622,11 +618,7 @@ static void got_deop(struct chanset_t *chan, char *nick, char *from,
 
     chan->channel.do_opreq=1;
 //    request_op(chan);
-/* need
-    check_tcl_need(chan->dname, "op");
-    if (chan->need_op[0])
-      do_tcl("need-op", chan->need_op);
-*/
+/* need: op */
     if (!nick[0])
       putlog(LOG_MODES, chan->dname, "TS resync deopped me on %s :(",
 	     chan->dname);
@@ -883,35 +875,281 @@ static void got_uninvite(struct chanset_t *chan, char *nick, char *from,
   }
 }
 #endif
-static int gotmode(char *from, char *origmsg)
+
+static int gotmode(char *from, char *msg)
 {
-  char *nick, *ch, *op, *chg, *msg;
-  char s[UHOSTLEN], buf[511];
+  char *nick, *ch, *op, *chg;
+  char s[UHOSTLEN];
   char ms2[3];
   int z;
-  struct userrec *u, *my_u;
+  struct userrec *u;
   memberlist *m;
   struct chanset_t *chan;
-  struct flag_record my_fr = { FR_GLOBAL | FR_CHAN, 0, 0 };
 
-Context;
-  strncpy(buf, origmsg, 510);
-  buf[510] = 0;
-  msg = buf;
   /* Usermode changes? */
   if (msg[0] && (strchr(CHANMETA, msg[0]) != NULL)) {
     ch = newsplit(&msg);
     if (match_my_nick(ch))
 	return 0;
-    chg = newsplit(&msg);
-    reversing = 0;
     chan = findchan(ch);
-Context;
     if (!chan) {
       putlog(LOG_MISC, "*", CHAN_FORCEJOIN, ch);
       dprintf(DP_SERVER, "PART %s\n", ch);
-    } else if (channel_active(chan) || channel_pending(chan)) {
-Context;
+      return 0;
+    }
+
+    /* let's pre-emptively check for mass op/deop, manual ops and cookieops */
+
+    if (strchr(from, '!')) {
+      char *modes[5] = { NULL, NULL, NULL, NULL, NULL };
+      char tmp[1024], sign = '+', *nfrom, *hfrom, *wptr, *p, work[1024];
+      struct userrec *ufrom = NULL;
+      memberlist *m;
+      int modecnt = 0, i = 0, n = 0, ops = 0, deops = 0, bans = 0, unbans = 0;
+
+      /* Split up the mode: #chan modes param param param param */
+      strncpy0(work, msg, sizeof(work));
+      wptr = work;
+      p = newsplit(&wptr);
+      while (*p) {
+        char *mp;
+        if (*p == '+')
+          sign = '+';
+        else if (*p == '-')
+          sign = '-';
+        else if (strchr(STR("oblkvIe"), p[0])) {
+          mp = newsplit(&wptr);
+          if (strchr("ob", p[0])) {
+            /* Just want o's and b's */
+            modes[modecnt] = nmalloc(strlen(mp) + 4);
+            sprintf(modes[modecnt], STR("%c%c %s"), sign, p[0], mp);
+            modecnt++;
+            if (p[0] == 'o') {
+              if (sign == '+')
+                ops++;
+              else
+                deops++;
+            }
+            if (p[0] == 'b') {
+              if (sign == '+')
+                bans++;
+              else
+                unbans++;
+            }
+          }
+        } else if (strchr(STR("pstnmi"), p[0])) {
+        } else {
+          /* hrmm... what modechar did i forget? */
+          putlog(LOG_ERRORS, "*", STR("Forgotten modechar in irc:gotmode: %c"), p[0]);
+        }
+        p++;
+      }
+
+      /* Split up from */
+      ufrom = get_user_by_host(from);
+      strncpy0(work, from, sizeof(work));
+      p = strchr(work, '!');
+      *p++ = 0;
+      nfrom = work; 		/* nick */
+      hfrom = p; 		/* host */
+
+      /* Now we got modes[], chan, ufrom, nfrom, hfrom, and count of each relevant mode */
+
+      /* check for mdop */
+      if ((chan) && (deops >= 3)) {
+        if ((!ufrom) || (!(ufrom->flags & USER_BOT))) {
+          if (ROLE_KICK_MDOP) {
+            m=ismember(chan, nfrom);
+            if (!m || !chan_sentkick(m)) {
+/* FIXME: A COMMON EXCESS FLOOD */
+              sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MASSDEOP));
+              tputs(servi, tmp, strlen(tmp));
+              if (m)
+                m->flags |= SENTKICK;
+            }
+          }
+        }
+      }
+
+      /* check for mop */
+      if (chan && (ops >= 3)) {
+        if (channel_nomop(chan)) {
+          if ((!ufrom) || (!(ufrom->flags & USER_BOT))) {
+            if (ROLE_KICK_MDOP) {
+              m=ismember(chan, nfrom);
+              if (!m || !chan_sentkick(m)) {
+                sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
+                tputs(servi, tmp, strlen(tmp));
+                if (m)
+                  m->flags |= SENTKICK;
+              }
+            }
+          }
+        }
+      }
+
+      if (chan && ops && (ufrom) && (ufrom->flags & USER_BOT) && !channel_fastop(chan) && !channel_take(chan)) {
+        int isbadop = 0;
+        if ((modecnt != 2) || (strncmp(modes[0], "+o", 2)) ||
+            (strncmp(modes[1], "-b", 2)))
+          isbadop = 1;
+        else {
+          char enccookie[25], plaincookie[25], key[NICKLEN + 20], goodcookie[25];
+
+          /* -b *!*@[...] */
+          strncpy0(enccookie, (char *) &(modes[1][8]), sizeof(enccookie));
+          p = enccookie + strlen(enccookie) - 1;
+/* old shit 
+          *p = 0;
+          while (p - enccookie < 24) {
+            *p++ = '.';
+            *p = 0;
+          }
+*/
+          strcpy(key, nfrom);
+          strcat(key, netpass);
+/* putlog(LOG_DEBUG, "*", "Decrypting cookie: %s with key %s", enccookie, key); */
+          p = decrypt_string(key, enccookie);
+/* putlog(LOG_DEBUG, "*", "Decrypted cookie: %s", p); */
+          strncpy0(plaincookie, p, sizeof(plaincookie));
+          nfree(p);
+          /*
+           * last 6 digits of time
+           * last 5 chars of nick
+           * last 5 regular chars of chan
+           */
+          makeplaincookie(chan->dname, (char *) (modes[0] + 3), goodcookie);
+/* putlog(LOG_DEBUG, "*", "cookie from %s: %s should be: %s", nfrom, plaincookie, goodcookie); */
+          if (strncmp((char *) &plaincookie[6], (char *) &goodcookie[6], 5))
+            isbadop = 2;
+          else if (strncmp((char *) &plaincookie[11], (char *) &goodcookie[11], 5))
+            isbadop = 3;
+          else {
+            char ltmp[20];
+            long optime;
+            int off;
+
+            sprintf(ltmp, STR("%010li"), (now + timesync));
+            strncpy0((char *) &ltmp[4], plaincookie, 7);
+            optime = atol(ltmp);
+            off = (now + timesync - optime);
+
+            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);
+            }
+          }
+        }
+        if (isbadop) {
+          char trg[NICKLEN + 1] = "";
+
+          n = i = 0;
+          switch (role) {
+          case 0:
+            break;
+          case 1:
+            /* Kick opper */
+            m = ismember(chan, nfrom);
+            if (!m || !chan_sentkick(m)) {
+              sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_BADOP));
+              tputs(servi, tmp, strlen(tmp));
+              if (m)
+                m->flags |= SENTKICK;
+            }
+            sprintf(tmp, STR("%s MODE %s"), from, msg);
+            deflag_user(ufrom, DEFLAG_BADCOOKIE, tmp, chan);
+            break;
+          default:
+            n = role - 1;
+            i = 0;
+            while ((i < 5) && (n > 0)) {
+              if (modes[i] && !strncmp(modes[i], "+o", 2))
+                n--;
+              if (n)
+                i++;
+            }
+            if (!n) {
+              strcpy(trg, (char *) &modes[i][3]);
+              m = ismember(chan, trg);
+              if (m) {
+                if (!(m->flags & CHANOP)) {
+                  if (!chan_sentkick(m)) {
+                    sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_BADOPPED));
+                    tputs(servi, tmp, strlen(tmp));
+                    m->flags |= SENTKICK;
+                  }
+                }
+              }
+            }
+          }
+          if (isbadop == 1)
+            putlog(LOG_WARN, "*", STR("Missing cookie: %s MODE %s"), from, msg);
+          else if (isbadop == 2)
+            putlog(LOG_WARN, "*", STR("Invalid cookie (bad nick): %s MODE %s"), from, msg);
+          else if (isbadop == 3)
+            putlog(LOG_WARN, "*", STR("Invalid cookie (bad chan): %s MODE %s"), from, msg);
+          else if (isbadop == 4)
+            putlog(LOG_WARN, "*", STR("Invalid cookie (bad time): %s MODE %s"), from, msg);
+        } else
+          putlog(LOG_DEBUG, "@", STR("Good op: %s"), msg);
+      }
+      if ((ops) && chan && !channel_manop(chan) && (ufrom) &&
+          !(ufrom->flags & USER_BOT)) {
+        char trg[NICKLEN + 1] = "";
+        n = i = 0;
+
+        switch (role) {
+        case 0:
+          break;
+        case 1:
+          /* Kick opper */
+          m = ismember(chan, nfrom);
+          if (!m || !chan_sentkick(m)) {
+            sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
+            tputs(servi, tmp, strlen(tmp));
+            if (m)
+              m->flags |= SENTKICK;
+          }
+          sprintf(tmp, STR("%s MODE %s"), from, msg);
+          deflag_user(ufrom, DEFLAG_MANUALOP, tmp, chan);
+          break;
+        default:
+          n = role - 1;
+          i = 0;
+          while ((i < 5) && (n > 0)) {
+            if (modes[i] && !strncmp(modes[i], "+o", 2))
+              n--;
+            if (n)
+              i++;
+          }
+          if (!n) {
+            strcpy(trg, (char *) &modes[i][3]);
+            m = ismember(chan, trg);
+            if (m) {
+              if (!(m->flags & CHANOP) && (rfc_casecmp(botname, trg))) {
+                if (!chan_sentkick(m)) {
+                  sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
+                  tputs(servi, tmp, strlen(tmp));
+                  m->flags |= SENTKICK;
+                }
+              }
+            } else {
+              sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
+              tputs(servi, tmp, strlen(tmp));
+            }
+          }
+        }
+      }
+      for (i = 0; i < 5; i++)
+        if (modes[i])
+          nfree(modes[i]);
+    }
+
+    /* Now do the modes again, this time throughly... */
+    chg = newsplit(&msg);
+    reversing = 0;
+
+    if (channel_active(chan) || channel_pending(chan)) {
       z = strlen(msg);
       if (msg[--z] == ' ')	/* I hate cosmetic bugs :P -poptix */
 	msg[z] = 0;
@@ -919,10 +1157,7 @@ Context;
 	     ch, chg, msg, from);
       u = get_user_by_host(from);
       get_user_flagrec(u, &user, ch);
-      my_u = get_user_by_handle(userlist, botnetnick);
-      get_user_flagrec(my_u, &my_fr, ch);
       nick = splitnick(&from);
-Context;
       m = ismember(chan, nick);
       if (m)
 	m->last = now;
@@ -946,7 +1181,6 @@ Context;
       }
       ms2[0] = '+';
       ms2[2] = 0;
-Context;
       while ((ms2[1] = *chg)) {
 	int todo = 0;
 
@@ -1026,7 +1260,6 @@ Context;
 	  if ((!nick[0]) && (bounce_modes))
 	    reversing = 1;
 	  if (ms2[0] == '-') {
-	    check_tcl_mode(nick, from, u, chan->dname, ms2, "");
 	    if (channel_active(chan)) {
 	      if ((reversing) && (chan->channel.maxmembers != 0)) {
 		simple_sprintf(s, "%d", chan->channel.maxmembers);
@@ -1035,7 +1268,7 @@ Context;
 		simple_sprintf(s, "%d", chan->limit_prot);
 		add_mode(chan, '+', 'l', s);
 	      } else {
-                if ((chan_dolimit(my_fr) || glob_dolimit(my_fr)) && 
+                if (dolimit(chan) && 
                    (!chan_master(user) && !glob_master(user) && !glob_bot(user))) {
                   if (chan->limitraise) {
                     chan->channel.maxmembers = 0;		/* set this to 0 so a new limit is generated */
@@ -1051,8 +1284,6 @@ Context;
 	    if (op == '\0')
 	      break;
 	    chan->channel.maxmembers = atoi(op);
-	    check_tcl_mode(nick, from, u, chan->dname, ms2,
-			   int_to_base10(chan->channel.maxmembers));
 	    if (channel_pending(chan))
 	      break;
 	    if (((reversing) &&
@@ -1068,7 +1299,7 @@ Context;
 	      add_mode(chan, '+', 'l', s);
             } 
             if (!glob_bot(user))
-              if ((chan_dolimit(my_fr) || glob_dolimit(my_fr)) && (!chan_master(user) && !glob_master(user)))
+              if (dolimit(chan) && (!chan_master(user) && !glob_master(user)))
                 if (chan->limitraise)
                   raise_limit(chan);
 
@@ -1084,7 +1315,6 @@ Context;
 	  if (op == '\0') {
 	    break;
 	  }
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+') {
 	    my_setkey(chan, op);
 	    if (channel_active(chan))
@@ -1135,7 +1365,6 @@ Context;
               }
  	      m->flags &= ~SENTVOICE;
  	      m->flags |= CHANVOICE;
- 	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
               if (channel_active(chan) && dovoice(chan)) {
                 if (dv || chk_devoice(victim, chan)) {
 		  add_mode(chan, '-', 'v', op);
@@ -1146,7 +1375,6 @@ Context;
 	    } else if (ms2[0] == '-') {
 	      m->flags &= ~SENTDEVOICE;
 	      m->flags &= ~CHANVOICE;
-	      check_tcl_mode(nick, from, u, chan->dname, ms2, op);
               if (channel_active(chan) && dovoice(chan)) {
                 /* revoice +v users */
                 if (chk_voice(victim, chan)) {
@@ -1171,7 +1399,6 @@ Context;
 	case 'b':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
 	    got_ban(chan, nick, from, op);
 	  else
@@ -1181,7 +1408,6 @@ Context;
 	case 'e':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
 	    got_exempt(chan, nick, from, op);
 	  else
@@ -1190,7 +1416,6 @@ Context;
 	case 'I':
 	  op = newsplit(&msg);
 	  fixcolon(op);
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, op);
 	  if (ms2[0] == '+')
 	    got_invite(chan, nick, from, op);
 	  else
@@ -1199,7 +1424,6 @@ Context;
 	}
 #endif
 	if (todo) {
-	  check_tcl_mode(nick, from, u, chan->dname, ms2, "");
 	  if (ms2[0] == '+')
 	    chan->channel.mode |= todo;
 	  else
@@ -1217,7 +1441,6 @@ Context;
 	}
 	chg++;
       }
-Context;
       if (chan->channel.do_opreq)
         request_op(chan);
       if (!me_op(chan) && !nick[0])

+ 2 - 2
src/mod/module.h

@@ -228,7 +228,7 @@
 #define share_greet (*(int *)global[99])
 /* 100 - 103 */
 #define max_dcc (*(int *)global[100])
-/* 101: require_p -- UNUSED */
+#define shouldjoin ((int (*) (struct chanset_t *))global[101])
 #define ignore_time (*(int *)(global[102]))
 #define use_console_r (*(int *)(global[103]))
 /* 104 - 107 */
@@ -267,7 +267,7 @@
 #define findanyidx ((int (*)(int))global[130])
 #define findchan ((struct chanset_t *(*)(char *))global[131])
 /* 132 - 135 */
-/* 132 -- UNUSED */
+#define dolimit ((int (*)(struct chanset_t *))global[132])
 #define days ((void (*)(time_t,time_t,char *))global[133])
 #define daysago ((void (*)(time_t,time_t,char *))global[134])
 #define daysdur ((void (*)(time_t,time_t,char *))global[135])

+ 0 - 48
src/mod/notes.mod/notes.c

@@ -22,8 +22,6 @@ static int note_life = 60;	/* Number of DAYS a note lives */
 static char notefile[121] = ".n";	/* Name of the notefile */
 static int allow_fwd = 1;	/* Allow note forwarding */
 static int notify_users = 1;	/* Notify users they have notes every hour? */
-static int notify_onjoin = 1;   /* Notify users they have notes on join?
-				   drummer */
 static Function *global = NULL;	/* DAMN fcntl.h */
 
 static struct user_entry_type USERENTRY_FWD =
@@ -598,34 +596,6 @@ static int chon_notes(char *nick, int idx)
   return 0;
 }
 
-static void join_notes(char *nick, char *uhost, char *handle, char *par)
-{
-  int i = -1, j;
-  struct chanset_t *chan = chanset;
-
-  if (notify_onjoin) { /* drummer */
-    for (j = 0; j < dcc_total; j++)
-      if ((dcc[j].type->flags & DCT_CHAT)
-	  && (!egg_strcasecmp(dcc[j].nick, handle))) {
-	return;			/* They already know they have notes */
-      }
-
-    while (!chan) {
-      if (ismember(chan, nick))
-        return;			/* They already know they have notes */
-      chan = chan->next;
-    }
-
-    i = num_notes(handle);
-    if (i) {
-      dprintf(DP_HELP, NOTES_WAITING_ON, nick, i, i == 1 ? "" : "s",
-	      botname);
-      dprintf(DP_HELP, "NOTICE %s :%s /MSG %s NOTES <pass> INDEX\n",
-	      nick, NOTES_FORLIST, botname);
-    }
-  }
-}
-
 /* Return either NULL or a pointer to the xtra_key structure
  * where the not ignores are kept.
  */
@@ -798,12 +768,6 @@ int match_note_ignore(struct userrec *u, char *from)
 }
 
 
-static cmd_t notes_join[] =
-{
-  {"*",		"",	(Function) join_notes,		"notes"},
-  {NULL,	NULL,	NULL,				NULL}
-};
-
 static cmd_t notes_nkch[] =
 {
   {"*",		"",	(Function) notes_change,	"notes"},
@@ -834,7 +798,6 @@ static tcl_ints notes_ints[] =
   {"max-notes",		&maxnotes},
   {"allow-fwd",		&allow_fwd},
   {"notify-users",	&notify_users},
-  {"notify-onjoin",	&notify_onjoin},
   {NULL,		NULL}
 };
 
@@ -844,15 +807,6 @@ static tcl_strings notes_strings[] =
   {NULL,		NULL,			0,	0}
 };
 
-static int notes_irc_setup(char *mod)
-{
-  p_tcl_bind_list H_temp;
-
-  if ((H_temp = find_bind_table("join")))
-    add_builtins(H_temp, notes_join);
-  return 0;
-}
-
 static int notes_server_setup(char *mod)
 {
   p_tcl_bind_list H_temp;
@@ -865,7 +819,6 @@ static int notes_server_setup(char *mod)
 static cmd_t notes_load[] =
 {
   {"server",	"",	notes_server_setup,		"notes:server"},
-  {"irc",	"",	notes_irc_setup,		"notes:irc"},
   {NULL,	NULL,	NULL,				NULL}
 };
 
@@ -912,7 +865,6 @@ char *notes_start(Function * global_funcs)
   add_builtins(H_nkch, notes_nkch);
   add_builtins(H_load, notes_load);
   notes_server_setup(0);
-  notes_irc_setup(0);
   my_memcpy(&USERENTRY_FWD, &USERENTRY_INFO, sizeof(void *) * 12);
   add_entry_type(&USERENTRY_FWD);
   return NULL;

+ 6 - 9
src/mod/server.mod/server.c

@@ -80,7 +80,7 @@ static int kick_method;
 static int optimize_kicks;
 
 
-static p_tcl_bind_list H_wall, H_raw, H_notc, H_msgm, H_msg, H_flud,
+static p_tcl_bind_list H_raw, H_msgm, H_msg, 
 		       H_ctcr, H_ctcp;
 #ifdef S_AUTH
 static p_tcl_bind_list H_msgc;
@@ -1920,7 +1920,7 @@ static Function server_table[] =
   (Function) & flud_ctcp_time,	/* int					*/
   /* 12 - 15 */
   (Function) match_my_nick,
-  (Function) check_tcl_flud,
+  (Function) 0,
   (Function) NULL,		/* fixfrom - moved to the core (drummer) */
   (Function) & answer_ctcp,	/* int					*/
   /* 16 - 19 */
@@ -1939,19 +1939,19 @@ static Function server_table[] =
   (Function) & min_servs,	/* int					*/
   (Function) & H_raw,		/* p_tcl_bind_list			*/
   /* 28 - 31 */
-  (Function) & H_wall,		/* p_tcl_bind_list			*/
+  (Function) 0,
   (Function) & H_msg,		/* p_tcl_bind_list			*/
   (Function) & H_msgm,		/* p_tcl_bind_list			*/
-  (Function) & H_notc,		/* p_tcl_bind_list			*/
+  (Function) 0,
   /* 32 - 35 */
-  (Function) & H_flud,		/* p_tcl_bind_list			*/
+  (Function) 0,
   (Function) & H_ctcp,		/* p_tcl_bind_list			*/
   (Function) & H_ctcr,		/* p_tcl_bind_list			*/
   (Function) ctcp_reply,
   /* 36 - 38 */
   (Function) get_altbotnick,	/* char *				*/
   (Function) & nick_len,	/* int					*/
-  (Function) check_tcl_notc,
+  (Function) 0,
   (Function) & server_lag, /* int */
   (Function) & curserv,
   (Function) cursrvname,
@@ -2060,15 +2060,12 @@ char *server_start(Function *global_funcs)
 	       TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
 	       traced_nicklen, NULL);
 
-  H_wall = add_bind_table("wall", HT_STACKABLE, server_2char);
   H_raw = add_bind_table("raw", HT_STACKABLE, server_raw);
-  H_notc = add_bind_table("notc", HT_STACKABLE, server_5char);
   H_msgm = add_bind_table("msgm", HT_STACKABLE, server_msg);
 #ifdef S_AUTH
   H_msgc = add_bind_table("msgc", 0, server_msgc);
 #endif /* S_AUTH */
   H_msg = add_bind_table("msg", 0, server_msg);
-  H_flud = add_bind_table("flud", HT_STACKABLE, server_5char);
   H_ctcr = add_bind_table("ctcr", HT_STACKABLE, server_6char);
   H_ctcp = add_bind_table("ctcp", HT_STACKABLE, server_6char);
   add_builtins(H_raw, my_raw_binds);

+ 0 - 5
src/mod/server.mod/server.h

@@ -23,7 +23,6 @@
 #define flud_ctcp_time (*(int*)(server_funcs[11]))
 /* 12 - 15 */
 #define match_my_nick ((int(*)(char *))server_funcs[12])
-#define check_tcl_flud ((int (*)(char *,char *,struct userrec *,char *,char *))server_funcs[13])
 /* #define fixfrom ((void (*)(char *))server_funcs[14]) -- moved to core */
 #define answer_ctcp (*(int *)(server_funcs[15]))
 /* 16 - 19 */
@@ -42,19 +41,15 @@
 #define min_servs (*(int *)(server_funcs[26]))
 /* 27 - 30 */
 #define H_raw (*(p_tcl_bind_list *)(server_funcs[27]))
-#define H_wall (*(p_tcl_bind_list *)(server_funcs[28]))
 #define H_msg (*(p_tcl_bind_list *)(server_funcs[29]))
 #define H_msgm (*(p_tcl_bind_list *)(server_funcs[30]))
 /* 31 - 34 */
-#define H_notc (*(p_tcl_bind_list *)(server_funcs[31]))
-#define H_flud (*(p_tcl_bind_list *)(server_funcs[32]))
 #define H_ctcp (*(p_tcl_bind_list *)(server_funcs[33]))
 #define H_ctcr (*(p_tcl_bind_list *)(server_funcs[34]))
 /* 35 - 38 */
 #define ctcp_reply ((char *)(server_funcs[35]))
 #define get_altbotnick ((char *(*)(void))(server_funcs[36]))
 #define nick_len (*(int *)(server_funcs[37]))
-#define check_tcl_notc ((int (*)(char *,char *,struct userrec *,char *,char *))server_funcs[38])
 #define server_lag (*(int *)(server_funcs[39]))
 #define curserv (*(int *)(server_funcs[40))
 #define cursrvname ((char *)(server_funcs[41]))

+ 18 - 352
src/mod/server.mod/servmsg.c

@@ -136,21 +136,6 @@ static int check_tcl_msgc(char *cmd, char *nick, char *uhost,
 }
 #endif /* S_AUTH */
 
-static void check_tcl_notc(char *nick, char *uhost, struct userrec *u,
-	       		   char *dest, char *arg)
-{
-  struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
-
-  get_user_flagrec(u, &fr, NULL);
-  Tcl_SetVar(interp, "_notc1", nick, 0);
-  Tcl_SetVar(interp, "_notc2", uhost, 0);
-  Tcl_SetVar(interp, "_notc3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_notc4", arg, 0);
-  Tcl_SetVar(interp, "_notc5", dest, 0);
-  check_tcl_bind(H_notc, arg, &fr, " $_notc1 $_notc2 $_notc3 $_notc4 $_notc5",
-		 MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
-}
-
 static void check_tcl_msgm(char *cmd, char *nick, char *uhost,
 			   struct userrec *u, char *arg)
 {
@@ -180,13 +165,14 @@ Context;
   Tcl_SetVar(interp, "_raw2", code, 0);
   Tcl_SetVar(interp, "_raw3", msg, 0);
   x = check_tcl_bind(H_raw, code, 0, " $_raw1 $_raw2 $_raw3",
-		     MATCH_EXACT | BIND_STACKABLE | BIND_WANTRET);
+                    MATCH_EXACT | BIND_STACKABLE | BIND_WANTRET);
   return (x == BIND_EXEC_LOG);
 }
 
+
 static int check_tcl_ctcpr(char *nick, char *uhost, struct userrec *u,
-			   char *dest, char *keyword, char *args,
-			   p_tcl_bind_list table)
+                          char *dest, char *keyword, char *args,
+                          p_tcl_bind_list table)
 {
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
   int x;
@@ -199,43 +185,12 @@ static int check_tcl_ctcpr(char *nick, char *uhost, struct userrec *u,
   Tcl_SetVar(interp, "_ctcpr5", keyword, 0);
   Tcl_SetVar(interp, "_ctcpr6", args, 0);
   x = check_tcl_bind(table, keyword, &fr,
-		     " $_ctcpr1 $_ctcpr2 $_ctcpr3 $_ctcpr4 $_ctcpr5 $_ctcpr6",
-		     MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE |
-		     ((table == H_ctcp) ? BIND_WANTRET : 0));
+                    " $_ctcpr1 $_ctcpr2 $_ctcpr3 $_ctcpr4 $_ctcpr5 $_ctcpr6",
+                    MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE |
+                    ((table == H_ctcp) ? BIND_WANTRET : 0));
   return (x == BIND_EXEC_LOG) || (table == H_ctcr);
 }
 
-static int check_tcl_wall(char *from, char *msg)
-{
-  int x;
-
-  Tcl_SetVar(interp, "_wall1", from, 0);
-  Tcl_SetVar(interp, "_wall2", msg, 0);
-  x = check_tcl_bind(H_wall, msg, 0, " $_wall1 $_wall2",
-		     MATCH_MASK | BIND_STACKABLE);
-  if (x == BIND_EXEC_LOG) {
-    putlog(LOG_WALL, "*", "!%s! %s", from, msg);
-    return 1;
-  } else
-    return 0;
-}
-
-static int check_tcl_flud(char *nick, char *uhost, struct userrec *u,
-			  char *ftype, char *chname)
-{
-  int x;
-
-  Tcl_SetVar(interp, "_flud1", nick, 0);
-  Tcl_SetVar(interp, "_flud2", uhost, 0);
-  Tcl_SetVar(interp, "_flud3", u ? u->handle : "*", 0);
-  Tcl_SetVar(interp, "_flud4", ftype, 0);
-  Tcl_SetVar(interp, "_flud5", chname, 0);
-  x = check_tcl_bind(H_flud, ftype, 0,
-		     " $_flud1 $_flud2 $_flud3 $_flud4 $_flud5",
-		     MATCH_MASK | BIND_STACKABLE | BIND_WANTRET);
-  return (x == BIND_EXEC_LOG);
-}
-
 static int match_my_nick(char *nick)
 {
   if (!rfc_casecmp(nick, botname))
@@ -270,7 +225,7 @@ static int got001(char *from, char *msg)
   if (module_find("irc", 0, 0))
     for (chan = chanset; chan; chan = chan->next) {
       chan->status &= ~(CHAN_ACTIVE | CHAN_PEND);
-      if (!channel_inactive(chan))
+      if (shouldjoin(chan))
 	dprintf(DP_SERVER, "JOIN %s %s\n",
 	        (chan->name[0]) ? chan->name : chan->dname,
 	        chan->channel.key[0] ? chan->channel.key : chan->key_prot);
@@ -319,7 +274,7 @@ static int got442(char *from, char *msg)
   chname = newsplit(&msg);
   chan = findchan(chname);
   if (chan)
-    if (!channel_inactive(chan)) {
+    if (shouldjoin(chan)) {
       module_entry	*me = module_find("channels", 0, 0);
 
       putlog(LOG_MISC, chname, IRC_SERVNOTONCHAN, chname);
@@ -417,8 +372,6 @@ static int detect_flood(char *floodnick, char *floodhost, char *from, int which)
     lastmsgtime[which] = 0;
     lastmsghost[which][0] = 0;
     u = get_user_by_host(from);
-    if (check_tcl_flud(floodnick, floodhost, u, ftype, "*"))
-      return 0;
     /* Private msg */
     simple_sprintf(h, "*!*@%s", p);
     putlog(LOG_MISC, "*", IRC_FLOODIGNORE1, p);
@@ -680,7 +633,7 @@ static int gotnotice(char *from, char *msg)
 	} else {
 	  u = get_user_by_host(from);
 	  if (!ignoring || trigger_on_ignore) {
-	    check_tcl_ctcr(nick, uhost, u, to, code, ctcp);
+            check_tcl_ctcr(nick, uhost, u, to, code, ctcp);
 	    if (!ignoring)
 	      /* Who cares? */
 	      putlog(LOG_MSGS, "*",
@@ -705,8 +658,6 @@ static int gotnotice(char *from, char *msg)
       } else {
         detect_flood(nick, uhost, from, FLOOD_NOTICE);
         u = get_user_by_host(from);
-        if (!ignoring || trigger_on_ignore)
-          check_tcl_notc(nick, uhost, u, botname, msg);
         if (!ignoring)
   	      putlog(LOG_MSGS, "*", "-%s (%s)- %s", nick, uhost, msg);
       }
@@ -748,21 +699,17 @@ static int got251(char *from, char *msg)
 static int gotwall(char *from, char *msg)
 {
   char *nick;
-  int r;
 
   fixcolon(msg);
-  r = check_tcl_wall(from, msg);
 
-  if (r == 0) {
-    /* Following is not needed at all, but we'll keep it for compatibility sak$
-     * so not to confuse possible scripts that are parsing log files.
-     */
-    if (strchr(from, '!')) {
+  /* Following is not needed at all, but we'll keep it for compatibility sak$
+   * so not to confuse possible scripts that are parsing log files.
+   */
+  if (strchr(from, '!')) {
     nick = splitnick(&from);
     putlog(LOG_WALL, "*", "!%s(%s)! %s", nick, from, msg);
-    } else
-      putlog(LOG_WALL, "*", "!%s! %s", from, msg);
-  }
+  } else
+    putlog(LOG_WALL, "*", "!%s! %s", from, msg);
   return 0;
 }
 
@@ -1185,17 +1132,14 @@ void got_rn(char *botnick, char *code, char *par) {
 
 static void server_activity(int idx, char *msg, int len)
 {
-  char *from, *code, tmp[1024];
-  char sign = '+';
+  char *from, *code;
 
-Context;
   if (trying_server) {
     strcpy(dcc[idx].nick, "(server)");
     putlog(LOG_SERV, "*", "Connected to %s", dcc[idx].host);
     trying_server = 0;
     SERVER_SOCKET.timeout_val = 0;
   }
-Context;
   waiting_for_awake = 0;
   from = "";
   if (msg[0] == ':') {
@@ -1204,286 +1148,8 @@ Context;
   }
   code = newsplit(&msg);
 
-/* check MODEs now, we're in a rush */
-Context;
-  if (!strcmp(code, STR("MODE")) && (msg[0] == '#') && strchr(from, '!')) {
-    /* It's MODE #chan by a user */
-    char *modes[5] = { NULL, NULL, NULL, NULL, NULL };
-    char *nfrom,
-     *hfrom;
-    int i;
-    struct userrec *ufrom = NULL;
-
-    struct chanset_t *chan = NULL;
-    char work[1024],
-     *wptr,
-     *p;
-
-    memberlist *m;
-    int modecnt = 0,
-      ops = 0,
-      deops = 0,
-      bans = 0,
-      unbans = 0;
-
-    /* Split up the mode: #chan modes param param param param */
-    strncpy0(work, msg, sizeof(work));
-    wptr = work;
-Context;
-    p = newsplit(&wptr);
-    chan = findchan(p);
-
-    p = newsplit(&wptr);
-    while (*p) {
-      char *mp;
-
-      if (*p == '+')
-	sign = '+';
-      else if (*p == '-')
-	sign = '-';
-      else if (strchr(STR("oblkvIe"), p[0])) {
-	mp = newsplit(&wptr);
-	if (strchr("ob", p[0])) {
-	  /* Just want o's and b's */
-	  modes[modecnt] = nmalloc(strlen(mp) + 4);
-	  sprintf(modes[modecnt], STR("%c%c %s"), sign, p[0], mp);
-	  modecnt++;
-	  if (p[0] == 'o') {
-	    if (sign == '+')
-	      ops++;
-	    else
-	      deops++;
-	  }
-	  if (p[0] == 'b') {
-	    if (sign == '+')
-	      bans++;
-	    else
-	      unbans++;
-	  }
-	}
-      } else if (strchr(STR("pstnmi"), p[0])) {
-      } else {
-	/* hrmm... what modechar did i forget? */
-	putlog(LOG_ERRORS, "*", STR("Forgotten modechar: %c"), p[0]);
-      }
-      p++;
-    }
-Context;
-    ufrom = get_user_by_host(from);
-    
-    /* Split up from */
-    strncpy0(work, from, sizeof(work));
-    p = strchr(work, '!');
-    *p++ = 0;
-    nfrom = work;
-    hfrom = p;
-
-    /* Now we got modes[], chan, ufrom, nfrom, hfrom, and count of each relevant mode */
-    // check for mdop
-    if ((chan) && (deops >= 3)) {
-      if ((!ufrom) || (!(ufrom->flags & USER_BOT))) {
-	if (ROLE_KICK_MDOP) {
-	  m=ismember(chan, nfrom);
-	  if (!m || !chan_sentkick(m)) {
-/* FIXME: POSSIBLE EXCESS FLOOD IS HERE. */
-putlog(LOG_MISC, "*", "DEBUG: kicking %s in %s for mdop (possible excess flood)", nfrom, chan->dname);
-	    sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MASSDEOP));
-	    tputs(serv, tmp, strlen(tmp));
-	    if (m)
-	      m->flags |= SENTKICK;
-	  }
-	}
-      }
-    }
-    //check for mop
-    if (chan && (ops >= 3)) {
-      if (channel_nomop(chan)) {
-        if ((!ufrom) || (!(ufrom->flags & USER_BOT))) {
-          if (ROLE_KICK_MDOP) {
-            m=ismember(chan, nfrom);
-            if (!m || !chan_sentkick(m)) {
-
-              sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
-              tputs(serv, tmp, strlen(tmp));
-              if (m)
-                m->flags |= SENTKICK;
-            }
-          }
-        }
-      }
-    }
-
-    if (chan && ops && (ufrom) && (ufrom->flags & USER_BOT)
-	&& (!channel_fastop(chan))
-	&& (!channel_take(chan))
-      ) {
-      int isbadop = 0;
-
-      if ((modecnt != 2) || (strncmp(modes[0], "+o", 2))
-	  || (strncmp(modes[1], "-b", 2)))
-	isbadop = 1;
-      else {
-	char enccookie[25],
-	  plaincookie[25],
-	  key[NICKLEN + 20],
-	  goodcookie[25];
-
-	/* -b *!*@[...] */
-	strncpy0(enccookie, (char *) &(modes[1][8]), sizeof(enccookie));
-	p = enccookie + strlen(enccookie) - 1;
-//	*p = 0;
-//	while (p - enccookie < 24) {
-//	  *p++ = '.';
-//	  *p = 0;
-//	}
-	strcpy(key, nfrom);
-	strcat(key, netpass);
-//putlog(LOG_DEBUG, "*", "Decrypting cookie: %s with key %s", enccookie, key);
-	p = decrypt_string(key, enccookie);
-//putlog(LOG_DEBUG, "*", "Decrypted cookie: %s", p);
-Context;
-	strncpy0(plaincookie, p, sizeof(plaincookie));
-	nfree(p);
-	/*
-	   last 6 digits of time
-	   last 5 chars of nick
-	   last 5 regular chars of chan
-	 */
-	makeplaincookie(chan->dname, (char *) (modes[0] + 3), goodcookie);
-  //      putlog(LOG_DEBUG, "*", "cookie from %s: %s should be: %s", nfrom, plaincookie, goodcookie);
-	if (strncmp((char *) &plaincookie[6], (char *) &goodcookie[6], 5))
-	  isbadop = 2;
-	else if (strncmp((char *) &plaincookie[11], (char *) &goodcookie[11], 5))
-	  isbadop = 3;
-	else {
-	  char tmp[20];
-	  long optime;
-          int off;
-
-	  sprintf(tmp, STR("%010li"), (now + timesync));
-	  strncpy0((char *) &tmp[4], plaincookie, 7);
-	  optime = atol(tmp);
-          off = (now + timesync - optime);
-
-          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);
-          }
-	}
-      }
-      if (isbadop) {
-	char trg[NICKLEN + 1] = "";
-	int n,
-	  i;
-	memberlist *m;
-Context;
-
-	switch (role) {
-	case 0:
-	  break;
-	case 1:
-	  /* Kick opper */
-          m=ismember(chan, nfrom);
-	  if (!m || !chan_sentkick(m)) {
-	    sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_BADOP));
-	    tputs(serv, tmp, strlen(tmp));
-	    if (m) 
-	      m->flags |= SENTKICK;
-	  }
-	  sprintf(tmp, STR("%s MODE %s"), from, msg);
-	  deflag_user(ufrom, DEFLAG_BADCOOKIE, tmp, chan);
-	  break;
-	default:
-	  n = role - 1;
-	  i = 0;
-	  while ((i < 5) && (n > 0)) {
-	    if (modes[i] && !strncmp(modes[i], "+o", 2))
-	      n--;
-	    if (n)
-	      i++;
-	  }
-	  if (!n) {
-	    strcpy(trg, (char *) &modes[i][3]);
-	    m = ismember(chan, trg);
-	    if (m) {
-	      if (!(m->flags & CHANOP)) {
-                if (!chan_sentkick(m)) {
-		  sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_BADOPPED));
-		  tputs(serv, tmp, strlen(tmp));
-                  m->flags |= SENTKICK;
-		}
-	      }
-	    }
-	  }
-	}
-	if (isbadop == 1)
-	  putlog(LOG_WARN, "*", STR("Missing cookie: %s MODE %s"), from, msg);
-	else if (isbadop == 2)
-	  putlog(LOG_WARN, "*", STR("Invalid cookie (bad nick): %s MODE %s"), from, msg);
-	else if (isbadop == 3)
-	  putlog(LOG_WARN, "*", STR("Invalid cookie (bad chan): %s MODE %s"), from, msg);
-	else if (isbadop == 4)
-	  putlog(LOG_WARN, "*", STR("Invalid cookie (bad time): %s MODE %s"), from, msg);
-      } else
-	putlog(LOG_DEBUG, "@", STR("Good op: %s"), msg);
-    }
-    if ((ops) && chan && !channel_manop(chan) && (ufrom)
-	&& !(ufrom->flags & USER_BOT)) {
-      char trg[NICKLEN + 1] = "";
-      int n,
-        i;
-      memberlist *m;
-
-      switch (role) {
-      case 0:
-	break;
-      case 1:
-	/* Kick opper */
-	m = ismember(chan, nfrom);
-	if (!m || !chan_sentkick(m)) {
-	  sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, nfrom, kickprefix, kickreason(KICK_MANUALOP));
-	  tputs(serv, tmp, strlen(tmp));
-	  if (m)
-	    m->flags |= SENTKICK;
-	}
-	sprintf(tmp, STR("%s MODE %s"), from, msg);
-	deflag_user(ufrom, DEFLAG_MANUALOP, tmp, chan);
-	break;
-      default:
-	n = role - 1;
-	i = 0;
-	while ((i < 5) && (n > 0)) {
-	  if (modes[i] && !strncmp(modes[i], "+o", 2))
-	    n--;
-	  if (n)
-	    i++;
-	}
-	if (!n) {
-	  strcpy(trg, (char *) &modes[i][3]);
-	  m = ismember(chan, trg);
-	  if (m) {
-	    if (!(m->flags & CHANOP) && (rfc_casecmp(botname, trg))) {
-              if (!chan_sentkick(m)) {
-		sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
-		tputs(serv, tmp, strlen(tmp));
-		m->flags |= SENTKICK;
-	      }
-	    }
-	  } else {
-	    sprintf(tmp, STR("KICK %s %s :%s%s\n"), chan->name, trg, kickprefix, kickreason(KICK_MANUALOPPED));
-	    tputs(serv, tmp, strlen(tmp));
-	  }
-	}
-      }
-    }
-    for (i = 0; i < 5; i++)
-      if (modes[i])
-	nfree(modes[i]);
-  }
-
   if (use_console_r) {
-    if (!strcmp(code, "PRIVMSG") ||
-	!strcmp(code, "NOTICE")) {
+    if (!strcmp(code, "PRIVMSG") || !strcmp(code, "NOTICE")) {
       if (!match_ignore(from))
 	putlog(LOG_RAW, "@", "[@] %s %s %s", from, code, msg);
     } else

+ 2 - 2
src/modules.c

@@ -284,7 +284,7 @@ Function global_table[] =
   (Function) & share_greet,	 /* int					*/
   /* 100 - 103 */
   (Function) & max_dcc,		 /* int					*/
-  (Function) 0, /* --UNUSED-- */
+  (Function) shouldjoin, 
   (Function) & ignore_time,	 /* int					*/
   (Function) & use_console_r,	 /* int					*/
   /* 104 - 107 */
@@ -323,7 +323,7 @@ Function global_table[] =
   (Function) findanyidx,
   (Function) findchan,
   /* 132 - 135 */
-  (Function) 0,
+  (Function) dolimit,
   (Function) days,
   (Function) daysago,
   (Function) daysdur,

+ 2 - 0
src/proto.h

@@ -114,6 +114,7 @@ void rmspace(char *s);
 void set_chanlist(const char *host, struct userrec *rec);
 void clear_chanlist(void);
 void clear_chanlist_member(const char *nick);
+int shouldjoin(struct chanset_t *);
 
 /* cmds.c */
 int check_dcc_attrs(struct userrec *, int);
@@ -256,6 +257,7 @@ int my_strcpy(char *, char *);
 void putlog EGG_VARARGS(int, arg1);
 int ischanhub();
 int dovoice(struct chanset_t *);
+int dolimit(struct chanset_t *);
 void maskhost(const char *, char *);
 char *stristr(char *, char *);
 void splitc(char *, char *, char);

+ 2 - 2
src/userrec.c

@@ -45,7 +45,7 @@ void *_user_malloc(int size, const char *file, int line)
   const char	*p;
 
   p = strrchr(file, '/');
-  simple_sprintf(x, "userrec.c:%s", p ? p + 1 : file);
+  simple_sprintf(x, "xuserrec.c:%s", p ? p + 1 : file);
   return n_malloc(size, x, line);
 #else
   return nmalloc(size);
@@ -59,7 +59,7 @@ void *_user_realloc(void *ptr, int size, const char *file, int line)
   const char	*p;
 
   p = strrchr(file, '/');
-  simple_sprintf(x, "userrec.c:%s", p ? p + 1 : file);
+  simple_sprintf(x, "xuserrec.c:%s", p ? p + 1 : file);
   return n_realloc(ptr, size, x, line);
 #else
   return nrealloc(ptr, size);