M6 KVM avatar M6 KVM committed 290c0fd

Entire changeset 0.1.8-pre1 -> 0.1.8-pre2

Comments (0)

Files changed (402)

-$Id: ChangeLog,v 0.1.8.12 2005/09/23 16:12:00 ddrp Exp $
+$Id: ChangeLog,v 0.1.8.19 2006/01/31 12:51:00 ddrp Exp $
 
 This ChangeLog was created 2001/11/24
 It is updated often and between releases
 at least every server release.
 
 
+0.1.8-pre2
+----------
+DDRP: Add Darwin/Fink paths to configure for GNU Portable Thread lib.
+DDRP: Further line length limitations in server source
+DDRP: timeago in pending kill should be a minimum of one, not zero
+DDRP: Removal of disassembler-spoofing pointers from server_message
+DDRP: Removal of ocquery/cmd_nickpub.c
+DDRP: options_GetConnectionLimit() returns 10, temporary hack
+DDRP: Change order of compiler existance tests to make sure we select
+      bcc32 on systems with Cygwin or Services for UNIX installed.
+DDRP: Rely on DayboThreads package, elimate all mutant and thread
+      debugging configure options from main configure program.
+DDRP: Remove depreciated server threads completely.  All threading and
+      mutant operations are now handled by DayboThreads.
+DDRP: (UNIX): Makefile builds configure to correctly know the hostname
+      and username on which it was built.
+DDRP: Switch to -mtune rather than -mcpu
+DDRP: Added test for dlstr to configure
+DDRP: DeadMan has been stripped because I could not get it to work
+      correctly under pre-emption.  Technical complexities posted to
+      mailing list.
+DDRP: Split server heartbeat startup into initialisation and starting
+      portions.  Added new stop code to Blake: BLAKESTOP_DDRP_UNINITED.
+DDRP: Remove all Indirection code from src/server.cpp
+DDRP: Mutants are officially deprecated.
+DDRP: All __INC_ macros are renamed INC_
+DDRP: blakeFastQueue now uses new dtlock_t and not a mutant
+DDRP: We now define DAYBOTHREADS_PTHREAD and not OVERCHAT_PTHREAD in
+      configure.
+
 0.1.8-pre1
 ----------
 DDRP: Modify root GNUmakefile to build the new tree
-$Id: LICENSE,v 0.3 2004/02/05 14:25:00 ddrp Rel $
-
-Copyright (C) 2001-2004 Daybo Logic.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-3. Neither the name of the project nor the names of its contributors
-   may be used to endorse or promote products derived from this software
-   without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
+$Id: LICENSE,v 0.4 2006/01/21 16:30:00 ddrp Rel $
+
+Copyright (C) 2001-2006 Daybo Logic.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the project nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
 STATIC=
 CC=bcc32
 CPPC=bcc32
-DEBUG=1
+#DEBUG=1
 OPTLEVEL=
 TMAKE=make
 CPPWARNINGS=-wamb \
 -wucp \
 -wuse
 ANSI=-A
-MASTER_CFLAGS=-D__WIN32__ -v -c
-MASTER_LFLAGS=-v
+MASTER_CFLAGS=-D__WIN32__  -c
+MASTER_LFLAGS=
+DAYBOTHREADS_NT=1
 H=.h
 LIB=.lib
 EXE=.exe
 O=.obj
 TV_DIR=.
 STRIP=tdstrp32
-PREFIX_BIN=/bin/
-PREFIX_LIB=/lib/
-PREFIX_INC=/include/
-PREFIX_DAYBODEP_BIN=/bin/
+PREFIX_BIN=d:/bin/
+PREFIX_LIB=d:/lib/
+PREFIX_INC=d:/include/
+PREFIX_DAYBODEP_BIN=d:/bin/
 THISFILE=Makefile.bor
 DIR=dir /b
+$Id: todo.txt,v 0.2 2003/10/27 11:55:00 ddrp Rel $
+
+DDRP: Strip critical integer and add it into DayboThreads
+
+DDRP: Remove handles internally from portthread in DayboThreads (they are deprecated)
+
+DDRP: Add database verification on server start and possibly periodically
+
+DDRP: Add SHA-1 to overchat/daybocrypt and change license as much as algorithms allow
+
+DDRP: Write a common command line tools library including a standard parameter interface for dealing with "--" and "-n 19" etc (like nice)  Don't forget options for printing errors via a callback in the case of invalid parameters
+
+DDRP: SHA-1 support
+
+DDRP: Create tools/verify_filelist to verify the package is complete
+
+DDRP: OberChatten to try most secure hash first and then use less secure ones as they fail
+
+DDRP: Secure client authentication server (for people who want to ensure only clients they allow can log in)
+
+DDRP: Other SHA support
+
+DDRP: Create a tool to create a default empty database (or nearly empty apart from an "OverChat" user)
+
+DDRP: Make a class to handle Blake and only use Blake through it make it auto destroying and the like
+
+DDRP: Add SIG_IGN instead of handler in SIGPIPE handlers and such
+
+DDRP: Move to MySQL
+
+DDRP: Write separate chat exchange server(s)
+
+Unassigned
+----------
+Poisonable identifiers (#pragma GCC poison)
+
+Add capabillities and client specific capabillities. new packet getcaps?
+
+Error notices if mails fail to be sent in OCQuery (better handling of sendmail)
+
+INI file writer for UNIX systems to be completed.
+
+Add new macro FULL_SERVER defined only for the central server not sub-servers.
+
+Advertising support.
+
+Grep for strncpy/strcpy and make sure that all uses are absolutely safe, especially that strncpy()'s are followed by manual termination of the last character in a string.
+
+Add a DPCRTLMM option to use PTH locks and not POSIX locks << Is this relevant?
+
+Make server print warning if regusers.db2 is not present
+
+Total split up of services <~ Major engineering work
+
+The event system should copy Oberchatten, ie, it must only call handlers which are relevant and not every single one, to save call time a bit ;)
+
+Drop r00t privelleges!
+
+Add 180 second ping/pong to prevent extended dead people using OverChat for 24 hours
+
+Add logoff packet to ensure users sign off correctly
+
+User sound effects on demand (CTCP SOUND blah.wav type of thing)
+
+Add safe allocator to allow Carly and Craig to come into the project without fouling up memory...
+
+Ensure OverChat does not allow a dynamic password update for user root
+
+SO_REUSEADDR in Blake networking connect
+
+gaim plugin

blake/FastQueueWrapper.cpp

