Commits

Palmer, 2E0EOL committed a4f8aa7

Entire changeset 0.0.17 -> 0.0.18

Comments (0)

Files changed (265)

0.0.19checklist.txt

+Add safe allocator to allow SBeast to come into the project without fouling up memory...
+Write OCQ's chmail
+Ensure root or password '*' cannot login to OverChat
+Ensure OverChat does not allow a dynamic password update for user root
+Fix crash in DBR2 if database is missing
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 at http://www.daybologic.co.uk/overchat/ChangeLog.txt
 at least every server release.
 
+0.0.18
+------
+DDRP: Ensure database R2 is deleted in releases
+DDRP: Add server_chat module
+DDRP: Random number of socket picker OK on FreeBSD
+DDRP: Idling works on UNIX, user response times are improved
+DDRP: core_SocketDescFromNick() to use proper nickname comparison
+DDRP: Whois support (broken)
+DDRP: IsOnline support for digiServ
+DDRP: Fix Blake error reporting corrupt packet codes
+Dagsylad: Converted an updated blake header to a VB module
+DDRP: Fix: Possible leak in nickname comparison
+DDRP: CGI-Helper hex case fix
+DDRP: Add NetBuffer to the project (C++), remove server_txrx.c
+DDRP: Added OverChat configuration program
+DDRP: Added Mutants with PTH support but PTH appears broken
+DDRP: Fix display of nuclear mushroom cloud on crash
+Haesu: Add watchproc daemon
+DDRP: Re-order global destruction to avoid a crash
+DDRP: OCQuery login, passwd, passwdf and kill commands added
+DDRP: DBR2 fix for deleted records
+DDRP: Started work on Blake's SafeAllocator
+DDRP: Ensured users at CLEARANCE_ROOT or password '*' cannot login to ocquery
+DDRP: Fix server_netbuffer BlakeOutgoingCallback to test socket number
+DDRP: Fix bad logic when calculating expected packet sizes in NetBuffer
+
 0.0.17
 ------
 DDRP: Remove ddrp00 picture from Blake, too large
 	cd raw2c
 	make -f $(THISFILE) all
 	cd ..
-	cd blakemake
-	make -f $(THISFILE) all
-	cd ..
 
 blake_lib : blake.lib
 
 blake.lib:
 	cd blake
-	..\blakemake\blakemake --debug --server
 	make -f $(THISFILE) blake_lib
 	cd ..
 
 	@echo "------------------------------------------------"
 	@echo
 	cd blake && $(TMAKE) -f $(THISFILE) depend
-	cd blakemake && $(TMAKE) -f $(THISFILE) depend
 	cd buildnum && $(TMAKE) -f $(THISFILE) depend
 	cd buildtimer && $(TMAKE) -f $(THISFILE) depend
 	cd cgi-bin && $(TMAKE) -f $(THISFILE) depend
 	cd rmw32 && $(TMAKE) -f $(THISFILE) depend
 	cd src && $(TMAKE) -f $(THISFILE) depend
 	cd testbed && $(TMAKE) -f $(THISFILE) depend
+	cd watchproc && $(TMAKE) -f $(THISFILE) depend
 
 basictools:
 	@echo "------------------------------------------------"
 	$(TMAKE) -f $(THISFILE) do_obn
 	cd rmw32 ; $(TMAKE) -f $(THISFILE) all
 	cd raw2c ; $(TMAKE) -f $(THISFILE) all
-	cd blakemake ; $(TMAKE) -f $(THISFILE) all
+	cd watchproc ; $(TMAKE) -f $(THISFILE) all
 
 blake_lib : libblake.a
 
 	@echo "------------------------------------------------"
 	@echo
 	cd blake \
-	&& ../blakemake/blakemake --debug --server \
-	&& $(TMAKE) -f $(THISFILE) blake_lib
+	&& $(TMAKE) -f $(THISFILE)
 
 libs : dlini_lib
 
 
 overchat : overchatd
 
-overchatd : src/$(THISFILE) src/*.h src/*.c
+overchatd : src/$(THISFILE) src/*$(H) src/*$(C)
 	@echo "------------------------------------------------"
 	@echo "                                                "
 	@echo "  Stage 5                                       "
 
 basictools_clean:
 	cd buildnum ; $(TMAKE) -f $(THISFILE) clean
-	cd blakemake ; $(TMAKE) -f $(THISFILE) clean
 	cd raw2c ; $(TMAKE) -f $(THISFILE) clean
 	cd rmw32 ; $(TMAKE) -f $(THISFILE) clean
 	cd buildtimer ; $(TMAKE) -f $(THISFILE) clean
+	cd watchproc ; $(TMAKE) -f $(THISFILE) clean
 
 memory_debugger : dpcrtlmm/libdpcrtlmm.a
 
+#  /*
+#  OverChat
+#  by David Duncan Ross Palmer <Overlord@DayboLogic.co.uk>
+#  Copyright 2002 Daybo Logic, all rights reserved.
 #
-# Master make file.  This makefile is included by all other makefiles
-# so anything defined here affects _all_ makefiles, master makefile,
-# source makefiles and individual target headers, except certain libs
-# which are maintained independently of OverChat.
+#  This file was auto generated by OverChat's autoconfigurator.
+#  Although the contents of the file, because they are written by
+#  machine and not by human belong to nobody, the program which created
+#  the file (overchat/configure/configure) is owned by DDRP.
+#  */
+
 #
-# This header in intended to be built with Borland make.
-#
-# OverChat
-# (C)Copyright 2001-2002 Daybo Logic, all rights reserved.
+# Autogenerated makeinclude, do not edit
 #
 
-# The default C compiler depends on the version of Borland C++ you use
-# In BCC 5.02 and below the default appears to be bcc.  In later versions it
-# is bcc32.  I manually over ride this to bcc32 here, to use the Borland default
-# comment it out and if you want bcc expliclt use change to bcc.  OverChat
-# is a 32-bit system so bcc will probally fail.
+STATIC=
 CC=bcc32
-
-# Make utility, alwayus make in Borland, but you never know eh?
-# You might have a better version.  Always refer to TMAKE in lower level
-# makefiles, never make directly.
+CPPC=bcc32
+DEBUG=1
+BLAKEDB_R2=1
+OPTLEVEL=
 TMAKE=make
-
-# Debugging.  If you want debugging for the entire project, make sure
-# that DEBUG is defined, otherwise comment it out.
-DEBUG=1
-
-# This specifies the default name of the Makefile, don't mess with it or
-# everything will be broken.
-THISFILE=Makefile.bor
-
-# The very strict ruleset applied to certain files.
 ANSI=-A
-
-# Default flags
-# CFLAGS specifies the default flags given to the compiler, they must not conflict
-# with specific compiler flags used by lower level makefiles.
-# LFLAGS specifies the linker default flags.
-
-!ifdef DEBUG
-
 MASTER_CFLAGS=-D__WIN32__ -v -c
 MASTER_LFLAGS=-v
-
-!else
-
-MASTER_CFLAGS=-D__WIN32__ -O2 -c
-MASTER_LFLAGS=
-
-!endif
+H=.h
+LIB=.lib
+EXE=.exe
+C=.c
+CPP=.cpp
+O=.o
+WITH_PTH=1
+#  /*
+#  OverChat
+#  by David Duncan Ross Palmer <Overlord@DayboLogic.co.uk>
+#  Copyright 2002 Daybo Logic, all rights reserved.
 #
-# Master make file.  This makefile is included by all other makefiles
-# so anything defined here affects _all_ makefiles, master makefile,
-# source makefiles and individual target headers, except certain libs
-# which are maintained independently of OverChat.
+#  This file was auto generated by OverChat's autoconfigurator.
+#  Although the contents of the file, because they are written by
+#  machine and not by human belong to nobody, the program which created
+#  the file (overchat/configure/configure) is owned by DDRP.
+#  */
+
 #
-# This header is intended to be built with GNU make.
-#
-# OverChat
-# (C)Copyright 2001-2002 Daybo Logic, all rights reserved.
+# Autogenerated makeinclude, do not edit
 #
 
