diff -uNrd operstats-1.2.0.dist/NOTES operstats-1.2.0/NOTES
--- operstats-1.2.0.dist/NOTES	Wed Dec 31 19:00:00 1969
+++ operstats-1.2.0/NOTES	Sun Sep  7 17:26:37 2003
@@ -0,0 +1,32 @@
+OperStats 1.2.0 port for ircd-hybrid-7 and ircd-ratbox.
+
+All servers must add a shared block for the services so that AKILL works.
+
+For Hybrid 7.0:
+
+shared {
+  name = "services.network.tld";
+  kline = yes;
+  unkline = yes;
+};
+
+For ircd-ratbox:
+
+shared {
+  name = "services.networkd.tld";
+  type = kline, unkline;
+};
+
+Replacing the name for whatever you name your operstats server.
+
+If you run Hybrid 7, you MUST run the +demon patch, or AKILL's will never
+be removed.
+
+SnoopChan must be -n if the services are not joining it (like ircu).
+
+It will not forcefully take ops in the JoinChan.  If there are users in it,
+  the services will join like normal users and will not be "server opped".
+
+SecuritySetting must be None on Hybrid 7 if you wish to access services when
+  you are not /oper'ed.
+
diff -uNrd operstats-1.2.0.dist/dist/operstats.conf operstats-1.2.0/dist/operstats.conf
--- operstats-1.2.0.dist/dist/operstats.conf	Sun Jan 26 00:31:15 2003
+++ operstats-1.2.0/dist/operstats.conf	Sun Sep  7 15:53:49 2003
@@ -40,12 +40,13 @@
 # this is not set properly, OperStats will not work properly on your network.
 # If your IRCd is not listed below, you can try a similar IRCd, but there
 # are no gaurantees with any IRCds not listed.
-# There are 5 supported IRCds:
+# There are 6 supported IRCds:
 #      DreamForge
 #      Prometheus
 #      Bahamut
 #      Unreal 3
 #      Unreal 3.2
+#      Hybrid
 # You must include any spaces shown above. For example:
 # IRCdType Unreal 3.2
 # This is required.
diff -uNrd operstats-1.2.0.dist/inc/config.h operstats-1.2.0/inc/config.h
--- operstats-1.2.0.dist/inc/config.h	Sun Jan 26 00:31:40 2003
+++ operstats-1.2.0/inc/config.h	Sun Sep  7 15:51:08 2003
@@ -45,6 +45,7 @@
 #define BAHAMUT		3
 #define UNREAL3		4
 #define UNREAL3_2	5