+/*
+Copyright (C) 2001-2006 Daybo Logic.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the project nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+*/
+/*
+  Blake C++ support
+  This software is suppied with source to aid the building of clients
+  which use the OverChat system.  The C++ wrappers allow
+  C++ programs to encapsulate routines which are exported from the Blake
+  library.
+*/
+#include "overchat_config.h"
+#include <assert.h>
+#include <limits.h>
+#include <stddef.h>
+#ifdef HDRSTOP
+# pragma hdrstop
+#endif
+
+#include "blake.h"
+#include "FastQueueWrapper.h"
+//---------------------------------------------------------------------------
+#ifdef OVERCHAT_RCS_STAMPS
+static const char *rcsid =
+  "$Id: FastQueueWrapper.cpp,v 0.2 2006/01/21 15:30:00 ddrp Exp $";
+#endif /*OVERCHAT_RCS_STAMPS*/
+//---------------------------------------------------------------------------
+Blake::TFastQueue::TFastQueue(
+  const unsigned int Size,
+  const size_t ElementSize
+)
+{
+  assert(Size && ElementSize);
+  _lastError = blake_InitFastQueue(&_queue, Size-1, ElementSize);
+  _elemSize = ElementSize;
+}
+//---------------------------------------------------------------------------
+Blake::TFastQueue::~TFastQueue()
+{
+  _lastError = blake_DestroyFastQueue(&_queue);
+  // I'm storing the last error anyway, though it would be inadvisable
+  // for the user to read it after object destruction really.  The only
+  // way in which it would be safe is a non-deleted object, local, static
+  // or global, where the destructor was called directly with ~TFastQueue().
+}
+//---------------------------------------------------------------------------
+enum blakeError Blake::TFastQueue::Add(
+  const void *NewItem
+)
+{
+  _lastError = blake_PushFastQueue(&_queue, NewItem);
+  return _lastError;
+}
+//---------------------------------------------------------------------------
+enum blakeError Blake::TFastQueue::Top(
+  void *NewItem
+)
+{
+  _lastError = blake_TopFastQueue(&_queue, NewItem, _elemSize);
+  return _lastError;
+}
+//---------------------------------------------------------------------------
+enum blakeError Blake::TFastQueue::Pop()
+{
+  _lastError = blake_PopFastQueue(&_queue);
+  return _lastError;
+}
+//---------------------------------------------------------------------------
+unsigned int Blake::TFastQueue::Count()
+{
+  return blake_CountFastQueue(&_queue);
+}
+//---------------------------------------------------------------------------
+bool Blake::TFastQueue::Good()
+{
+  if ( _lastError == blakeSuccess )
+    return true;
+
+  return false;
+}
+//---------------------------------------------------------------------------
+bool Blake::TFastQueue::Bad()
+{
+  return !Good();
+}
+//---------------------------------------------------------------------------

blake/FastQueueWrapper.h

+/*
+$Id: FastQueueWrapper.h,v 0.2 2006/01/21 15:30:00 ddrp Exp $
+
+Copyright (C) 2001-2006 Daybo Logic.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. Neither the name of the project nor the names of its contributors
+   may be used to endorse or promote products derived from this software
+   without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+*/
+/*
+  Blake C++ support
+  This software is suppied with source to aid the building of clients
+  which use the OverChat system.  The C++ wrappers allow C++ programs
+  to encapsulate routines which are exported from the Blake library.
+  You may use these wrappers to aid use of Blake within C++.
+*/
+
+#ifndef INC_BLAKE_FASTQUEUEWRAPPER_H
+#define INC_BLAKE_FASTQUEUEWRAPPER_H
+/*-------------------------------------------------------------------------*/
+#ifndef __cplusplus
+# error ("Blake FastQueueWrapper is designed for C++."
+#endif /*!__cplusplus*/
+
+namespace Blake {
+  class TFastQueue {
+  private:
+    struct blakeFastQueue _queue;
+    size_t _elemSize;
+    enum blakeError _lastError;
+  public:
+    TFastQueue(const unsigned int Size, const size_t ElementSize);
+    ~TFastQueue(); // Destructor
+    enum blakeError Add(const void* NewItem);
+    enum blakeError Top(void* NewItem);
+    enum blakeError Pop();
+    unsigned int Count();
+    bool Good();
+    bool Bad();
+  };
+};
+/*-------------------------------------------------------------------------*/
+#endif /*!INC_BLAKE_FASTQUEUEWRAPPER_H*/

blake/GNUmakefile

-# $Id: GNUmakefile,v 2.0 2005/09/22 17:31:00 ddrp Exp $
+# $Id: GNUmakefile,v 2.2 2006/02/01 23:32:00 ddrp Exp $
 #
-# Copyright (C) 2001-2005 Daybo Logic.
+# Copyright (C) 2001-2006 Daybo Logic.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # libdlini for the Daybo Logic INI support library
 # libdybocryp for the cryptographic features
 
-ifdef OVERCHAT_PTH
+ifdef DAYBOTHREADS_PTH
 THREAD_LIBRARY=$(PTH_LIB)
 THREAD_PTHINCLUDE=-I$(PTH_DIR)
 else
 DLINI_LIB=$(PREFIX_LIB)libdlini$(LIB)
 DYBOCRYP_LIB=$(PREFIX_LIB)libdybocryp$(LIB)
 RTTB_LIB=$(PREFIX_LIB)librttb$(LIB)
+DAYBOTHREADS_LIB=$(PREFIX_LIB)libdaybothreads$(LIB)
 
 CFLAGS=$(MASTER_CFLAGS) $(IPATH)
 LFLAGS=$(MASTER_LFLAGS) \
        $(DLINI_LIB) \
        $(DYBOCRYP_LIB) \
        $(RTTB_LIB) \
+       $(DAYBOTHREADS_LIB) \
        $(THREAD_LIBRARY)
 
 COMPILE=$(CC) $(CFLAGS) $(CWARNINGS)
         blake_network$(O) \
         blake_nick$(O) \
         blake_pendingloop$(O) \
-        blake_portmutant$(O) \
-        blake_portthread$(O) \
         blake_protocol$(O) \
         blake_ansi$(O) \
         blake_strfunc$(O) \
         blake_chomp$(O) \
         blake_options$(O) \
         blakedb$(O) \
-        criticalinteger$(O) \
-        recursivemutant$(O) \
+        blake_criticalinteger$(O) \
         blake_netbuffer$(O) \
         NetBuffer$(O)
 
- 
+blake.c
+blake_ansi.c
+blake_authorisedclients.c
+blake_bench.c
+blake_cb.c
+blake_chksum.c
+blake_chomp.c
+blake_contact.c
+blake_criticalinteger.c
+blake_debugtables.c
+blake_fastqueue.c
+blake_fs.c
+blake_hashes.c
+blake_here.c
+blake_lang.c
+blake_ll.c
+blake_logger.c
+blake_main.c
+blake_network.c
+blake_nick.c
+blake_options.c
+blake_panic.c
+blake_pendingloop.c
+blake_protocol.c
+blake_safeallocate.c
+blake_strfunc.c
+blake_template.c
+blake_trace.c
+blake_version.c
+blakedb.c
+dllclient.c
+FastQueueWrapper.h
+blake.h
+blake_ansi.h
+blake_authorisedclients.h
+blake_bench.h
+blake_cb.h
+blake_chksum.h
+blake_chomp.h
+blake_criticalinteger.h
+blake_debugtables.h
+blake_fastqueue.h
+blake_fs.h
+blake_hashes.h
+blake_here.h
+blake_lang.h
+blake_ll.h
+blake_logger.h
+blake_main.h
+blake_netbuffer.h
+blake_network.h
+blake_nick.h
+blake_options.h
+blake_panic.h
+blake_pendingloop.h
+blake_protocol.h
+blake_safeallocate.h
+blake_strfunc.h
+blake_template.h
+blake_trace.h
+blake_version.h
+blakedb.h
+ddrpsocket.h
+stopcodes.h
+FastQueueWrapper.cpp
+blake_netbuffer.cpp
 /*
-Copyright (C) 2001-2005 Daybo Logic.
+Copyright (C) 2001-2006 Daybo Logic.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 #ifdef __WIN32__
 # include <windows.h>
 #endif /*__WIN32__*/
