Skip to content

Commit d04d058

Browse files
author
drscholl
committed
updated version to 0.34
removed notify_mods() from all channel specific calls. notify_ops() will now notify mods+ in the channel.
1 parent 77574c9 commit d04d058

File tree

7 files changed

+78
-111
lines changed

7 files changed

+78
-111
lines changed

channel.c

+75-95
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ HANDLER (channel_ban)
232232
pass_message_args (con, tag, ":%s %s %s%s%s%s", sender, chan->name,
233233
b->target, ac > 2 ? " \"" : "", ac > 2 ? av[2] : "",
234234
ac > 2 ? "\"" : "");
235-
notify_mods (BANLOG_MODE, "%s banned %s from %s: %s", sender, b->target,
236-
chan->name, NONULL (b->reason));
237235
notify_ops (chan, "%s banned %s from %s: %s", sender, b->target,
238236
chan->name, NONULL (b->reason));
239237
}
@@ -299,9 +297,6 @@ HANDLER (channel_unban)
299297
sender, chan->name, b->target,
300298
ac > 2 ? " \"" : "",
301299
ac > 2 ? av[2] : "", ac > 2 ? "\"" : "");
302-
notify_mods (BANLOG_MODE, "%s unbanned %s from %s: %s",
303-
sender, b->target, chan->name,
304-
(ac > 2) ? av[2] : "");
305300
notify_ops (chan, "%s unbanned %s from %s: %s",
306301
sender, b->target, chan->name, (ac > 2) ? av[2] : "");
307302
free_ban (b);
@@ -387,8 +382,6 @@ HANDLER (channel_clear_bans)
387382
}
388383
list_free (chan->bans, (list_destroy_t) free_ban);
389384
chan->bans = 0;
390-
notify_mods (BANLOG_MODE, "%s cleared the ban list on %s", sender->nick,
391-
chan->name);
392385
notify_ops (chan, "%s cleared the ban list on %s", sender->nick,
393386
chan->name);
394387
}
@@ -494,9 +487,6 @@ HANDLER (channel_op)
494487
send_cmd (user->con, MSG_SERVER_NOSUCH,
495488
"%s removed you as operator on channel %s",
496489
sender, chan->name);
497-
notify_mods (CHANGELOG_MODE,
498-
"%s removed %s as operator on channel %s",
499-
sender, user->nick, chan->name);
500490
notify_ops (chan,
501491
"%s removed %s as operator on channel %s",
502492
sender, user->nick, chan->name);
@@ -517,9 +507,6 @@ HANDLER (channel_op)
517507
send_cmd (user->con, MSG_SERVER_NOSUCH,
518508
"%s set you as operator on channel %s",
519509
sender, chan->name);
520-
notify_mods (CHANGELOG_MODE,
521-
"%s set %s as operator on channel %s",
522-
sender, user->nick, chan->name);
523510
notify_ops (chan, "%s set %s as operator on channel %s",
524511
sender, user->nick, chan->name);
525512
/* only do the following if the user is in the channel */
@@ -553,7 +540,9 @@ notify_ops (CHANNEL * chan, const char *fmt, ...)
553540
{
554541
chanUser = list->data;
555542
ASSERT (chanUser->magic == MAGIC_CHANUSER);
556-
if (ISUSER (chanUser->user->con) && (chanUser->flags & ON_OPERATOR))
543+
if (ISUSER (chanUser->user->con) &&
544+
((chanUser->flags & ON_OPERATOR) ||
545+
chanUser->user->level > LEVEL_USER))
557546
queue_data (chanUser->user->con, buf, 4 + len);
558547
}
559548
}
@@ -628,8 +617,6 @@ HANDLER (channel_drop)
628617
}
629618
pass_message_args (con, tag, ":%s %s \"%s\"", sender->nick, chan->name,
630619
(ac > 1) ? av[1] : "");
631-
notify_mods (CHANGELOG_MODE, "%s dropped channel %s: %s",
632-
sender->nick, chan->name, (ac > 1) ? av[1] : "");
633620
notify_ops (chan, "%s dropped channel %s: %s",
634621
sender->nick, chan->name, (ac > 1) ? av[1] : "");
635622

@@ -650,8 +637,6 @@ HANDLER (channel_wallop)
650637
USER *sender;
651638
CHANNEL *chan;
652639
char *chanName;
653-
LIST *list;
654-
CHANUSER *chanUser;
655640

