#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"
#include "s_user.h"
#include "send.h"
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
+#include <string.h>
/*
* user_set_away - set user away state
*/
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;
/*
- * m_away - generic message handler template
+ * m_away - generic message handler
* - Added 14 Dec 1988 by jto.
*
* parv[0] = sender prefix
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 {
}
/*
- * ms_away - server message handler template
+ * ms_away - server message handler
* - Added 14 Dec 1988 by jto.
*
* parv[0] = sender prefix