+
+#if defined(DAYBOTHREADS_NT)
+# include <windows.h>
+#elif defined(DAYBOTHREADS_PTH)
+# include <pth.h>
+#else
+# include <pthread.h>
+#endif /*DAYBOTHREADS_NT*/
+
 #ifdef HDRSTOP
 #  pragma hdrstop
 #endif /*HDRSTOP*/
 /*-------------------------------------------------------------------------*/
 #ifdef OVERCHAT_RCS_STAMPS
 static const char *const rcsid =
-  "$Id: blake.c,v 0.4 2005/09/22 17:30:00 ddrp Stab $";
+  "$Id: blake.c,v 0.5 2006/01/31 14:16:00 ddrp Rel $";
 #endif /*OVERCHAT_RCS_STAMPS*/
 /*-------------------------------------------------------------------------*/
 #if ( defined(BLAKE_AS_DLL) && defined(__WIN32__) )
 #define OVERCHAT_OFFENSIVE "offensive.txt" /* FIXME: Must be removed */
 
 /*
-$Id: blake.h,v 1.8 2005/09/22 13:34:00 ddrp Exp $
+$Id: blake.h,v 2.0.3 2006/01/31 13:57:00 ddrp Rel $
 
-Copyright (C) 2001-2005 Daybo Logic.
+Copyright (C) 2001-2006 Daybo Logic.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 
 #ifndef INC_BLAKE_H
 #define INC_BLAKE_H
+
+#include "daybothreads.h" /* Required library */
 /*-------------------------------------------------------------------------*/
 /*
   Export/import definition for easy library building.  Do not be confused
 
 enum blakeClientCodes {   /* code sent from the client(s) to the server */
   bcclogin,                  /* Respond to an authentication challenge */
-  bccsuper_request,          /* Get information about your current privellege */
+  bccsuper_request,          /* Get information about your current privilege */
   bccadd_enemy,              /* Block an anoying user */
   bccnot_enemy,              /* Unblock a user */
   bccjoin_chat,              /* Attempt to join a group chat (may not be suppoed by the server) */
 };
 
 /*
-  Privelleges are used internally by the server and are requested by
-  clients.  Use one of the privelleges here, if it corrosponds to the value
-  in your account you will be awarded the privellege.  See titles.txt
-  for more information of titles and privelleges.
+  Privileges are used internally by the server and are requested by
+  clients.  Use one of the privileges here, if it corrosponds to the value
+  in your account you will be awarded the privilege.  See titles.txt
+  for more information of titles and privileges.
 */
 /* Ordinary mortals */
 #define CLEARANCE_ZERO 0
   call this function, the code won't port to other platforms.  This only
   applies when Blake is built as a DLL anyway.  Please make sure you
   call the function.
+
+  Thread information: As of OverChat 0.1.8, the threads and mutants code
+  has been stripped into a separate library called DayboThreads.  DayboThreads
+  _must_ be initialised _before_ the call to blake_Init().
 */
 BLAKEAPI(blake_bool_t) blake_Init(void);
 
   better at a leter date. Note: Technically Win32 is capable of dealing
   with this cleanup automatically.  However, if you rely on this and don't
   call this function, the code won't port to other platforms.
+
+  Thread information: As of OverChat 0.1.8, the thread and mutant code has
+  been stripped from Blake and is now in a separate library called
+  DayboThreads.  blake_Cleanup() will no longer shut down threads.  The thread
+  library should only be shut down _after_ Blake has been cleaned up.
 */
 BLAKEAPI(blake_bool_t) blake_Cleanup(void);
 
           blake_dTrace(__FILE__, __LINE__, (msg))
 
 /*
-  These "mutant" versions deal with creating mutexes in a portable fasion.
-  It is preferable to use these rather than Win32 critical sections or
-  POSIX mutexes because these are always around in the Blake library
-  rather than platform specific.
-*/
-typedef unsigned int BLAKE_MUTANT_HANDLE;
-/*
-  This nil handle is in use for other things apart from mutants too
+  This nil handle is in use for other things apart from mutants
   but it is generally for optional initialisation of a mutant handle,
   where it is necessary to indicate the handle does not represent
-  any valid mutant
+  any valid mutant.  For more information on mutants, which are
+  wrappers around mutexes or critical sections, see the daybothreads
+  library.
 */