+#define HYBRID		6
 
 /* Do you want OperStats to generate a core file if it crashes?
    I'd suggest you leave this option on. If you experience crashes,
diff -uNrd operstats-1.2.0.dist/misc/makeconf operstats-1.2.0/misc/makeconf
--- operstats-1.2.0.dist/misc/makeconf	Sun Jan 26 00:32:12 2003
+++ operstats-1.2.0/misc/makeconf	Sun Sep  7 15:53:20 2003
@@ -174,6 +174,7 @@
 echo "    3) Bahamut"
 echo "    4) UnrealIRCd 3"
 echo "    5) UnrealIRCd 3.2"
+echo "    6) Hybrid 7.0/ircd-ratbox 1.x"
 while [ $ok -eq 0 ] ; do
 	echo2 "[$IRCDTYPE] "
 	if read INPUT ; then : ; else echo "" ; exit 1 ; fi
@@ -181,7 +182,7 @@
 		INPUT=$IRCDTYPE
 	fi
 	case $INPUT in
-		[1-5])
+		[1-6])
 			ok=1
 			;;
 		*)
@@ -277,12 +278,13 @@
 # this is not set properly, OperStats will not work properly on your network.
 # If your IRCd is not listed below, you can try a similar IRCd, but there
 # are no gaurantees with any IRCds not listed.
-# There are 5 supported IRCds:
+# There are 6 supported IRCds:
 #      DreamForge
 #      Prometheus
 #      Bahamut
 #      Unreal 3
 #      Unreal 3.2
+#      Hybrid
 # You must include any spaces shown above. For example:
 # IRCdType Unreal 3.2
 # This is required.
@@ -311,6 +313,11 @@
 
 if [ "$IRCDTYPE" -eq "5" ] ; then cat <<_EOT_ >>operstats.conf
 IRCdType Unreal 3.2
+_EOT_
+fi
+
+if [ "$IRCDTYPE" -eq "6" ] ; then cat <<_EOT_ >>operstats.conf
+IRCdType Hybrid
 _EOT_
 fi
 
diff -uNrd operstats-1.2.0.dist/src/Makefile operstats-1.2.0/src/Makefile
--- operstats-1.2.0.dist/src/Makefile	Sat Apr  5 06:08:47 2003
+++ operstats-1.2.0/src/Makefile	Sun Sep  7 17:37:43 2003
@@ -2,7 +2,7 @@
 
 include ../Makefile.inc
 
-VERSION=1.2.0
+VERSION=1.2.0+hybrid_0.4
 
 OBJS=main.o shared.o operserv.o statserv.o process.o socket.o function.o server.o conf.o help.o
 
diff -uNrd operstats-1.2.0.dist/src/conf.c operstats-1.2.0/src/conf.c
--- operstats-1.2.0.dist/src/conf.c	Tue Feb  4 21:14:09 2003
+++ operstats-1.2.0/src/conf.c	Sun Sep  7 15:54:54 2003
@@ -225,6 +225,9 @@
 	    else if (stristr (s, "Unreal 3.2"))
 		ircdtype = UNREAL3_2;
 
+            else if (stristr (s, "Hybrid"))
+                ircdtype = HYBRID;
+
 	    else
 		fatal (0, "Config: IRCdType is not set properly: Invalid value.");
 
diff -uNrd operstats-1.2.0.dist/src/function.c operstats-1.2.0/src/function.c
--- operstats-1.2.0.dist/src/function.c	Sat Apr  5 08:35:53 2003
+++ operstats-1.2.0/src/function.c	Sun Sep  7 15:58:30 2003
@@ -1769,6 +1769,9 @@
 	if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 	    send_cmd (s_OperServ, "SJOIN %ld %ld %s + :%s", time (NULL), time (NULL),
 		joinchan, s_OperServ);
+        else if (ircdtype == HYBRID)
+            send_cmd (me.name, "SJOIN %ld %s + :@%s", time (NULL), joinchan,
+                s_OperServ);
 	else
 	    send_cmd (s_OperServ, "%s %s", me.token ? "C" : "JOIN", joinchan);
     }
@@ -1778,6 +1781,9 @@
 	if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 	    send_cmd (s_StatServ, "SJOIN %ld %ld %s + :%s", time (NULL), time (NULL),
 		joinchan, s_StatServ);
+        else if (ircdtype == HYBRID)
+            send_cmd (me.name, "SJOIN %ld %s + :@%s", time (NULL), joinchan,    
+                s_StatServ);
 	else
 	    send_cmd (s_StatServ, "%s %s", me.token ? "C" : "JOIN", joinchan);
     }
@@ -1787,6 +1793,9 @@
 	if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 	    send_cmd (s_GlobalNoticer, "SJOIN %ld %ld %s + :%s", time (NULL), time (NULL),
 		joinchan, s_GlobalNoticer);
+        else if (ircdtype == HYBRID)
+            send_cmd (me.name, "SJOIN %ld %s + :@%s", time (NULL), joinchan,    
+                s_GlobalNoticer);
 	else
 	    send_cmd (s_GlobalNoticer, "%s %s", me.token ? "C" : "JOIN", joinchan);
     }
diff -uNrd operstats-1.2.0.dist/src/main.c operstats-1.2.0/src/main.c
--- operstats-1.2.0.dist/src/main.c	Sun Jan 26 00:33:32 2003
+++ operstats-1.2.0/src/main.c	Sun Sep  7 17:32:04 2003
@@ -320,11 +320,14 @@
     if (ircdtype == DREAMFORGE)
 	send_cmd (NULL, "PROTOCTL TOKEN NOQUIT");
 
-    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
-	send_cmd (NULL, "PASS %s :TS", me.pass);
+    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS || ircdtype == HYBRID)
+	send_cmd (NULL, "PASS %s TS", me.pass);
     else
 	send_cmd (NULL, "PASS :%s", me.pass);
 
+    if (ircdtype == HYBRID)
+        send_cmd (NULL, "CAPAB QS KLN UNKLN");
+
     if (ircdtype == UNREAL3 || ircdtype == UNREAL3_2)
 	send_cmd (NULL, "SERVER %s 1 :U0-*-%d %s", me.name, unreal_numeric, me.desc);
     else
@@ -336,6 +339,9 @@
 	send_cmd (NULL, "CAPAB TS3 NOQUIT");
     }
 
+    if (ircdtype == HYBRID)
+        send_cmd (NULL, "SVINFO 5 3 0 :%lu", time (NULL));
+
     /* Now bring on our clients.. */
     if (operserv_on == TRUE)
     {
@@ -374,7 +380,8 @@
     if (ircdtype == BAHAMUT)
 	bursting = 2;
 
-    if (ircdtype == PROMETHEUS || ircdtype == UNREAL3 || ircdtype == UNREAL3_2)
+    if (ircdtype == PROMETHEUS || ircdtype == UNREAL3 ||
+        ircdtype == UNREAL3_2 || ircdtype == HYBRID)
 	bursting = 1;
 
     runflags &= ~RUN_STARTING;
@@ -436,6 +443,10 @@
 	send_cmd (NULL, "NICK %s 1 %lu %s %s %s %s 0 :%s", nick, time (NULL), modes,
 	    user, host, me.name, real);
 
+    if (ircdtype == HYBRID)
+        send_cmd (NULL, "NICK %s 1 %lu %s %s %s %s :%s", nick, time (NULL),
+            modes, user, host, me.name, real);
+
     if (ircdtype == DREAMFORGE)
     {
 	send_cmd (NULL, "%s %s 1 %lu %s %s %s 1 :%s", me.token ? "&" : "NICK",
@@ -492,7 +503,10 @@
     }	
 
     /* Change to the new nickname */
-    send_cmd (sp.nick, "%s %s", me.token ? "&" : "NICK", guest);
+    if (ircdtype == HYBRID)
+        send_cmd (sp.nick, "NICK %s :%ld", guest, time (NULL));
+    else
+        send_cmd (sp.nick, "%s %s", me.token ? "&" : "NICK", guest);
 
     /* Now replace the nick */
     strscpy (sp.nick, guest, sizeof (sp.nick));
diff -uNrd operstats-1.2.0.dist/src/operserv.c operstats-1.2.0/src/operserv.c
--- operstats-1.2.0.dist/src/operserv.c	Thu Jan 30 05:20:54 2003
+++ operstats-1.2.0/src/operserv.c	Sun Sep  7 17:29:52 2003
@@ -726,6 +726,9 @@
 		if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 		    send_cmd (me.name, "AKILL %s %s 0 %s %ld :%s", hostname,
 			username, s_OperServ, time (NULL), akill->reason);
+                else if (ircdtype == HYBRID)
+                    send_cmd (s_OperServ, "KLINE * %d %s %s :%s",
+                        akill->expires, username, hostname, akill->reason);
 		else
 		    send_cmd (me.name, "%s %s %s :%s", me.token ? "V" : "AKILL",
 			hostname, username, akill->reason);
@@ -742,6 +745,9 @@
 			if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 			    send_cmd (me.name, "AKILL %s * 0 %s %ld :%s", u->host,
 				s_OperServ, time (NULL), akill->reason);
+                        else if (ircdtype == HYBRID)  
+                            send_cmd (s_OperServ, "KLINE * %d * %s :%s",
+                                akill->expires, u->host, akill->reason);
 			else
 			    send_cmd (me.name, "%s %s * :%s", me.token ? "V" :
 				"AKILL", u->host, akill->reason);
@@ -785,8 +791,12 @@
 		{
 		    *hostname++ = 0;
 
-		    send_cmd (me.name, "%s %s %s", me.token ? "Y" : "RAKILL",
-			hostname, username);
+                    if (ircdtype == HYBRID)
+                        send_cmd (s_OperServ, "UNKLINE * %s %s", username,
+                            hostname);
+                    else
+		        send_cmd (me.name, "%s %s %s", me.token ? "Y" : "RAKILL",
+			    hostname, username);
 		}
 
 		/* Send it out to Services */
@@ -831,8 +841,12 @@
 		    {
 			*hostname++ = 0;
 
-			send_cmd (me.name, "%s %s %s", me.token ? "Y" :
-			    "RAKILL", hostname, username);
+                        if (ircdtype == HYBRID)
+                            send_cmd (s_OperServ, "UNKLINE * %s %s", username,
+                                hostname);
+                        else
+                            send_cmd (me.name, "%s %s %s", me.token ? "Y" :
+			        "RAKILL", hostname, username);
 		    }
 
 		    /* Send it out to Services */
@@ -949,8 +963,12 @@
 		{
 		    *host++ = 0;
 
-		    send_cmd (me.name, "%s %s %s", me.token ? "Y" :
-			"RAKILL", host, user);
+                    if (ircdtype == HYBRID)
+                        send_cmd (s_OperServ, "UNKLINE * %s %s", user,
+                            host);
+                    else
+		        send_cmd (me.name, "%s %s %s", me.token ? "Y" :
+			    "RAKILL", host, user);
 		}
 
 		/* Send it out to Services */
@@ -1007,6 +1025,9 @@
 	    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 		send_cmd (me.name, "AKILL %s * 0 %s %ld :%s", host,
 		    s_OperServ, time (NULL), akills[i].reason);
+            else if (ircdtype == HYBRID)  
+                send_cmd (s_OperServ, "KLINE * %d * %s :%s",
+                    akills[i].expires, host, akills[i].reason);
 	    else
 		send_cmd (me.name, "%s %s * :%s", me.token ? "V" : "AKILL",
 		    host, akills[i].reason);
diff -uNrd operstats-1.2.0.dist/src/process.c operstats-1.2.0/src/process.c
--- operstats-1.2.0.dist/src/process.c	Sat Apr  5 08:35:53 2003
+++ operstats-1.2.0/src/process.c	Sun Sep  7 16:12:33 2003
@@ -853,7 +853,8 @@
     /* Bahamut, Prometheus and Unreal 3.2 only send SQUITs for the splitting server,
        not servers linked to it. So we have to free those servers and their users here.
      */
-    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS || ircdtype == UNREAL3_2)
+    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS ||
+        ircdtype == UNREAL3_2 || ircdtype == HYBRID)
     {
 	for (s = firstserv (); s; s = nextserv ())
 	{
@@ -1616,6 +1617,9 @@
 		if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 		    send_cmd (me.name, "AKILL %s %s 0 %s %ld :%s", hostname,
 			username, s_OperServ, time (NULL), akill->reason);
+                else if (ircdtype == HYBRID)  
+                    send_cmd (s_OperServ, "KLINE * %d %s %s :%s",
+                        akill->expires, username, hostname, akill->reason);
 		else
 		    send_cmd (me.name, "%s %s %s :%s", me.token ? "V" : "AKILL",
 			hostname, username, akill->reason);
diff -uNrd operstats-1.2.0.dist/src/server.c operstats-1.2.0/src/server.c
--- operstats-1.2.0.dist/src/server.c	Fri Jan 31 06:25:02 2003
+++ operstats-1.2.0/src/server.c	Sun Sep  7 16:17:40 2003
@@ -266,6 +266,9 @@
 		if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 		    send_cmd (me.name, "AKILL %s * 0 %s %ld :%s", u->host,
 			s_OperServ, time (NULL), akill->reason);
+                else if (ircdtype == HYBRID)  
+                    send_cmd (s_OperServ, "KLINE * %d * %s :%s",
+                        akill->expires, u->host, akill->reason);
 		else
 		    send_cmd (me.name, "%s %s * :%s", me.token ? "V" : "AKILL",
 			u->host, akill->reason);
@@ -419,6 +422,11 @@
 	    if (check_akill (av[0], av[4], av[5], av[8]))
 		return;
 	}
+        if (ircdtype == HYBRID)
+        {
+            if (check_akill (av[0], av[4], av[5], av[7]))
+                return;
+        }
 	else
 	{
 	    if (check_akill (av[0], av[3], av[4], av[7]))
@@ -438,6 +446,16 @@
 	    av[1] = av[3];
 	    do_umode (av[0], 2, av);
 	}
+        if (ircdtype == HYBRID)
+        {
+            user->user = sstrdup (av[4]);
+            user->host = sstrdup (av[5]);
+            user->server = sstrdup (av[6]);
+            user->real = sstrdup (av[7]);
+
+            av[1] = av[3];
+            do_umode (av[0], 2, av);
+        }
 	else if (ircdtype == UNREAL3 || ircdtype == UNREAL3_2)
 	{
 	    user->user = sstrdup (av[3]);
@@ -987,6 +1005,9 @@
 	    if (ircdtype == BAHAMUT || ircdtype == PROMETHEUS)
 		send_cmd (av[1], "SJOIN %ld %ld %s + :%s", time (NULL), time (NULL),
 		    joinchan, av[1]);
+            else if (ircdtype == HYBRID)
+                send_cmd (me.name, "SJOIN %ld %s + :@%s", time (NULL),
+                    joinchan, av[1]);
 	    else
 		send_cmd (av[1], "%s %s", me.token ? "C" : "JOIN", joinchan);
 
diff -uNrd operstats-1.2.0.dist/src/socket.c operstats-1.2.0/src/socket.c
--- operstats-1.2.0.dist/src/socket.c	Sun Jan 26 00:33:06 2003
+++ operstats-1.2.0/src/socket.c	Sun Sep  7 17:13:03 2003
@@ -172,8 +172,6 @@
     va_start (args, fmt);
     vsnprintf (buf, BUFSIZE, fmt, args);
 
-    sstrlcat (buf, "\n", BUFSIZE);
-
     if ((write (servsock, buf, strlen (buf))) == -1)
     {
 	log (RPL_WRITE_ERROR);
