Source

blake / blake_main.c

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
/*
Copyright (C) 2001-2007 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.
*/
/*
  This module is the main portable module of the Blake library,
  not specific to the Blake protocol detail.
*/

#define BLAKE_SOURCE

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /*HAVE_CONFIG_H*/

#include <time.h>
#include <stdio.h>
#include <assert.h>

#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif /*HAVE_LIMITS_H*/

#ifdef HAVE_STDDEF_H
# include <stddef.h>
#endif /*HAVE_STDDEF_H*/

#ifdef HAVE_STRING_H
# include <string.h>
#endif /*HAVE_STRING_H*/

#ifdef BLAKE_HDRSTOP
# pragma hdrstop
#endif /*BLAKE_HDRSTOP*/

#ifdef HAVE_DLSTDINC_H
# include "dlstdinc.h"
#endif /*HAVE_DLSTDINC_H*/

#ifdef HAVE_DPCRTLMM_H
# include "dpcrtlmm.h"
#endif /*HAVE_DPCRTLMM_H*/

#include "blake.rh"
#include "blake_threads.h"
#include "blake.h"
#include "blake_main.h"
#include "blake_protocol.h"
#include "blake_sockets.h"
#include "blake_pendingloop.h"
#include "blake_db.h"
#include "blake_logger.h"
#include "blake_netbuffer_wrapper.h"
#include "blake_lang.h"
#include "blake_bench.h"
#include "blake_nick.h"
#include "blake_fastqueue.h"
#include "blake_trace.h"
#include "blake_ll.h"
#include "blake_cb.h"
#include "blake_logger.h"
#include "blake_chomp.h"
#include "blake_bench.h"
#include "blake_ansi.h"
#include "blake_here.h"
#include "blake_fs.h"
#include "blake_strfunc.h"
#include "blake_panic.h"
#include "blake_hashes.h"
#include "blake_safeallocate.h"
#include "blake_debugtables.h"
#include "blake_authorisedclients.h"
#include "blake_chksum.h"
#include "blake_version.h"
#include "blake_options.h"
#include "blake_time.h"
#include "blake_main.h"
/*-------------------------------------------------------------------------*/
static const char *const rcsid =
  "$Id: blake_main.c,v 1.9 2007/01/14 18:19:06 ddrp Exp $";

static bool _dpcrtlmmStarted;
static enum {
  initedUninitialised, /* Blake library is not initialised */
  initedInitialising,  /* Blake library is being initialised */
  initedInitialised    /* Blake library is fully initialised */
} inited = initedUninitialised;

/**************************************************
 * These error messages are in a mess, to conform *
 * to line-length limitations.  Don' worry        *
 * about the mess, these will be moved to         *
 * external resource files before long.           *
 **************************************************/

/* English (originals) of the error messages (the only ones I understand!) */
static const char* errorMessages_en[] = {
  "No error (success)",
  /*blakeSuccess*/

  "Not enough memory to complete the requested operation",
  /*blakeNotEnoughMem*/

  "Invalid parameter",
  /*blakeInvalidParam*/

  "No callback could process the packet or event",
  /*blakeNoCallback*/

  "The callback routine reported a failure",
  /*blakeCallbackFail*/

  "Insufficient buffer size",
  /*blakeBufferTooSmall*/

  "Blake library not initialised",
  /*blakeNotStarted*/

  "The protocol cannot be supported by this version of Blake",
  /*blakeProtoNoSupport*/

  "Connection error: Cannot bind the network socket",
  /*blakeBindFailure*/

  "Connection error: The server refused the connection",
  /*blakeConnRefused*/

  "The connection timed out or was dropped by a firewall",
  /*blakeTimedOut*/

  "The network is down",
  /*blakeNetDown*/

  "The network error is unknown or not handled",
  /*blakeUnknownNetError*/

  "(Internal) The object was already registered",
  /*blakeRegAlready*/

  "(Internal) The object does not exist, is unitialised, "
  "busy or inappropriate",
  /*blakeBadObject*/

  "The queue is full",
  /*blakeQueueFull*/

  "Unknown Blake error or library abuse",
  /*blakeUnknownFailure*/

  "Queue empty",
  /*blakeQueueEmpty*/

  "The function is not supported in this version of Blake",
  /*blakeUnsupported*/

  "Blake header/library mismatch detected or structure packing failed",
  /*blakeMismatch*/

  "A hard coded limit on a Blake object was exceeded, "
  "you need to rebuild from source with a greater MAX[BLAH]",
  /*blakeLimit*/

  "The user database is full, no more users can be registered",
  /*blakeDbFull*/

  "The database cannot be accessed for writing at this time",
  /*blakeDbAccessWrite*/

  "The database cannot be accessed for reading at this time",
  /*blakeDbAccessRead*/

  "The file cannot be opened for exclusive access",
  /*blakeExclusiveFileFailure*/

  "The SA handle is bad",
  /*blakeBadSAHandle*/

  "The database record is corrupt",
  /*blakeDbRecordCorrupt*/

  "The file is truncated",
  /*blakeFileTruncated*/

  "Cannot open archived file",
  /*blakeArchivedFileError*/

  "A parameter is out of range",
  /*blakeRange*/
  
  "Cannot open a connection to the database",
  /*blakeDbAccessOpen*/
  
  "Function dependencies cannot be met due to unsupported features"
  /*blakeSubUnsupported*/
};