-#define BLAKE_INVALID_HANDLE (0U)
-
-/*
-  To create a thread synchonisation object for mutual exclusion, use
-  blake_CreateMutant().  Mutants may be locked, unlocked but must
-  eventually be destroyed.  If the function returns zero it has failed.
-  This typically means that the process is out of memory.  There is
-  no arbitary limit on the number of mutants a process may make.
-*/
-BLAKEAPI(BLAKE_MUTANT_HANDLE) blake_CreateMutant(void);
-
-/*
-  To lock a mutant, call this function, failures cannot be seen for speed,
-  it is very important that mutants are locked and unlocked very quickly.
-  If the handle is a valid return from blake_CreateMutant(), the function
-  will not fail.  When the mutant has been locked, no other thread may lock
-  it.  Under Win32, it is possible to use mutants recursively but this
-  behaviour must not be relied upon and I may exclude this behaviour at some
-  point to force compatibilly with POSIX.
-*/
-BLAKEAPI(void) blake_LockMutant(BLAKE_MUTANT_HANDLE MutantHandle);
-
-/*
-  blake_TryLockMutant() was added to support an attempt to lock a mutant
-  without blocking.  It is supported on UNIX, Windows NT and Windows 9x
-  (Win32).  Though non-NT versions of Windows do not have the function
-  TryEnterCriticalSection(), support is used through the Win32 global
-  mutex interface which is a lot slower than the normal critical section
-  interface.  The function returns false if the mutant cannot be immediately
-  locked.
-*/
-BLAKEAPI(bool) blake_TryLockMutant(BLAKE_MUTANT_HANDLE MutantHandle);
-
-/*
-  It is critical that a locked mutant be unlocked as soon as possible,
-  failure to unlock a mutant could result in a deadlocked thread.
-*/
-BLAKEAPI(void) blake_UnlockMutant(BLAKE_MUTANT_HANDLE MutantHandle);
-
-/*
-  Once a mutant has no further use, it should be destroyed.  It should
-  not be destroyed whilst it is locked.  If so, the behaviour is
-  undefined.  Don't do it.
-*/
-BLAKEAPI(void) blake_DestroyMutant(BLAKE_MUTANT_HANDLE MutantHandle);
-
-/*
-  This function simply validates if a mustant handle is valid.  It
-  returns no other information about the state of the mutant.  It
-  cannot be used for recursive mutants.
-*/
-BLAKEAPI(bool) blake_ValidateMutant(const BLAKE_MUTANT_HANDLE MutantHandle);
-
-/*
-  The following functions work in the same way as the normal mutant
-  control functions but allow for verbose tracking via logging and/or
-  the dead man.  They accept an optional filename/linenumber.  This
-  should be __FILE__, __LINE__ as defined by most C compilers.  If you
-  have wrapped mutants with a C++ wrapper it should pass on the correct
-  details and not give the line number of the actual call.
-*/
-BLAKEAPI(BLAKE_MUTANT_HANDLE) blake_DebugCreateMutant(const char* SourceFile, const unsigned int SourceLine);
-BLAKEAPI(void) blake_DebugLockMutant(BLAKE_MUTANT_HANDLE MutantHandle, const char* SourceFile, const unsigned int SourceLine);
-BLAKEAPI(bool) blake_DebugTryLockMutant(BLAKE_MUTANT_HANDLE MutantHandle, const char* SourceFile, const unsigned int SourceLine);
-BLAKEAPI(void) blake_DebugUnlockMutant(BLAKE_MUTANT_HANDLE MutantHandle, const char* SourceFile, const unsigned int SourceLine);
-BLAKEAPI(void) blake_DebugDestroyMutant(BLAKE_MUTANT_HANDLE MutantHandle, const char* SourceFile, const unsigned int SourceLine);
-BLAKEAPI(bool) blake_DebugValidateMutant(const BLAKE_MUTANT_HANDLE MutantHandle, const char* SourceFile, const unsigned int SourceLine);
-
-/*
-  If you have defined DEBUG I default to redirecting normal mutant
-  functions to debug mutant functions automatically.  Hope this helps,
-  my fellow nerdy programmers!  Note: Don't define BLAKE_PORTMUTANT_SOURCE,
-  that is only defined in blake_portmutant.c to stop internal recursion
-  which would cause a stack overslow were these functions executed there.
-*/
-#if ( ( defined(DEBUG) ) && !defined(BLAKE_PORTMUTANT_SOURCE) )
-# define blake_CreateMutant() \
-           blake_DebugCreateMutant(__FILE__, __LINE__)
-# define blake_LockMutant(m) \
-           blake_DebugLockMutant((m), __FILE__, __LINE__)
-# define blake_TryLockMutant(m) \
-           blake_DebugTryLockMutant((m), __FILE__, __LINE__)
-# define blake_UnlockMutant(m) \
-           blake_DebugUnlockMutant((m), __FILE__, __LINE__)
-# define blake_DestroyMutant(m) \
-           blake_DebugDestroyMutant((m), __FILE__, __LINE__)
-# define blake_ValidateMutant(m) \
-           blake_DebugValidateMutant((m), __FILE__, __LINE__)
-#endif
-
-/*
-  The following sections deals portably with an object known as a
-  "recursive mutant".  A recursive mutant may be locked twice by the
-  same thread without deadlocking provided you have a way to know
-  all threads by a thread ID.  This is a very useful feature which
-  Win32 critical sections support anyway and which POSIX does not without
-  non-portable extensions.
-*/
-
-typedef struct _recursiveMutant {
-  /* Private logically opaque data... */
-  struct {
-    unsigned int recursiveLocks;
-    int ownerThreadID;
-    int locked; /* boolean */
-    BLAKE_MUTANT_HANDLE mutex;
-  } _protected;
-  BLAKE_MUTANT_HANDLE _mutantMutex;
-} recursiveMutant;
-
-/*
-  To initialise a recursive mutant, call blake_InitRecursiveMutant()
-  with a pointer to your recursiveMutant.  The function may fail because
-  recursive mutants require two normal mutants to be created internally.
-  If it fails it will return false, no cleanup is neccersary in this case.
-  Normally, cleanup is required with blake_DestroyRecursiveMutant()
-*/
-BLAKEAPI(blake_bool_t) blake_InitRecursiveMutant(recursiveMutant* PMutant);
-
-/*
-  When a recursive mutant has no further use, destroy it with this
-  function.  Do not destroy mutants which are locked.
-*/
-BLAKEAPI(void) blake_DestroyRecursiveMutant(recursiveMutant* PMutant);
-
-/*
-  To lock a recursive mutant, don't use the ordinary mutant locker,
-  use this function.  The calling thread's ID must be passed so
-  recursive mutants can keep track of the right owners.
-*/
-BLAKEAPI(void) blake_LockRecursiveMutant(recursiveMutant* PMutant, const int ThreadID);
-
-/*
-  To unlock a recursive mutant which must be done an equal number of time
-  as locking by the thread which locked the mutant, call this function.
-  The current thread's ID must be passed.
-*/
-BLAKEAPI(void) blake_UnlockRecursiveMutant(recursiveMutant* PMutant, const int ThreadID);
+#define BLAKE_INVALID_HANDLE (DAYBOTHREADS_INVALID_HANDLE)
 
 /*
   A critical integer is a very useful object which is an integer which is
     signed long int sl;
     unsigned long int ul;
   } _integer;
-  BLAKE_MUTANT_HANDLE _lock;
+  DAYBOTHREADS_OLDMUTANT_HANDLE _lock;
 
   /* Public - use these functions to manipulate */
   enum critIntType (*DetermineType)(struct _critInt* PObject); /* Returns the type of integer */
 BLAKEAPI(void) blake_DestroyCriticalInteger(critInt* CriticalInteger); /* Destroy & cleanup a critical integer */
 
 /*
-  To portably cause a timed blocking event call this function.  It will
-  only return once Seconds is up, never before.  Similar functionallty
-  is easy to access but is not generally portable.  Relying on Blake is
-  the best way to ensure portabillty.  There is not much to know about
-  the return value, it will only fail if Blake is not initialised.
-  Zero can be used to surrender the calling thread's timeslice.
-*/
-BLAKEAPI(enum blakeError) blake_Sleep(unsigned int Seconds);
-
-/*
-  Alternatively for finer precision use blake_SleepMS() which is times
-  in 1000ths of a second.
-*/
-BLAKEAPI(enum blakeError) blake_SleepMS(unsigned int Seconds);
-
-/*
   This is a linked list based on pointers, it's used for all sorts
   of things inside the Blake library but is also offered to outsiders
   if you cannot be bothered to code your own linked list in.
   the size element of the structure is set to the correct sizeof() else the function
   will fail, reporting blakeBadObject.
 */
-BLAKEAPI(enum blakeError) blake_InitLinkPtrs(struct blake_link_ptrs* Obj, size_t NodeSize);
-BLAKEAPI(enum blakeError) blake_DebugInitLinkPtrs(const char* SourceFile, const unsigned int SourceLine, struct blake_link_ptrs* Obj, size_t NodeSize);
+BLAKEAPI(enum blakeError) blake_InitLinkPtrs(
+  struct blake_link_ptrs *Obj,
+  size_t NodeSize
+);
+
+BLAKEAPI(enum blakeError) blake_DebugInitLinkPtrs(
+  const char *SourceFile,
+  const unsigned int SourceLine,
+  struct blake_link_ptrs *Obj,
+  size_t NodeSize
+);
 
 #if ( defined(DEBUG) && !defined(BLAKE_LL_SOURCE) )
 # define blake_InitLinkPtrs(o, ns) \
   unsigned int Count; /* Current used items */
   struct blakeFastQueueInternal* Base;
   void* MemoryDebugger; /* This is used by the Blake memory debugger, do not touch */
-  BLAKE_MUTANT_HANDLE MutantHandle; /* This is used automatically by any code working on the queue, don't touch it.  If not multithreading it is not used. */
+  dtlock_t Lock; /* This DayboThreads lock is used by the fast queue internally.  Do not tamper with it */
+  bool LockCreated; /* Internally used to prevent direct access to the above */
 };
 
 /*
   later.  Do not over do any of these values or blakeNotEnoughMem will
   return.
 */
-BLAKEAPI(enum blakeError) blake_InitFastQueue(struct blakeFastQueue* PQueue, const unsigned int UBound, const size_t ElemSize);
+BLAKEAPI(enum blakeError) blake_InitFastQueue(
+  struct blakeFastQueue *PQueue,
+  const unsigned int UBound,
+  const size_t ElemSize
+);
 
 /*
   To add an item to the back of the queue call this function.
   data basis into the back of the queue.  It shall not be topped
   until all other pending items in front of it have been popped.
 */
