X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc-mode.c;h=75f99d9eb7b465a2a8ca907823500e563be658b1;hb=fa7bb279;hp=d83355690b86f8e1b6d1ff3f1c97539376abd3ef;hpb=8adff5922376676c2eeb49de1cbab86cc345b887;p=ngircd-alex.git diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index d8335569..75f99d9e 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-mode.c,v 1.40 2005/03/19 18:43:48 fw Exp $"; +static char UNUSED id[] = "$Id: irc-mode.c,v 1.48 2006/12/07 17:57:20 fw Exp $"; #include "imp.h" #include @@ -22,10 +22,10 @@ static char UNUSED id[] = "$Id: irc-mode.c,v 1.40 2005/03/19 18:43:48 fw Exp $"; #include #include +#include "defines.h" #include "conn.h" #include "client.h" #include "channel.h" -#include "defines.h" #include "irc-write.h" #include "lists.h" #include "log.h" @@ -38,16 +38,16 @@ static char UNUSED id[] = "$Id: irc-mode.c,v 1.40 2005/03/19 18:43:48 fw Exp $"; #include "irc-mode.h" -LOCAL bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )); -LOCAL bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )); +static bool Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )); +static bool Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )); -LOCAL bool Add_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); -LOCAL bool Add_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); +static bool Add_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); +static bool Add_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); -LOCAL bool Del_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); -LOCAL bool Del_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); +static bool Del_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); +static bool Del_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern )); -LOCAL bool Send_ListChange PARAMS(( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Mask )); +static bool Send_ListChange PARAMS(( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Mask )); GLOBAL bool @@ -69,21 +69,26 @@ IRC_MODE( CLIENT *Client, REQUEST *Req ) if( ! origin ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); } else origin = Client; - + /* Channel or user mode? */ - cl = chan = NULL; - if( Client_IsValidNick( Req->argv[0] )) cl = Client_Search( Req->argv[0] ); - if( Channel_IsValidName( Req->argv[0] )) chan = Channel_Search( Req->argv[0] ); + cl = NULL; chan = NULL; + if (Client_IsValidNick(Req->argv[0])) + cl = Client_Search(Req->argv[0]); + if (Channel_IsValidName(Req->argv[0])) + chan = Channel_Search(Req->argv[0]); - if( cl ) return Client_Mode( Client, Req, origin, cl ); - if( chan ) return Channel_Mode( Client, Req, origin, chan ); + if (cl) + return Client_Mode(Client, Req, origin, cl); + if (chan) + return Channel_Mode(Client, Req, origin, chan); /* No target found! */ - return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] ); + return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, + Client_ID(Client), Req->argv[0]); } /* IRC_MODE */ -LOCAL bool +static bool Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ) { /* Handle client mode requests */ @@ -166,7 +171,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ) if( Client_Type( Client ) == CLIENT_SERVER ) { x[0] = 'a'; - Client_SetAway( Client, DEFAULT_AWAY_MSG ); + Client_SetAway( Origin, DEFAULT_AWAY_MSG ); } else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin )); break; @@ -236,7 +241,7 @@ client_exit: } /* Client_Mode */ -LOCAL bool +static bool Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) { /* Handle channel and channel-user modes */ @@ -257,13 +262,13 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) /* The sender is a member: generate extended reply */ strlcpy( the_modes, Channel_Modes( Channel ), sizeof( the_modes )); mode_ptr = the_modes; - strcpy( the_args, "" ); + the_args[0] = '\0'; while( *mode_ptr ) { switch( *mode_ptr ) { case 'l': - snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel )); + snprintf( argadd, sizeof( argadd ), " %lu", Channel_MaxUsers( Channel )); strlcat( the_args, argadd, sizeof( the_args )); break; case 'k': @@ -472,7 +477,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) Req->argv[arg_arg][0] = '\0'; arg_arg++; } - else Lists_ShowInvites( Origin, Channel ); + else Channel_ShowInvites( Origin, Channel ); break; case 'b': /* Ban lists */ @@ -488,7 +493,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) Req->argv[arg_arg][0] = '\0'; arg_arg++; } - else Lists_ShowBans( Origin, Channel ); + else Channel_ShowBans( Origin, Channel ); break; default: @@ -627,7 +632,7 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req ) } /* IRC_AWAY */ -LOCAL bool +static bool Add_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) { char *mask; @@ -639,17 +644,19 @@ Add_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) mask = Lists_MakeMask( Pattern ); - already = Lists_IsInviteEntry( mask, Channel ); - - if( ! Lists_AddInvited( mask, Channel, false )) return CONNECTED; - - if(( Client_Type( Prefix ) == CLIENT_SERVER ) && ( already == true)) return CONNECTED; + already = Lists_CheckDupeMask(Channel_GetListInvites(Channel), mask ); + if (!already) { + if( ! Channel_AddInvite(Channel, mask, false )) + return CONNECTED; + } + if ( already && ( Client_Type( Prefix ) == CLIENT_SERVER )) + return CONNECTED; return Send_ListChange( "+I", Prefix, Client, Channel, mask ); } /* Add_Invite */ -LOCAL bool +static bool Add_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) { char *mask; @@ -661,17 +668,19 @@ Add_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) mask = Lists_MakeMask( Pattern ); - already = Lists_IsBanEntry( mask, Channel ); - - if( ! Lists_AddBanned( mask, Channel )) return CONNECTED; - - if(( Client_Type( Prefix ) == CLIENT_SERVER ) && ( already == true)) return CONNECTED; + already = Lists_CheckDupeMask(Channel_GetListBans(Channel), mask ); + if (!already) { + if( ! Channel_AddBan(Channel, mask)) + return CONNECTED; + } + if ( already && ( Client_Type( Prefix ) == CLIENT_SERVER )) + return CONNECTED; return Send_ListChange( "+b", Prefix, Client, Channel, mask ); } /* Add_Ban */ -LOCAL bool +static bool Del_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) { char *mask; @@ -681,12 +690,12 @@ Del_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) assert( Pattern != NULL ); mask = Lists_MakeMask( Pattern ); - Lists_DelInvited( mask, Channel ); + Lists_Del(Channel_GetListInvites(Channel), mask); return Send_ListChange( "-I", Prefix, Client, Channel, mask ); } /* Del_Invite */ -LOCAL bool +static bool Del_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) { char *mask; @@ -696,12 +705,12 @@ Del_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Pattern ) assert( Pattern != NULL ); mask = Lists_MakeMask( Pattern ); - Lists_DelBanned( mask, Channel ); + Lists_Del(Channel_GetListBans(Channel), mask); return Send_ListChange( "-b", Prefix, Client, Channel, mask ); } /* Del_Ban */ -LOCAL bool +static bool Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, char *Mask ) { /* Bestaetigung an Client schicken & andere Server sowie Channel-User informieren */