]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Use channel flags, not channel user flags.
authorChris Porter <redacted>
Wed, 2 Apr 2008 14:22:08 +0000 (15:22 +0100)
committerChris Porter <redacted>
Wed, 2 Apr 2008 14:22:08 +0000 (15:22 +0100)
chanserv/newsearch/csns-qchanflags.c
irc/irc.c
newsearch/newsearch.c
newsearch/ns-gline.c

index 39f098ff7271de287d0421bbf756d4f1514f5598..b14bd8129b841b71fc26c1f6d71fa415a25b87a6 100644 (file)
@@ -43,8 +43,8 @@ struct searchNode *qchanflags_parse(searchCtx *ctx, int type, int argc, char **a
     localdata->setmodes=0;
     localdata->clearmodes=~0;
     
-    setflags(&(localdata->setmodes), QCFLAG_ALL, argv[0], rcuflags, REJECT_NONE);
-    setflags(&(localdata->clearmodes), QCFLAG_ALL, argv[0], rcuflags, REJECT_NONE);
+    setflags(&(localdata->setmodes), QCFLAG_ALL, argv[0], rcflags, REJECT_NONE);
+    setflags(&(localdata->clearmodes), QCFLAG_ALL, argv[0], rcflags, REJECT_NONE);
     
     localdata->clearmodes = ~localdata->clearmodes;
   }
index cf35fec2ec37504feca707c96e35221565c68376..d2cffb3f93d3f21f914ff3bc69564cc6bf6b7975 100644 (file)
--- a/irc/irc.c
+++ b/irc/irc.c
@@ -30,6 +30,8 @@ MODULE_VERSION("");
 #define MIN_NUMERIC          100
 #define MAX_NUMERIC          999
 
+#define IRC_DUMP
+
 void irc_connect(void *arg);
 
 CommandTree *servercommands;
@@ -215,7 +217,12 @@ void irc_send(char *format, ... ) {
   
   buf[len++]='\r';
   buf[len++]='\n';
-  
+
+#ifdef IRC_DUMP
+  buf[len]='\0';
+  printf(">> %s",buf);
+#endif
+
   write(serverfd,buf,len);
 }
 
@@ -294,6 +301,10 @@ int parseline() {
   
   /* OK, currentline points at a valid NULL-terminated line */
   /* and nextline points at where we are going next */      
+
+#ifdef IRC_DUMP
+  printf("<< %s\n",currentline);
+#endif
   
   linesreceived++;
 
index 911df297993d791bd267f58c91a7ea57339f97d0..50fed1785367660aac20920564f794c24eafd15d 100644 (file)
@@ -155,6 +155,54 @@ void deregistersearchterm(char *term, parseFunc parsefunc) {
   deletecommandfromtree(searchTree, term, (CommandHandler) parsefunc);
 }
 
+#define SHOWFUNCLIST_MAXCMDS   300
+
+void printcmdlist(replyFunc reply, void *source, struct Command **thecmds, int numcmds) {
+  unsigned int i;
+  char buf[512];
+  int bufpos=0;
+  
+  for (i=0;i<numcmds;i++) {
+    if (bufpos+thecmds[i]->command->length > 300) {
+      reply(source, "%s", buf);
+      bufpos=0;
+    }
+    
+    bufpos+=sprintf(buf+bufpos, "%s%s", bufpos?", ":"", thecmds[i]->command->content);
+  }
+  
+  reply(source, "%s", buf);
+}
+
+/* showfunclist: dump a list of valid functions and output formats */
+void showfunclist(replyFunc reply, void *source, CommandTree *outputs) {
+  struct Command *thecmds[SHOWFUNCLIST_MAXCMDS];
+  int ncmds;
+
+  reply(source, "Usage: *SEARCH <opts> <search terms>");
+  reply(source, "Valid options:");
+  reply(source, " -l <num>     Limits output to <num> matches");
+  reply(source, " -d <format>  Selects named output format");
+  reply(source, "<search terms> is a lisp-style string describing what you want to match.  Function calls");
+  reply(source, "consist of parentheses with a space separated list of arguments, the function name");
+  reply(source, "being the first argument.  For example:");
+  reply(source, "*search (match (name) *trout*)  will return the list of objects named *trout*");
+  reply(source, "*search (and (match (name) *trout*) (modes +r)) will return the list of objects");
+  reply(source, "     named *trout* with mode +r set");
+  
+  ncmds=getcommandlist(searchTree, thecmds, SHOWFUNCLIST_MAXCMDS);
+  if (ncmds) {
+    reply(source, "Valid search functions:");
+    printcmdlist(reply, source, thecmds, ncmds);
+  }
+  
+  ncmds=getcommandlist(outputs, thecmds, SHOWFUNCLIST_MAXCMDS);
+  if (ncmds) {
+    reply(source, "Valid output functions for this search type:");
+    printcmdlist(reply, source, thecmds, ncmds);
+  }
+}
+
 static void controlwallwrapper(int level, char *format, ...) {
   char buf[1024];
   va_list ap;
@@ -223,7 +271,7 @@ int do_nicksearch_real(replyFunc reply, wallFunc wall, void *source, int cargc,
     return ret;
 
   if (arg>=cargc) {
-    reply(sender,"No search terms - aborting.");
+    showfunclist(reply, source, nickOutputTree);
     return CMD_ERROR;
   }
 
@@ -311,7 +359,7 @@ int do_chansearch_real(replyFunc reply, wallFunc wall, void *source, int cargc,
     return ret;
 
   if (arg>=cargc) {
-    reply(sender,"No search terms - aborting.");
+    showfunclist(reply, source, chanOutputTree);
     return CMD_ERROR;
   }
 
@@ -378,7 +426,7 @@ int do_usersearch_real(replyFunc reply, wallFunc wall, void *source, int cargc,
     return ret;
 
   if (arg>=cargc) {
-    reply(sender,"No search terms - aborting.");
+    showfunclist(reply, source, userOutputTree);
     return CMD_ERROR;
   }
 
index 8bc393560225e8627b2ffd032ce6f54171ab5351..43c516b9a3357b175c68740484b57dbbc1cd681f 100644 (file)
@@ -164,9 +164,9 @@ void gline_free(searchCtx *ctx, struct searchNode *thenode) {
               if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
                 nssnprintf(msgbuf, sizeof(msgbuf), localdata->reason, np);
                 if (np->host->clonecount <= NSMAX_GLINE_CLONES)
-                  irc_send("%s GL * +*@%s %u :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+                  irc_send("%s GL * +*@%s %u %u :%s", mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration +  time(NULL), time(NULL), localdata->duration);
                 else
-                  irc_send("%s GL * +%s@%s %u :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, msgbuf);
+                  irc_send("%s GL * +%s@%s %u %u :%s", mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration + time(NULL), time(NULL), msgbuf);
               }
               else
                 safe++;