-# CC is the C compiler, it is set by default to cc, if you want to use
-# gcc or something else, uncomment and edit the line below.
-#CC=gcc
-
-# The make utility the build process uses _matters_.  BSD's make won't
-# suffice.  GNU make is what I use.  I'll point to gmake everywhere in
-# the tree if it matters.  If you want to point to another make program
-# change the line below.  Don't remove the line below.
+STATIC=-static
+CC=gcc
+CPPC=g++
+#DEBUG=1
+BLAKEDB_R2=1
+OPTLEVEL=
 TMAKE=gmake
-
-# Debugging.  If you want debugging on the entire build, make sure
-# that DEBUG is defined, otherwise comment it out.
-#DEBUG=1
-
-# If you want to use the new binary databases (R2) on the server and ocquery
-# you need to uncomment this line.
-BLAKEDB_R2=1
-
-# This specifies the default name of the makefile, don't remove it,
-# it's not optional.
-THISFILE=Makefile.gnu
-
-# This command lists the files in a directory, line by line
-# we had problems with ls -l1 and now use ls -1, perhaps we will make our
-# own tools if ls gives us any more problems.
-DIR=ls -1
-
-# The very strict ruleset applied to certain files.  If the build is broken
-# you might try altering this.
 ANSI=-ansi -pedantic -Wall
-
-# Default flags
-# CFLAGS specifies the default flags given to the compiler, they should
-# not conflict with specific overrides given by lower level makefiles.
-# The ruleset is very basic and you shouldn't need to mess with it.
-# LFLAGS specifies the default flags given to the linker when creating
-# executable programs.  Again, nothing here must conflict with lower
-# level makefiles or things will get broken.  All lower level Makefiles
-# should specify their CFLAGS like this:
-# CFLAGS=$(MASTER_CFLAGS) -pipe (or whatever)
-
-ifdef DEBUG
-
-MASTER_CFLAGS=-D__UNIX__ -g -c
-MASTER_LFLAGS=-g
-
-else
-
-MASTER_CFLAGS=-DNDEBUG -D__UNIX__ -O3 -c
+MASTER_CFLAGS=-D__UNIX__  -c $(OPTLEVEL)
 MASTER_LFLAGS=
-
-endif
-
-#
-# Filenme extensions section
-# This deals with differently named files on different systems,
-# for example Borland uses obj and UNIX uses o for object.
-# EXE file sometimes have an extension, sometimes not.
-# For all new makefiles please use these macros.
-#
-
+H=.h
 LIB=.a
-O=.o
 EXE=
 C=.c
 CPP=.cpp
-H=.h
-
-# Legacy database support.  Use the macro DB in the compiler flags of any
-# module which needs access to the user database.
-ifdef BLAKEDB_R2
+O=.o
+WITH_PTH=1
+PTH_DIR=/usr/local/include/
+PTH_LIB=/usr/local/lib/libpth.a
 DB=-DBLAKEDB_R2=1
-else
-DB=
-endif
+THISFILE=Makefile.gnu
+DIR=ls -1

MasterMake.gnu.old

+#
+# Master make file.  This makefile is included by all other makefiles
+# so anything defined here affects _all_ makefiles, master makefile,
+# source makefiles and individual target headers, except certain libs
+# which are maintained independently of OverChat.
+#
+# This header is intended to be built with GNU make.
+#
+# OverChat
+# (C)Copyright 2001-2002 Daybo Logic, all rights reserved.
+#
+
+# CC is the C compiler, it is set by default to cc, if you want to use
+# gcc or something else, uncomment and edit the line below.
+#CC=gcc
+
+# CPPC is the C++ compiler
+CPPC=g++
+
+# The make utility the build process uses _matters_.  BSD's make won't
+# suffice.  GNU make is what I use.  I'll point to gmake everywhere in
+# the tree if it matters.  If you want to point to another make program
+# change the line below.  Don't remove the line below.
+TMAKE=gmake
+
+# Debugging.  If you want debugging on the entire build, make sure
+# that DEBUG is defined, otherwise comment it out.
+DEBUG=1
+
+# If you want to use the new binary databases (R2) on the server and ocquery
+# you need to uncomment this line.
+BLAKEDB_R2=1
+
+# This specifies the default name of the makefile, don't remove it,
+# it's not optional.
+THISFILE=Makefile.gnu
+
+# This command lists the files in a directory, line by line
+# we had problems with ls -l1 and now use ls -1, perhaps we will make our
+# own tools if ls gives us any more problems.
+DIR=ls -1
+
+# The very strict ruleset applied to certain files.  If the build is broken
+# you might try altering this.
+ANSI=-ansi -pedantic -Wall
+
+# Default flags
+# CFLAGS specifies the default flags given to the compiler, they should
+# not conflict with specific overrides given by lower level makefiles.
+# The ruleset is very basic and you shouldn't need to mess with it.
+# LFLAGS specifies the default flags given to the linker when creating
+# executable programs.  Again, nothing here must conflict with lower
+# level makefiles or things will get broken.  All lower level Makefiles
+# should specify their CFLAGS like this:
+# CFLAGS=$(MASTER_CFLAGS) -pipe (or whatever)
+
+ifdef DEBUG
+
+MASTER_CFLAGS=-D__UNIX__ -g -c
+MASTER_LFLAGS=-g
+
+else
+
+MASTER_CFLAGS=-DNDEBUG -D__UNIX__ -O3 -c
+MASTER_LFLAGS=
+
+endif
+
+#
+# Filenme extensions section
+# This deals with differently named files on different systems,
+# for example Borland uses obj and UNIX uses o for object.
+# EXE file sometimes have an extension, sometimes not.
+# For all new makefiles please use these macros.
+#
+
+LIB=.a
+O=.o
+EXE=
+C=.c
+CPP=.cpp
+H=.h
+
+# Legacy database support.  Use the macro DB in the compiler flags of any
+# module which needs access to the user database.
+ifdef BLAKEDB_R2
+DB=-DBLAKEDB_R2=1
+else
+DB=
+endif

NetBuffer/NetBuffer.cpp

