Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / send.c
index 787eeae01cc57134a982c45d55314eb2ff3e5465..f5adb86d5cf8b35b6ab9390a4098979e5c3b80cc 100644 (file)
@@ -61,7 +61,7 @@ int sdbflag;
  * generate ExitClient from the main loop.
  *
  * If 'notice' is not NULL, it is assumed to be a format
- * for a message to local opers. I can contain only one
+ * for a message to local opers. It can contain only one
  * '%s', which will be replaced by the sockhost field of
  * the failing link.
  *
@@ -79,13 +79,14 @@ static void dead_link(struct Client *to, char *notice)
   DBufClear(&to->recvQ);
   DBufClear(&to->sendQ);
 
-  /* Keep a copy of the last comment, for later use... */
-  ircd_strncpy(LastDeadComment(to), notice, sizeof(LastDeadComment(to) - 1));
-  LastDeadComment(to)[sizeof(LastDeadComment(to)) - 1] = '\0';
+  /*
+   * Keep a copy of the last comment, for later use...
+   */
+  ircd_strncpy(to->info, notice, REALLEN);
 
   if (!IsUser(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING))
-    sendto_ops("%s for %s", LastDeadComment(to), to->name);
-  Debug((DEBUG_ERROR, LastDeadComment(to)));
+    sendto_ops("%s for %s", to->info, to->name);
+  Debug((DEBUG_ERROR, to->info));
 }
 
 static int can_send(struct Client* to)
@@ -161,8 +162,11 @@ void send_queued(struct Client *to)
         break;
     }
     else {
-      if (IsDead(to))
-        dead_link(to, "Write error, closing link");
+      if (IsDead(to)) {
+        char tmp[512];
+        sprintf(tmp,"Write error: %s",(strerror(to->error)) ? (strerror(to->error)) : "Unknown error" );
+        dead_link(to, tmp);
+      }
       break;
     }
   }
@@ -371,6 +375,7 @@ void sendmsgto_channel_butone(struct Client *one, struct Client *from,
   int i;
   int flag=-1;
 
+  assert(0 != cmd);
   /* 
    * Precalculate the buffers we sent to the clients instead of doing an
    * expensive sprintf() per member that we send to.  We still have to
@@ -378,20 +383,14 @@ void sendmsgto_channel_butone(struct Client *one, struct Client *from,
    */
   if (IsServer(from)) {
     sprintf(userbuf,":%s %s %s :%s",
-        from->name, 
-        ((cmd[0] == 'P') ? MSG_PRIVATE : MSG_NOTICE),
-        chname, msg);
-    sprintf(servbuf,"%s " TOK_PRIVATE " %s :%s",
-        NumServ(from), chname, msg);
-  } else {
+            from->name, ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
+    sprintf(servbuf,"%s %s %s :%s", NumServ(from), cmd, chname, msg);
+  }
+  else {
     sprintf(userbuf,":%s!%s@%s %s %s :%s",
-      from->name, from->username, from->user->host,
-      ((cmd[0] == 'P') ? MSG_PRIVATE : MSG_NOTICE),
-      chname, msg);
-    sprintf(servbuf,"%s%s %s %s :%s",
-      NumNick(from), 
-       ((cmd[0] == 'P') ? TOK_PRIVATE : TOK_NOTICE),
-     chname, msg);
+            from->name, from->username, from->user->host,
+            ('P' == *cmd) ? MSG_PRIVATE : MSG_NOTICE, chname, msg);
+    sprintf(servbuf,"%s%s %s %s :%s", NumNick(from), cmd, chname, msg);
   }
 
   ++sentalong_marker;
@@ -540,7 +539,7 @@ void sendto_chanopsserv_butone(struct Client *one, struct Client *from, struct C
 }
 
 /*
- * sendto_server_butone
+ * sendto_serv_butone
  *
  * Send a message to all connected servers except the client 'one'.
  */