-BLAKEAPI(enum blakeError) blake_PushFastQueue(struct blakeFastQueue* PQueue, const void* NewItem);
+BLAKEAPI(enum blakeError) blake_PushFastQueue(
+  struct blakeFastQueue *PQueue,
+  const void *NewItem
+);
 
 /*
   To "top" a fast queue, call this function with a pointer to the
   is returned and the element is cleared.  The same element will
   always be returned until the queue is popped.
 */
-BLAKEAPI(enum blakeError) blake_TopFastQueue(struct blakeFastQueue* PQueue, void* PReceiveItem, const size_t SizeItem);
+BLAKEAPI(enum blakeError) blake_TopFastQueue(
+  struct blakeFastQueue *PQueue,
+  void *PReceiveItem,
+  const size_t SizeItem
+);
 
 /*
   This function "pops" a queue.  What that means is that the element
   at the front of the queue is discarded, normally done after "topping"
   the queue.
 */
-BLAKEAPI(enum blakeError) blake_PopFastQueue(struct blakeFastQueue* PQueue);
+BLAKEAPI(enum blakeError) blake_PopFastQueue(
+  struct blakeFastQueue *PQueue
+);
 
 /*
   This functions is a simple call which does not return extended
   with the Count variable but is inadvisable, CountFastQueue()
   follows proper locking symantics.
 */
-BLAKEAPI(unsigned int) blake_CountFastQueue(struct blakeFastQueue* PQueue);
+BLAKEAPI(unsigned int) blake_CountFastQueue(
+  struct blakeFastQueue *PQueue
+);
 
 /*
   In order to free the resources allocated inside a fast queue
   to free.  This function will fail gracefully with a blakeBadObject
   if you try it.
 */
-BLAKEAPI(enum blakeError) blake_DestroyFastQueue(struct blakeFastQueue* PQueue);
+BLAKEAPI(enum blakeError) blake_DestroyFastQueue(
+  struct blakeFastQueue *PQueue
+);
 
 /*
   If a client receives data from the server, it contains a raw stream (TCOP)
   if the callback was executed but failed for whatever reason.  Two is
   returned if the callback was called and reported success.
 */
