]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-notice.c
SearchCtx should contain 'type' - this is to make life easier when defining new searc...
[irc/quakenet/newserv.git] / newsearch / ns-notice.c
index dfd0121fe1984ef377fe93ed10df1c98edb8757a..5adeeb7707e4f16ed9b91c0df8ade247156ec048 100644 (file)
 
 extern nick *senderNSExtern;
 
-void *notice_exe(struct searchNode *thenode, void *theinput);
-void notice_free(struct searchNode *thenode);
+void *notice_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void notice_free(searchCtx *ctx, struct searchNode *thenode);
 
 struct notice_localdata {
   unsigned int marker;
   int count;
-  int type;
   char message[NSMAX_NOTICE_LEN];
 };
 
-struct searchNode *notice_parse(int type, int argc, char **argv) {
+struct searchNode *notice_parse(searchCtx *ctx, int argc, char **argv) {
   struct notice_localdata *localdata;
   struct searchNode *thenode;
   int len;
@@ -36,8 +35,7 @@ struct searchNode *notice_parse(int type, int argc, char **argv) {
     return NULL;
   }
   localdata->count = 0;
-  localdata->type = type;
-  if (type == SEARCHTYPE_CHANNEL)
+  if (ctx->type == SEARCHTYPE_CHANNEL)
     localdata->marker = nextchanmarker();
   else
     localdata->marker = nextnickmarker();
@@ -75,14 +73,14 @@ struct searchNode *notice_parse(int type, int argc, char **argv) {
   return thenode;
 }
 
-void *notice_exe(struct searchNode *thenode, void *theinput) {
+void *notice_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
   struct notice_localdata *localdata;
   nick *np;
   chanindex *cip;
 
   localdata = thenode->localdata;
 
-  if (localdata->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->type == SEARCHTYPE_CHANNEL) {
     cip = (chanindex *)theinput;
     cip->marker = localdata->marker;
     localdata->count += cip->channel->users->totalusers;
@@ -96,7 +94,7 @@ void *notice_exe(struct searchNode *thenode, void *theinput) {
   return (void *)1;
 }
 
-void notice_free(struct searchNode *thenode) {
+void notice_free(searchCtx *ctx, struct searchNode *thenode) {
   struct notice_localdata *localdata;
   nick *np, *nnp;
   chanindex *cip, *ncip;
@@ -105,7 +103,7 @@ void notice_free(struct searchNode *thenode) {
 
   localdata = thenode->localdata;
 
-  if (localdata->type == SEARCHTYPE_CHANNEL) {
+  if (ctx->type == SEARCHTYPE_CHANNEL) {
     nickmarker=nextnickmarker();
     for (i=0;i<CHANNELHASHSIZE;i++) {
       for (cip=chantable[i];cip;cip=ncip) {
@@ -139,7 +137,7 @@ void notice_free(struct searchNode *thenode) {
     }
   }
   /* notify opers of the action */
-  controlwall(NO_OPER, NL_BROADCASTS, "%s/%s sent the following message to %d %s: %s", senderNSExtern->nick, senderNSExtern->authname, localdata->count, localdata->count != 1 ? "users" : "user", localdata->message);
+  ctx->wall(NL_BROADCASTS, "%s/%s sent the following message to %d %s: %s", senderNSExtern->nick, senderNSExtern->authname, localdata->count, localdata->count != 1 ? "users" : "user", localdata->message);
   free(localdata);
   free(thenode);
 }