]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Added (kick <username>) function to chansearch.
authorsplidge <redacted>
Thu, 14 Jun 2007 13:53:58 +0000 (14:53 +0100)
committersplidge <redacted>
Thu, 14 Jun 2007 13:53:58 +0000 (14:53 +0100)
newsearch/Makefile
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/ns-kick.c [new file with mode: 0644]

index 2d69f98a6b83262a5e093bc68763e6c72dbf9fd6..a08800a60928e6d65f1b44fbf2513357b2786270 100644 (file)
@@ -2,5 +2,5 @@
 .PHONY: all
 all: newsearch.so
 
-newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-hostpct.o ns-authedpct.o ns-length.o
+newsearch.so: newsearch.o ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o
        ld -shared -Bdynamic $(LIBPCRE) -o $@ $^
index 4967cde6be8844e908ce55b87ef47b2e8b3efa59..666fd63f007a349b94c0a1e24284be176a3a1c00 100644 (file)
@@ -66,6 +66,7 @@ void _init() {
   registersearchterm("oppct",oppct_parse);
   registersearchterm("uniquehostpct",hostpct_parse);
   registersearchterm("authedpct",authedpct_parse);
+  registersearchterm("kick",kick_parse);
 
   /* Nickname / channel operations */
   registersearchterm("modes",modes_parse);
index 28714aa52424f1ad68259691320c0eba54828fd3..f17f87fea43d8614ab79bb1c6933ad7e17d4cad7 100644 (file)
@@ -76,6 +76,7 @@ struct searchNode *topic_parse(int type, int argc, char **argv);
 struct searchNode *oppct_parse(int type, int argc, char **argv);
 struct searchNode *hostpct_parse(int type, int argc, char **argv);
 struct searchNode *authedpct_parse(int type, int argc, char **argv);
+struct searchNode *kick_parse(int type, int argc, char **argv);
 
 /* Interpret a string to give a node */
 struct searchNode *search_parse(int type, char *input);
diff --git a/newsearch/ns-kick.c b/newsearch/ns-kick.c
new file mode 100644 (file)
index 0000000..60d4295
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * KICK functionality 
+ */
+
+#include "newsearch.h"
+#include "../localuser/localuserchannel.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void *kick_exe(struct searchNode *thenode, void *theinput);
+void kick_free(struct searchNode *thenode);
+
+struct searchNode *kick_parse(int type, int argc, char **argv) {
+  struct searchNode *thenode;
+  void *localdata;
+
+  if (type!=SEARCHTYPE_CHANNEL) {
+    parseError="kick: only channel searches are supported";
+    return NULL;
+  }
+
+  if (argc!=1) {
+    parseError="kick: usage: (kick target)";
+    return NULL;
+  }
+
+  if ((localdata=getnickbynick(argv[0]))==NULL) {
+    parseError="kick: unknown nickname";
+    return NULL;
+  }
+
+  if (!(thenode=(struct searchNode *)malloc(sizeof(struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
+    return NULL;
+  }
+
+  thenode->returntype = RETURNTYPE_BOOL;
+  thenode->localdata = localdata;
+  thenode->exe = kick_exe;
+  thenode->free = kick_free;
+
+  return thenode;
+}
+
+void *kick_exe(struct searchNode *thenode, void *theinput) {
+  nick *np;
+  chanindex *cip;
+
+  np=thenode->localdata;
+  cip=(chanindex *)theinput;
+
+  if (cip->channel==NULL || getnumerichandlefromchanhash(cip->channel->users, np->numeric)==NULL)
+    return (void *)0;
+  
+  localkickuser(NULL, cip->channel, np, NULL);
+  return (void *)1;
+}
+
+void kick_free(struct searchNode *thenode) {
+  free(thenode);
+}