/* French translations of the error messages */
static const char* errorMessages_fr[] = {
  "aucune erreur (succs)",
  /*blakeSuccess*/

  "pas assez de mmoire pour accomplir l'opration demande",
  /*blakeNotEnoughMem*/

  "paramtre inadmissible",
  /*blakeInvalidParam*/

  "aucun rappel de service pourrait traiter le paquet ou l'vnement",
  /*blakeNoCallback*/

  "la routine de rappel de service a rapport un chec",
  /*blakeCallbackFail*/

  "taille d'amortisseur insuffisante",
  /*blakeBufferTooSmall*/

  "non initialis de bibliothque de Blake",
  /* blakeNotStarted */

  "le protocole ne peut pas tre soutenu par cette version de Blake",
  /*blakeProtoNoSupport*/

  "le raccordement erreur: Peut pas lier rseau douille ",
  /*blakeBindFailure*/

  "de erreur de raccordement: Serveur a refus raccordement",
  /*blakeConnRefused*/

  "raccordement chronomtr dehors ou tait laiss tomber "
  "par mur  l'preuve du feu",
  /*blakeTimedOut*/

  "rseau est en bas de",
  /*blakeNetDown*/

  "rseau erreur est inconnu ou pas manipul",
  /*blakeUnknownNetError*/

  "(interne) objet tait dj enregistr",
  /*blakeRegAlready*/

  "(interne) objet pas exister, est unitialised, occup ou inadquat",
  /*blakeBadObject*/

  "file d'attente est plein",
  /*blakeQueueFull*/

  "d'erreur inconnue de Blake ou d'abus de bibliothque",
  /*blakeUnknownFailure*/

  "file d'attente vide",
  /*blakeQueueEmpty*/

  "fonction est pas soutenu en cela version de Blake",
  /*blakeUnsupported*/

  "Blake header/library disparit dtect ou structure emballage chou",
  /*blakeMismatch*/

  "dur cod limite sur Blake objet tiez excd, vous avez besoin pour "
  "reconstruire de source avec grand MAX[BLAH ]",
  /*blakeLimit*/

  "utilisateur base de donnes est plein, plus utilisateur pouvez tre "
  "enregistr",
  /*blakeDbFull*/

  "base de donnes pouvez pas tre consult pour crivant actuellement",
  /*blakeDbAccessWrite*/

  "la base de donnes ne pouvez tre consults pour la lecture  ce heure",
  /*blakeDbAccessRead*/

  "dossier peut pas tre ouvert pour exclusif accs",
  /*blakeExclusiveFileFailure*/

  "SA poigne est mauvais",
  /*blakeBadSAHandle*/

  "base de donnes disque est corrompu",
  /*blakeDbRecordCorrupt*/

  "dossier est tronqu",
  /*blakeFileTruncated*/

  "Ne peut pas ouvrir le dossier archiv",
  /*blakeArchivedFileError*/

  "Un paramtre est hors de gamme",
  /*blakeRange*/
  
  "Ne peut pas ouvrir un raccordement � la base de donn�es",
  /*blakeDbAccessOpen*/
  
  "Les d�pendances de fonction ne peuvent pas �tre dues rencontr� aux dispositifs non soutenus"
  /*blakeSubUnsupported*/
};

