]> jfr.im git - irc/quakenet/newserv.git/commitdiff
3 fixes to my newsearch stuff:
authorPaul <redacted>
Fri, 29 Aug 2008 19:30:20 +0000 (20:30 +0100)
committerPaul <redacted>
Fri, 29 Aug 2008 19:30:20 +0000 (20:30 +0100)
a) only allow inclusion of newsearch.h once

b) registering a command should just 'cheat'  and access raw tree instead of calling registersearchterm - otherwise global commands are not treated
as such

c) we need to delete the command from the main searchCmdTree when unregistering it

newsearch/newsearch.c
newsearch/newsearch.h

index 0e9879957b293f45412c31f495ab3f2599396d7e..91357dd48c7a64026d909fce9ca540f09eb1f691 100644 (file)
@@ -53,7 +53,7 @@ searchCmd *registersearchcommand(char *name, int level, CommandHandler cmd, void
   addcommandtotree(searchCmdTree, name, 0, 0, (CommandHandler)acmd);
 
   for (sl=globalterms; sl; sl=sl->next) {
-    registersearchterm( acmd, sl->name->content, sl->cmd, 0, sl->help);
+    addcommandexttotree(acmd->searchtree, sl->name->content, 0, 1, (CommandHandler)sl->cmd, sl->help);
   }
 
   return acmd;
@@ -63,6 +63,7 @@ void deregistersearchcommand(searchCmd *scmd) {
   deregistercontrolcmd(scmd->name->content, (CommandHandler)scmd->handler);
   destroycommandtree(scmd->outputtree);
   destroycommandtree(scmd->searchtree);
+  deletecommandfromtree(searchCmdTree, scmd->name->content, (CommandHandler) scmd);
   freesstring(scmd->name);
   free(scmd);
 }
index 9950ab7da37dc6c663d7765c434cf25e4459112b..525b24c2542710fecc37cab9a76052558dd7a032 100644 (file)
@@ -6,6 +6,9 @@
 #include "../authext/authext.h"
 #include "../patricia/patricia.h"
 
+#ifndef __NEWSEARCH_H
+#define __NEWSEARCH_H
+
 #define    NSMAX_KILL_LIMIT       500
 #define    NSMAX_GLINE_LIMIT      500
 #define    NSMAX_GLINE_CLONES     5
@@ -259,3 +262,4 @@ extern UserDisplayFunc defaultuserfn;
 extern NickDisplayFunc defaultnickfn;
 extern ChanDisplayFunc defaultchanfn;
 
+#endif