656641
ASSERT (validate_connection (con));
657642
if (pop_user (con, &pkt, &sender))
@@ -679,28 +664,18 @@ HANDLER (channel_wallop)
679664
status otherwise, and is_chanop() will fail). mods+ are assumed to
680665
be trusted enough that the check for membership is not required. */
681666
pass_message_args (con, tag, ":%s %s %s", sender->nick, chan->name, pkt);
682-
len = form_message (Buf, sizeof (Buf), MSG_SERVER_NOSUCH,
683-
"%s [ops/%s]: %s", sender->nick, chan->name, pkt);
684-
for (list = chan->users; list; list = list->next)
685-
{
686-
chanUser = list->data;
687-
ASSERT (chanUser->magic == MAGIC_CHANUSER);
688-
if (ISUSER (chanUser->user->con) &&
689-
/* send to mods+ and ops */
690-
(chanUser->user->level > LEVEL_USER ||
691-
(chanUser->flags & ON_OPERATOR)))
692-
queue_data (chanUser->user->con, Buf, len);
693-
}
667+
notify_ops(chan, "%s [ops/%s]: %s", sender->nick, chan->name, pkt);
694668
}
695669

696670
static void
697-
add_flag(char *d, int dsize, char *flag, int bit, int onmask, int offmask)
671+
add_flag (char *d, int dsize, char *flag, int bit, int onmask, int offmask)
698672
{
699-
if((onmask & bit)||(offmask&bit))
673+
if ((onmask & bit) || (offmask & bit))
700674
{
701-
int len=strlen(d);
702-
snprintf(d+len,dsize-len,"%s%c%s", dsize>0?" ":"",
703-
(onmask&bit)?'+':'-', flag);
675+
int len = strlen (d);
676+
677+
snprintf (d + len, dsize - len, "%s%c%s", dsize > 0 ? " " : "",
678+
(onmask & bit) ? '+' : '-', flag);
704679
}
705680
}
706681

@@ -764,11 +739,13 @@ HANDLER (channel_mode)
764739
{
765740
if (ISUSER (con))
766741
send_cmd_pre (con, tag, "mode for channel ", "%s%s%s%s",
767-
chan->name,
768-
(chan->flags & ON_CHANNEL_PRIVATE) ? " +PRIVATE" : "",
769-
(chan->flags & ON_CHANNEL_MODERATED) ? " +MODERATED" : "",
770-
(chan->flags & ON_CHANNEL_INVITE) ? " +INVITE" : "",
771-
(chan->flags & ON_CHANNEL_TOPIC) ? " +TOPIC" : "");
742+
chan->name,
743+
(chan->
744+
flags & ON_CHANNEL_PRIVATE) ? " +PRIVATE" : "",
745+
(chan->
746+
flags & ON_CHANNEL_MODERATED) ? " +MODERATED" : "",
747+
(chan->flags & ON_CHANNEL_INVITE) ? " +INVITE" : "",
748+
(chan->flags & ON_CHANNEL_TOPIC) ? " +TOPIC" : "");
772749
return;
773750
}
774751
while (pkt)
@@ -826,30 +803,32 @@ HANDLER (channel_mode)
826803

827804
chan->timestamp = Current_Time;
828805
msg[0] = 0;
829-
add_flag(msg,sizeof(msg),"PRIVATE",ON_CHANNEL_PRIVATE,onmask,offmask);
830-
add_flag(msg,sizeof(msg),"MODERATED",ON_CHANNEL_MODERATED,onmask,offmask);
831-
add_flag(msg,sizeof(msg),"INVITE",ON_CHANNEL_INVITE,onmask,offmask);
832-
add_flag(msg,sizeof(msg),"TOPIC",ON_CHANNEL_TOPIC,onmask,offmask);
806+
add_flag (msg, sizeof (msg), "PRIVATE", ON_CHANNEL_PRIVATE, onmask,
807+
offmask);
808+
add_flag (msg, sizeof (msg), "MODERATED", ON_CHANNEL_MODERATED,
809+
onmask, offmask);
810+
add_flag (msg, sizeof (msg), "INVITE", ON_CHANNEL_INVITE, onmask,
811+
offmask);
812+
add_flag (msg, sizeof (msg), "TOPIC", ON_CHANNEL_TOPIC, onmask,
813+
offmask);
833814

834815
notify_ops (chan, "%s changed mode on channel %s:%s",
835816
senderName, chan->name, msg);
836-
notify_mods (CHANGELOG_MODE,
837-
"%s changed mode on channel %s:%s", senderName,
838-
chan->name, msg);
839817
pass_message_args (con, tag, ":%s %s %s", senderName,
840818
chan->name, msg);
841819
}
842820
}
843821