/* Spanish translations of the error messages */
static const char* errorMessages_es[] = {
  "ningn error (xito)",
  /*blakeSuccess*/

  "no bastante memoria para terminar la operacin solicitada",
  /*blakeNotEnoughMem*/

  "parmetro invlido",
  /*blakeInvalidParam*/

  "ningn servicio repetido podra procesar el el paquete o acontecimiento",
  /*blakeNoCallback*/

  "la rutina del servicio repetido divulg una falta",
  /*blakeCallbackFail*/

  "tamao de almacenador intermediario escaso",
  /*blakeBufferTooSmall*/

  "no inicializado de la biblioteca de Blake",
  /*blakeNotStarted*/

  "el protocolo no se puede apoyar por esta versin de Blake",
  /*blakeProtoNoSupport*/

  "conexin error: Puede no atar red zcalo ",
  /*blakeBindFailure*/

  "error de la conexin: Servidor rechaz conexin",
  /*blakeConnRefused*/

  "conexin medido el tiempo hacia fuera o era cado por cortafuego",
  /*blakeTimedOut*/

  "red es abajo de",
  /*blakeNetDown*/

  "red error es desconocido o no dirigido",
  /*blakeUnknownNetError*/

  "(interno) objeto era ya colocado",
  /*blakeRegAlready*/

  "(interno) objeto no existir, es unitialised, ocupado o inadecuado",
  /*blakeBadObject*/

  "coleta es lleno",
  /*blakeQueueFull*/

  "del error desconocido de Blake o del abuso de la biblioteca",
  /*blakeUnknownFailure*/

  "coleta vaco",
  /*blakeQueueEmpty*/

  "funcin es no apoyado en este versin de Blake",
  /*blakeUnsupported*/

  "Blake header/library unin mal hecho detectado o estructura embalaje"
  " fallado",
  /*blakeMismatch*/

  "duro cifrado lmite en Blake objeto era excedido, usted necesita "
  "reconstruir de fuente con mayor MAX[BLAH]",
  /*blakeLimit*/

  "usuario base de datos es lleno, no ms usuario puede ser colocado",
  /*blakeDbFull*/

  "base de datos puede no estar tenido acceso para escribiendo en este"
  " tiempo",
  /*blakeDbAccessWrite*/

  "la base de datos no puede ser alcanzado para la lectura en este hora",
  /*blakeDbAccessRead*/

  "archivo puede no ser abierto para exclusivo acceso",
  /*blakeExclusiveFileFailure*/

  "SA manija es malo",
  /*blakeBadSAHandle*/

  "base de datos expediente es corrupto",
  /*blakeDbRecordCorrupt*/

  "archivo es truncado",
  /*blakeFileTruncated*/

  "No puede abrir el archivo archivado",
  /*blakeArchivedFileError*/

  "Un parmetro est fuera de gama",
  /*blakeRange*/
  
  "No puede abrir una conexi�n a la base de datos",
  /*blakeDbAccessOpen*/
  
  "Las dependencias de la funci�n no pueden ser resuelto debido a las caracter�sticas sin apoyo"
  /*blakeSubUnsupported*/
};

static void NotUserCleanup(void); /* For us only */