+/*
+  NetBuffer is a by David Duncan Ross Palmer <Overlord@DayboLogic.co.uk>
+  which will handle the Blake communication aspect of Oberchatten.
+  GlobalNetBuffer is the global instantaniation of the class which
+  will handle one client side socket using Blake networking features.
+  The C function DataReader and DataWriter have to be installed into
+  Blake before the global class GlobalNetBuffer can know about data
+  or send data.  It also exists in the server to handle clients,
+  in such circumstances, don't use Connect() feature, just use
+  the Push and Pop etc and construct with a pre-existing socket.
+  Either keep pointers to dynamically created TNetBuffer's in a linked
+  list or some sort of fixed structure.
+*/
+//---------------------------------------------------------------------------
+#include "overchat_config.h" // Global project options
+#include <assert.h>
+#include <string>
+#include <limits.h>
+#include <time.h>
+#include <iostream>
+#include <stdio.h>
+#ifdef HDRSTOP
+#  pragma hdrstop
+#endif /*HDRSTOP*/
+
+#include "ddrptype.h"
+#include "blake.h"
+#include "NetBuffer.h"
+
+using namespace std;
+//---------------------------------------------------------------------------
+static void (*UserErrorHandler)(enum blakeError ErrNum) = NULL;
+static size_t GetExpectSz(const unsigned char* RawData);
+
+#ifdef DEBUG
+static void DumpBuff(const char* File, const unsigned int Line, const unsigned char* RawBuffer, unsigned int Level);
+#endif //DEBUG
+//---------------------------------------------------------------------------
+void TNetBuffer::InitBuffers()
+{
+  outBuffLevel = 0U;
+  inBuffLevel = 0U;
+  memset(outBuff, 0, sizeof(outBuff));
+  memset(inBuff, 0, sizeof(inBuff));
+
+  memset(buff, 0, sizeof(buff)); // Current packet buffer
+  marker = 0U;
+  expectSz = 0U;
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer()
+:
+  s(0),
+  UseIPv6(false),
+  Port(OVERCHAT_PORT_DEFAULT)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer(int S)
+:
+  s(S),
+  UseIPv6(false),
+  Port(0)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer(unsigned short int Port, bool UseIpv6)
+:
+  s(0),
+  UseIPv6(UseIpv6),
+  Port(Port)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::~TNetBuffer()
+{
+  Close();
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::Resolve(const string& ServerName, OVERCHAT_IP* ReturnedAddress)
+{
+  return network_Resolve(ServerName.c_str(), ReturnedAddress);
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::CreateSocket(int* PSocket)
+{
+  s = network_CreateSocket(UseIPv6, false, false);
+  if ( s == -1 ) { // Blake could not create a socket
+    s = 0;
+    return blakeUnknownFailure;
+  }
+  return blakeSuccess;
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::Connect(const OVERCHAT_IP* Address)
+{
+  enum blakeError err;
+
+  err = network_Connect(s, UseIPv6, Port, Address); // Connect to server
+  if ( err != blakeSuccess ) // Fail
+    Close(); // Socket cannot be used (clean up)
+
+  // Conencted to server, switch to nonblocking
+  network_MakeNonBlocking(s);
+
+  return err;
+}
+//---------------------------------------------------------------------------
+void TNetBuffer::Close()
+{
+  if ( s ) {
+    network_CloseSocket(s);
+    s = 0;
+  }
+}
+//---------------------------------------------------------------------------
+enum NetBufferError TNetBuffer::Push(enum NetBufferDirection Direction, const void* Data, const size_t DataSize)
+{
+  enum NetBufferError err = nbeNoError;
+
+  assert(Data && DataSize);
+  if ( DataSize > OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ )
+    return nbeExtremeSize;
+
+  switch ( Direction ) {
+    case nbdIncoming : {
+      if ( DataSize > (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ) - inBuffLevel ) {
+        err = nbeCannotAccommodate;
+        break;
+      }
+      memcpy((char*)inBuff + inBuffLevel, Data, DataSize);
+      inBuffLevel += DataSize;
+      assert(inBuffLevel <= (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ));
+      break;
+    }
+    case nbdOutgoing : {
+      if ( DataSize > (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ) - outBuffLevel ) {
+        err = nbeCannotAccommodate;
+        break;
+      }
+      memcpy((char*)outBuff + outBuffLevel, Data, DataSize);
+      outBuffLevel += DataSize;
+      assert(outBuffLevel <= (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ));
+      break;
+    }
+    default : {
+      err = nbeBadDirection;
+    }
+  }
+
+  return err;
+}
+//---------------------------------------------------------------------------
+size_t TNetBuffer::Pop(enum NetBufferDirection Direction, void* Data, const size_t MaxDataSize, enum NetBufferError* PNetError)
+{
+  enum NetBufferError err = nbeNoError;
+  size_t ret = 0;
+
+  assert(Data && MaxDataSize);
+  switch ( Direction ) {
+    case nbdIncoming : {
+      unsigned int MoveAmount = BLAKE_MIN(MaxDataSize, inBuffLevel);
+      if ( MoveAmount ) {
+        memcpy(Data, inBuff, MoveAmount);
+        memmove(inBuff, (char*)inBuff+MoveAmount, (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ) - MoveAmount);
+        inBuffLevel -= MoveAmount;
+      }
+      ret = MoveAmount;
+      break;
+    }
+    case nbdOutgoing : {
+      unsigned int MoveAmount = BLAKE_MIN(MaxDataSize, outBuffLevel);
+      if ( MoveAmount ) {
+        memcpy(Data, outBuff, MoveAmount);
+        memmove(outBuff, (char*)outBuff+MoveAmount, (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ) - MoveAmount);
+        outBuffLevel -= MoveAmount;
+      }
+      ret = MoveAmount;
+      break;
+    }
+    default : {
+      err = nbeBadDirection;
+    }
+  }
+
+  if ( PNetError ) *PNetError = err;
+  return ret;
+}
+//---------------------------------------------------------------------------
+void TNetBuffer::PacketCompiler(size_t Amount)
+{
+#ifdef DEBUG
+  DumpBuff(__FILE__, __LINE__, inBuff, inBuffLevel);
+#endif //DEBUG
+
+  while ( Amount ) {
+    if ( marker == 0 ) { /* Begin new packet - length reader */
+      int nread = Pop(nbdIncoming, buff, 2, NULL); /* Read max two bytes (length indicator) */
+      if ( !nread ) return;
+      Amount -= nread; /* Remove from master packet independent bytes arrived marker */
+      switch ( nread ) {
+        case 0 : /* Nowt read */
+          goto setandunlock; /* Bugger off, stop wasting my time, bloody buffers */
+        case 1 : { /* Could only read 'alf of the blighter */
+          marker++; /* Remember it was read */
+          break;
+        }
+        case 2 : { /* Got it!  Now swap it... */
+          marker += 2;
+          expectSz = GetExpectSz(buff);
+          assert(expectSz); // Remember to turn off debugging in production servers
+          if ( expectSz >= 2 ) expectSz -= 2; // Expect packet size - length field already read
+          break;
+        }
+        default : /* What's this, -1? */
+          goto setandunlock; /* Forget it mate */
+      }
+    }
+    else if ( marker == 1 ) { /* Previously read half the length! */
+      /* OK we only want one byte!  I don't care how much is waiting */
+      int nread = Pop(nbdIncoming, buff + 1, 1, NULL);
+      if ( !nread ) return;
+      if ( nread != 1 ) goto setandunlock;
+      marker++;
+      expectSz = GetExpectSz(buff);
+      assert(expectSz);
+      if ( expectSz >= 2 ) expectSz -= 2;
+      assert(expectSz);
+      Amount -= nread;
+    }
+    else { /* Already got length, read packet */
+      /* Read in up to the the packet size, if the length is malicious or
+      corrupt cap at size of the RX buffer. */
+      int maxRead;
+      expectSz = expectSz % ((OVERCHAT_NET_PKTMAXSZ-2)+1); /* Cap packet length field to what we can handle */
+      maxRead = BLAKE_MIN((expectSz+2) - marker, sizeof(buff));
+       /* Do some error/warning checking for diagnostics and for safety */
+      if ( !expectSz ) goto setandunlock; /* Get out if no packet */
+      if ( expectSz < 2 ) { /* Not enough room to have even sent the length */
+        goto unlock;
+      }
+      else if ( expectSz < 3 ) { /* Just the two bytes for the length!? */
+       goto setandunlock;
+      }
+      /* Back to some real work */
+      if ( maxRead ) {
+        int nread = Pop(nbdIncoming, buff + marker, maxRead, NULL);
+        if ( !nread ) return;
+        marker += nread;
+        Amount -= nread;
+      }
+      if ( (expectSz) && marker == (expectSz+2) ) {
+        /* Pass to the Blake cracker */
+        enum blakeError err = blake_CrackPacket(GetSocket(), buff, expectSz+2);
+        /* Reset variables for next packet */
+        marker = 0;
+        expectSz = 0;
+        /* Check for Blake errors */
+        if ( err != blakeSuccess ) {
+          if ( UserErrorHandler )
+            UserErrorHandler(err);
+        }
+      }
+    }
+  }
+
+setandunlock:
+
+
+unlock:
+
+  return;
+}
+//---------------------------------------------------------------------------
+void NetBufferInstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum))
+{
+  assert(ErrorHandler); // NULL is not acceptable, use uninstall
+  assert(!UserErrorHandler); // Ensure no previous handler
+  UserErrorHandler = ErrorHandler; // Install it
+}
+//---------------------------------------------------------------------------
+void NetBufferUninstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum))
+{
+  assert(ErrorHandler == UserErrorHandler); // Make sure caller knows what he's talking about
+  UserErrorHandler = NULL; // Uninstall
+}
+//---------------------------------------------------------------------------
+#ifdef DEBUG
+static void DumpBuff(const char* File, const unsigned int Line, const unsigned char* RawBuffer, unsigned int Level)
+{
+  unsigned int i;
+
+  printf("Dump buffer called from %s L%u\n", File, Line);
+  if ( Level ) {
+    for ( i = 0U; i < Level; i++ )
+      printf("%X, ", RawBuffer[i]);
+    putchar('\n');
+  }
+  else
+    puts("Nothing to dump.");
+}
+#endif //DEBUG
+//---------------------------------------------------------------------------
+static size_t GetExpectSz(const unsigned char* RawData)
+{
+  size_t sz = 0U;
+  unsigned char rawnumber[sizeof(unsigned short)];
+  char test[3];
+
+  test[0] = RawData[0];
+  test[1] = RawData[1];
+  test[2] = '\0';
+
+  if ( RawData ) {
+    unsigned short int* pnum;
+    memcpy(rawnumber, RawData, 2); /* Get first two bytes */
+    pnum = (unsigned short int*)rawnumber;
+    sz = *pnum;
+    /* Now do a swap */
+    sz = network_NetToHostShort((unsigned short int)sz);
+    /* Now cap */
+    sz = sz % ((OVERCHAT_NET_PKTMAXSZ-2)+1);
+  }
+#ifdef DEBUG
+  printf("DEBUG: sz==%u  TESTRAW(%c%c)\n", sz, test[0], test[1]);
+#endif /*DEBUG*/
+  return sz;
+}
+//---------------------------------------------------------------------------

