From: Kevin L. Mitchell Date: Mon, 27 Mar 2000 16:15:06 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=0c1a20913f8d51518101e52866fe5c79f87c36bb;p=ircu2.10.12-pk.git Author: Kev Log message: Some more options in modebuf_flush(); add the skeleton for CLEARMODE and OPMODE git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@75 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index 8a5157e..4b9630d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,29 @@ 2000-03-27 Kevin L. Mitchell + * ircd/m_clearmode.c: define skeleton for m{o,s}_clearmode + + * ircd/m_opmode.c: define skeleton for m{o,s}_opmode + + * ircd/Makefile.in (SRC): added m_opmode() and m_clearmode() to + the list + + * ircd/parse.c: added messages for opmode and clearmode + + * include/handlers.h: added declarations for mo_opmode(), + ms_opmode(), mo_clearmode(), and ms_clearmode() + + * include/msg.h: define MSG_OPMODE, TOK_OPMODE, MSG_CLEARMODE, and + TOK_CLEARMODE + + * include/channel.h (MODEBUF_DEST_OPMODE): Define the + MODEBUF_DEST_OPMODE flag + + * ircd/channel.c (modebuf_flush): added new flag, + MODEBUF_DEST_OPMODE; causes channel MODE/HACK(4) notice to appear + to originate from source's server (or source itself, if + IsServer(source)); also causes a server-level MODE to be sent as + OPMODE instead + * include/channel.h: defined MODEBUF_DEST_SERVER, MODEBUF_DEST_HACK4 @@ -24,7 +48,7 @@ # # ChangeLog for ircu2.10.11 # -# $Id: ChangeLog,v 1.25 2000-03-27 15:36:41 kev Exp $ +# $Id: ChangeLog,v 1.26 2000-03-27 16:15:06 kev Exp $ # # Insert new changes at beginning of the change list. # diff --git a/include/channel.h b/include/channel.h index 53a34ea..a75b576 100644 --- a/include/channel.h +++ b/include/channel.h @@ -253,6 +253,7 @@ struct ModeBuf { #define MODEBUF_DEST_CHANNEL 0x01 /* Mode is flushed to channel */ #define MODEBUF_DEST_SERVER 0x02 /* Mode is flushed to server */ +#define MODEBUF_DEST_OPMODE 0x40 /* Send server mode as OPMODE */ #define MODEBUF_DEST_HACK4 0x80 /* Send a HACK(4) notice and, on server sends, use a TS of 0 */ diff --git a/include/handlers.h b/include/handlers.h index dac14ed..7a4c4d0 100644 --- a/include/handlers.h +++ b/include/handlers.h @@ -132,6 +132,7 @@ extern int m_wallchops(struct Client*, struct Client*, int, char*[]); extern int m_who(struct Client*, struct Client*, int, char*[]); extern int m_whois(struct Client*, struct Client*, int, char*[]); extern int m_whowas(struct Client*, struct Client*, int, char*[]); +extern int mo_clearmode(struct Client*, struct Client*, int, char*[]); extern int mo_close(struct Client*, struct Client*, int, char*[]); extern int mo_connect(struct Client*, struct Client*, int, char*[]); extern int mo_die(struct Client*, struct Client*, int, char*[]); @@ -141,6 +142,7 @@ extern int mo_jupe(struct Client*, struct Client*, int, char*[]); extern int mo_kill(struct Client*, struct Client*, int, char*[]); extern int mo_notice(struct Client*, struct Client*, int, char*[]); extern int mo_oper(struct Client*, struct Client*, int, char*[]); +extern int mo_opmode(struct Client*, struct Client*, int, char*[]); extern int mo_privmsg(struct Client*, struct Client*, int, char*[]); extern int mo_rehash(struct Client*, struct Client*, int, char*[]); extern int mo_restart(struct Client*, struct Client*, int, char*[]); @@ -157,6 +159,7 @@ extern int mr_server(struct Client*, struct Client*, int, char*[]); extern int ms_admin(struct Client*, struct Client*, int, char*[]); extern int ms_away(struct Client*, struct Client*, int, char*[]); extern int ms_burst(struct Client*, struct Client*, int, char*[]); +extern int ms_clearmode(struct Client*, struct Client*, int, char*[]); extern int ms_connect(struct Client*, struct Client*, int, char*[]); extern int ms_create(struct Client*, struct Client*, int, char*[]); extern int ms_destruct(struct Client*, struct Client*, int, char*[]); @@ -179,6 +182,7 @@ extern int ms_names(struct Client*, struct Client*, int, char*[]); extern int ms_nick(struct Client*, struct Client*, int, char*[]); extern int ms_notice(struct Client*, struct Client*, int, char*[]); extern int ms_oper(struct Client*, struct Client*, int, char*[]); +extern int ms_opmode(struct Client*, struct Client*, int, char*[]); extern int ms_part(struct Client*, struct Client*, int, char*[]); extern int ms_ping(struct Client*, struct Client*, int, char*[]); extern int ms_pong(struct Client*, struct Client*, int, char*[]); diff --git a/include/msg.h b/include/msg.h index 1941d2e..70a39f5 100644 --- a/include/msg.h +++ b/include/msg.h @@ -247,6 +247,12 @@ struct Client; #define MSG_JUPE "JUPE" /* JUPE */ #define TOK_JUPE "JU" +#define MSG_OPMODE "OPMODE" /* OPMO */ +#define TOK_OPMODE "OM" + +#define MSG_CLEARMODE "CLEARMODE" /* CLMO */ +#define TOK_CLEARMODE "CM" + /* * Constants diff --git a/ircd/Makefile.in b/ircd/Makefile.in index a5e52c1..a492869 100644 --- a/ircd/Makefile.in +++ b/ircd/Makefile.in @@ -84,6 +84,7 @@ SRC = \ m_admin.c \ m_away.c \ m_burst.c \ + m_clearmode.c \ m_close.c \ m_connect.c \ m_cprivmsg.c \ @@ -113,6 +114,7 @@ SRC = \ m_nick.c \ m_notice.c \ m_oper.c \ + m_opmode.c \ m_part.c \ m_pass.c \ m_ping.c \ diff --git a/ircd/channel.c b/ircd/channel.c index c842285..e4475f4 100644 --- a/ircd/channel.c +++ b/ircd/channel.c @@ -2775,6 +2775,8 @@ modebuf_flush(struct ModeBuf *mbuf) int i; int *flag_p; + struct Client *app_source; + char addbuf[20] = "+"; int addbuf_i = 1; char rembuf[20] = "-"; @@ -2793,6 +2795,11 @@ modebuf_flush(struct ModeBuf *mbuf) assert(0 != mbuf); + if (mbuf->mb_dest & MODEBUF_DEST_OPMODE && !IsServer(mbuf->mb_source)) + app_source = mbuf->mb_source->from; + else + app_source = mbuf->mb_source; + for (flag_p = flags; flag_p[0]; flag_p += 2) { if (*flag_p & mbuf->mb_add) addbuf[addbuf_i++] = flag_p[1]; @@ -2853,13 +2860,13 @@ modebuf_flush(struct ModeBuf *mbuf) } if (mbuf->mb_dest & MODEBUF_DEST_CHANNEL) - sendto_channel_butserv(mbuf->mb_channel, mbuf->mb_source, - ":%s MODE %s %s%s%s%s", mbuf->mb_source->name, + sendto_channel_butserv(mbuf->mb_channel, app_source, + ":%s MODE %s %s%s%s%s", app_source->name, mbuf->mb_channel->chname, addbuf, rembuf, addstr, remstr); if (mbuf->mb_dest & MODEBUF_DEST_HACK4) sendto_op_mask(SNO_HACK4, "HACK(4): %s MODE %s %s%s%s%s [" TIME_T_FMT - "]", mbuf->mb_source->name, mbuf->mb_channel->chname, + "]", app_source->name, mbuf->mb_channel->chname, addbuf, rembuf, addstr, remstr, mbuf->mb_channel->creationtime); } @@ -2887,18 +2894,29 @@ modebuf_flush(struct ModeBuf *mbuf) build_string(strptr, strptr_i, limitbuf, 0); } - if (IsServer(mbuf->mb_source)) - sendto_all_butone(mbuf->mb_connect, "%s " TOK_MODE " %s %s%s%s%s " - TIME_T_FMT, NumServ(mbuf->mb_source), - mbuf->mb_channel->chname, addbuf, rembuf, addstr, - remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 : - mbuf->mb_channel->creationtime); - else - sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_MODE " %s %s%s%s%s " - TIME_T_FMT, NumNick(mbuf->mb_source), - mbuf->mb_channel->chname, addbuf, rembuf, addstr, - remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 : - mbuf->mb_channel->creationtime); + if (mbuf->mb_dest & MODEBUF_DEST_OPMODE) { + if (IsServer(mbuf->mb_source)) + sendto_all_butone(mbuf->mb_connect, "%s " TOK_OPMODE " %s %s%s%s%s", + NumServ(mbuf->mb_source), mbuf->mb_channel->chname, + addbuf, rembuf, addstr, remstr); + else + sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_OPMODE " %s %s%s%s%s", + NumNick(mbuf->mb_source), mbuf->mb_channel->chname, + addbuf, rembuf, addstr, remstr); + } else { + if (IsServer(mbuf->mb_source)) + sendto_all_butone(mbuf->mb_connect, "%s " TOK_MODE " %s %s%s%s%s " + TIME_T_FMT, NumServ(mbuf->mb_source), + mbuf->mb_channel->chname, addbuf, rembuf, addstr, + remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 : + mbuf->mb_channel->creationtime); + else + sendto_all_butone(mbuf->mb_connect, "%s%s " TOK_MODE " %s %s%s%s%s " + TIME_T_FMT, NumNick(mbuf->mb_source), + mbuf->mb_channel->chname, addbuf, rembuf, addstr, + remstr, (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 : + mbuf->mb_channel->creationtime); + } } mbuf->mb_add = 0; diff --git a/ircd/m_clearmode.c b/ircd/m_clearmode.c new file mode 100644 index 0000000..0f734e0 --- /dev/null +++ b/ircd/m_clearmode.c @@ -0,0 +1,119 @@ +/* + * IRC - Internet Relay Chat, ircd/m_tmpl.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#if 0 +/* + * No need to include handlers.h here the signatures must match + * and we don't need to force a rebuild of all the handlers everytime + * we add a new one to the list. --Bleep + */ +#include "handlers.h" +#endif /* 0 */ +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "numeric.h" +#include "numnicks.h" +#include "send.h" + +#include + +/* + * ms_clearmode - server message handler + */ +int ms_clearmode(struct Client* cptr, struct Client* sptr, int parc, + char* parv[]) +{ + return 0; +} + +/* + * mo_clearmode - oper message handler + */ +int mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, + char* parv[]) +{ + return 0; +} + diff --git a/ircd/m_opmode.c b/ircd/m_opmode.c new file mode 100644 index 0000000..e051b42 --- /dev/null +++ b/ircd/m_opmode.c @@ -0,0 +1,117 @@ +/* + * IRC - Internet Relay Chat, ircd/m_tmpl.c + * Copyright (C) 1990 Jarkko Oikarinen and + * University of Oulu, Computing Center + * Copyright (C) 2000 Kevin L. Mitchell + * + * See file AUTHORS in IRC package for additional names of + * the programmers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 1, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +/* + * m_functions execute protocol messages on this server: + * + * cptr is always NON-NULL, pointing to a *LOCAL* client + * structure (with an open socket connected!). This + * identifies the physical socket where the message + * originated (or which caused the m_function to be + * executed--some m_functions may call others...). + * + * sptr is the source of the message, defined by the + * prefix part of the message if present. If not + * or prefix not found, then sptr==cptr. + * + * (!IsServer(cptr)) => (cptr == sptr), because + * prefixes are taken *only* from servers... + * + * (IsServer(cptr)) + * (sptr == cptr) => the message didn't + * have the prefix. + * + * (sptr != cptr && IsServer(sptr) means + * the prefix specified servername. (?) + * + * (sptr != cptr && !IsServer(sptr) means + * that message originated from a remote + * user (not local). + * + * combining + * + * (!IsServer(sptr)) means that, sptr can safely + * taken as defining the target structure of the + * message in this server. + * + * *Always* true (if 'parse' and others are working correct): + * + * 1) sptr->from == cptr (note: cptr->from == cptr) + * + * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr + * *cannot* be a local connection, unless it's + * actually cptr!). [MyConnect(x) should probably + * be defined as (x == x->from) --msa ] + * + * parc number of variable parameter strings (if zero, + * parv is allowed to be NULL) + * + * parv a NULL terminated list of parameter pointers, + * + * parv[0], sender (prefix string), if not present + * this points to an empty string. + * parv[1]...parv[parc-1] + * pointers to additional parameters + * parv[parc] == NULL, *always* + * + * note: it is guaranteed that parv[0]..parv[parc-1] are all + * non-NULL pointers. + */ +#if 0 +/* + * No need to include handlers.h here the signatures must match + * and we don't need to force a rebuild of all the handlers everytime + * we add a new one to the list. --Bleep + */ +#include "handlers.h" +#endif /* 0 */ +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_reply.h" +#include "ircd_string.h" +#include "numeric.h" +#include "numnicks.h" +#include "send.h" + +#include + +/* + * ms_opmode - server message handler + */ +int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + return 0; +} + +/* + * mo_opmode - oper message handler + */ +int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + return 0; +} + diff --git a/ircd/parse.c b/ircd/parse.c index a3b59ed..3654e40 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -446,6 +446,20 @@ struct Message msgtab[] = { /* UNREG, CLIENT, SERVER, OPER, SERVICE */ { m_unregistered, m_jupe, ms_jupe, mo_jupe, m_ignore } }, + { + MSG_OPMODE, + TOK_OPMODE, + 0, MAXPARA, MFLG_SLOW, 0, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_unregistered, m_not_oper, ms_opmode, mo_opmode, m_ignore } + }, + { + MSG_CLEARMODE, + TOK_CLEARMODE, + 0, MAXPARA, MFLG_SLOW, 0, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_unregistered, m_not_oper, ms_clearmode, mo_clearmode, m_ignore } + }, { MSG_UPING, TOK_UPING,