/*
  This is to call initialisers in modules which have no equivillant or
  required cleanup, static array setups or calculations at run-time
  or whatnot
*/
static void NonCleanableInit(void);
/*-------------------------------------------------------------------------*/
BLAKEAPI(blake_bool_t) blake_Init()
{
  blake_Unused(rcsid);

  if ( inited == initedUninitialised ) {
    bool ok;
    inited = initedInitialising;
    NonCleanableInit(); /* No cleanup required for these inits */
    _dpcrtlmmStarted = dpcrtlmm_IsStarted();
    if ( !_dpcrtlmmStarted )
      dpcrtlmm_Startup();

    ok = blake_int_PendingLoopInit();
    if ( ok ) {
      ok = network_Init();
      if ( ok ) {
        ok = blake_ProtocolInit();
        if ( ok ) {
          ok = blake_db_Init();
          if ( ok ) {
            ok = blake_logger_Init();
            if ( ok ) {
              ok = netbuffer_Init();
              if ( ok ) {
                ok = blake_LangInit();
                if ( ok ) {
                  ok = blake_BenchInit();
                  if ( ok ) {
                    ok = blake_OptionsInit();
		    if ( ok ) {
		      ok = blake_TimeInit();
		    }
                  }
                }
              }
            }
          }
        }
      }
    }
    if ( ok )
      inited = initedInitialised;
    else {
      NotUserCleanup();
      inited = initedUninitialised;
    }
  }
  return blake_int_IsInited();
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(blake_bool_t) blake_Cleanup()
{
  if ( inited == initedInitialised ) {
    NotUserCleanup();
    inited = initedUninitialised;
  }
  return (blake_bool_t)(inited == initedUninitialised);
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(blake_bool_t) blake_Verify()
{
  return blake_int_IsInited();
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(unsigned int) blake_GetErrorMessage(
  const enum blakeError BlakeError,
  char *Buff,
  size_t MaxSize,
  enum blakeLang Language
)
{
  unsigned int i = (unsigned int)BlakeError;
  const char* msgptr;

  static const char tempUnsupportedLanguage[] =
    "This language translation has not been made, "
    "make updates to overchat/blake/blake_main.c";

  if ( !blake_int_IsInited() ) return 0U;

  switch ( Language ) {
    case langEnglish : {
      if ( i < sizeof(errorMessages_en)/sizeof(errorMessages_en[0]) )
        msgptr = errorMessages_en[i];
      else
        msgptr = blake_int_NoSuchError(langEnglish);
      break;
    }
    case langFrench : {
      if ( i < sizeof(errorMessages_fr)/sizeof(errorMessages_fr[0]) )
        msgptr = errorMessages_fr[i];
      else
        msgptr = blake_int_NoSuchError(langFrench);
      break;
    }
    case langSpanish : {
      if ( i < sizeof(errorMessages_es)/sizeof(errorMessages_es[0]) )
        msgptr = errorMessages_es[i];
      else
        msgptr = blake_int_NoSuchError(langSpanish);
      break;
    }
    default : {
      msgptr = tempUnsupportedLanguage;
    }
  }

  if ( Buff && MaxSize ) {
    Buff[0] = '\0';
    strncat(Buff, msgptr, MaxSize);
  }

  return (unsigned int)strlen(msgptr);
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(unsigned int) blake_GetNumberOfErrorMessages()
{
  unsigned int msglen, msglen_compare;

  if ( !blake_int_IsInited() ) return 0U;

  /* Get number of English error messages */
  msglen = sizeof(errorMessages_en)/sizeof(errorMessages_en[0]);

  /* Get number of French error messages */
  msglen_compare = sizeof(errorMessages_fr)/sizeof(errorMessages_fr[0]);
  if ( msglen != msglen_compare ) {
    blake_word32_t paramArr[3];
    paramArr[0] = sizeof(errorMessages_en)/sizeof(errorMessages_en[0]);
    paramArr[1] = sizeof(errorMessages_fr)/sizeof(errorMessages_fr[0]);
    paramArr[2] = (blake_word32_t)langFrench;
    PANIC(
      BLAKESTOP_DDRP_LANG_MSGCOUNT_MISMATCH,
      sizeof(paramArr)/sizeof(paramArr[0]),
      paramArr
    );
  }

  /* Get number of Spanish error messages */
  msglen_compare = sizeof(errorMessages_es)/sizeof(errorMessages_es[0]);
  if ( msglen != msglen_compare ) {
    blake_word32_t paramArr[3];
    paramArr[0] = sizeof(errorMessages_en)/sizeof(errorMessages_en[0]);
    paramArr[1] = sizeof(errorMessages_es)/sizeof(errorMessages_es[0]);
    paramArr[2] = (blake_word32_t)langSpanish;
    PANIC(
      BLAKESTOP_DDRP_LANG_MSGCOUNT_MISMATCH,
      sizeof(paramArr)/sizeof(paramArr[0]),
      paramArr
    );
  }

  return msglen;
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(const char*) blake_GetErrorMessageMnemonic(
  const enum blakeError Err
)
{
  static const char* mnemonics[] = {
    "blakeSuccess",
    "blakeNotEnoughMem",
    "blakeInvalidParam",
    "blakeNoCallback",
    "blakeCallbackFail",
    "blakeBufferTooSmall",
    "blakeNotStarted",
    "blakeProtoNoSupport",
    "blakeBindFailure",
    "blakeConnRefused",
    "blakeTimedOut",
    "blakeNetDown",
    "blakeUnknownNetError",
    "blakeRegAlready",
    "blakeBadObject",
    "blakeQueueFull",
    "blakeUnknownFailure",
    "blakeQueueEmpty",
    "blakeUnsupported",
    "blakeMismatch",
    "blakeLimit",
    "blakeDbFull",
    "blakeDbAccessWrite",
    "blakeDbAccessRead",
    "blakeExclusiveFileFailure",
    "blakeBadSAHandle",
    "blakeDbRecordCorrupt",
    "blakeFileTruncated",
    "blakeArchivedFileError",
    "blakeRange",
    "blakeDbAccessOpen"
  };

  if ( Err >= sizeof(mnemonics)/sizeof(mnemonics[0]) )
    return NULL;
  return mnemonics[Err];
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(void) blake_DebugDump(const char* FileName)
{
  if ( FileName && blake_int_IsInited() ) {
    if ( FileName[0] ) {
      FILE* handle = fopen(FileName, "at");
      if ( handle ) {
        dpcrtlmm_Dump(handle);
        fclose(handle);
      }
    }
  }
  return;
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(void) blake_UnusedVar(
  const void *UnusedParam,
  blake_bool_t Recursed
)
{
  if ( !Recursed )
    blake_UnusedVar(UnusedParam, 1);
}
/*-------------------------------------------------------------------------*/
bool blake_int_IsInited()
{
  return (inited == initedInitialised);
}
/*-------------------------------------------------------------------------*/
bool blake_int_InInit()
{
  return (inited == initedInitialising);
}
/*-------------------------------------------------------------------------*/
const char* blake_int_NoSuchError(const enum blakeLang Language)
{
  unsigned int i;
  static const struct {
    const enum blakeLang language;
    const char* message;
  } msgs[] = {
    {
      langEnglish,
      "This error message does not exist!"
    },
    {
      langFrench,
      "Ce message d'errror n'existe pas!"
    },
    {
      langSpanish,
      "Este mensaje de error no existe!"
    },
    {
      langGerman,
      "Diese Fehlermeldung besteht nicht!"
    },
    {
      langItalian,
      "Questo messaggio di errore non esiste!"
    },
    {
      langPortuguese,
      "Esta mensagem de erro no existe!"
    }
  };

  for ( i = 0U; i < sizeof(msgs)/sizeof(msgs[0]); i++ ) {
    if ( Language == msgs[i].language )
      return msgs[i].message;
  };

  return NULL; /* Unknown language */
};
/*-------------------------------------------------------------------------*/
static void NotUserCleanup()
{
  if ( blake_TimeIsInited() )
    blake_TimeCleanup();
    
  if ( blake_OptionsIsInited() )
    blake_OptionsCleanup();

  if ( blake_BenchIsInited() )
    blake_BenchCleanup();

  if ( blake_LangIsInited() )
    blake_LangCleanup();

  if ( netbuffer_IsInited() )
    netbuffer_Cleanup();

  if ( blake_logger_IsInited() )
    blake_logger_Cleanup();

  if ( blake_db_IsInited() )
    blake_db_Cleanup();

  if ( blake_ProtocolIsInited() )
    blake_ProtocolCleanup();

  if ( network_IsInited() )
    network_Cleanup();

  if ( blake_int_PendingLoopIsInited() )
    blake_int_PendingLoopCleanup();

  if ( !_dpcrtlmmStarted )
    dpcrtlmm_Shutdown();

  return;
}
/*-------------------------------------------------------------------------*/
static void NonCleanableInit()
{
  /*
    The following functions are NCI (Not Cleanable Initialisation) fuctions.
    Most modules in Blake have a compatible function.  It is used for any
    initialisation tasks which conform to these requirements:

    1) Must not fail (unless the failure is so serious that program cannot
       handle it and the OS kills the program).. or the failure is dealt
       with by other code outside of the call
    2) Requires no cleanup of dynamically created structures

    Typically this function is used purely to pass any RCS id string to
    blake_Unused() to prevent warnings.  If you're debugging here, don't
    bother!  Just place your breakpoint somewhere to avoid calling
    NonCleanableInit( ) as this will take you around the houses!
  */
  blake_int_fastqueue_NCI();
  blake_int_ll_NCI();
  blake_int_network_NCI();
  blake_int_nick_NCI();
  blake_int_pendingloop_NCI();
  blake_int_protocol_NCI();
  blake_int_trace_NCI();
  blake_int_cb_NCI();
  blake_int_logger_NCI();
  blake_int_fs_NCI();
  blake_int_strfunc_NCI();
  blake_int_ansi_NCI();
  blake_int_safeallocate_NCI();
  blake_int_debugtables_NCI();
  blake_int_db_NCI();
  blake_int_hashes_NCI();
  blake_int_panic_NCI();
  blake_int_chksum_NCI();
  blake_int_here_NCI();
  blake_int_authorisedclients_NCI();
  blake_int_netbuffer_NCI(); /* blake_netbuffer.cpp, not NetBuffer.cpp */
  blake_int_lang_NCI();
  blake_int_bench_NCI();
  blake_int_chomp_NCI();
  blake_int_version_NCI();
  blake_int_options_NCI();
  blake_int_time_NCI();
}
/*-------------------------------------------------------------------------*/