NetBuffer/NetBuffer.h

+#ifndef __INC_NETBUFFER_H
+#define __INC_NETBUFFER_H
+/*-------------------------------------------------------------------------*/
+#ifdef __cplusplus
+# include <string>
+#endif
+
+enum NetBufferError {
+  nbeNoError,
+  nbeCannotAccommodate,
+  nbeExtremeSize,
+  nbeBadDirection,
+  nbeSocketRegistered
+};
+
+enum NetBufferDirection {
+  nbdIncoming,
+  nbdOutgoing
+};
+
+#ifdef __cplusplus
+class TNetBuffer {
+  private:
+    int s; /* Socket number from Blake */
+    size_t outBuffLevel;
+    size_t inBuffLevel;
+    unsigned char outBuff[OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ];
+    unsigned char inBuff[OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ];
+  protected:
+    void InitBuffers();
+    unsigned char buff[OVERCHAT_NET_PKTMAXSZ]; /* Buffer for current packet being compiled */
+    unsigned int marker, expectSz;  /* Relating to packet compiler */
+  public:
+    bool UseIPv6;
+    unsigned short int Port;
+
+    TNetBuffer(); /* Normal constructor */
+    TNetBuffer(int S); /* Constructor for pre-existing socket */
+    TNetBuffer(unsigned short int Port, bool UseIpv6);
+    ~TNetBuffer(); /* Destructor */
+    enum blakeError Resolve(const std::string& ServerName, OVERCHAT_IP* ReturnedAddress);
+    enum blakeError CreateSocket(int* PSocket); /* Call before Connect() */
+    enum blakeError Connect(const OVERCHAT_IP* Address);
+    void Close(); /* Shut down the connection, socket becomes invalid */
+    enum NetBufferError Push(enum NetBufferDirection Direction, const void* Data, const size_t DataSize);
+    size_t Pop(enum NetBufferDirection Direction, void* Data, const size_t MaxDataSize, enum NetBufferError* PNetError);
+    void PacketCompiler(size_t Amount);
+    inline int GetSocket() /* Return the socket number we're using */
+      { return s; }
+};
+
+void NetBufferInstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum));
+void NetBufferUninstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum));
+
+#endif /*__cplusplus*/
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_NETBUFFER_H*/

NetBuffer/NetBuffer.~cp

