dancer-ircd (1.0.36-8) src/m_lpart.c

Summary

 src/m_lpart.c |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

    
download this patch

Patch contents

--- dancer-ircd-1.0.36.orig/src/m_lpart.c
+++ dancer-ircd-1.0.36/src/m_lpart.c
@@ -0,0 +1,102 @@
+/************************************************************************
+ *   IRC - Internet Relay Chat, src/m_lpart.c
+ *   This file is copyright (C) 2001 Andrew Suffield
+ *                                    <asuffield@freenode.net>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+#include "client.h"
+#include "ircd.h"
+#include "common.h"
+#include "numeric.h"
+#include "send.h"
+#include "channel.h"
+#include "umodes.h"
+#include "m_commands.h"
+#include "struct.h"
+#include "irc_string.h"
+#include "hash.h"
+#include "list.h"
+
+#include <string.h>
+
+int m_lpart(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+  struct Channel *chptr;
+  char  *p, *name;
+
+  if (parc < 2 || parv[1][0] == '\0')
+    {
+      sendto_one(sptr, form_str(ERR_NEEDMOREPARAMS),
+                 me.name, parv[0], "LPART");
+      return 0;
+    }
+
+  for (name = strtoken( &p, parv[1], ","); name; name = strtoken(&p, NULL, ","))
+    {
+      Link **curr, *tmp;
+
+      chptr = hash_find_channel(name, NULL);
+      if (!chptr)
+        {
+          sendto_one(sptr, form_str(ERR_NOSUCHCHANNEL),
+                     me.name, parv[0], name);
+          continue;
+        }
+
+      if (!IsLogger(sptr, chptr))
+        {
+          sendto_one(sptr, form_str(ERR_NOTONCHANNEL),
+                     me.name, parv[0], name);
+          continue;
+        }
+
+      sendto_match_servs(chptr, cptr, ":%s LPART %s",
+			 sptr->name, chptr->chname);
+
+      for (curr = &chptr->loggers; (tmp = *curr); curr = &tmp->next)
+        {
+          if (tmp->value.cptr == sptr)
+            {
+              *curr = tmp->next;
+              free_link(tmp);
+              chptr->logcount--;
+              if (!chptr->logcount)
+                {
+                  chptr->mode.mode &= ~MODE_LOGGING;
+                  sendto_channel_butserv(chptr, sptr, ":%s MODE %s -L",
+                                         sptr->name, chptr->chname);
+                }
+              break;
+            }
+        }
+
+      for (curr = &sptr->user->logging; (tmp = *curr); curr = &tmp->next)
+        {
+          if (tmp->value.chptr == chptr)
+            {
+              *curr = tmp->next;
+              free_link(tmp);
+              sptr->user->logcount--;
+	      if (MyConnect(sptr))
+		sendto_one(sptr, ":%s LPART %s",
+			   sptr->name, chptr->chname);
+              break;
+            }
+        }
+    }
+  return 0;
+}