From: Kevin L. Mitchell Date: Thu, 20 Apr 2000 03:09:35 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=88a44236c3b3bea079efb3f4304e178b7265b01f;p=ircu2.10.12-pk.git Author: Kev Log message: * ircd/send.c: define sendcmdto_channel_butone, wrote a simplified vsendto_op_mask that uses '*' instead of the receiving client nickname * include/send.h: declare sendcmdto_channel_butone; takes a skip argument that allows you to skip (or not to skip) deaf users, users behind bursting servers, and non channel operators git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@190 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 3961f53..007b992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-04-19 Kevin L. Mitchell + + * ircd/send.c: define sendcmdto_channel_butone, wrote a simplified + vsendto_op_mask that uses '*' instead of the receiving client + nickname + + * include/send.h: declare sendcmdto_channel_butone; takes a skip + argument that allows you to skip (or not to skip) deaf users, + users behind bursting servers, and non channel operators + 2000-04-17 Kevin L. Mitchell * ircd/send.c: new sendcmdto_channel_butserv -- note that old @@ -618,7 +628,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.95 2000-04-17 20:41:57 kev Exp $ +# $Id: ChangeLog,v 1.96 2000-04-20 03:09:35 kev Exp $ # # Insert new changes at beginning of the change list. # diff --git a/include/send.h b/include/send.h index 7e9afa5..8ba0db7 100644 --- a/include/send.h +++ b/include/send.h @@ -81,5 +81,13 @@ extern void sendcmdto_common_channels(struct Client *cptr, const char *cmd, extern void sendcmdto_channel_butserv(struct Channel *chan, const char *cmd, const char *tok, struct Client *from, const char *pattern, ...); +extern void sendcmdto_channel_butone(struct Client *one, struct Channel *chan, + const char *cmd, const char *tok, + struct Client *from, unsigned int skip, + const char *pattern, ...); + +#define SKIP_DEAF 0x01 /* skip users that are +d */ +#define SKIP_BURST 0x02 /* skip users that are bursting */ +#define SKIP_NONOPS 0x04 /* skip users that aren't chanops */ #endif /* INCLUDED_send_h */ diff --git a/ircd/send.c b/ircd/send.c index 9561db3..33b3065 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -458,6 +458,58 @@ void sendmsgto_channel_butone(struct Client *one, struct Client *from, } /* of for(members) */ } +void sendcmdto_channel_butone(struct Client *one, struct Channel *chan, + const char *cmd, const char *tok, + struct Client *from, unsigned int skip, + const char *pattern, ...) +{ + struct Membership *member; + struct VarData vd; + char userbuf[IRC_BUFSIZE]; + char servbuf[IRC_BUFSIZE]; + + vd.vd_format = pattern; + + /* Build buffer to send to users */ + va_start(vd.vd_args, pattern); + if (IsServer(from) || IsMe(from)) + ircd_snprintf(from, userbuf, sizeof(userbuf) - 2, ":%s %s %v", from->name, + cmd, &vd); + else + ircd_snprintf(from, userbuf, sizeof(userbuf) - 2, ":%s!%s@%s %s %v", + from->name, from->user->username, from->user->host, cmd, + &vd); + va_end(vd.vd_args); + + /* Build buffer to send to servers */ + va_start(vd.vd_args, pattern); + ircd_snprintf(from, servbuf, sizeof(servbuf) - 2, "%C %s %v", from, tok, + &vd); + va_end(vd.vd_args); + + /* send buffer along! */ + sentalong_marker++; + for (member = chan->members; member; member = member->next_member) { + /* skip one, zombies, and deaf users... */ + if (member->user->from == one || IsZombie(member) || + (skip & SKIP_DEAF && IsDeaf(member->user)) || + (skip & SKIP_NONOPS && !IsChanOp(member))) + continue; + + if (MyConnect(member->user)) + send_buffer(member->user, userbuf); /* send user buffer */ + else if (-1 < member->user->from->fd && + sentalong[member->user->from->fd] != sentalong_marker) { + sentalong[member->user->from->fd] = sentalong_marker; + + if (skip & SKIP_BURST && IsBurstOrBurstAck(member->user->from)) + continue; /* skip bursting servers */ + + send_buffer(member->user->from, servbuf); /* send server buffer */ + } + } +} + void sendto_lchanops_butone(struct Client *one, struct Client *from, struct Channel *chptr, const char* pattern, ...) { @@ -878,6 +930,7 @@ void sendto_lops_butone(struct Client* one, const char* pattern, ...) * Don't try to send to more than one list! That is not supported. * Xorath 5/1/97 */ +#ifdef OLD_VSENDTO_OP_MASK void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl) { static char fmt[1024]; @@ -901,6 +954,33 @@ void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl) } while (opslist); } +#else /* !OLD_VSENDTO_OP_MASK */ +void vsendto_op_mask(unsigned int mask, const char *pattern, va_list vl) +{ + struct VarData vd; + char sndbuf[IRC_BUFSIZE]; + int i = 0; /* so that 1 points to opsarray[0] */ + struct SLink *opslist; + + while ((mask >>= 1)) + i++; + + if (!(opslist = opsarray[i])) + return; + + /* + * build string; I don't want to bother with client nicknames, so I hope + * this is ok... + */ + vd.vd_format = pattern; + vd.vd_args = vl; + ircd_snprintf(0, sndbuf, sizeof(sndbuf) - 2, ":%s " MSG_NOTICE + " * :*** Notice -- %v", me.name, &vd); + + for (; opslist; opslist = opslist->next) + send_buffer(opslist->value.cptr, sndbuf); +} +#endif /* OLD_VSENDTO_OP_MASK */ /* * sendbufto_op_mask