+/*
+  NetBuffer is a by David Duncan Ross Palmer <Overlord@DayboLogic.co.uk>
+  which will handle the Blake communication aspect of Oberchatten.
+  GlobalNetBuffer is the global instantaniation of the class which
+  will handle one client side socket using Blake networking features.
+  The C function DataReader and DataWriter have to be installed into
+  Blake before the global class GlobalNetBuffer can know about data
+  or send data.  It also exists in the server to handle clients,
+  in such circumstances, don't use Connect() feature, just use
+  the Push and Pop etc and construct with a pre-existing socket.
+  Either keep pointers to dynamically created TNetBuffer's in a linked
+  list or some sort of fixed structure.
+*/
+//---------------------------------------------------------------------------
+#include "overchat_config.h" // Global project options
+#include <assert.h>
+#include <string>
+#include <limits.h>
+#include <time.h>
+#include <iostream>
+#include <stdio.h>
+#ifdef HDRSTOP
+#  pragma hdrstop
+#endif /*HDRSTOP*/
+
+#include "ddrptype.h"
+#include "blake.h"
+#include "NetBuffer.h"
+
+using namespace std;
+//---------------------------------------------------------------------------
+static void (*UserErrorHandler)(enum blakeError ErrNum) = NULL;
+static size_t GetExpectSz(const unsigned char* RawData);
+
+#ifdef DEBUG
+static void DumpBuff(const char* File, const unsigned int Line, const unsigned char* RawBuffer, unsigned int Level);
+#endif //DEBUG
+//---------------------------------------------------------------------------
+void TNetBuffer::InitBuffers()
+{
+  outBuffLevel = 0U;
+  inBuffLevel = 0U;
+  memset(outBuff, 0, sizeof(outBuff));
+  memset(inBuff, 0, sizeof(inBuff));
+
+  memset(buff, 0, sizeof(buff)); // Current packet buffer
+  marker = 0U;
+  expectSz = 0U;
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer()
+:
+  s(0),
+  UseIPv6(false),
+  Port(OVERCHAT_PORT_DEFAULT)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer(int S)
+:
+  s(S),
+  UseIPv6(false),
+  Port(0)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::TNetBuffer(unsigned short int Port, bool UseIpv6)
+:
+  s(0),
+  UseIPv6(UseIpv6),
+  Port(Port)
+{
+  InitBuffers();
+}
+//---------------------------------------------------------------------------
+TNetBuffer::~TNetBuffer()
+{
+  Close();
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::Resolve(const string& ServerName, OVERCHAT_IP* ReturnedAddress)
+{
+  return network_Resolve(ServerName.c_str(), ReturnedAddress);
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::CreateSocket(int* PSocket)
+{
+  s = network_CreateSocket(UseIPv6, false, false);
+  if ( s == -1 ) { // Blake could not create a socket
+    s = 0;
+    return blakeUnknownFailure;
+  }
+  return blakeSuccess;
+}
+//---------------------------------------------------------------------------
+enum blakeError TNetBuffer::Connect(const OVERCHAT_IP* Address)
+{
+  enum blakeError err;
+
+  err = network_Connect(s, UseIPv6, Port, Address); // Connect to server
+  if ( err != blakeSuccess ) // Fail
+    Close(); // Socket cannot be used (clean up)
+
+  // Conencted to server, switch to nonblocking
+  network_MakeNonBlocking(s);
+
+  return err;
+}
+//---------------------------------------------------------------------------
+void TNetBuffer::Close()
+{
+  if ( s ) {
+    network_CloseSocket(s);
+    s = 0;
+  }
+}
+//---------------------------------------------------------------------------
+enum NetBufferError TNetBuffer::Push(enum NetBufferDirection Direction, const void* Data, const size_t DataSize)
+{
+  enum NetBufferError err = nbeNoError;
+
+  assert(Data && DataSize);
+  if ( DataSize > OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ )
+    return nbeExtremeSize;
+
+  switch ( Direction ) {
+    case nbdIncoming : {
+      if ( DataSize > (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ) - inBuffLevel ) {
+        err = nbeCannotAccommodate;
+        break;
+      }
+      memcpy((char*)inBuff + inBuffLevel, Data, DataSize);
+      inBuffLevel += DataSize;
+      assert(inBuffLevel <= (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ));
+      break;
+    }
+    case nbdOutgoing : {
+      if ( DataSize > (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ) - outBuffLevel ) {
+        err = nbeCannotAccommodate;
+        break;
+      }
+      memcpy((char*)outBuff + outBuffLevel, Data, DataSize);
+      outBuffLevel += DataSize;
+      assert(outBuffLevel <= (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ));
+      break;
+    }
+    default : {
+      err = nbeBadDirection;
+    }
+  }
+
+  return err;
+}
+//---------------------------------------------------------------------------
+size_t TNetBuffer::Pop(enum NetBufferDirection Direction, void* Data, const size_t MaxDataSize, enum NetBufferError* PNetError)
+{
+  enum NetBufferError err = nbeNoError;
+  size_t ret = 0;
+
+  assert(Data && MaxDataSize);
+  switch ( Direction ) {
+    case nbdIncoming : {
+      unsigned int MoveAmount = BLAKE_MIN(MaxDataSize, inBuffLevel);
+      if ( MoveAmount ) {
+        memcpy(Data, inBuff, MoveAmount);
+        memmove(inBuff, (char*)inBuff+MoveAmount, (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ) - MoveAmount);
+        inBuffLevel -= MoveAmount;
+      }
+      ret = MoveAmount;
+      break;
+    }
+    case nbdOutgoing : {
+      unsigned int MoveAmount = BLAKE_MIN(MaxDataSize, outBuffLevel);
+      if ( MoveAmount ) {
+        memcpy(Data, outBuff, MoveAmount);
+        memmove(outBuff, (char*)outBuff+MoveAmount, (OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ) - MoveAmount);
+        outBuffLevel -= MoveAmount;
+      }
+      ret = MoveAmount;
+      break;
+    }
+    default : {
+      err = nbeBadDirection;
+    }
+  }
+
+  if ( PNetError ) *PNetError = err;
+  return ret;
+}
+//---------------------------------------------------------------------------
+void TNetBuffer::PacketCompiler(size_t Amount)
+{
+#ifdef DEBUG
+  DumpBuff(__FILE__, __LINE__, inBuff, inBuffLevel);
+#endif //DEBUG
+
+  while ( Amount ) {
+    if ( marker == 0 ) { /* Begin new packet - length reader */
+      int nread = Pop(nbdIncoming, buff, 2, NULL); /* Read max two bytes (length indicator) */
+      if ( !nread ) return;
+      Amount -= nread; /* Remove from master packet independent bytes arrived marker */
+      switch ( nread ) {
+        case 0 : /* Nowt read */
+          goto setandunlock; /* Bugger off, stop wasting my time, bloody buffers */
+        case 1 : { /* Could only read 'alf of the blighter */
+          marker++; /* Remember it was read */
+          break;
+        }
+        case 2 : { /* Got it!  Now swap it... */
+          marker += 2;
+          expectSz = GetExpectSz(buff);
+          assert(expectSz); // Remember to turn off debugging in production servers
+          if ( expectSz >= 2 ) expectSz -= 2; // Expect packet size - length field already read
+          break;
+        }
+        default : /* What's this, -1? */
+          goto setandunlock; /* Forget it mate */
+      }
+    }
+    else if ( marker == 1 ) { /* Previously read half the length! */
+      /* OK we only want one byte!  I don't care how much is waiting */
+      int nread = Pop(nbdIncoming, buff + 1, 1, NULL);
+      if ( !nread ) return;
+      if ( nread != 1 ) goto setandunlock;
+      marker++;
+      expectSz = GetExpectSz(buff);
+      assert(expectSz);
+      if ( expectSz >= 2 ) expectSz -= 2;
+      assert(expectSz);
+      Amount -= nread;
+    }
+    else { /* Already got length, read packet */
+      /* Read in up to the the packet size, if the length is malicious or
+      corrupt cap at size of the RX buffer. */
+      int maxRead;
+      expectSz = expectSz % ((OVERCHAT_NET_PKTMAXSZ-2)+1); /* Cap packet length field to what we can handle */
+      maxRead = BLAKE_MIN((expectSz+2) - marker, sizeof(buff));
+       /* Do some error/warning checking for diagnostics and for safety */
+      if ( !expectSz ) goto setandunlock; /* Get out if no packet */
+      if ( expectSz < 2 ) { /* Not enough room to have even sent the length */
+        goto unlock;
+      }
+      else if ( expectSz < 3 ) { /* Just the two bytes for the length!? */
+       goto setandunlock;
+      }
+      /* Back to some real work */
+      if ( maxRead ) {
+        int nread = Pop(nbdIncoming, buff + marker, maxRead, NULL);
+        if ( !nread ) return;
+        marker += nread;
+        Amount -= nread;
+      }
+      if ( (expectSz) && marker == (expectSz+2) ) {
+        /* Pass to the Blake cracker */
+        enum blakeError err = blake_CrackPacket(GetSocket(), buff, expectSz+2);
+        /* Reset variables for next packet */
+        marker = 0;
+        expectSz = 0;
+        /* Check for Blake errors */
+        if ( err != blakeSuccess ) {
+          if ( UserErrorHandler )
+            UserErrorHandler(err);
+        }
+      }
+    }
+  }
+
+setandunlock:
+
+
+unlock:
+
+  return;
+}
+//---------------------------------------------------------------------------
+void NetBufferInstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum))
+{
+  assert(ErrorHandler); // NULL is not acceptable, use uninstall
+  assert(!UserErrorHandler); // Ensure no previous handler
+  UserErrorHandler = ErrorHandler; // Install it
+}
+//---------------------------------------------------------------------------
+void NetBufferUninstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum))
+{
+  assert(ErrorHandler == UserErrorHandler); // Make sure caller knows what he's talking about
+  UserErrorHandler = NULL; // Uninstall
+}
+//---------------------------------------------------------------------------
+#ifdef DEBUG
+static void DumpBuff(const char* File, const unsigned int Line, const unsigned char* RawBuffer, unsigned int Level)
+{
+  unsigned int i;
+
+  printf("Dump buffer called from %s L%u\n", File, Line);
+  if ( Level ) {
+    for ( i = 0U; i < Level; i++ )
+      printf("%X, ", RawBuffer[i]);
+    putchar('\n');
+  }
+  else
+    puts("Nothing to dump.");
+}
+#endif //DEBUG
+//---------------------------------------------------------------------------
+static size_t GetExpectSz(const unsigned char* RawData)
+{
+  size_t sz = 0U;
+  unsigned char rawnumber[sizeof(unsigned short)];
+  char test[3];
+
+  test[0] = RawData[0];
+  test[1] = RawData[1];
+  test[2] = '\0';
+
+  if ( RawData ) {
+    unsigned short int* pnum;
+    memcpy(rawnumber, RawData, 2); /* Get first two bytes */
+    pnum = (unsigned short int*)rawnumber;
+    sz = *pnum;
+    /* Now do a swap */
+    sz = network_NetToHostShort((unsigned short int)sz);
+    /* Now cap */
+    sz = sz % ((OVERCHAT_NET_PKTMAXSZ-2)+1);
+  }
+#ifdef DEBUG
+  printf("DEBUG: sz==%u  TESTRAW(%c%c)\n", sz, test[0], test[1]);
+#endif /*DEBUG*/
+  return sz;
+}
+//---------------------------------------------------------------------------

NetBuffer/NetBuffer.~h

+#ifndef __INC_NETBUFFER_H
+#define __INC_NETBUFFER_H
+/*-------------------------------------------------------------------------*/
+#ifdef __cplusplus
+# include <string>
+#endif
+
+enum NetBufferError {
+  nbeNoError,
+  nbeCannotAccommodate,
+  nbeExtremeSize,
+  nbeBadDirection,
+  nbeSocketRegistered
+};
+
+enum NetBufferDirection {
+  nbdIncoming,
+  nbdOutgoing
+};
+
+#ifdef __cplusplus
+class TNetBuffer {
+  private:
+    int s; /* Socket number from Blake */
+    size_t outBuffLevel;
+    size_t inBuffLevel;
+    unsigned char outBuff[OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_TXSZ];
+    unsigned char inBuff[OVERCHAT_NET_PKTMAXSZ * OVERCHAT_NET_RXSZ];
+  protected:
+    void InitBuffers();
+    char buff[OVERCHAT_NET_PKTMAXSZ]; /* Buffer for current packet being compiled */
+    unsigned int marker, expectSz;  /* Relating to packet compiler */
+  public:
+    bool UseIPv6;
+    unsigned short int Port;
+
+    TNetBuffer(); /* Normal constructor */
+    TNetBuffer(int S); /* Constructor for pre-existing socket */
+    TNetBuffer(unsigned short int Port, bool UseIpv6);
+    ~TNetBuffer(); /* Destructor */
+    enum blakeError Resolve(const std::string& ServerName, OVERCHAT_IP* ReturnedAddress);
+    enum blakeError CreateSocket(int* PSocket); /* Call before Connect() */
+    enum blakeError Connect(const OVERCHAT_IP* Address);
+    void Close(); /* Shut down the connection, socket becomes invalid */
+    enum NetBufferError Push(enum NetBufferDirection Direction, const void* Data, const size_t DataSize);
+    size_t Pop(enum NetBufferDirection Direction, void* Data, const size_t MaxDataSize, enum NetBufferError* PNetError);
+    void PacketCompiler(size_t Amount);
+    inline int GetSocket() /* Return the socket number we're using */
+      { return s; }
+};
+
+void NetBufferInstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum));
+void NetBufferUninstallBlakeErrorCallback(void (*ErrorHandler)(enum blakeError ErrNum));
+
+#endif /*__cplusplus*/
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_NETBUFFER_H*/
+NetBuffer is the only known working version of the extremly difficult to
+use packet compilation of Blake.  To centralise all network buffer
+manipulation (TX/RX buffers), it is recommended that all Blake clients
+make use of NetBuffer (which is C++) and never use proprietary ways of
+compiling packets.  This does of course make it difficult for other
+languages, but those programmers of those languages will have to fend on
+their own based on this authoritative source.

