added basic ssl support to ircu
[ircu2.10.12-pk.git] / ircd / m_away.c
index 642ea94eca844c0e778cf83295fe46404fe99878..ef440c19ab37a54009864dd76bdbbcf0cc5c897c 100644 (file)
@@ -84,6 +84,7 @@
 #include "client.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "msg.h"
@@ -92,7 +93,7 @@
 #include "s_user.h"
 #include "send.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <string.h>
 
 /*
@@ -124,14 +125,13 @@ static int user_set_away(struct User* user, char* message)
      */
     unsigned int len = strlen(message);
 
-    if (len > TOPICLEN) {
-      message[TOPICLEN] = '\0';
-      len = TOPICLEN;
+    if (len > AWAYLEN) {
+      message[AWAYLEN] = '\0';
+      len = AWAYLEN;
     }
     if (away)
-      away = (char*) MyRealloc(away, len + 1);
-    else
-      away = (char*) MyMalloc(len + 1);
+      MyFree(away);
+    away = (char*) MyMalloc(len + 1);
     assert(0 != away);
 
     user->away = away;
@@ -142,7 +142,7 @@ static int user_set_away(struct User* user, char* message)
 
 
 /*
- * m_away - generic message handler template
+ * m_away - generic message handler
  * - Added 14 Dec 1988 by jto.
  *
  * parv[0] = sender prefix
@@ -154,12 +154,15 @@ static int user_set_away(struct User* user, char* message)
 int m_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   char* away_message = parv[1];
+  int was_away = cli_user(sptr)->away != 0;
 
   assert(0 != cptr);
   assert(cptr == sptr);
 
-  if (user_set_away(cli_user(sptr), away_message)) {
-    sendcmdto_serv_butone(sptr, CMD_AWAY, cptr, ":%s", away_message);
+  if (user_set_away(cli_user(sptr), away_message))
+  {
+    if (!was_away)    
+      sendcmdto_serv_butone(sptr, CMD_AWAY, cptr, ":%s", away_message);
     send_reply(sptr, RPL_NOWAWAY);
   }
   else {
@@ -170,7 +173,7 @@ int m_away(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 }
 
 /*
- * ms_away - server message handler template
+ * ms_away - server message handler
  * - Added 14 Dec 1988 by jto.
  *
  * parv[0] = sender prefix