--- m_operspy.c.dist	Mon Apr  5 11:28:09 2004
+++ m_operspy.c	Mon Apr  5 11:52:47 2004
@@ -118,7 +118,7 @@
 #endif
 
 #ifdef OPERSPY_LOG
-static void operspy_log(struct Client *, const char *, const char *);
+static void operspy_log(struct Client *, int, char **);
 #endif
 
 static void
@@ -126,7 +126,7 @@
            int parc, char *parv[])
 {
 #ifdef OPERSPY_LOG
-  operspy_log(source_p, parv[1], parv[2]);
+  operspy_log(source_p, parc - 1, &parv[1]);
 #endif
 }
 
@@ -196,7 +196,7 @@
   if (irccmp(parv[1], "LIST") == 0)
   {
 #ifdef OPERSPY_LOG
-    operspy_log(client_p, "LIST", parv[2]);
+    operspy_log(client_p, parc - 1, &parv[1]);
 #endif
 
     sendto_one(client_p, form_str(RPL_LISTSTART),
@@ -244,7 +244,7 @@
     }
 
 #ifdef OPERSPY_LOG
-    operspy_log(client_p, "MODE", parv[2]);
+    operspy_log(client_p, parc - 1, &parv[1]);
 #endif
 
     /* this is a dirty nasty kludge to trick channel_modes() into giving us the key */
@@ -281,7 +281,7 @@
     }
 
 #ifdef OPERSPY_LOG
-    operspy_log(client_p, "NAMES", parv[2]);
+    operspy_log(client_p, parc - 1, &parv[1]);
 #endif
 
     /* the way to go with this, rather than temporarily setting -sp,
@@ -309,7 +309,7 @@
     }
 
 #ifdef OPERSPY_LOG
-    operspy_log(client_p, "TOPIC", parv[2]);
+    operspy_log(client_p, parc - 1, &parv[1]);
 #endif
 
     if (chptr_topic->topic == NULL)
@@ -345,7 +345,12 @@
     else
     {
 #ifdef OPERSPY_LOG
-      operspy_log(client_p, "WHO", "*");
+      int lparc = 2;
+      char *lparv[3];
+      lparv[0] = "WHO";
+      lparv[1] = "*";
+      lparv[2] = NULL;
+      operspy_log(client_p, lparc, lparv);
 #endif
       who_global(client_p, NULL, server_oper);
       sendto_one(client_p, form_str(RPL_ENDOFWHO),
@@ -359,7 +364,12 @@
       if ((chptr_who = hash_find_channel(mask)) != NULL)
       {
 #ifdef OPERSPY_LOG
-        operspy_log(client_p, "WHO", mask);
+        int lparc = 2;
+        char *lparv[3];
+        lparv[0] = "WHO";
+        lparv[1] = mask;
+        lparv[2] = NULL;
+        operspy_log(client_p, lparc, lparv);
 #endif
         do_who_on_channel(client_p, chptr_who, chptr_who->chname);
       }
@@ -374,10 +384,15 @@
         IsPerson(target_p_who))
     {
 #ifdef OPERSPY_LOG
+      int lparc = 2;
+      char *lparv[3];
+      lparv[0] = "WHO";
+      lparv[1] = nuh;
+      lparv[2] = NULL;
       ircsprintf(nuh, "%s!%s@%s %s",
                  target_p_who->name, target_p_who->username, target_p_who->host,
                  target_p_who->user->server->name);
-      operspy_log(client_p, "WHO", nuh);
+      operspy_log(client_p, lparc, lparv);
 #endif
 
       if (target_p_who->user->channel.head != NULL)
@@ -399,7 +414,7 @@
     }
 
 #ifdef OPERSPY_LOG
-    operspy_log(client_p, "WHO", parv[2]);
+    operspy_log(client_p, parc - 1, &parv[1]);
 #endif
 
     /* /who 0 */
@@ -439,7 +454,14 @@
     ircsprintf(nuh, "%s!%s@%s %s",
                target_p->name, target_p->username, target_p->host,
                target_p->user->server->name);
-    operspy_log(client_p, "WHOIS", nuh);
+    {
+      int lparc = 2;
+      char *lparv[3];
+      lparv[0] = "WHOIS";
+      lparv[1] = nuh;
+      lparv[2] = NULL;
+      operspy_log(client_p, lparc, lparv);
+    }
 #endif
 
     a2client_p = target_p->user->server;
@@ -581,9 +603,11 @@
 
 #ifdef OPERSPY_LOG
 static void
-operspy_log(struct Client *source_p, const char *command, const char *target)
+operspy_log(struct Client *source_p, int parc, char *parv[])
 {
   struct ConfItem *conf;
+  char command[BUFSIZE];
+  int i;
 #ifdef OPERSPY_LOGFILE
   size_t nbytes = 0;
   FBFILE *operspy_fb;
@@ -594,6 +618,16 @@
 
   assert(source_p != NULL);
 
+  if (parc < 1)
+    return; /* Nothing sent */
+
+  strlcpy(command, parv[0], BUFSIZE);
+  for (i = 1; i < parc; i++)
+  {
+    strlcat(command, " ", BUFSIZE);
+    strlcat(command, parv[i], BUFSIZE);
+  }
+
 #ifdef OPERSPY_LOGFILE
   if (IsOper(source_p) && MyClient(source_p))
   {
@@ -613,21 +647,21 @@
   if ((operspy_fb = fbopen(logfile, "a")) == NULL)
     return;
 
-  nbytes = ircsprintf(linebuf, "[%s] OPERSPY %s %s %s\n",
+  nbytes = ircsprintf(linebuf, "[%s] OPERSPY %s %s\n",
                       smalldate(CurrentTime),
                       get_oper_name(source_p),
-                      command, target);
+                      command);
   fbputs(linebuf, operspy_fb, nbytes);
   fbclose(operspy_fb);
 #endif
 
 #ifdef OPERSPY_NOTICE
-  sendto_realops_flags(UMODE_SPY, L_ALL, "OPERSPY %s %s %s",
-                       get_oper_name(source_p), command, target);
+  sendto_realops_flags(UMODE_SPY, L_ALL, "OPERSPY %s %s",
+                       get_oper_name(source_p), command);
 #endif
 
   if (MyClient(source_p))
-    sendto_match_servs(source_p, "*", CAP_ENCAP, "ENCAP * OPERSPY %s :%s",
-                       command, target);
+    sendto_match_servs(source_p, "*", CAP_ENCAP, "ENCAP * OPERSPY %s",
+                       command);
 }
 #endif /* OPERSPY_LOG */