blake/Makefile.bor

 # twice as a static library firstly and then a DLL.
 # This Makefile also builds and runs some tests.
 
+#    !include ..\MasterMake.bor    <- Get this made integral to Blake on Borland ASAP
+
+
 # Force 32-bit link
 CC=bcc32 -v
 RC=brcc32
 COPY=copy
 DPCRTLMM=..\dpcrtlmm\dpcrtlmm.lib
 
+!ifdef BLAKEDB_R2
+BLAKEDB_OBJ=blakedb2.obj
+!else
+BLAKEDB_OBJ=blakedb1.obj
+!endif
+
 BLAKE_OBJ=blake.obj \
           blake_cb.obj \
           blake_fastqueue.obj \
           blake_protocol.obj \
           criticalinteger.obj \
           recursivemutant.obj \
-          blakedb.obj \
+          $(BLAKEDB_OBJ) \
           blake_nick.obj \
           blake_portthread.obj \
           blake_trace.obj \
           blake_ansi.obj \
-          blake_strfunc.obj
+          blake_strfunc.obj \
+          blake_logger.obj
 
 BLAKE_RES_OBJ=res\btfuck.obj \
-              res\ddrp00.obj \
               res\murder_microsoft.obj \
               res\sbeast.obj
 
 	tlib ..\blake.lib +blake_protocol.obj
 	tlib ..\blake.lib +criticalinteger.obj
 	tlib ..\blake.lib +recursivemutant.obj
-	tlib ..\blake.lib +blakedb.obj
+	tlib ..\blake.lib +$(BLAKEDB_OBJ)
 	tlib ..\blake.lib +blake_nick.obj
 	tlib ..\blake.lib +blake_portthread.obj
 	tlib ..\blake.lib +blake_trace.obj
 	tlib ..\blake.lib +blake_ansi.obj
 	tlib ..\blake.lib +blake_strfunc.obj
+	tlib ..\blake.lib +blake_logger.obj
 	tlib ..\blake.lib +res\btfuck.obj
-	tlib ..\blake.lib +res\ddrp00.obj
 	tlib ..\blake.lib +res\murder_microsoft.obj
 	tlib ..\blake.lib +res\sbeast.obj
 
 ..\blake.dll : $(BLAKE_OBJ) blake.res $(MDF) blake_obj_res_dep
 	echo $(MAKEDIR)\..\lib\c0d32.obj + > $(TMPLINKFILE)
 	echo res\btfuck.obj + >> $(TMPLINKFILE)
-	echo res\ddrp00.obj + >> $(TMPLINKFILE)
 	echo res\murder_microsoft.obj + >> $(TMPLINKFILE)
 	echo res\sbeast.obj + >> $(TMPLINKFILE)
 	echo blake.obj + >> $(TMPLINKFILE)
         echo blake_protocol.obj + >> $(TMPLINKFILE)
         echo criticalinteger.obj + >> $(TMPLINKFILE)
         echo recursivemutant.obj + >> $(TMPLINKFILE)
-	echo blakedb.obj + >> $(TMPLINKFILE)
+	echo $(BLAKEDB_OBJ) + >> $(TMPLINKFILE)
 	echo blake_nick.obj + >> $(TMPLINKFILE)
 	echo blake_portthread.obj + >> $(TMPLINKFILE)
 	echo blake_trace.obj + >> $(TMPLINKFILE)
 	echo blake_ansi.obj + >> $(TMPLINKFILE)
 	echo blake_strfunc.obj + >> $(TMPLINKFILE)
+	echo blake_logger.obj + >> $(TMPLINKFILE)
 	echo $(MAKEDIR)\..\lib\cw32mti.lib + > $(TMPLINKFILE2)
 	echo $(MAKEDIR)\..\lib\import32.lib + >> $(TMPLINKFILE2)
 	echo ..\dpcrtlmm\dpcrtlmm.lib + >> $(TMPLINKFILE2)

blake/Makefile.gnu

 # . is a backward reference for those files to get to Blake headers
 # ../dpcrtlmm is because Blake relies on DPCRTLMM for debugging.
 # ../dlini is for the Daybo Logic INI support library
-IPATH=-I../src -I. -I../dpcrtlmm -I../dlini
+
+ifdef WITH_PTH
+THREAD_LIBRARY=$(PTH_LIB)
+THREAD_PTHINCLUDE=-I$(PTH_DIR)
+else
+THREAD_LIBRARY=-pthread
+THREAD_PTHINCLUDE=
+endif
+
+IPATH=-I../src -I. -I../dpcrtlmm -I../dlini $(THREAD_PTHINCLUDE)
 CFLAGS=$(MASTER_CFLAGS) $(IPATH)
-LFLAGS=$(MASTER_LFLAGS) ../libblake.a ../dpcrtlmm/libdpcrtlmm.a ../dlini/libdlini.a -pthread
+LFLAGS=$(MASTER_LFLAGS) ../libblake.a ../dpcrtlmm/libdpcrtlmm.a ../dlini/libdlini.a $(THREAD_LIBRARY)
 COMPILE=$(CC) $(CFLAGS)
 
 #BLAKEDB_R2 is the new binary database revsion 2 which is a lot faster
         blake_lang$(O) \
         $(BLAKEDBO) \
         criticalinteger$(O) \
-        recursivemutant$(O)
+        recursivemutant$(O) \
+        blake_safeallocate$(O)
 
 RESFILES=res/btfuck$(O) \
          res/murder_microsoft$(O) \

blake/Makefile.ms

