X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=ircd%2Fm_away.c;h=ef440c19ab37a54009864dd76bdbbcf0cc5c897c;hb=refs%2Fheads%2Fupstream-ssl;hp=cf4efe0babb42dce7ed65746eab5daa90e425255;hpb=56f512008e81aeae915b2b7f6bcdd54b549188d3;p=ircu2.10.12-pk.git diff --git a/ircd/m_away.c b/ircd/m_away.c index cf4efe0..ef440c1 100644 --- a/ircd/m_away.c +++ b/ircd/m_away.c @@ -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,8 @@ #include "s_user.h" #include "send.h" -#include +/* #include -- Now using assert in ircd_log.h */ +#include /* * user_set_away - set user away state @@ -123,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; @@ -141,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 @@ -153,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 { @@ -169,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