From 583f064fef96ab1f30817a313a2fe9c080894f07 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 19 Nov 2015 22:43:45 -0600 Subject: [PATCH] send: add negation argument to sendto_common_channels_local() and friends --- include/send.h | 4 ++-- modules/core/m_nick.c | 4 ++-- modules/m_away.c | 4 ++-- modules/m_services.c | 4 ++-- src/client.c | 4 ++-- src/s_user.c | 6 +++--- src/send.c | 12 ++++++++---- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/include/send.h b/include/send.h index 5b1a0772..08a33626 100644 --- a/include/send.h +++ b/include/send.h @@ -68,8 +68,8 @@ extern void sendto_channel_local_with_capability(int type, int caps, int negcaps extern void sendto_channel_local_with_capability_butone(struct Client *, int type, int caps, int negcaps, struct Channel *, const char *, ...) AFP(6, 7); -extern void sendto_common_channels_local(struct Client *, int cap, const char *, ...) AFP(3, 4); -extern void sendto_common_channels_local_butone(struct Client *, int cap, const char *, ...) AFP(3, 4); +extern void sendto_common_channels_local(struct Client *, int cap, int negcap, const char *, ...) AFP(4, 5); +extern void sendto_common_channels_local_butone(struct Client *, int cap, int negcap, const char *, ...) AFP(4, 5); extern void sendto_match_butone(struct Client *, struct Client *, diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index 56f047f9..ff0878b4 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -712,7 +712,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p, source_p->name, nick, source_p->username, source_p->host); /* send the nick change to the users channels */ - sendto_common_channels_local(source_p, NOCAPS, ":%s!%s@%s NICK :%s", + sendto_common_channels_local(source_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s", source_p->name, source_p->username, source_p->host, nick); /* send the nick change to servers.. */ @@ -773,7 +773,7 @@ change_remote_nick(struct Client *client_p, struct Client *source_p, monitor_signoff(source_p); } - sendto_common_channels_local(source_p, NOCAPS, ":%s!%s@%s NICK :%s", + sendto_common_channels_local(source_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s", source_p->name, source_p->username, source_p->host, nick); if(source_p->user) diff --git a/modules/m_away.c b/modules/m_away.c index 27cdac9c..60680e52 100644 --- a/modules/m_away.c +++ b/modules/m_away.c @@ -85,7 +85,7 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p ":%s AWAY", use_id(source_p)); free_away(source_p); - sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY", + sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY", source_p->name, source_p->username, source_p->host); } if(MyConnect(source_p)) @@ -119,7 +119,7 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s AWAY :%s", use_id(source_p), source_p->user->away); sendto_common_channels_local_butone(source_p, - CLICAP_AWAY_NOTIFY, + CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY :%s", source_p->name, source_p->username, diff --git a/modules/m_services.c b/modules/m_services.c index 24878ad1..8355b153 100644 --- a/modules/m_services.c +++ b/modules/m_services.c @@ -134,7 +134,7 @@ me_su(struct Client *client_p, struct Client *source_p, else rb_strlcpy(target_p->user->suser, parv[2], sizeof(target_p->user->suser)); - sendto_common_channels_local_butone(target_p, CLICAP_ACCOUNT_NOTIFY, ":%s!%s@%s ACCOUNT %s", + sendto_common_channels_local_butone(target_p, CLICAP_ACCOUNT_NOTIFY, NOCAPS, ":%s!%s@%s ACCOUNT %s", target_p->name, target_p->username, target_p->host, EmptyString(target_p->user->suser) ? "*" : target_p->user->suser); @@ -258,7 +258,7 @@ doit: target_p->name, parv[2], target_p->username, target_p->host); - sendto_common_channels_local(target_p, NOCAPS, ":%s!%s@%s NICK :%s", + sendto_common_channels_local(target_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s", target_p->name, target_p->username, target_p->host, parv[2]); diff --git a/src/client.c b/src/client.c index 4edfe35b..b5765046 100644 --- a/src/client.c +++ b/src/client.c @@ -666,7 +666,7 @@ resv_nick_fnc(const char *mask, const char *reason, int temp_time) invalidate_bancache_user(client_p); - sendto_common_channels_local(client_p, NOCAPS, ":%s!%s@%s NICK :%s", + sendto_common_channels_local(client_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s", client_p->name, client_p->username, client_p->host, nick); sendto_server(client_p, NULL, CAP_TS6, NOCAPS, ":%s NICK %s :%ld", use_id(client_p), nick, (long) client_p->tsinfo); @@ -1185,7 +1185,7 @@ exit_generic_client(struct Client *client_p, struct Client *source_p, struct Cli if(IsOper(source_p)) rb_dlinkFindDestroy(source_p, &oper_list); - sendto_common_channels_local(source_p, NOCAPS, ":%s!%s@%s QUIT :%s", + sendto_common_channels_local(source_p, NOCAPS, NOCAPS, ":%s!%s@%s QUIT :%s", source_p->name, source_p->username, source_p->host, comment); diff --git a/src/s_user.c b/src/s_user.c index f75b73a7..e380f66d 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1431,7 +1431,7 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use vsnprintf(reason, 255, format, ap); va_end(ap); - sendto_common_channels_local_butone(target_p, NOCAPS, ":%s!%s@%s QUIT :%s", + sendto_common_channels_local_butone(target_p, NOCAPS, NOCAPS, ":%s!%s@%s QUIT :%s", target_p->name, target_p->username, target_p->host, reason); @@ -1474,7 +1474,7 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use /* Resend away message to away-notify enabled clients. */ if (target_p->user->away) - sendto_common_channels_local_butone(target_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s", + sendto_common_channels_local_butone(target_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY :%s", nick, user, host, target_p->user->away); @@ -1486,7 +1486,7 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use } else if(changed_case) { - sendto_common_channels_local(target_p, NOCAPS, ":%s!%s@%s NICK :%s", + sendto_common_channels_local(target_p, NOCAPS, NOCAPS, ":%s!%s@%s NICK :%s", target_p->name, target_p->username, target_p->host, nick); diff --git a/src/send.c b/src/send.c index cc169f1b..cb211205 100644 --- a/src/send.c +++ b/src/send.c @@ -778,6 +778,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr, * * inputs - pointer to client * - capability mask + * - negated capability mask * - pattern to send * output - NONE * side effects - Sends a message to all people on local server who are @@ -785,7 +786,7 @@ sendto_channel_local_butone(struct Client *one, int type, struct Channel *chptr, * used by m_nick.c and exit_one_client. */ void -sendto_common_channels_local(struct Client *user, int cap, const char *pattern, ...) +sendto_common_channels_local(struct Client *user, int cap, int negcap, const char *pattern, ...) { va_list args; rb_dlink_node *ptr; @@ -817,7 +818,8 @@ sendto_common_channels_local(struct Client *user, int cap, const char *pattern, if(IsIOError(target_p) || target_p->serial == current_serial || - !IsCapable(target_p, cap)) + !IsCapable(target_p, cap) || + !NotCapable(target_p, negcap)) continue; target_p->serial = current_serial; @@ -839,13 +841,14 @@ sendto_common_channels_local(struct Client *user, int cap, const char *pattern, * * inputs - pointer to client * - capability mask + * - negated capability mask * - pattern to send * output - NONE * side effects - Sends a message to all people on local server who are * in same channel with user, except for user itself. */ void -sendto_common_channels_local_butone(struct Client *user, int cap, const char *pattern, ...) +sendto_common_channels_local_butone(struct Client *user, int cap, int negcap, const char *pattern, ...) { va_list args; rb_dlink_node *ptr; @@ -879,7 +882,8 @@ sendto_common_channels_local_butone(struct Client *user, int cap, const char *pa if(IsIOError(target_p) || target_p->serial == current_serial || - !IsCapable(target_p, cap)) + !IsCapable(target_p, cap) || + !NotCapable(target_p, negcap)) continue; target_p->serial = current_serial;