-# Microsoft Developer Studio Generated NMAKE File, Based on blake.dsp
-!IF "$(CFG)" == ""
-CFG=blake - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to blake - Win32 Debug.
-!ENDIF 
-
-!IF "$(CFG)" != "blake - Win32 Release" && "$(CFG)" != "blake - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "blake.mak" CFG="blake - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "blake - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "blake - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE 
-!ERROR An invalid configuration is specified.
-!ENDIF 
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE 
-NULL=nul
-!ENDIF 
-
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF  "$(CFG)" == "blake - Win32 Release"
-
-OUTDIR=.\Release
-INTDIR=.\Release
-# Begin Custom Macros
-OutDir=.\Release
-# End Custom Macros
-
-ALL : "$(OUTDIR)\blake.dll"
-
-
-CLEAN :
-	-@erase "$(INTDIR)\blake.obj"
-	-@erase "$(INTDIR)\blake.res"
-	-@erase "$(INTDIR)\blake_cb.obj"
-	-@erase "$(INTDIR)\blake_fastqueue.obj"
-	-@erase "$(INTDIR)\blake_ll.obj"
-	-@erase "$(INTDIR)\blake_main.obj"
-	-@erase "$(INTDIR)\blake_network.obj"
-	-@erase "$(INTDIR)\blake_pendingloop.obj"
-	-@erase "$(INTDIR)\blake_portmutant.obj"
-	-@erase "$(INTDIR)\blake_protocol.obj"
-	-@erase "$(INTDIR)\btfuck.obj"
-	-@erase "$(INTDIR)\criticalinteger.obj"
-	-@erase "$(INTDIR)\ddrp00.obj"
-	-@erase "$(INTDIR)\murder_microsoft.obj"
-	-@erase "$(INTDIR)\recursivemutant.obj"
-	-@erase "$(INTDIR)\vc60.idb"
-	-@erase "$(OUTDIR)\blake.dll"
-	-@erase "$(OUTDIR)\blake.exp"
-	-@erase "$(OUTDIR)\blake.lib"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /G4 /MT /W3 /GX /O2 /I "..\dpcrtlmm" /I ".." /D "NDEBUG" /D "BLAKE_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fp"$(INTDIR)\blake.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
-MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 
-RSC_PROJ=/l 0x809 /fo"$(INTDIR)\blake.res" /d "NDEBUG" 
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\blake.bsc" 
-BSC32_SBRS= \
-	
-LINK32=link.exe
-LINK32_FLAGS=wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /dll /incremental:no /pdb:"$(OUTDIR)\blake.pdb" /machine:I386 /def:".\blake.def" /out:"$(OUTDIR)\blake.dll" /implib:"$(OUTDIR)\blake.lib" 
-DEF_FILE= \
-	".\blake.def"
-LINK32_OBJS= \
-	"$(INTDIR)\blake.obj" \
-	"$(INTDIR)\blake_cb.obj" \
-	"$(INTDIR)\blake_fastqueue.obj" \
-	"$(INTDIR)\blake_ll.obj" \
-	"$(INTDIR)\blake_main.obj" \
-	"$(INTDIR)\blake_network.obj" \
-	"$(INTDIR)\blake_pendingloop.obj" \
-	"$(INTDIR)\blake_portmutant.obj" \
-	"$(INTDIR)\blake_protocol.obj" \
-	"$(INTDIR)\btfuck.obj" \
-	"$(INTDIR)\criticalinteger.obj" \
-	"$(INTDIR)\ddrp00.obj" \
-	"$(INTDIR)\murder_microsoft.obj" \
-	"$(INTDIR)\recursivemutant.obj" \
-	"$(INTDIR)\blake.res" \
-	"..\dpcrtlmm\Debug\dpcrtlmm.lib"
-
-"$(OUTDIR)\blake.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF  "$(CFG)" == "blake - Win32 Debug"
-
-OUTDIR=.\Debug
-INTDIR=.\Debug
-# Begin Custom Macros
-OutDir=.\Debug
-# End Custom Macros
-
-ALL : "$(OUTDIR)\blake.dll"
-
-
-CLEAN :
-	-@erase "$(INTDIR)\blake.obj"
-	-@erase "$(INTDIR)\blake.res"
-	-@erase "$(INTDIR)\blake_cb.obj"
-	-@erase "$(INTDIR)\blake_fastqueue.obj"
-	-@erase "$(INTDIR)\blake_ll.obj"
-	-@erase "$(INTDIR)\blake_main.obj"
-	-@erase "$(INTDIR)\blake_network.obj"
-	-@erase "$(INTDIR)\blake_pendingloop.obj"
-	-@erase "$(INTDIR)\blake_portmutant.obj"
-	-@erase "$(INTDIR)\blake_protocol.obj"
-	-@erase "$(INTDIR)\btfuck.obj"
-	-@erase "$(INTDIR)\criticalinteger.obj"
-	-@erase "$(INTDIR)\ddrp00.obj"
-	-@erase "$(INTDIR)\murder_microsoft.obj"
-	-@erase "$(INTDIR)\recursivemutant.obj"
-	-@erase "$(INTDIR)\vc60.idb"
-	-@erase "$(INTDIR)\vc60.pdb"
-	-@erase "$(OUTDIR)\blake.dll"
-	-@erase "$(OUTDIR)\blake.exp"
-	-@erase "$(OUTDIR)\blake.ilk"
-	-@erase "$(OUTDIR)\blake.lib"
-	-@erase "$(OUTDIR)\blake.pdb"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-CPP_PROJ=/nologo /G4 /Gz /MT /W3 /Gm /GX /ZI /Od /I "c:\overchat" /I "c:\overchat\dpcrtlmm" /I "..\dpcrtlmm" /I ".." /D "_DEBUG" /D "BLAKE_AS_DLL" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fp"$(INTDIR)\blake.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c 
-MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 
-RSC_PROJ=/l 0x809 /fo"$(INTDIR)\blake.res" /d "_DEBUG" 
-BSC32=bscmake.exe
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\blake.bsc" 
-BSC32_SBRS= \
-	
-LINK32=link.exe
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /dll /incremental:yes /pdb:"$(OUTDIR)\blake.pdb" /debug /machine:I386 /def:".\blake.def" /out:"$(OUTDIR)\blake.dll" /implib:"$(OUTDIR)\blake.lib" /pdbtype:sept 
-DEF_FILE= \
-	".\blake.def"
-LINK32_OBJS= \
-	"$(INTDIR)\blake.obj" \
-	"$(INTDIR)\blake_cb.obj" \
-	"$(INTDIR)\blake_fastqueue.obj" \
-	"$(INTDIR)\blake_ll.obj" \
-	"$(INTDIR)\blake_main.obj" \
-	"$(INTDIR)\blake_network.obj" \
-	"$(INTDIR)\blake_pendingloop.obj" \
-	"$(INTDIR)\blake_portmutant.obj" \
-	"$(INTDIR)\blake_protocol.obj" \
-	"$(INTDIR)\btfuck.obj" \
-	"$(INTDIR)\criticalinteger.obj" \
-	"$(INTDIR)\ddrp00.obj" \
-	"$(INTDIR)\murder_microsoft.obj" \
-	"$(INTDIR)\recursivemutant.obj" \
-	"$(INTDIR)\blake.res" \
-	"..\dpcrtlmm\Debug\dpcrtlmm.lib"
-
-"$(OUTDIR)\blake.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF 
-
-.c{$(INTDIR)}.obj::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-.cpp{$(INTDIR)}.obj::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-.cxx{$(INTDIR)}.obj::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-.c{$(INTDIR)}.sbr::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-.cpp{$(INTDIR)}.sbr::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-.cxx{$(INTDIR)}.sbr::
-   $(CPP) @<<
-   $(CPP_PROJ) $< 
-<<
-
-
-!IF "$(NO_EXTERNAL_DEPS)" != "1"
-!IF EXISTS("blake.dep")
-!INCLUDE "blake.dep"
-!ELSE 
-!MESSAGE Warning: cannot find "blake.dep"
-!ENDIF 
-!ENDIF 
-
-
-!IF "$(CFG)" == "blake - Win32 Release" || "$(CFG)" == "blake - Win32 Debug"
-SOURCE=.\blake.c
-
-"$(INTDIR)\blake.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_cb.c
-
-"$(INTDIR)\blake_cb.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_fastqueue.c
-
-"$(INTDIR)\blake_fastqueue.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_ll.c
-
-"$(INTDIR)\blake_ll.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_main.c
-
-"$(INTDIR)\blake_main.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_network.c
-
-"$(INTDIR)\blake_network.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_pendingloop.c
-
-"$(INTDIR)\blake_pendingloop.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_portmutant.c
-
-"$(INTDIR)\blake_portmutant.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake_protocol.c
-
-"$(INTDIR)\blake_protocol.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\res\btfuck.c
-
-"$(INTDIR)\btfuck.obj" : $(SOURCE) "$(INTDIR)"
-	$(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\criticalinteger.c
-
-"$(INTDIR)\criticalinteger.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\res\ddrp00.c
-
-"$(INTDIR)\ddrp00.obj" : $(SOURCE) "$(INTDIR)"
-	$(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\res\murder_microsoft.c
-
-"$(INTDIR)\murder_microsoft.obj" : $(SOURCE) "$(INTDIR)"
-	$(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-SOURCE=.\recursivemutant.c
-
-"$(INTDIR)\recursivemutant.obj" : $(SOURCE) "$(INTDIR)"
-
-
-SOURCE=.\blake.rc
-
-"$(INTDIR)\blake.res" : $(SOURCE) "$(INTDIR)"
-	$(RSC) $(RSC_PROJ) $(SOURCE)
-
-
-
-!ENDIF 
-

blake/_blakemakeconfig.default

-#error ("Please configure Blake build options with blakemake before continuting the build")

blake/_blakemakeconfig.h

-/*
-  Generated header, do not edit
-*/
-
-#define DEBUG
-#define BLAKE_SERVER

blake/blake.DSW

Binary file modified.

blake/blake.OBR

Binary file modified.
 Const OVERCHAT_ROOMNAME_LIMIT = 20
 Const OVERCHAT_CHUMGROUPNAME_LIMIT = 128
 
+Const OVERCHAT_MINUTE = 60
+Const OVERCHAT_HOUR = 3600
+Const OVERCHAT_DAY = (OVERCHAT_HOUR) * 24
+Const OVERCHAT_YEAR = (OVERCHAT_DAY) * 365
+
+Const OVERCHAT_NET_PKTMAXSZ = 10240
+Const OVERCHAT_NET_TXSZ = 25
+Const OVERCHAT_NET_RXSZ = OVERCHAT_NET_TXSZ
+
 '/*
 '  Any of these error codes can be returned by Blake functions:
 '*/
   blakeNetDown = 11         '/* The network is down */
   blakeUnknownNetError = 12 '/* The network error is unknown or unhandled, report the code to DDRP */
   blakeRegAlready = 13      '/* Something was already registered */
+  blakeBadObject = 14       '/* An unitialised or unknown/unregistered object was passed for working on */
+  blakeQueueFull = 15       '/* A fixed size queue was full, dynamic queues return NotEnoughMem instead */
+  blakeUnknownFailure = 16  '/* Catch all condition or user tampering with data structures */
+  blakeQueueEmpty = 17      '/* The queue is empty */
+  blakeUnsupported = 18     '/* The function is not supported or not written yet */
+  blakeMismatch = 19        '/* Structure alignment or version mismatch */
+  blakeLimit = 20           '/* A hard coded limit was reached. */
+  blakeDbFull = 21          '/* The database is full. */
+  blakeDbAccessWrite = 22   '/* Unable to write to the database at this time */
+  blakeDbAccessRead = 23    '/* Unable to access the database (read) */
+End Enum
+
+Public Enum blakeLang
+  langEnglish = 0
+  langFrench = 1
+  langSpanish = 2
+  langGerman = 3
+  langItalian = 4
+  langPortuguese = 5
 End Enum
 
 Public Enum blakeExchange '/* AIM-like codes for different exchange virtual servers.  Used for chats */
   operatedRooms = 3       '/* Guests cannot enter these areas, here, operators may kick people from rooms */
   administrativeRooms = 4 '/* Reserved for operators, administrators and DDRP */
   debugRooms = 5          '/* Debugging only. these rooms may be unstable and include new features or testing stuff */
+  adultRooms = 6          '/* Rooms for adult content */
 End Enum
 
 Public Enum blakeServerCodes '/* Codes sent from the server to the client(s) */
   bscchum_signon = 9         '/* One of your chums just signed on */
   bscchum_signoff = 10       '/* One of your chums just signed off */
   bscchum_idle = 11          '/* One of your chums went into or came out of an idle state */
+  bscloginreply = 12         '/* You have have failed or succeed to authorise */
 End Enum
 
 Public Enum blakeClientCodes '/* code sent from the client(s) to the server */
   becchumalready = 11        '/* Said shum already a chum even if in another group */
 End Enum
 
+Public Enum blakeLoginReplyCode
+  blrSuccess = 0                '/* Logged in successfully */
+  blrNoSuchUser = 1             '/* This user does not exist in the server's database */
+  blrInvalidPassword = 2        '/* The supplied password is not correct */
+  blrAlreadyConnected = 3       '/* You are already logged in! */
+  blrConnLimitExceeded = 4      '/* You have too many clones on your network */
+  blrGlinedHost = 5             '/* Your host has been banned from OverChat */
+  blrGlinedDomain = 6           '/* Your domain is no longer welcome on OverChat */
+  blrKlinedHost = 7             '/* Your host may not connect to this server, find another one */
+  blrKlinedDomain = 8           '/* Your domain is not welcomed by the server administrator */
+  blrGeneral = 9                '/* General failure on OverChat */
+  blrUnknown = 10               '/* Unknown login failure */
+  blrOpenBlakeBannedProxy = 11   '/* No Open Blake users from this proxy (glined) */
+  blrOpenBlakeDisallowed = 12     '/* No Open Blake user from any proxy */
+End Enum
+
+'/* Ordinary mortals */
+Const CLEARANCE_ZERO = 0
+Const CLEARANCE_UNAUTHORISED = CLEARANCE_ZERO
+Const CLEARANCE_GUEST = 1
+Const CLEARANCE_ROOKIE = 2
+Const CLEARANCE_LESSER_BETA_TESTER = 3
+Const CLEARANCE_ROOKIE_REPRESENTITIVE = 4
+Const CLEARANCE_ROOKIE_WHIP = 5
+Const CLEARANCE_ROOKIE_WHIP_CHAIRMAN = 6
+Const CLEARANCE_USER_REPRESENTITVE = 7
+
+'/* Officers */
+Const CLEARANCE_SERVICE_CONTROLLER = 108
+Const CLEARANCE_HEAD_CONTROLLER = 109
+Const CLEARANCE_COMMITTEE = 110
+Const CLEARANCE_COMMITTEE_CHAIRMAN = 111
+Const CLEARANCE_FINANCIAL_ADVISOR = 112
+Const CLEARANCE_SPIRITUAL_ADVISOR = 113
+
+'/* Programmers */
+Const CLEARANCE_GREATER_BETA_TESTER = 214
+Const CLEARANCE_CODE_PATCHER = 215
+Const CLEARANCE_PROGRAMMER = 216
+Const CLEARANCE_SYSTEM_DESIGNER = 217
+Const CLEARANCE_DLOB_ENGINEER = 218
+Const CLEARANCE_BLAKE_ENGINEER = 219
+Const CLEARANCE_ENGINEER = 220
+
+'/* The gods */
+Const CLEARANCE_PROPHET = 248
+Const CLEARANCE_PROPHET_HEAD = 249
+Const CLEARANCE_FLOATING_SPECTATE = 250
+Const CLEARANCE_SUPERIOR_MYSTIC_CONTROLLER = 251
+Const CLEARANCE_HOLOGRAPHIC_DICTATOR = 252
+Const CLEARANCE_INVINSIBLE_ABSOLUTE_DICTATOR = 253
+Const CLEARANCE_SUPREME_COMMANDER = 254
+Const CLEARANCE_ROOT = 255 '/* Reserved for the system */
+
 '/* Declaration of fixed type blake_byte_t */
 Public Type blake_byte_t
   data As String * 1
   idle_secs As blake_word32_t                   '/* Seconds idle, calculated by the server internal information regardless of the back_flag or the idle state indicator */
 End Type
 
+Public Type blakeLoginReply
+  failcode As blake_byte_t   '/* See blakeLoginReplyCode */
+End Type
+
 Public Type blakeLogin                            '/* Client side */
   username(OVERCHAT_NICK_LIMIT) As blake_byte_t   '/* Your username, use padding, no NULL terminator is full length */
   password(OVERCHAT_PASS_LIMIT) As blake_byte_t   '/* Your password (sorry it's plaintext at the moment).  Same format as above */
 
 '/* What a packet looks like */
 'struct blakePacket {
+'  blake_word16_t len; /* Length of complete packet and extended packet, including self */
 '  blake_word8_t server; /* If nonzero use serverCode, if zero use clientCode */
 '  union {
 '    enum blakeServerCodes serverCode;
 '    enum blakeClientCodes clientCode;
 '  } code;
-'
 '  union { /* info (packet dependent) */
 '    /* ---- server side type packets ---- */
 '    struct blakeSuspend _suspend;
 '*/
 'void BLAKEAPI blake_InitCriticalInteger(critInt* CriticalInteger); /* Initialize a critical integer */
 'void BLAKEAPI blake_DestroyCriticalInteger(critInt* CriticalInteger); /* Destroy & cleanup a critical integer */
+Public Declare Sub blake_InitCriticalInteger Lib "blake" (CriticalInteger As critInt)
+Public Declare Sub blake_DestroyCriticalInteger Lib "blake" (CriticalInteger As critInt)
 
 '/*
 '  This is a linked list based on pointers, it's used for all sorts
   Overlord@DayboLogic.co.uk
 */
 
+#define BLAKE_SOURCE
 #include "overchat_config.h" /* Project configuration */
 #include <limits.h>
 #include <time.h>
 #define OVERCHAT_NET_RXSZ (OVERCHAT_NET_TXSZ)
 
 /*
+  C and C++ mixing macros.  For any function which is a C callable function
+  existing in a C++ module, OVERCHAT_C_IN_CPP must be placed _before_ the
+  declaration.  In C++, void in a prototype is not expected, in C it is.
+  Therefore if there are no paramters to a function, OVERCHAT_PROTOTYPE_VOID
+  must be placed in place of the parameter list.
+*/
+#ifdef __cplusplus /* C++ */
+# define OVERCHAT_C_IN_CPP extern "C"
+# define OVERCHAT_PROTOTYPE_VOID
+#else /* C */
+# define OVERCHAT_C_IN_CPP
+# define OVERCHAT_PROTOTYPE_VOID void
+#endif /*__cplusplus*/
+
+/*
   These definitions are used within Blake and within the OverChat server.  You
   are welcome to use them too.
 */
 */