.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 $@ $^
registersearchterm("oppct",oppct_parse);
registersearchterm("uniquehostpct",hostpct_parse);
registersearchterm("authedpct",authedpct_parse);
+ registersearchterm("kick",kick_parse);
/* Nickname / channel operations */
registersearchterm("modes",modes_parse);
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);
--- /dev/null
+/*
+ * 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);
+}