NOTE: feature SPLIT is default enabled as that is just easier when working on this patch.
-diff -r bcffa56c93d4 doc/api/log.txt
---- a/doc/api/log.txt Fri Jan 23 18:45:25 2009 +0100
-+++ b/doc/api/log.txt Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 doc/api/log.txt
+--- a/doc/api/log.txt Sat Jan 24 12:58:40 2009 +0100
++++ b/doc/api/log.txt Sat Jan 24 18:42:34 2009 +0100
@@ -41,7 +41,7 @@
<enum>
LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET,
LS_DEBUG, LS_OLDLOG,
LS_LAST_SYSTEM
-diff -r bcffa56c93d4 include/handlers.h
---- a/include/handlers.h Fri Jan 23 18:45:25 2009 +0100
-+++ b/include/handlers.h Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 include/handlers.h
+--- a/include/handlers.h Sat Jan 24 12:58:40 2009 +0100
++++ b/include/handlers.h Sat Jan 24 18:42:34 2009 +0100
@@ -139,6 +139,7 @@
extern int m_registered(struct Client*, struct Client*, int, char*[]);
extern int m_sethost(struct Client*, struct Client*, int, char*[]);
extern int ms_squit(struct Client*, struct Client*, int, char*[]);
extern int ms_stats(struct Client*, struct Client*, int, char*[]);
extern int ms_topic(struct Client*, struct Client*, int, char*[]);
-diff -r bcffa56c93d4 include/ircd_features.h
---- a/include/ircd_features.h Fri Jan 23 18:45:25 2009 +0100
-+++ b/include/ircd_features.h Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 include/ircd_features.h
+--- a/include/ircd_features.h Sat Jan 24 12:58:40 2009 +0100
++++ b/include/ircd_features.h Sat Jan 24 18:42:34 2009 +0100
@@ -111,6 +111,10 @@
FEAT_SETHOST_USER,
FEAT_SETHOST_AUTO,
FEAT_HIS_STATS_s,
FEAT_HIS_STATS_t,
FEAT_HIS_STATS_T,
-diff -r bcffa56c93d4 include/ircd_log.h
---- a/include/ircd_log.h Fri Jan 23 18:45:25 2009 +0100
-+++ b/include/ircd_log.h Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 include/ircd_log.h
+--- a/include/ircd_log.h Sat Jan 24 12:58:40 2009 +0100
++++ b/include/ircd_log.h Sat Jan 24 18:42:34 2009 +0100
@@ -55,6 +55,7 @@
LS_OPERMODE, /**< Uses of OPMODE, CLEARMODE< etc. */
LS_GLINE, /**< Adding, (de-)activating or removing GLINEs. */
LS_WHO, /**< Use of extended WHO privileges. */
LS_NETWORK, /**< New server connections. */
LS_OPERKILL, /**< Kills by IRC operators. */
-diff -r bcffa56c93d4 include/msg.h
---- a/include/msg.h Fri Jan 23 18:45:25 2009 +0100
-+++ b/include/msg.h Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 include/msg.h
+--- a/include/msg.h Sat Jan 24 12:58:40 2009 +0100
++++ b/include/msg.h Sat Jan 24 18:42:34 2009 +0100
@@ -332,6 +332,10 @@
#define TOK_JUPE "JU"
#define CMD_JUPE MSG_JUPE, TOK_JUPE
#define MSG_OPMODE "OPMODE" /* OPMO */
#define TOK_OPMODE "OM"
#define CMD_OPMODE MSG_OPMODE, TOK_OPMODE
-diff -r bcffa56c93d4 include/numeric.h
---- a/include/numeric.h Fri Jan 23 18:45:25 2009 +0100
-+++ b/include/numeric.h Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 include/numeric.h
+--- a/include/numeric.h Sat Jan 24 12:58:40 2009 +0100
++++ b/include/numeric.h Sat Jan 24 18:42:34 2009 +0100
@@ -117,6 +117,7 @@
RPL_STATSVLINE 227 unreal */
#define RPL_STATSALINE 226 /* Hybrid, Undernet */
#define ERR_SILELISTFULL 511 /* Undernet extension */
/* ERR_NOTIFYFULL 512 aircd */
/* ERR_TOOMANYWATCH 512 Numeric List: Dalnet */
-diff -r bcffa56c93d4 include/split.h
+diff -r 0f7ba4913233 include/split.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/include/split.h Fri Jan 23 23:04:58 2009 +0100
++++ b/include/split.h Sat Jan 24 18:42:34 2009 +0100
@@ -0,0 +1,106 @@
+#ifndef INCLUDED_split_h
+#define INCLUDED_split_h
+};
+
+/* Split update flags. */
-+#define SPLIT_EXPIRE 0x02 /**< Expiration time update. */
-+#define SPLIT_LIFETIME 0x04 /**< Record lifetime update. */
-+#define SPLIT_REASON 0x08 /**< Reason update. */
-+#define SPLIT_CREATION 0x10 /**< TODO: Creation time update - unused. */
-+#define SPLIT_MODIFY 0x20 /**< No state change. */
++#define SPLIT_EXPIRE 0x01 /**< Expiration time update. */
++#define SPLIT_LIFETIME 0x02 /**< Record lifetime update. */
++#define SPLIT_REASON 0x04 /**< Reason update. */
++#define SPLIT_CREATION 0x08 /**< TODO: Creation time update - unused. */
++#define SPLIT_MODIFY 0x10 /**< No state change. */
+
+/* mask for Split update flags. */
-+#define SPLIT_UPDATE (SPLIT_EXPIRE | SPLIT_LIFETIME | SPLIT_REASON)
++#define SPLIT_UPDATE (SPLIT_EXPIRE | SPLIT_CREATION | SPLIT_LIFETIME | SPLIT_REASON)
+
+/* test whether a split entry is active. */
+#define SplitIsActive(s) ((s)->sp_flags & SPLIT_ACTIVE)
+extern int split_memory_count(size_t *sp_size);
+
+#endif /* INCLUDED_split_h */
-diff -r bcffa56c93d4 ircd/Makefile.in
---- a/ircd/Makefile.in Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/Makefile.in Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/Makefile.in
+--- a/ircd/Makefile.in Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/Makefile.in Sat Jan 24 18:42:34 2009 +0100
@@ -173,6 +173,7 @@
m_sethost.c \
m_settime.c \
uping.o: uping.c ../config.h ../include/uping.h ../include/ircd_defs.h \
../include/ircd_events.h ../config.h ../include/res.h \
../include/client.h ../include/dbuf.h ../include/msgq.h \
-diff -r bcffa56c93d4 ircd/ircd.c
---- a/ircd/ircd.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/ircd.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/ircd.c
+--- a/ircd/ircd.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/ircd.c Sat Jan 24 18:42:34 2009 +0100
@@ -55,6 +55,7 @@
#include "s_misc.h"
#include "s_stats.h"
event_loop();
return 0;
-diff -r bcffa56c93d4 ircd/ircd_features.c
---- a/ircd/ircd_features.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/ircd_features.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/ircd_features.c
+--- a/ircd/ircd_features.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/ircd_features.c Sat Jan 24 18:42:34 2009 +0100
@@ -365,6 +365,10 @@
F_B(SETHOST_USER, 0, 0, 0),
F_B(SETHOST_AUTO, 0, 0, 0),
F_B(HIS_STATS_s, 0, 1, 0),
F_B(HIS_STATS_t, 0, 1, 0),
F_B(HIS_STATS_T, 0, 1, 0),
-diff -r bcffa56c93d4 ircd/ircd_log.c
---- a/ircd/ircd_log.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/ircd_log.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/ircd_log.c
+--- a/ircd/ircd_log.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/ircd_log.c Sat Jan 24 18:42:34 2009 +0100
@@ -154,6 +154,7 @@
S(OPERMODE, -1, SNO_HACK4),
S(GLINE, -1, SNO_GLINE),
S(WHO, -1, 0),
S(NETWORK, -1, SNO_NETWORK),
S(OPERKILL, -1, 0),
-diff -r bcffa56c93d4 ircd/m_endburst.c
---- a/ircd/m_endburst.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/m_endburst.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/m_endburst.c
+--- a/ircd/m_endburst.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/m_endburst.c Sat Jan 24 18:42:34 2009 +0100
@@ -85,6 +85,7 @@
#include "client.h"
#include "hash.h"
if (MyConnect(sptr))
sendcmdto_one(&me, CMD_END_OF_BURST_ACK, sptr, "");
-diff -r bcffa56c93d4 ircd/m_reburst.c
---- a/ircd/m_reburst.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/m_reburst.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/m_reburst.c
+--- a/ircd/m_reburst.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/m_reburst.c Sat Jan 24 18:42:34 2009 +0100
@@ -102,6 +102,7 @@
#include "ircd_snprintf.h"
#include "gline.h"
default:
break;
}
-diff -r bcffa56c93d4 ircd/m_server.c
---- a/ircd/m_server.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/m_server.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/m_server.c
+--- a/ircd/m_server.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/m_server.c Sat Jan 24 18:42:34 2009 +0100
@@ -47,6 +47,7 @@
#include "s_misc.h"
#include "s_serv.h"
/*
* Old sendto_serv_but_one() call removed because we now need to send
* different names to different servers (domain name matching).
-diff -r bcffa56c93d4 ircd/m_split.c
+diff -r 0f7ba4913233 ircd/m_split.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/ircd/m_split.c Fri Jan 23 23:04:58 2009 +0100
-@@ -0,0 +1,374 @@
++++ b/ircd/m_split.c Sat Jan 24 18:42:34 2009 +0100
+@@ -0,0 +1,376 @@
+/*
+ * IRC - Internet Relay Chat, ircd/m_split.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+ unsigned int flags = 0;
+ enum SplitAction action = SPLIT_MODIFY;
+ time_t creation = 0, expire = 0, lastmod = 0, lifetime = 0;
-+ char *server = parv[1], *tmp = 0;
++ char *server = 0, *tmp = 0;
+ const char *reason = "No reason";
+
-+ /* TODO: perhaps make some fields optional? reason? */
-+ if (parc < 6)
++ /* reason is optional - for lazy services, we always send it */
++ if (parc < 5)
+ return need_more_params(sptr, "SPLIT");
+
+ if (*server == '!') {
+ }
+
+ /* Next, try to find the split entry... */
++ server = parv[1];
+ asplit = split_find(server);
+
+ /* We now have all the pieces to tell us what we've got; let's put
+ if (!asplit && action == SPLIT_MODIFY)
+ action = SPLIT_ACTIVATE;
+
-+ /* OK, let's figure out what other parameters we may have... */
++ /* set all flags for modification */
++ if (asplit && action != SPLIT_REMOVE)
++ flags = SPLIT_UPDATE;
++
++ /* set the things we need */
+ creation = atoi(parv[2]);
+ expire = atoi(parv[3]);
+ lastmod = atoi(parv[4]);
+ lifetime = atoi(parv[5]);
-+ reason = parv[parc - 1];
++ /* got a reason too */
++ if (parc < 6)
++ reason = parv[parc - 1];
+
+ Debug((DEBUG_DEBUG, "I have a SPLIT I am acting upon now; "
+ "server %s, action %s, creation %Tu, expire %Tu, "
+ lastmod, lifetime, flags);
+ }
+
++ /* desynch or cross - we do not have it so we cannot remove it */
++ /* TODO: manually propagate the message ?
++ * ..but if we do not have it, can our downlinks have it?
++ * they could if my oper force removed it earlier, and then my downlinks linked
++ * no, then they would have bursted it again to us.. argh
++ */
++ if (!asplit && action == SPLIT_REMOVE)
++ return 0;
++
+ assert(action != SPLIT_MODIFY);
++ assert(action != SPLIT_REMOVE);
+
++ /* only give one flag when needed - SPLIT_ACTIVE */
+ return split_add(cptr, sptr, server, reason, creation, expire, lastmod, lifetime,
-+ flags | ((action == SPLIT_ACTIVATE) ? SPLIT_ACTIVE : 0));
++ (flags & SPLIT_ACTIVATE) ? SPLIT_ACTIVE : 0);
+}
+
+
+ char *server = parv[1], *end;
+ const char *reason = NULL;
+
++ /* listing */
+ if (parc < 2) {
+ if (!HasPriv(sptr, PRIV_ROUTEINFO))
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+ return split_list(sptr, 0);
+ }
+
++ /* force removal */
+ if (*server == '!') {
+ server++;
-+ action = SPLIT_REMOVE; /* force removal */
++ action = SPLIT_REMOVE;
+ }
+
+ switch (*server) { /* handle + and - */
+ server++;
+ break;
+ }
-+
-+ /* OK, let's figure out the parameters... */
-+ switch (action) {
-+ /* no specific action */
-+ case SPLIT_MODIFY:
-+ /* user wants a listing of a specific SPLIT */
-+ if (parc == 2)
-+ return split_list(sptr, server);
-+ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */
-+ if (*end != '\0')
-+ return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE,
-+ "%s :Bad expire time", parv[2]);
+
-+ flags |= SPLIT_EXPIRE; /* remember that we got an expire time */
-+
-+ if (parc > 3) { /* also got a reason... */
-+ reason = parv[parc - 1];
++ /* user wants listing */
++ if (action == SPLIT_MODIFY && parc == 2)
++ return split_list(sptr, server);
++
++ /* if we have an expire, this must be it */
++ if (parc > 2)
++ expire = strtol(parv[2], &end, 10); /* and the expiration */
++
++ /* got reason and expire */
++ if (parc > 3) {
++ flags |= SPLIT_EXPIRE;
++ flags |= SPLIT_REASON;
++ }
++ /* got reason or expire */
++ else if (parc > 2) {
++ if (*end != '\0')
+ flags |= SPLIT_REASON;
-+ }
-+ break;
-+
-+ case SPLIT_REMOVE: /* TODO: require reason for this, but not expire? */
-+ if (parc < 4)
-+ return need_more_params(sptr, "SPLIT");
++ else
++ flags |= SPLIT_EXPIRE;
++ }
++
++ /* set reason */
++ if (flags & SPLIT_REASON) {
+ reason = parv[parc - 1];
-+ flags |= SPLIT_REASON;
-+ break;
-+
-+ case SPLIT_ACTIVATE: /* TODO: require expire and reason when new */
-+ if (parc > 2) {
-+ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */
-+ if (*end != '\0')
-+ return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE,
-+ "%s :Bad expire time", parv[2]);
-+ flags |= SPLIT_EXPIRE; /* remember that we got an expire time */
-+ }
-+
-+ if (parc > 3) { /* also got a reason... */
-+ reason = parv[parc - 1];
-+ flags |= SPLIT_REASON;
-+ }
-+ break;
-+
-+ case SPLIT_DEACTIVATE: /* TODO: duplicate code? must be a cleaner way */
-+ if (parc > 2) {
-+ expire = strtol(parv[2], &end, 10) + TStime(); /* and the expiration */
-+ if (*end != '\0')
-+ return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE,
-+ "%s :Bad expire time", parv[2]);
-+ flags |= SPLIT_EXPIRE; /* remember that we got an expire time */
-+ }
-+
-+ if (parc > 3) { /* also got a reason... */
-+ reason = parv[parc - 1];
-+ flags |= SPLIT_REASON;
-+ }
-+ break;
++ if (reason[0] == '\0') /* reason is empty */
++ flags &= ~SPLIT_REASON;
+ }
-+
+
-+ /* check for permissions... */
++ /* bad expire */
++ if (flags & SPLIT_EXPIRE && *end != '\0')
++ return send_reply(sptr, SND_EXPLICIT | ERR_BADEXPIRE, "%s :Bad expire time", parv[2]);
++
++ /* require a reason for forced removal */
++ if (!(flags & SPLIT_REASON) && action == SPLIT_REMOVE)
++ return need_more_params(sptr, "SPLIT");
++
++ /* we got expire */
++ if (flags & SPLIT_EXPIRE) {
++ if (expire == 0) /* dummy value 0 given, no change to expire */
++ flags &= ~SPLIT_EXPIRE;
++ else /* turn expire into timestamp */
++ expire += TStime();
++ }
++
++ /* check feature and privs */
+ if (!feature_bool(FEAT_SPLIT)) /* TODO: but allow force removal? */
+ return send_reply(sptr, ERR_DISABLED, "SPLIT");
+ else if (!HasPriv(sptr, PRIV_SERVERINFO)) /* TODO: create PRIV_SPLIT - need help there */
+ return send_reply(sptr, ERR_NOPRIVILEGES);
+
-+ /* Next, try to find the SPLIT... */
++ /* find the split */
+ asplit = split_find(server);
+
+ /* We now have all the pieces to tell us what we've got; let's put
+ * it all together and convert the rest of the arguments.
+ */
+
-+ /* SPLIT not found and thus we:
-+ * cannot remove SPLIT we do not have
-+ * cannot add new SPLIT without expire and reason
++ /* SPLIT not found and thus we cannot:
++ * remove SPLIT we do not have
++ * add new SPLIT without expire and reason
+ */
+ if (!asplit &&
+ ((action == SPLIT_REMOVE) ||
+ * m_split - user message handler
+ *
+ * parv[0] = Send prefix
-+ *
-+ * From user:
-+ *
+ * parv[1] = [<server name>]
+ *
+ */
+
+ return split_list(sptr, parv[1]);
+}
-diff -r bcffa56c93d4 ircd/parse.c
---- a/ircd/parse.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/parse.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/parse.c
+--- a/ircd/parse.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/parse.c Sat Jan 24 18:42:34 2009 +0100
@@ -505,6 +505,13 @@
0, MAXPARA, MFLG_SLOW, 0, NULL,
/* UNREG, CLIENT, SERVER, OPER, SERVICE */
},
{
MSG_OPMODE,
-diff -r bcffa56c93d4 ircd/s_conf.c
---- a/ircd/s_conf.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_conf.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_conf.c
+--- a/ircd/s_conf.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_conf.c Sat Jan 24 18:42:34 2009 +0100
@@ -53,6 +53,7 @@
#include "s_debug.h"
#include "s_misc.h"
return ret;
}
-diff -r bcffa56c93d4 ircd/s_debug.c
---- a/ircd/s_debug.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_debug.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_debug.c
+--- a/ircd/s_debug.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_debug.c Sat Jan 24 18:42:34 2009 +0100
@@ -48,6 +48,7 @@
#include "s_user.h"
#include "s_stats.h"
send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG,
":Hash: client %d(%zu), chan is the same", HASHSIZE,
-diff -r bcffa56c93d4 ircd/s_err.c
---- a/ircd/s_err.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_err.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_err.c
+--- a/ircd/s_err.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_err.c Sat Jan 24 18:42:34 2009 +0100
@@ -490,7 +490,7 @@
/* 228 */
{ RPL_STATSQLINE, "Q %s :%s", "228" },
/* 511 */
{ ERR_SILELISTFULL, "%s :Your silence list is full", "511" },
/* 512 */
-diff -r bcffa56c93d4 ircd/s_misc.c
---- a/ircd/s_misc.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_misc.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_misc.c
+--- a/ircd/s_misc.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_misc.c Sat Jan 24 18:42:34 2009 +0100
@@ -53,6 +53,7 @@
#include "s_stats.h"
#include "s_user.h"
}
/*
-diff -r bcffa56c93d4 ircd/s_serv.c
---- a/ircd/s_serv.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_serv.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_serv.c
+--- a/ircd/s_serv.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_serv.c Sat Jan 24 18:42:34 2009 +0100
@@ -54,6 +54,7 @@
#include "s_misc.h"
#include "s_user.h"
/*
* Pass on my client information to the new server
-diff -r bcffa56c93d4 ircd/s_stats.c
---- a/ircd/s_stats.c Fri Jan 23 18:45:25 2009 +0100
-+++ b/ircd/s_stats.c Fri Jan 23 23:04:58 2009 +0100
+diff -r 0f7ba4913233 ircd/s_stats.c
+--- a/ircd/s_stats.c Sat Jan 24 12:58:40 2009 +0100
++++ b/ircd/s_stats.c Sat Jan 24 18:42:34 2009 +0100
@@ -52,6 +52,7 @@
#include "s_stats.h"
#include "s_user.h"
stats_sline, 0,
"Spoofed hosts information." },
{ 'T', "motds", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_T,
-diff -r bcffa56c93d4 ircd/split.c
+diff -r 0f7ba4913233 ircd/split.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
-+++ b/ircd/split.c Fri Jan 23 23:04:58 2009 +0100
-@@ -0,0 +1,773 @@
++++ b/ircd/split.c Sat Jan 24 18:42:34 2009 +0100
+@@ -0,0 +1,786 @@
+/*
+ * IRC - Internet Relay Chat, ircd/split.c
+ * Copyright (C) 1990 Jarkko Oikarinen and
+
+ struct Split *asplit;
+ struct Client *acptr;
++ char noreason[BUFSIZE];
+
++ assert(0 != cptr);
++ assert(0 != sptr);
+ assert(0 != server);
+ assert(0 != reason);
-+ assert(NULL != cptr);
-+ assert(NULL != sptr);
+
+ Debug((DEBUG_DEBUG, "split_add(\"%s\", \"%s\", \"%s\", \"%s\", %Tu, %Tu, %Tu, "
+ "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), server, reason,
+ * duration greater than SPLIT_MAX_EXPIRE.
+ */
+ if (expire - TStime() <= 0 || expire - TStime() > SPLIT_MAX_EXPIRE) {
-+ if (!IsServer(cptr) && MyConnect(cptr))
++ /* TODO: cptr or sptr here? */
++ if (MyUser(sptr))
+ return send_reply(cptr, ERR_BADEXPIRE, expire - TStime());
+ if (lifetime <= TStime()) /* no point going further */
+ /* CHECK: sptr may have the wrong idea about the nettime?
+ return 0;
+ }
+
++ /* empty reason */
++ if (reason[0] == '\0')
++ ircd_snprintf(0, noreason, sizeof(noreason), "%C gave no reason.", sptr);
++
+ /* TODO: add opername */
+ /* inform ops and log it */
+ sendto_opmask_butone(0, SNO_NETWORK, "%s adding%sSPLIT for %s, expiring at %Tu: %s",
+ (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
+ cli_name(sptr) : cli_name((cli_user(sptr))->server),
+ !(flags & SPLIT_ACTIVE) ? " deactivated " : " ",
-+ server, expire, reason);
++ server, expire, reason[0] == '\0' ? noreason : reason);
+
+ log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE,
+ "%#C adding%sSPLIT for %s, expiring at %Tu: %s",
+ sptr, !(flags & SPLIT_ACTIVE) ? " deactivated " : " ",
-+ server, expire, reason);
++ server, expire, reason[0] == '\0' ? noreason : reason);
+
+ /* make the split entry */
-+ asplit = split_make(server, reason, creation, expire, lastmod, lifetime, flags);
++ asplit = split_make(server, reason[0] == '\0' ? noreason : reason,
++ creation, expire, lastmod, lifetime, flags);
+
+ assert(asplit);
+
+ char buf[BUFSIZE];
+ int pos = 0;
+
-+ /* TODO: assert() on other inputs? */
-+ assert(split);
-+ assert(NULL != cptr);
-+ assert(NULL != sptr);
++ assert(0 != cptr);
++ assert(0 != sptr);
++ assert(0 != split);
+
-+ Debug((DEBUG_DEBUG, "split_modify(\"%s\", \"%s\", \"%s\", \"%s\", %d, %Tu, %Tu, %Tu, "
-+ "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), split->sp_server, reason, action,
++ Debug((DEBUG_DEBUG, "split_modify(cptr \"%s\", sptr \"%s\", split \"%s\", reason \"%s\","
++ " action %d, creation %Tu, expire %Tu, lastmod %Tu, lifetime %Tu, flags 0x%04x)",
++ cli_name(cptr), cli_name(sptr), split->sp_server, reason, action,
+ creation, expire, lastmod, lifetime, flags));
+
+ /* not modifying SPLIT for server that is linked
+ split_free(split); /* and free it */
+ return 0;
+ }
-+
-+ /* First, let's check lastmod... */
++
++ /* check lastmod */
+ if (split->sp_lastmod > lastmod) { /* we have a more recent version */
-+ if (IsBurstOrBurstAck(cptr))
-+ return 0; /* middle of a burst, it'll resync on its own */
++ if (IsBurstOrBurstAck(cptr)) /* middle of a burst, it will resync on its own */
++ return 0;
+ return split_resend(cptr, split); /* resync the server */
-+ } else if (split->sp_lastmod == lastmod)
-+ return 0; /* we have that version of the split entry... */
++ } else if (split->sp_lastmod == lastmod) /* same version */
++ return 0;
+
-+ /* All right, we know that there's a change of some sort. What is it? */
-+ /* first, check out the expiration time... */
-+ /* TODO: expire != 0 or NULL - check that we have something? */
-+ if (expire != 0 && expire != split->sp_expire) {
-+ if (expire - TStime() <= 0 || expire - TStime() > SPLIT_MAX_EXPIRE) {
-+ if (!IsServer(sptr) && MyConnect(sptr)) /* bad expiration time */
++ /* there is a change of some sort */
++ /* check out the expiration time */
++ if (flags & SPLIT_EXPIRE) {
++ if (expire != split->sp_expire) {
++ /* bad expiration time */
++ if (MyUser(sptr) && (expire < TStime() || expire - TStime() > SPLIT_MAX_EXPIRE))
+ return send_reply(sptr, ERR_BADEXPIRE, expire - TStime());
-+ }
-+ flags |= SPLIT_EXPIRE;
-+ } else
-+ flags &= ~SPLIT_EXPIRE;
++ /* expire timestamp is in the past, so remap to deactivate */
++ if (expire < TStime() && action == SPLIT_ACTIVATE)
++ action = SPLIT_DEACTIVATE;
++ } else
++ flags &= ~SPLIT_EXPIRE;
++ }
+
+ /* Next, check out lifetime */
+ if (!(flags & SPLIT_LIFETIME) || !lifetime)
+ flags &= ~SPLIT_LIFETIME; /* no change to lifetime */
+ lifetime = 0;
+ }
-+
++
+ /* Finally, let's see if the reason needs to be updated */
-+ /* TODO: (reason) or use != NULL / 0 ? */
-+ if ((flags & SPLIT_REASON) && reason &&
-+ ircd_strcmp(split->sp_reason, reason) != 0)
++ if ((flags & SPLIT_REASON) && (reason[0] == '\0' || !ircd_strcmp(split->sp_reason, reason)))
+ flags &= ~SPLIT_REASON; /* no changes to the reason */
+
+ /* OK, now let's take a look at the action... */
+ (action == SPLIT_MODIFY ? "SPLIT_MODIFY" : "<UNKNOWN>"))));
+
+ /* If there are no changes to perform, do no changes */
-+ if (!(flags & SPLIT_UPDATE) && action == SPLIT_MODIFY)
++ if (!(flags & SPLIT_UPDATE) && action == SPLIT_MODIFY) {
++ if (MyUser(sptr))
++ sendcmdto_one(&me, CMD_NOTICE, sptr,
++ "%C :Cannot modify SPLIT %s - nothing to change.", sptr, split->sp_server);
+ return 0;
++ }
+
+ /* Start by updating lastmod, if indicated... */
+ split->sp_lastmod = lastmod;
+ break;
+ }
+
++ /* TODO: Handle creation changes... */
++
+ /* Handle expiration changes... */
+ if (flags & SPLIT_EXPIRE) {
+ split->sp_expire = expire; /* save new expiration time */