-BLAKEAPI(enum blakeError) blake_CrackPacket(int Socket, const void* PacketBuffer, const size_t BufferLength);
+BLAKEAPI(enum blakeError) blake_CrackPacket(
+  int Socket,
+  const void *PacketBuffer,
+  const size_t BufferLength
+);
 
 /*
   In order to handle logging messages which Blake sometimes
   A unique number corrosponding to the thread you are calling from is
   required for safe installation of callbacks (a recursive mutant is used
   internally).  If you are not using a multithreaded program, zero will
-  suffice, otherwise a unique number returned by a Blake threading function
-  is acceptable or your own numbering system.  but don't get the two systems
-  confused!
+  suffice, otherwise a unique number returned by a daybothreads
+  threading function is acceptable or your own numbering system but don't
+  get the two systems confused!
 */
 BLAKEAPI(enum blakeError) blake_InstallCallback(
   const int ThreadID,
   See other manuals for in depth conversation on this.
   On failure the function returns -1.
 */
-BLAKEAPI(int) network_CreateSocket(blake_bool_t IPv6, blake_bool_t Datagram, blake_bool_t NonBlocking);
+BLAKEAPI(int) network_CreateSocket(
+  blake_bool_t IPv6,
+  blake_bool_t Datagram,
+  blake_bool_t NonBlocking
+);
 
 
 /*
   I have provided this nice, portable way of switching the socket
   mode.
 */
-BLAKEAPI(void) network_MakeNonBlocking(int SocketDesc);
+BLAKEAPI(void) network_MakeNonBlocking(
+  int SocketDesc
+);
 
 /*
   The traditonal resolvers for UNIX and WinSock were not thread safe,
   can fail for other reasons such as bad parameters or library not
   initialised.
 */
-BLAKEAPI(enum blakeError) network_Resolve(const char* HostNameIn, OVERCHAT_IP* IPOut);
+BLAKEAPI(enum blakeError) network_Resolve(
+  const char *HostNameIn,
+  OVERCHAT_IP *IPOut
+);
 
 /*
   It is simple to determine whether an IP is zero or not but this
   returns false if the IP is OK.  It returns true if no address is passed
   or the IP is zero (for example 0.0.0.0).
 */
-BLAKEAPI(bool) network_IsZeroIP(const OVERCHAT_IP* PIP);
+BLAKEAPI(bool) network_IsZeroIP(
+  const OVERCHAT_IP *PIP
+);
 
 /*
   This function is experimental, it prints an IP to stdout but may be
   scrapped as it is of limited use, it might be better to use the Get
   IP as string function.
 */
-BLAKEAPI(void) network_PrintIP(const OVERCHAT_IP* IP);
+BLAKEAPI(void) network_PrintIP(
+  const OVERCHAT_IP *IP
+);
 
 /*
   This function compares two IPs and returns true if they are the same,
   that is, NULL and NULL match (true), NULL and an IP, even if that IP is
   zero, do not match (false).
 */
-BLAKEAPI(bool) network_CompareIP(const OVERCHAT_IP* IP1, const OVERCHAT_IP* IP2);
+BLAKEAPI(bool) network_CompareIP(
+  const OVERCHAT_IP *IP1,
+  const OVERCHAT_IP *IP2
+);
 
 /*
   This function cracks a traditional IP (32-bit value), IPv4 from a
   functions such as get as string.  It splits apart the DWORD into the
   four byte portions ready for dotted notation.
 */
-BLAKEAPI(enum blakeError) network_CrackIPv4(const DWORD dwIPIn, OVERCHAT_IP* IPOut);
+BLAKEAPI(enum blakeError) network_CrackIPv4(
+  const DWORD dwIPIn,
+  OVERCHAT_IP *IPOut
+);
 
 /*
   See the above cracker, this function re-concatinates the IP into
   a DWORD for easy and smaller storage and for network interaction.
 */
-BLAKEAPI(enum blakeError) network_DecrackIPv4(const OVERCHAT_IP* IPIn, DWORD* dwIPOut);
+BLAKEAPI(enum blakeError) network_DecrackIPv4(
+  const OVERCHAT_IP *IPIn,
+  DWORD *dwIPOut
+);
+
 /*
   This function connects a client to the server.  A socket open on the
   client side should be passed.  The socket should have been returned
   returns blakeSuccess then the socket has been successfully connected to
   the server, congratulation.
 */
-BLAKEAPI(enum blakeError) network_Connect(int Socket, blake_bool_t IPv6, const unsigned short int Port, const OVERCHAT_IP* IP);
+BLAKEAPI(enum blakeError) network_Connect(
+  int Socket,
+  blake_bool_t IPv6,
+  const unsigned short int Port,
+  const OVERCHAT_IP *IP
+);
+
 /*
   To allow your program to be called when raw data arrives on a socket,
   a special raw data callback must be installed.  Simply pass the number
   the callback to be called for all sockets Blake knows about.
   Note: The callback returns nothing and accepts the socket number.
 */
-BLAKEAPI(enum blakeError) network_InstallIncomingCallback(int Socket, void (*DataReader)(int S));
+BLAKEAPI(enum blakeError) network_InstallIncomingCallback(
+  int Socket,
+  void (*DataReader)(int S)
+);
 
 /*
   Attention: This is an import function, one outgoing callback is allowed per
     blakeRegAlready - This already was the callback (redundant)
     blakeNotStarted - Blake was not started
 */
-BLAKEAPI(enum blakeError) network_InstallOutgoingCallback(void (*Sender)(int Socket, const void* RawData, size_t RawDataSize));
+BLAKEAPI(enum blakeError) network_InstallOutgoingCallback(
+  void (*Sender)(int Socket, const void* RawData, size_t RawDataSize)
+);
 
 /*
   This function returns the next available socket for writing.  It returns
   This function initialises the IP, effectively a call to network_LoadIP()
   with NULL as a source.  Do not use with IPv6 IPs
 */
-BLAKEAPI(enum blakeError) network_InitIPv4(OVERCHAT_IP* PIP);
+BLAKEAPI(enum blakeError) network_InitIPv4(
+  OVERCHAT_IP *PIP
+);
 
 /*
   This is the Blake pending loop.  It must be called frequently in order
   from inside any callback such as those installed by
   network_InstallRawCallback() can deadlock the thread.
 */
-BLAKEAPI(void) blake_PendingLoop(blake_bool_t RunForever);
+BLAKEAPI(void) blake_PendingLoop(
+  blake_bool_t RunForever
+);
+
 /*
   When the pending loop is running in 'RunForever' mode it should
   be cancelled before the process is cleaned up.  To do this
   'RunForever' mode, this function has no effect whatsoever.
 */
 BLAKEAPI(void) blake_CancelPendingLoop(void);
-BLAKEAPI(blake_bool_t) network_Write(int SocketDesc, const void* Buffer, const size_t BufferSize);
-BLAKEAPI(int) network_Read(int SocketDesc, void* Buffer, const size_t BufferSize); /* This works the same way as recv() */
-BLAKEAPI(void) network_LoadIP(OVERCHAT_IP* PDest, OVERCHAT_IP* PSource); /* Copies an IP address, NULL as PSource maybe used to init an IP address */
-BLAKEAPI(void) network_GetIPOnSocket(OVERCHAT_IP* PDest, int SocketDesc); /* Loads the IP holder with the IP when given the socket descriptor for the user */
-BLAKEAPI(void) network_GetIPAsString(char* DestBuff, UINT DestMaxLen, OVERCHAT_IP* IPStore); /* Get IP as a string for printing */
-BLAKEAPI(unsigned long int) network_HostToNetLong(unsigned long int Value); /* Change byte order for network */
-BLAKEAPI(unsigned short int) network_HostToNetShort(unsigned short int Value);
-BLAKEAPI(unsigned long int) network_NetToHostLong(unsigned long int Value); /* Change byte order from network */
-BLAKEAPI(unsigned short int) network_NetToHostShort(unsigned short int Value);
-BLAKEAPI(blake_bool_t) network_WriteString(int SocketDesc, const char* Str); /* Writes a string to the socket */
-BLAKEAPI(blake_bool_t) network_WriteChar(int SocketDesc, char Char); /* Faster if you only have one byte to write */
+
+BLAKEAPI(blake_bool_t) network_Write(
+  int SocketDesc,
+  const void *Buffer,
+  const size_t BufferSize
+);
+
+/*
+  This works the same way as recv()
+*/
+BLAKEAPI(int) network_Read(
+  int SocketDesc,
+  void *Buffer,
+  const size_t BufferSize
+);
+
+/*
+  Copies an IP address, NULL as PSource maybe used to init an IP address
+*/
+BLAKEAPI(void) network_LoadIP(
+  OVERCHAT_IP *PDest,
+  OVERCHAT_IP *PSource
+);
+
+/*
+  Loads the IP holder with the IP when given the socket descriptor for
+  the user
+*/
+BLAKEAPI(void) network_GetIPOnSocket(
+  OVERCHAT_IP *PDest,
+  int SocketDesc
+);
+
+/*
+  Get IP as a string for printing
+*/
+BLAKEAPI(void) network_GetIPAsString(
+  char *DestBuff,
+  UINT DestMaxLen,
+  OVERCHAT_IP *IPStore
+);
+
+/*
+  Change byte order for network
+*/
+BLAKEAPI(unsigned long int) network_HostToNetLong(
+  unsigned long int Value
+);
+
+BLAKEAPI(unsigned short int) network_HostToNetShort(
+  unsigned short int Value
+);
+
+/*
+  Change byte order from network
+*/
+BLAKEAPI(unsigned long int) network_NetToHostLong(
+  unsigned long int Value
+);
+
+BLAKEAPI(unsigned short int) network_NetToHostShort(
+  unsigned short int Value
+);
+
+/*
+  Writes a string to the socket
+*/
+BLAKEAPI(blake_bool_t) network_WriteString(
+  int SocketDesc,
+  const char *Str
+);
+
+/*
+  Faster if you only have one byte to write
+*/
+BLAKEAPI(blake_bool_t) network_WriteChar(
+  int SocketDesc,
+  char Char
+);
 
 /*
   This function is for incoming connections to the server.  This
   is Blake (yet) for temporarily denying connections.  The callback simply
   is given the socket of the client who has connection.  You may be wondering
   how to set this up, how to get program control to work.  Make sure you call
-  the blake_PendingLoop() or Ccb() will never be called.  The function doesn't
-  fail, that is not to say that it cannot.  It certainly fails if the Blake
-  library is not initialised.  The port socket is the socket prepared for
-  listening with network_StartListening().
+  the blake_PendingLoop() or Ccb() will never be called.  The function
+  doesn't fail, that is not to say that it cannot.  It certainly fails if the
+  Blake library is not initialised.  The port socket is the socket prepared
+  for listening with network_StartListening().
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) network_InstallCC(int PortSocket, void Ccb(int SocketNumber));
+  BLAKEAPI(enum blakeError) network_InstallCC(
+    int PortSocket,
+    void Ccb(int SocketNumber)
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
-  The start listening function takes a socket returned by network_CreateSocket()
-  and prepares the socket for listening.  It takes a call to the pending loop
-  catalyst (as much as possible) to actually grab those callers which are
-  coming in.  It also takes a function installed with network_InstallCC() to
-  get those socket numbers of the connections.  However, before a socket
-  has been prepared for listening, the port is not open and it is impossible
-  for for callers to connect.  You'll generally only call this once.
-  It can only work once per port number unless the port is closed with
-  network_CloseSocket().  OverChat has one port (port 3277 as of writing).
-  Two ports don't have a purpose at this time but may later.  Presently,
-  this function is only useful for the server not the client.  That may
-  change if direct instant message connection becomes possible.
+  The start listening function takes a socket returned by
+  network_CreateSocket() and prepares the socket for listening.  It takes a
+  call to the pending loop catalyst (as much as possible) to actually grab
+  those callers which are coming in.  It also takes a function installed
+  with network_InstallCC() to get those socket numbers of the connections.
+  However, before a socket has been prepared for listening, the port is not
+  open and it is impossible for for callers to connect.  You'll generally
+  only call this once.  It can only work once per port number unless the
+  port is closed with network_CloseSocket().  OverChat has one port
+  (port 3277 as of writing).  Two ports don't have a purpose at this time
+  but may later.  Presently, this function is only useful for the server
+  not the client.  That may change if direct instant message connection
+  becomes possible.
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) network_StartListening(int PortSocket, unsigned short PortNumber);
+  BLAKEAPI(enum blakeError) network_StartListening(
+    int PortSocket,
+    unsigned short PortNumber
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
   asks a client to login with an amount of time.
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(bool) blake_Challenge(int Sock, USHORT MaxSecs, const unsigned char ChallengeDigest[BLAKE_MD5HASHLEN]);
-BLAKEAPI(bool) blake_LoginReply(int Sock, enum blakeLoginReplyCode LoginReplyCode);
+  BLAKEAPI(bool) blake_Challenge(
+    int Sock,
+    USHORT MaxSecs,
+    const unsigned char ChallengeDigest[BLAKE_MD5HASHLEN]
+  );
+
+  BLAKEAPI(bool) blake_LoginReply(
+    int Sock,
+    enum blakeLoginReplyCode LoginReplyCode
+  );
 #endif /*BLAKE_SERVER*/
 /*
   To login normally pass Username and Password, to login as a guest pass NULL
   unauthorised clients.  They must be correct or later security questions by
   the server will fail.
 */
-BLAKEAPI(blake_bool_t) blake_Login(int Sock, const char* Username, const char* Password, enum blakeLang Language, const unsigned char ChallengeDigest[BLAKE_MD5HASHLEN], const enum blakeClientID ClientID, const unsigned long ClientVersion, enum blakeHashType LoginHashType);
+BLAKEAPI(blake_bool_t) blake_Login(
+  int Sock,
+  const char *Username,
+  const char *Password,
+  enum blakeLang Language,
+  const unsigned char ChallengeDigest[BLAKE_MD5HASHLEN],
+  const enum blakeClientID ClientID,
+  const unsigned long ClientVersion,
+  enum blakeHashType LoginHashType
+);
+
 /*
   Functions called by the server to make the client "shaddup" occasionally.
   Listen to the server when you receive these packets!  Else the server
   will kill you!
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(blake_bool_t) blake_Suspend(int Sock, const unsigned long Seconds); /* if Seconds == 0UL client waits for a resume */
-BLAKEAPI(blake_bool_t) blake_Resume(int Sock);
+  /*
+    if Seconds == 0UL client waits for a resume
+  */
+  BLAKEAPI(blake_bool_t) blake_Suspend(
+    int Sock,
+    const unsigned long Seconds
+  );
+
+  BLAKEAPI(blake_bool_t) blake_Resume(
+    int Sock
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
   is usually 0, check the BLAKEMESSAGE_FLAGS1_ flags for more information,
   always use BLAKEMESSAGE_FLAGS1_NOTICE for notices such as away messages.
 */
-BLAKEAPI(enum blakeError) blake_Msg(int Sock, const char* NickName, const char* Msg, enum blakeCipherID BCID, blake_word8_t Flags1);
+BLAKEAPI(enum blakeError) blake_Msg(
+  int Sock,
+  const char *NickName,
+  const char *Msg,
+  enum blakeCipherID BCID,
+  blake_word8_t Flags1
+);
 
 /*
   blake_Msg2() is the function which doesn't message a user, it is very
   similar to blake_Msg(), except that it messages the server (or the client).
   Bi-directional just like IM type messages.
 */
-BLAKEAPI(enum blakeError) blake_Msg2(int Sock, const char* Msg);
+BLAKEAPI(enum blakeError) blake_Msg2(
+  int Sock,
+  const char *Msg
+);
 
 /*
   blake_Whois() is a function which requests whois info about a person who
   When a whois is requested, a whois info is returned, so ensure you
   have a callback to collect the data when it comes through.
 */
-BLAKEAPI(enum blakeError) blake_Whois(int Sock, const char* NickName);
+BLAKEAPI(enum blakeError) blake_Whois(
+  int Sock,
+  const char *NickName
+);
 
 /*
   blake_WhoisInfo() is a server side only function which is used to reply
   structure is modified.
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) blake_WhoisInfo(
-  int Sock,
-  const struct blakeWhoisInfo* PWhoisInfo
-);
+  BLAKEAPI(enum blakeError) blake_WhoisInfo(
+    int Sock,
+    const struct blakeWhoisInfo *PWhoisInfo
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
 */
 BLAKEAPI(enum blakeError) blake_IsOnline(
   int Sock,
-  const char* NickName
+  const char *NickName
 );
+
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) blake_IsOnlineReply(
-  int Sock,
-  const char* NickName,
-  blake_bool_t Yes
-);
+  BLAKEAPI(enum blakeError) blake_IsOnlineReply(
+    int Sock,
+    const char *NickName,
+    blake_bool_t Yes
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
-  These two functions enable a client to request it's current privellege
-  (clearance) level and the server to reply with the privellege.
+  These two functions enable a client to request it's current privilege
+  (clearance) level and the server to reply with the privilege.
   Set reserved to zero.
 */
 BLAKEAPI(enum blakeError) blake_SuperRequest(
   blake_word8_t Reserved
 );
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) blake_Super(
-  int Sock,
-  blake_word8_t Clearance
-);
+  BLAKEAPI(enum blakeError) blake_Super(
+    int Sock,
+    blake_word8_t Clearance
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
   These two functions are used for one of the most evil functions of
   OverChat.  /kill (grin).  Kill is used to disconnect another user
-  and is only available to g0ds of the service.  Anybody else trying
+  and is only available to gods of the service.  Anybody else trying
   to use it will just be returned one of the standard error codes.
   Via the typical blake error reporting packet, the same one which
   is used when somebody you're messing isn't online, etc.  Note:
-  The Snear is used to tell the user they are a loser generally.
+  The Sneer is used to tell the user they are a loser generally.
 */
 BLAKEAPI(enum blakeError) blake_Kill(
   int Sock,
-  const char* NickName,
-  const char* Snear
+  const char *NickName,
+  const char *Sneer
 );
+
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) blake_Killed(
-  int Sock,
-  const char* NickOfKiller,
-  const char* Snear
-);
+  BLAKEAPI(enum blakeError) blake_Killed(
+    int Sock,
+    const char *NickOfKiller,
+    const char *Sneer
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
 */
 BLAKEAPI(enum blakeError) blake_Register(
   int Sock,
-  const char* Nick,
-  const char* Email
+  const char *Nick,
+  const char *Email
 );
 #ifdef BLAKE_SERVER
-BLAKEAPI(enum blakeError) blake_RegisterReply(
-  int Sock,
-  const enum blakeRegisterReplyCode ReplyCode,
-  const char* Password
-);
+  BLAKEAPI(enum blakeError) blake_RegisterReply(
+    int Sock,
+    const enum blakeRegisterReplyCode ReplyCode,
+    const char *Password
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
   can be written to the packet's len member so that the other side of
   the conversation can read the packet and know when it truely ends.
 */
-BLAKEAPI(blake_word16_t) blake_RecalculateRealPktSz(struct blakePacket* PPacket);
+BLAKEAPI(blake_word16_t) blake_RecalculateRealPktSz(
+  struct blakePacket *PPacket
+);
 
 /*
   This function may do nothing depending on what version of Blake
   indicated as having memory allocated by the name of blake_fastqueue.c
   you know a queue is allocated etc.
 */
-BLAKEAPI(void) blake_DebugDump(const char* FileName);
+BLAKEAPI(void) blake_DebugDump(
+  const char *FileName
+);
 
 /*
   This function is useful for when functions have to receive parameters
   blake_UnusedVar((v), 0)
 
 /*
-  If you encounter a deadlock and you use mutants in your program,
-  make sure Blake was built with BLAKE_DEADMAN defined.  If not
-  this entrypoint does absolutely nothing.  It is unlikely to be
-  defined for clients unless specifically requested, it is only
-  defined for unstable versions of the server.  DeadMan is a hack
-  which will help trap deadlocked mutants, it should be called
-  every few minutes from a thread which does not wait on any other
-  objects which could in theory deadlock.  A dedicated thread is
-  preferable.  WARNING: If a deadlock is detected, DeadMan does not
-  return, the process calls abort() and writes a string containing
-  debug information about the state and owner of the affected mutant
-  to stderr.
-*/
-BLAKEAPI(enum blakeError) blake_DeadMan(void);
-
-/*
-  Here's another debugging function, call this to dump the entire
-  mutant states to stdout.  It depends on whether mutant debug info
-  is present in the build of Blake.  Either mutant logging has to
-  be on or the dead man has to be included.
-*/
-BLAKEAPI(enum blakeError) blake_MutantDump(void);
-
-/*
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   % This section deals with OverChat database registration (locally  %
   % not remotely.  The atomic, physical process of adding, changing  %
   is done by blakedb_DestroyDBHandle( ).
 */
 BLAKEAPI(enum blakeError) blakedb_CreateDBHandle(
-  const char* InDBFN,
-  BLAKE_DATABASE_HANDLE* PHandleOut
+  const char *InDBFN,
+  BLAKE_DATABASE_HANDLE *PHandleOut
 );
 
 /*
   program clean up or whenever the database will be no longer required.
   Failure to do so will leak memory.
 */
-BLAKEAPI(enum blakeError) blakedb_DestroyDBHandle(BLAKE_DATABASE_HANDLE DBHandle);
+BLAKEAPI(enum blakeError) blakedb_DestroyDBHandle(
+  BLAKE_DATABASE_HANDLE DBHandle
+);
 
 /*
   blakedb_LockDatabase( )
   state during this call as well as an internal mutant state change.
   Misuse of locking functions will cause a failure.
 */
-BLAKEAPI(enum blakeError) blakedb_LockDatabase(BLAKE_DATABASE_HANDLE DBHandle);
+BLAKEAPI(enum blakeError) blakedb_LockDatabase(
+  BLAKE_DATABASE_HANDLE DBHandle
+);
 
 /*
   blakedb_UnlockDatabase( )
   may result in deadlock and will lead to a locked file which can no longer
   be accessed.
 */
-BLAKEAPI(void) blakedb_UnlockDatabase(BLAKE_DATABASE_HANDLE DBHandle);
+BLAKEAPI(void) blakedb_UnlockDatabase(
+  BLAKE_DATABASE_HANDLE DBHandle
+);
 
 /*
   blakedb_RemoteBackup( )
   via a dedicated email address which should receive nothing else!
 */
 #ifdef BLAKE_SERVER
-BLAKEAPI(bool) blakedb_RemoteBackup(const char* DBFN);
+  BLAKEAPI(bool) blakedb_RemoteBackup(
+    const char *DBFN
+  );
 #endif /*BLAKE_SERVER*/
 
 /*
   a record's saving and check it on it's retrieval.  However, it may be useful
   for repair tools.
 */
-BLAKEAPI(blake_word16_t) blakedb_Checksum16(const struct blakedb_User* UserRecord);
+BLAKEAPI(blake_word16_t) blakedb_Checksum16(
+  const struct blakedb_User *UserRecord
+);
 
 /*
   blakedb_GetUserData( )
 BLAKEAPI(enum blakeError) blakedb_GetUserData(
   BLAKE_DATABASE_HANDLE DBH,
   unsigned int UserIndex,
-  struct blakedb_User* PUserData,
+  struct blakedb_User *PUserData,
   size_t SizeOfUserData
 );
 
 */
 BLAKEAPI(enum blakeError) blakedb_CreateUser(
   BLAKE_DATABASE_HANDLE DBH,
-  struct blakedb_User* PNewUserDataIn,
-  unsigned int* PUserIndexOut
+  struct blakedb_User *PNewUserDataIn,
+  unsigned int *PUserIndexOut
 );
 
 /*
 */
 BLAKEAPI(unsigned int) blakedb_GetUserIndex(
   BLAKE_DATABASE_HANDLE DBHandle,
-  const char* NickName
+  const char *NickName
 );
 
 /*
   This simple function initialises a blakedb_User structure.
 */
-BLAKEAPI(void) blakedb_InitUser(struct blakedb_User* PUserData, size_t UserDataSz);
+BLAKEAPI(void) blakedb_InitUser(
+  struct blakedb_User *PUserData,
+  size_t UserDataSz
+);
 
 /*
   This function sets an exisitng user record with updated data.
 BLAKEAPI(enum blakeError) blakedb_UpdateUser(
   BLAKE_DATABASE_HANDLE DBHandle,
   unsigned int Index,
-  struct blakedb_User* NewUserRecord,
+  struct blakedb_User *NewUserRecord,
   size_t UserRecordSz
 );
 
 */
 BLAKEAPI(enum blakeError) blakedb_GetHeader(
   BLAKE_DATABASE_HANDLE DBHandle,
-  struct blakedb_Header* PHeaderOut
+  struct blakedb_Header *PHeaderOut
 );
 
 /*
 */
 BLAKEAPI(enum blakeError) blakedb_PutHeader(
   BLAKE_DATABASE_HANDLE DBHandle,
-  const struct blakedb_Header* PHeaderIn
+  const struct blakedb_Header *PHeaderIn
 );
 
 /*
   which will fill a header structure full of the correct data in for you,
   then call blakedb_PutHeader() above.
 */
-BLAKEAPI(enum blakeError) blakedb_InitHeader(struct blakedb_Header* PHeader);
+BLAKEAPI(enum blakeError) blakedb_InitHeader(
+  struct blakedb_Header *PHeader
+);
 
 /*
   This function allows one to count how many users have been registered,
   database (it doesn't really exist), don't forget these rules when using
   the database yourself.
 */
-BLAKEAPI(unsigned long int) blakedb_CountUsers(BLAKE_DATABASE_HANDLE DBHandle);
+BLAKEAPI(unsigned long int) blakedb_CountUsers(
+  BLAKE_DATABASE_HANDLE DBHandle
+);
 
 /*
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   If the nick is too long the TooLong flag is set.
 */
 BLAKEAPI(blake_bool_t) blake_NickTest(
-  const char* Nickname,
-  blake_bool_t* PTooLong,
-  char* PSingleInvalidCharacter
+  const char *Nickname,
+  blake_bool_t *PTooLong,
+  char *PSingleInvalidCharacter
 );
 
 /*
   is designed for passwords.
 */
 BLAKEAPI(blake_bool_t) blake_PassTest(
-  const char* Password,
-  blake_bool_t* PTooLong,
-  char* PSingleInvalidCharacter
+  const char *Password,
+  blake_bool_t *PTooLong,
+  char *PSingleInvalidCharacter
 );
 
 /*
   they are not.  "Toad" and "t   oaD" are deemed the same nick.
   "David" and "dA v1d" are not.
 */
-BLAKEAPI(bool) blake_NickCompare(const char* Nick1, const char* Nick2);
+BLAKEAPI(bool) blake_NickCompare(
+  const char *Nick1,
+  const char *Nick2
+);
 #define blake_ChatCompare(cr1, cr2) \
           blake_NickCompare((cr1), (cr2))
 
   converts to uppercase for the comparision and strips and trailing or