fixed MODE_REGISTERED bug; introduced MCP_REGISTERED
[srvx.git] / src / proto.h
index 85f0491090ceb95e8e0a2f4e2d8cb24c75bb05fd..3b60c7221745b2cd13fad53d7295388f311a0258 100644 (file)
@@ -1,11 +1,12 @@
 /* proto.h - IRC protocol output
  * Copyright 2000-2004 srvx Development Team
  *
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of srvx.
+ *
+ * srvx 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 2 of the License, or
- * (at your option) any later version.  Important limitations are
- * listed in the COPYING file that accompanies this software.
+ * (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
@@ -13,7 +14,8 @@
  * 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, email srvx-maintainers@srvx.net.
+ * along with srvx; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
 
 #if !defined(PROTO_H)
@@ -28,6 +30,7 @@
 #define COMBO_NUMERIC_LEN 5   /* 1/2, 1/3 or 2/3 digits for server/client parts */
 #define MAXLEN         512   /* Maximum IRC line length */
 #define MAXNUMPARAMS    200
+#define ALLCHANMSG_FUNCS_MAX  4 /* +1 == 5 potential 'allchanmsg' funcs */
 
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
@@ -93,11 +96,14 @@ int parse_line(char *line, int recursive);
 /* Callback notifications for protocol support. */
 typedef void (*chanmsg_func_t) (struct userNode *user, struct chanNode *chan, char *text, struct userNode *bot);
 void reg_chanmsg_func(unsigned char prefix, struct userNode *service, chanmsg_func_t handler);
+void reg_allchanmsg_func(struct userNode *service, chanmsg_func_t handler);
 struct userNode *get_chanmsg_bot(unsigned char prefix);
 
 typedef void (*privmsg_func_t) (struct userNode *user, struct userNode *target, char *text, int server_qualified);
 void reg_privmsg_func(struct userNode *user, privmsg_func_t handler);
 void reg_notice_func(struct userNode *user, privmsg_func_t handler);
+void unreg_privmsg_func(struct userNode *user, privmsg_func_t handler);
+void unreg_notice_func(struct userNode *user, privmsg_func_t handler);
 
 typedef void (*oper_func_t) (struct userNode *user);
 void reg_oper_func(oper_func_t handler);
@@ -121,6 +127,7 @@ void irc_squit(struct server *srv, const char *message, const char *service_mess
 /* messages */
 void irc_privmsg(struct userNode *from, const char *to, const char *message);
 void irc_notice(struct userNode *from, const char *to, const char *message);
+void irc_notice_user(struct userNode *from, struct userNode *to, const char *message);
 void irc_wallchops(struct userNode *from, const char *to, const char *message);
 
 /* channel maintenance */
@@ -145,6 +152,7 @@ void irc_svsnick(struct userNode *from, struct userNode *target, const char *new
 /* account maintenance */
 void irc_account(struct userNode *user, const char *stamp);
 void irc_regnick(struct userNode *user);
+void irc_fakehost(struct userNode *user, const char *host);
 
 /* numeric messages */
 void irc_numeric(struct userNode *user, unsigned int num, const char *format, ...);
@@ -161,7 +169,7 @@ void irc_numeric(struct userNode *user, unsigned int num, const char *format, ..
 /* stuff originally from other headers that is really protocol-specific */
 int IsChannelName(const char *name);
 int is_valid_nick(const char *nick);
-struct userNode *AddService(const char *nick, const char *desc);
+struct userNode *AddService(const char *nick, const char *desc, const char *hostname);
 struct userNode *AddClone(const char *nick, const char *ident, const char *hostname, const char *desc);
 struct server* AddServer(struct server* uplink, const char *name, int hops, time_t boot, time_t link, const char *numeric, const char *description);
 void DelServer(struct server* serv, int announce, const char *message);
@@ -182,6 +190,9 @@ typedef unsigned long chan_mode_t;
 struct mod_chanmode {
     chan_mode_t modes_set, modes_clear;
     unsigned int new_limit, argc;
+#ifndef NDEBUG
+    unsigned int alloc_argc;
+#endif
     char new_key[KEYLEN + 1];
     struct {
         unsigned int mode;
@@ -194,8 +205,15 @@ struct mod_chanmode {
 #define MCP_ALLOW_OVB     0x0001 /* allow op, voice, ban manipulation */
 #define MCP_FROM_SERVER   0x0002 /* parse as from a server */
 #define MCP_KEY_FREE      0x0004 /* -k without a key argument */
+#define MCP_REGISTERED   0x0008 /* chan is already registered; do not allow changes to MODE_REGISTERED */
 #define MC_ANNOUNCE       0x0100 /* send a mod_chanmode() change out */
 #define MC_NOTIFY         0x0200 /* make local callbacks to announce */
+#ifdef NDEBUG
+#define mod_chanmode_init(CHANMODE) do { memset((CHANMODE), 0, sizeof(*CHANMODE)); } while (0)
+#else
+#define mod_chanmode_init(CHANMODE) do { memset((CHANMODE), 0, sizeof(*CHANMODE)); (CHANMODE)->alloc_argc = ArrayLength((CHANMODE)->args); } while (0)
+#endif
+
 struct mod_chanmode *mod_chanmode_alloc(unsigned int argc);
 struct mod_chanmode *mod_chanmode_dup(struct mod_chanmode *orig, unsigned int extra);
 struct mod_chanmode *mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, unsigned int flags);