]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-kill.c
LUA: add function for channel chanop notice
[irc/quakenet/newserv.git] / newsearch / ns-kill.c
index 1b7aadd4f8b17f9bc5b934fc8faa70c1f0f137e6..f0cb2deaa3e253aab1ef33a3c9d3090a2a2917a0 100644 (file)
@@ -29,7 +29,6 @@ struct kill_localdata {
 struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv) {
   struct kill_localdata *localdata;
   struct searchNode *thenode;
-  int len;
 
   if (!(localdata = (struct kill_localdata *) malloc(sizeof(struct kill_localdata)))) {
     parseError = "malloc: could not allocate memory for this search.";
@@ -41,24 +40,25 @@ struct searchNode *kill_parse(searchCtx *ctx, int argc, char **argv) {
   else if (ctx->searchcmd == reg_nicksearch) 
     localdata->marker = nextnickmarker();
   else {
+    free(localdata);
     parseError = "kill: invalid search type";
     return NULL;
   }
 
   if (argc==1) {
-    char *p = argv[0];
-    if(*p == '\"')
-      p++;
-    len = strlcpy(localdata->reason, p, sizeof(localdata->reason));
-    if(len >= sizeof(localdata->reason)) {
-      localdata->reason[sizeof(localdata->reason)-1] = '\0';
-    } else {
-      localdata->reason[len-1] = '\0';
+    struct searchNode *reasonstr;
+    char *p;
+    if (!(reasonstr=argtoconststr("kill", ctx, argv[0], &p))) {
+      free(localdata);
+      return NULL;
     }
-  }
-  else
+    
+    strlcpy(localdata->reason, p, sizeof(localdata->reason));
+    reasonstr->free(ctx, reasonstr);
+  } else {
     strlcpy(localdata->reason, defaultreason, sizeof(localdata->reason));
-
+  }
+  
   if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
     /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
     parseError = "malloc: could not allocate memory for this search.";