844822
static int
845-
is_member(CHANNEL *chan, USER *user)
823+
is_member (CHANNEL * chan, USER * user)
846824
{
847825
LIST *list;
848826
CHANUSER *chanUser;
849-
for(list=chan->users;list;list=list->next)
827+
828+
for (list = chan->users; list; list = list->next)
850829
{
851-
chanUser=list->data;
852-
if(chanUser->user==user)
830+
chanUser = list->data;
831+
if (chanUser->user == user)
853832
return 1;
854833
}
855834
return 0;
@@ -860,83 +839,84 @@ is_member(CHANNEL *chan, USER *user)
860839
HANDLER (channel_invite)
861840
{
862841
USER *sender, *user;
863-
int ac=-1;
842+
int ac = -1;
864843
char *av[2];
865844
LIST *list;
866845
CHANNEL *chan;
867846

868-
ASSERT(validate_connection(con));
869-
if(pop_user(con,&pkt,&sender))
847+
ASSERT (validate_connection (con));
848+
if (pop_user (con, &pkt, &sender))
870849
return;
871-
if(pkt)
872-
ac=split_line(av,FIELDS(av),pkt);
873-
if(ac<2)
850+
if (pkt)
851+
ac = split_line (av, FIELDS (av), pkt);
852+
if (ac < 2)
874853
{
875-
unparsable(con);
854+
unparsable (con);
876855
return;
877856
}
878-
chan=hash_lookup(Channels,av[0]);
879-
if(!chan)
857+
chan = hash_lookup (Channels, av[0]);
858+
if (!chan)
880859
{
881-
nosuchchannel(con);
860+
nosuchchannel (con);
882861
return;
883862
}
884-
if(!(chan->flags&ON_CHANNEL_INVITE))
863+
if (!(chan->flags & ON_CHANNEL_INVITE))
885864
{
886-
if(ISUSER(con))
887-
send_cmd(con,MSG_SERVER_NOSUCH,"channel is not invite only");
865+
if (ISUSER (con))
866+
send_cmd (con, MSG_SERVER_NOSUCH, "channel is not invite only");
888867
return;
889868
}
890869
/* ensure this user meets the minimum level requirements */
891-
if(sender->level<chan->level)
870+
if (sender->level < chan->level)
892871
{
893-
permission_denied(con);
872+
permission_denied (con);
894873
return;
895874
}
896875
/*ensure the user is on this channel */
897-
if(!is_member(chan,sender))
876+
if (!is_member (chan, sender))
898877
{
899-
permission_denied(con);
900-
return;
901-
}
902-
user=hash_lookup(Users,av[1]);
903-
if(!user)
904-
{
905-
nosuchuser(con);
878+
permission_denied (con);
906879
return;
907880
}
908-
if(is_member(chan,user))
881+
user = hash_lookup (Users, av[1]);
882+
if (!user)
909883
{
910-
if(ISUSER(con))
911-
send_cmd(con,MSG_SERVER_NOSUCH,"user is already in channel");
884+
nosuchuser (con);
912885
return;
913886
}
914-
/*ensure the user is not already invited*/
915-
if(list_find(user->invited,chan))
887+
if (is_member (chan, user))
916888
{
917-
if(ISUSER(con))
918-
send_cmd(con,MSG_SERVER_NOSUCH,"user is already invited");
889+
if (ISUSER (con))
890+
send_cmd (con, MSG_SERVER_NOSUCH, "user is already in channel");
919891
return;
920892
}
893+
/*ensure the user is not already invited */
894+
if (list_find (user->invited, chan))
895+
return; /* already invited */
921896

922-
list=CALLOC(1,sizeof(LIST));
923-
list->data=chan;
924-
list->next=user->invited;
925-
user->invited=list;
897+
list = CALLOC (1, sizeof (LIST));
898+
list->data = chan;
899+
list->next = user->invited;
900+
user->invited = list;
926901

927-
list=CALLOC(1,sizeof(LIST));
928-
list->data=user;
929-
list->next=chan->invited;
930-
chan->invited=list;
902+
list = CALLOC (1, sizeof (LIST));
903+
list->data = user;
904+
list->next = chan->invited;
905+
chan->invited = list;
931906

932-
pass_message_args(con,tag,":%s %s %s",sender->nick,chan->name,user->nick);
907+
pass_message_args (con, tag, ":%s %s %s", sender->nick, chan->name,
908+
user->nick);
933909

934-
if(ISUSER(user->con))
910+
if (ISUSER (user->con))
935911
{
936-
if(user->con->numerics)
937-
send_cmd(user->con,tag,"%s %s",chan->name,sender->nick);
912+
if (user->con->numerics)
913+
send_cmd (user->con, tag, "%s %s", chan->name, sender->nick);
938914
else
939-
send_cmd(user->con,MSG_SERVER_NOSUCH,"%s invited you to channel %s",
940-
sender->nick, chan->name);
915+
send_cmd (user->con, MSG_SERVER_NOSUCH,
916+
"%s invited you to channel %s", sender->nick,
917+
chan->name);
941918
}
919+
920+
notify_ops(chan,"%s invited %s to channel %s",sender->nick,user->nick,
921+
chan->name);
942922
}

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fi
705705

706706
PACKAGE=opennap
707707

708-
VERSION=0.33
708+
VERSION=0.34
709709

710710
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
711711
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }

configure.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl $Id$
22
AC_INIT(opennap.h)
3-
AM_INIT_AUTOMAKE(opennap,0.33)
3+
AM_INIT_AUTOMAKE(opennap,0.34)
44
AM_MAINTAINER_MODE
55
AM_PROG_CC_STDC
66
AC_HEADER_STDC

join.c

-7
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ HANDLER (join)
244244
if (!strcasecmp (user->nick, list->data))
245245
{
246246
notifyUser = 1;
247-
notify_mods (CHANGELOG_MODE,
248-
"%s set %s as operator on channel %s",
249-
Server_Name, user->nick, chan->name);
250247
notify_ops (chan, "%s set %s as operator on channel %s",
251248
Server_Name, user->nick, chan->name);
252249
chanUser->flags |= ON_OPERATOR;
@@ -403,8 +400,6 @@ HANDLER (channel_level)
403400
pass_message_args (con, tag, ":%s %s %s", sender, chan->name,
404401
Levels[level]);
405402
chan->level = level;
406-
notify_mods (CHANNELLOG_MODE, "%s set channel %s to level %s",
407-
sender, chan->name, Levels[level]);
408403
notify_ops (chan, "%s set channel %s to level %s",
409404
sender, chan->name, Levels[level]);
410405
}
@@ -500,8 +495,6 @@ HANDLER (channel_limit)
500495
chan->limit = limit;
501496
chan->timestamp = Current_Time;
502497
pass_message_args (con, tag, ":%s %s %d", sender, chan->name, limit);
503-
notify_mods (CHANNELLOG_MODE, "%s set limit on channel %s to %d",
504-
sender, chan->name, limit);
505498
notify_ops (chan, "%s set limit on channel %s to %d",
506499
sender, chan->name, limit);
507500
}

kick.c

-4
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ HANDLER (kick)
108108

109109
user->channels = list_delete (user->channels, chan);
110110

111-
notify_mods (CHANNELLOG_MODE, "%s kicked %s out of channel %s: %s",
112-
sender->nick, user->nick, chan->name, ac == 3 ? av[2] : "");
113111
notify_ops (chan, "%s kicked %s out of channel %s: %s",
114112
sender->nick, user->nick, chan->name, ac == 3 ? av[2] : "");
115113

@@ -153,8 +151,6 @@ HANDLER (clear_channel)
153151
truncate_reason(pkt);
154152
pass_message_args (con, tag, ":%s %s %s", sender->nick, chan->name,
155153
NONULL (pkt));
156-
notify_mods (CHANNELLOG_MODE, "%s cleared channel %s: %s", sender->nick,
157-
chan->name, NONULL (pkt));
158154
notify_ops (chan, "%s cleared channel %s: %s", sender->nick,
159155
chan->name, NONULL (pkt));
160156
list = chan->users;

opennap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ typedef unsigned int socklen_t;
866866

867867
#define SHAREDIR "/opennap"
868868
#define PACKAGE "opennap"
869-
#define VERSION "0.33"
869+
#define VERSION "0.34"
870870

871871
#define strcasecmp stricmp
872872
#define strncasecmp strnicmp

topic.c

-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ HANDLER (topic)
110110
if (chanUser->user->local)
111111
queue_data (chanUser->user->con, Buf, l);
112112
}
113-
notify_mods (TOPICLOG_MODE, "%s set topic on %s: %s", nick,
114-
chan->name, chan->topic);
115113
notify_ops (chan, "%s set topic on %s: %s", nick,
116114
chan->name, chan->topic);
117115
}

0 commit comments

Comments
 (0)