Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Console.c
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

#include "TgS Common - Console - Internal.h"
#include "TgS Common - Console.inl"


/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Data                                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

STg2_UTM_AM_RW                              g_sCN_Command_Name_Lock;
P_STg2_CN_Command_Common                    g_apsCN_Command_Hash_Set[KTgCN_MAX_COMMAND_HASH_SET];
P_STg2_CN_Command_Common                    g_apsCommand_Lexical_Set[KTgCN_MAX_COMMAND_LEXICAL_LIST];




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Constants */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if TgCOMPILE_CONSOLE

enum { KTgCN_OSCON_LINE_LENGTH             = 256 }; /*« Maximum length of a console command | buffer | display line */
enum { KTgCN_OSCON_MAX_LINE                = 256 }; /*« Number of console lines retained in the buffer */
enum { KTgCN_OSLOG_LINE_LENGTH             = 128 }; /*« Maximum length of an on screen log line */
enum { KTgCN_OSLOG_MAX_LINE                = 52  }; /*« Number of on screen log lines */

enum { KTgCN_MAX_CHANNEL                   = KTgCN_CHANEL_BITS }; /*« Maximum number of channels in the system */
enum { KTgCN_MAX_CHANNEL_OUTPUT            = 8 }; /*« Maximum number of output devices that can be attached to a single channel */

/*# TgCOMPILE_CONSOLE */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Types */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

#if TgCOMPILE_CONSOLE

TgTYPE_STRUCT(STg2_CN_OnScreen_Line,)
{
    TgCHAR                                      m_szLog[KTgCN_OSLOG_LINE_LENGTH];
    TgUINT32                                    m_uiSeverity;
    TgUINT32                                    m_uiUID;
    TgFLOAT32                                   m_fLife_Time;
    TgUINT32                                    m_uiPad0;
    P_STg2_CN_OnScreen_Line                     m_psNext;
};


TgTYPE_STRUCT(STg2_CN_Command_Function,)
{
    STg2_CN_Command_Common                      m_sCommon;
    TgFCN_CONSOLE                               m_pfnExecute;
};

/*# TgCOMPILE_CONSOLE */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions and Data                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

static ETgMODULE_STATE                      s_enConsole_State = ETgMODULE_STATE__FREED;

#if TgCOMPILE_CONSOLE

static TgVOID                               tgCN_UID_Print_Internal( C_TgUINT32, C_TgUINT32, CP_TgCHAR );
static TgVOID                               tgCN_Scroll_Display( C_TgSINT32, C_TgSINT32 );

static TgSIZE                               tgCN_Default_Break_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgCN_Default_Abort_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );

static TgSIZE                               tgLOG_CON_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_LOG_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_FCN_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_MEM_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_MSG_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_WRN_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_ERR_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_CRT_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_INT_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );
static TgSIZE                               tgLOG_LDN_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );

static TgSIZE                               tgLOG_STD_File_Write( PC_STg2_Output, C_TgSIZE, CP_TgVOID, C_TgSIZE );

                                            /* System state and Configuration */
static STg1_MP_CS                           s_sSystem_Lock;

                                            /* On Screen Console */
static STg1_MP_CS                           s_sOS_Lock; /* Lock for the On Screen Buffers */
static TgCHAR                               s_szOS_Console_Buffer[KTgCN_OSCON_MAX_LINE][KTgCN_OSCON_LINE_LENGTH];
static TgSINT32                             s_iOS_Console_Buffer_Index;
static TgSINT32                             s_iOS_Console_Cmd_Index;
static TgSINT32                             s_iOS_Console_Display_Index;
static TgSINT32                             s_iOS_Console_Cmd_History_Index;
static TgBOOL                               s_bOS_Console_Render;
static TgSINT32                             s_iOS_Console_Render_Page_Height;
static TgSINT32                             s_iOS_Console_Render_Font_Height;
static STg2_CN_OnScreen_Line                s_asOS_Log_Data[KTgCN_OSLOG_MAX_LINE];
static P_STg2_CN_OnScreen_Line              s_psOS_Log_Display;
static P_STg2_CN_OnScreen_Line              s_psOS_Log_Free;
static TgFLOAT32                            s_fOS_Log_Default_Life_Time;

                                            /* Console Command List */
static STg2_CN_Command_Function             s_asCommand_Function[KTgCN_MAX_COMMAND_FCN]; /* This is the key for the group */
static STg2_UTM_AM_ST_ISO                   s_sCommand_Function_Stack;
static TgSINT32                             s_niCommand_Function_Used;

                                            /* Channel Descriptors and Information */
static CP_TgCHAR                            s_pzOutput_Prefix[KTgCN_MAX_CHANNEL];
static TgSIZE                               s_nuiOutput_Prefix[KTgCN_MAX_CHANNEL];
static TgBOOL                               s_abOutput_Prefix[KTgCN_MAX_CHANNEL]; /* Tracks whether we are at the start of a line */
static P_STg2_Output                        s_apsOutput[KTgCN_MAX_CHANNEL][KTgCN_MAX_CHANNEL_OUTPUT];
static TgUINT32                             s_auiUID_Filter[KTgCN_MAX_CHANNEL];
static TgUINT32                             s_auiSeverity_Filter[KTgCN_MAX_CHANNEL];

                                            /* Default Output Functions */
static STg2_Output                          s_sDefault_Output_Break;
static STg2_Output                          s_sDefault_Output_Abort;
static TgSINTPTR                            s_iLOG_Output_File;
static STg2_Output                          s_sOuput_Std = { tgLOG_STD_File_Write, nullptr };

                                            /* Default Prefixes for channel output */
static C_TgCHAR                             s_szPrefix_Console[] = TgT("CON: ");
static STg2_Output                          s_sOuput_Console = { tgLOG_CON_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Console_File;
static C_TgCHAR                             s_szPrefix_Log_Screen[] = TgT("SCN: ");
static C_TgCHAR                             s_szPrefix_Log[] = TgT("LOG: ");
static STg2_Output                          s_sOuput_Log = { tgLOG_LOG_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Log_File;
static C_TgCHAR                             s_szPrefix_Log_FCN[] = TgT("FCN: ");
static STg2_Output                          s_sOuput_Log_FCN = { tgLOG_FCN_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Log_FCN_File;
static C_TgCHAR                             s_szPrefix_Log_MEM[] = TgT("MEM: ");
static STg2_Output                          s_sOuput_Log_Mem = { tgLOG_MEM_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Log_Mem_File;
static C_TgCHAR                             s_szPrefix_Message[] = TgT("MSG: ");
static STg2_Output                          s_sOuput_Msg = { tgLOG_MSG_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Msg_File;
static C_TgCHAR                             s_szPrefix_Warning[] = TgT("WRN: ");
static STg2_Output                          s_sOuput_Wrn = { tgLOG_WRN_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Wrn_File;
static C_TgCHAR                             s_szPrefix_Error[] = TgT("ERR: ");
static STg2_Output                          s_sOuput_Err = { tgLOG_ERR_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Err_File;
static C_TgCHAR                             s_szPrefix_Critical[] = TgT("CRT: ");
static STg2_Output                          s_sOuput_Crt = { tgLOG_CRT_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Crt_File;
static C_TgCHAR                             s_szPrefix_Initialize[] = TgT("INT: ");
static STg2_Output                          s_sOuput_Int = { tgLOG_INT_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Int_File;
static C_TgCHAR                             s_szPrefix_Loading[] = TgT("LDN: ");
static STg2_Output                          s_sOuput_Ldn = { tgLOG_LDN_File_Write, nullptr };
static TgSINTPTR                            s_iOuput_Ldn_File;

/*# TgCOMPILE_CONSOLE */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgCN_Init ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* NOTE: Called prior to MM and SM Init */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgCN_Init( TgVOID )
{
    TgSINT32                            iIndex, iIndex2;

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__FREED == s_enConsole_State);
    s_enConsole_State = ETgMODULE_STATE__INITIALIZING;
    (void)iIndex;
    (void)iIndex2;

    /* Initialize Console Command Common Data - Console Variables are always compiled */
    TgVERIFY( KTgS_OK == tgCM_UTM_AM_RW_Init( &g_sCN_Command_Name_Lock ) );
    memset( (P_TgVOID)g_apsCN_Command_Hash_Set, 0, sizeof( g_apsCN_Command_Hash_Set ) );
    memset( (P_TgVOID)g_apsCommand_Lexical_Set, 0, sizeof( g_apsCommand_Lexical_Set ) );

#if TgCOMPILE_CONSOLE

    TgCOMPILER_ASSERT( (1 << KTgCN_SEVERITY_BITS) > 3, 0 );

    /* Initialize system variables */
#if TgCOMPILE_THREAD
    TgVERIFY( KTgS_OK == tgCM_MP_CS_Init( &s_sSystem_Lock ) );
/*# TgCOMPILE_THREAD */
#endif

    /* Initialize On Screen Console and Logging */
    tgCM_MP_CS_Init( &s_sOS_Lock );
    memset( s_szOS_Console_Buffer, 0, sizeof( s_szOS_Console_Buffer ) );
    s_iOS_Console_Buffer_Index = 0;
    s_iOS_Console_Cmd_Index = 0;
    s_iOS_Console_Display_Index = 0;
    s_iOS_Console_Cmd_History_Index = 0;
    s_bOS_Console_Render = TgFALSE;
    s_iOS_Console_Render_Page_Height = 0;
    s_iOS_Console_Render_Font_Height = 0;
    memset( s_asOS_Log_Data, 0, sizeof( s_asOS_Log_Data ) );
    s_psOS_Log_Display = nullptr;
    s_psOS_Log_Free = s_asOS_Log_Data;
    s_fOS_Log_Default_Life_Time = 10.0F;

    /* Attach sequential elements of the on screen log link list */
    for (iIndex = 0; iIndex + 1 < KTgCN_OSLOG_MAX_LINE; ++iIndex)
    {
        s_asOS_Log_Data[iIndex].m_psNext = s_asOS_Log_Data + iIndex + 1;
    };

    /* Initialize Console Command Function Data */
    memset( s_asCommand_Function, 0, sizeof( s_asCommand_Function ) );
    s_niCommand_Function_Used = 0;
    tgCM_UTM_AM_ST_Init_PreLoad( &s_sCommand_Function_Stack.m_sStack, s_asCommand_Function, sizeof( STg2_CN_Command_Function ), KTgCN_MAX_COMMAND_FCN );

    /* Initialize Channel Descriptors and Information */
    memset( s_nuiOutput_Prefix, 0, sizeof( s_nuiOutput_Prefix ) );
    for (iIndex = 0; iIndex < KTgCN_MAX_CHANNEL; ++iIndex)
    {
        s_pzOutput_Prefix[iIndex] = nullptr;
        s_abOutput_Prefix[iIndex] = TgTRUE;
        s_auiUID_Filter[iIndex] = KTgUID_NONE;
        s_auiSeverity_Filter[iIndex] = KTgCN_MAX_SEVERITY;
        for (iIndex2 = 0; iIndex2 < KTgCN_MAX_CHANNEL_OUTPUT; ++iIndex2)
            s_apsOutput[iIndex][iIndex2] = nullptr;
    };

    /* Create the two default output objects */
    s_sDefault_Output_Break.m_pfnWrite = tgCN_Default_Break_Write;
    s_sDefault_Output_Break.m_pfnClose = nullptr;
    s_sDefault_Output_Abort.m_pfnWrite = tgCN_Default_Abort_Write;
    s_sDefault_Output_Abort.m_pfnClose = nullptr;

    /* Preset some of the variables */
    s_pzOutput_Prefix[0] = s_szPrefix_Console;
    s_nuiOutput_Prefix[0] = tgSZ_Length( s_pzOutput_Prefix[0] );
    s_iOuput_Console_File = -1;
    s_pzOutput_Prefix[1] = s_szPrefix_Log_Screen;
    s_nuiOutput_Prefix[1] = tgSZ_Length( s_pzOutput_Prefix[1] );
    s_pzOutput_Prefix[2] = s_szPrefix_Log;
    s_nuiOutput_Prefix[2] = tgSZ_Length( s_pzOutput_Prefix[2] );
    s_iOuput_Log_File = -1;
    s_pzOutput_Prefix[3] = s_szPrefix_Log_FCN;
    s_nuiOutput_Prefix[3] = tgSZ_Length( s_pzOutput_Prefix[3] );
    s_iOuput_Log_FCN_File = -1;
    s_pzOutput_Prefix[4] = s_szPrefix_Log_MEM;
    s_nuiOutput_Prefix[4] = tgSZ_Length( s_pzOutput_Prefix[4] );
    s_iOuput_Log_Mem_File = -1;
    s_pzOutput_Prefix[5] = s_szPrefix_Message;
    s_nuiOutput_Prefix[5] = tgSZ_Length( s_pzOutput_Prefix[5] );
    s_iOuput_Msg_File = -1;
    s_pzOutput_Prefix[6] = s_szPrefix_Warning;
    s_nuiOutput_Prefix[6] = tgSZ_Length( s_pzOutput_Prefix[6] );
    s_iOuput_Wrn_File = -1;
    s_pzOutput_Prefix[7] = s_szPrefix_Error;
    s_nuiOutput_Prefix[7] = tgSZ_Length( s_pzOutput_Prefix[7] );
    s_iOuput_Err_File = -1;
    s_pzOutput_Prefix[8] = s_szPrefix_Critical;
    s_nuiOutput_Prefix[8] = tgSZ_Length( s_pzOutput_Prefix[8] );
    s_iOuput_Crt_File = -1;
    s_pzOutput_Prefix[9] = s_szPrefix_Initialize;
    s_nuiOutput_Prefix[9] = tgSZ_Length( s_pzOutput_Prefix[9] );
    s_iOuput_Int_File = -1;
    s_pzOutput_Prefix[10] = s_szPrefix_Loading;
    s_nuiOutput_Prefix[10] = tgSZ_Length( s_pzOutput_Prefix[10] );
    s_iOuput_Ldn_File = -1;

/*# TgCOMPILE_CONSOLE */
#endif

    s_enConsole_State = ETgMODULE_STATE__INITIALIZED;

    tgCN_Var_Init();
    return (KTgS_OK);
}


/* ---- tgCN_Boot ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* NOTE: Called prior to MM and SM Init */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgCN_Boot( TgVOID )
{
    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__INITIALIZED == s_enConsole_State);

#if TgCOMPILE_CONSOLE

    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Console_File, TgT("teikitu_console.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_CONSOLE, &s_sOuput_Console );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Log_File, TgT("teikitu_log.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_LOG, &s_sOuput_Log );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Log_FCN_File, TgT("teikitu_log_fcn.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_LOG_FCN, &s_sOuput_Log_FCN );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Log_Mem_File, TgT("teikitu_memory.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_LOG_MEM, &s_sOuput_Log_Mem );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Msg_File, TgT("teikitu_message.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_MESSAGE, &s_sOuput_Msg );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Wrn_File, TgT("teikitu_warning.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_WARNING, &s_sOuput_Wrn );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Err_File, TgT("teikitu_error.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_ERROR, &s_sOuput_Err );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Crt_File, TgT("teikitu_critical.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_CRITICAL, &s_sOuput_Crt );
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Int_File, TgT("teikitu_init.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
    {
        tgCN_Attach_Output( KTgCN_CHANEL_INITIALIZE, &s_sOuput_Int );
        tgCN_Attach_Output( KTgCN_CHANEL_INITIALIZE_MEMORY, &s_sOuput_Int );
    };
    if (TgSUCCEEDED( tgIO_File_Open( &s_iOuput_Ldn_File, TgT("teikitu_loading.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
        tgCN_Attach_Output( KTgCN_CHANEL_LOADING, &s_sOuput_Ldn );

    if (TgSUCCEEDED( tgIO_File_Open( &s_iLOG_Output_File, TgT("teikitu_output.log"), ETgFILE_IO_ACCESS__READ | ETgFILE_IO_ACCESS__WRITE | ETgFILE_IO_ACCESS__SHARED ) ))
    {
        tgCN_Attach_Output( KTgCN_CHANEL_LOG, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_LOG_FCN, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_MESSAGE, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_WARNING, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_ERROR, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_CRITICAL, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_INITIALIZE, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_INITIALIZE_MEMORY, &s_sOuput_Std );
        tgCN_Attach_Output( KTgCN_CHANEL_LOADING, &s_sOuput_Std );
    };

/*# TgCOMPILE_CONSOLE */
#endif

    s_enConsole_State = ETgMODULE_STATE__BOOTED;

    tgCN_Var_Boot();
    return (KTgS_OK);
}


/* ---- tgCN_Stop ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Stop( TgVOID )
{
    if (ETgMODULE_STATE__FREED == s_enConsole_State || ETgMODULE_STATE__INITIALIZED == s_enConsole_State)
    {
        return;
    };

    tgCN_Var_Stop();

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State);

#if TgCOMPILE_CONSOLE
    if (tgIO_File_Valid( s_iLOG_Output_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_LOADING, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_INITIALIZE_MEMORY, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_INITIALIZE, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_CRITICAL, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_ERROR, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_WARNING, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_MESSAGE, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_LOG_MEM, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_LOG_FCN, &s_sOuput_Std );
        tgCN_Remove_Output( KTgCN_CHANEL_LOG, &s_sOuput_Std );

        tgIO_File_Close( s_iLOG_Output_File );
        s_iLOG_Output_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Ldn_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_LOADING, &s_sOuput_Ldn );
        tgIO_File_Close( s_iOuput_Ldn_File );
        s_iOuput_Ldn_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Int_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_INITIALIZE_MEMORY, &s_sOuput_Int );
        tgCN_Remove_Output( KTgCN_CHANEL_INITIALIZE, &s_sOuput_Int );
        tgIO_File_Close( s_iOuput_Int_File );
        s_iOuput_Int_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Crt_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_CRITICAL, &s_sOuput_Crt );
        tgIO_File_Close( s_iOuput_Crt_File );
        s_iOuput_Crt_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Err_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_ERROR, &s_sOuput_Err );
        tgIO_File_Close( s_iOuput_Err_File );
        s_iOuput_Err_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Wrn_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_WARNING, &s_sOuput_Wrn );
        tgIO_File_Close( s_iOuput_Wrn_File );
        s_iOuput_Wrn_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Msg_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_MESSAGE, &s_sOuput_Msg );
        tgIO_File_Close( s_iOuput_Msg_File );
        s_iOuput_Msg_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Log_Mem_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_LOG_MEM, &s_sOuput_Log_Mem );
        tgIO_File_Close( s_iOuput_Log_Mem_File );
        s_iOuput_Log_Mem_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Log_FCN_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_LOG_FCN, &s_sOuput_Log_FCN );
        tgIO_File_Close( s_iOuput_Log_FCN_File );
        s_iOuput_Log_FCN_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Log_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_LOG, &s_sOuput_Log );
        tgIO_File_Close( s_iOuput_Log_File );
        s_iOuput_Log_File = -1;
    };

    if (tgIO_File_Valid( s_iOuput_Console_File ))
    {
        tgCN_Remove_Output( KTgCN_CHANEL_CONSOLE, &s_sOuput_Console );
        tgIO_File_Close( s_iOuput_Console_File );
        s_iOuput_Console_File = -1;
    };
/*# TgCOMPILE_CONSOLE */
#endif

    s_enConsole_State = ETgMODULE_STATE__STOPPED;
}


/* ---- tgCN_Free ------------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Free( TgVOID )
{
    TgSINT32                            iIndex;

    if (ETgMODULE_STATE__FREED == s_enConsole_State)
    {
        return;
    };

    (TgVOID)iIndex;

    tgCN_Var_Free();

#if TgCOMPILE_CONSOLE

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__STOPPED == s_enConsole_State || ETgMODULE_STATE__INITIALIZED == s_enConsole_State);
    s_enConsole_State = ETgMODULE_STATE__FREEING;

    /* Clear out all of the console functions registered with the system.  Entities that install console functions are expected to remove them when no longer needed. */
    /* Thus, by the time this module is freed all functions should have been removed. */
    for (iIndex = 0; iIndex < KTgCN_MAX_COMMAND_FCN; ++iIndex)
    {
        P_STg2_CN_Command_Function          psCmd_Fcn;

        psCmd_Fcn = s_asCommand_Function + iIndex;
        if (nullptr == psCmd_Fcn->m_pfnExecute)
            continue;

        TgWARNING_MSGF( 0, TgT("%-16.16s(%-32.32s): Console command (%s) was not removed.\n"), TgT("Console"), TgT("Free_Module"), psCmd_Fcn->m_sCommon.m_pzName );
        tgCN_Remove_Command_Function( psCmd_Fcn->m_sCommon.m_pzName );
    }

    /* Remove all output objects from the system.  Similar to above, proper life time management requires the installing entity to remove the object from the console when */
    /* it is no longer needed or used.  At this point, they should have all been removed. */
    for (iIndex = 0; iIndex < KTgCN_MAX_CHANNEL; ++iIndex)
    {
        while (0 != s_apsOutput[iIndex][0])
        {
            TgWARNING_MSGF( 0, TgT("%-16.16s(%-32.32s): Output was not removed.\n"), TgT("Console"), TgT("Free_Module") );
            tgCN_Remove_Output( 1 << (iIndex + KTgCN_SEVERITY_BITS), s_apsOutput[iIndex][0] );
        };
    };

    /* Clear out all the prefix headers */
    memset( s_abOutput_Prefix, 0x00, sizeof( s_abOutput_Prefix ) );

    /* Clear out on screen displays */
    s_iOS_Console_Cmd_Index = 0;
    s_iOS_Console_Buffer_Index = 0;
    s_iOS_Console_Display_Index = 0;

    s_psOS_Log_Display = nullptr;
    s_psOS_Log_Free = s_asOS_Log_Data;
    for (iIndex = 0; iIndex + 1 < KTgCN_OSLOG_MAX_LINE; ++iIndex)
    {
        s_asOS_Log_Data[iIndex].m_psNext = s_asOS_Log_Data + iIndex + 1;
    };

    /* Destroy the critical section */
    tgCM_MP_CS_Exit( &s_sSystem_Lock );
    tgCM_MP_CS_Free( &s_sOS_Lock );
    tgCM_MP_CS_Free( &s_sSystem_Lock );

/*# TgCOMPILE_CONSOLE */
#endif

    s_enConsole_State = ETgMODULE_STATE__FREED;
}


/* ---- tgCN_Update ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* Note: This should be called on the primary render thread so that messages will have at least one frame to render */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgCN_Update( C_TgFLOAT32 fDT )
{
#if TgCOMPILE_CONSOLE

    P_STg2_CN_OnScreen_Line             psOS_Log_Display, psOS_Log_Display_Prev;

    tgCM_MP_CS_Enter_Block( &s_sOS_Lock );

    /* Verify the state of the system (technically should have the system lock for comparison but its validation only) */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State);

    psOS_Log_Display = s_psOS_Log_Display;
    psOS_Log_Display_Prev = nullptr;

    /* Update all messages, removing those whose life is now negative and updating the time for active messages */
    while (nullptr != psOS_Log_Display)
    {
        PC_STg2_CN_OnScreen_Line            psOS_Log_Display_Next = psOS_Log_Display->m_psNext;

        /* If the life time of this message is no longer non-negative move it from the display list to the free list.  Otherwise */
        /* decrement the life time of the message by the time delta. */
        if (0.0F >= psOS_Log_Display->m_fLife_Time)
        {
            if (nullptr != psOS_Log_Display_Prev)
            {
                psOS_Log_Display_Prev->m_psNext = psOS_Log_Display_Next;
            }
            else
            {
                s_psOS_Log_Display = psOS_Log_Display_Next;
            };
            psOS_Log_Display->m_psNext = s_psOS_Log_Free;
            s_psOS_Log_Free = psOS_Log_Display;
        }
        else
        {
            psOS_Log_Display->m_fLife_Time -= fDT;
        };

        psOS_Log_Display = psOS_Log_Display_Next;
    };

    tgCM_MP_CS_Exit( &s_sOS_Lock );

/*# TgCOMPILE_CONSOLE */
#endif

    return (KTgS_OK);
}


/* ---- tgCN_Query_Init ------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgEXTN TgBOOL tgCN_Query_Init( TgVOID )
{
    return (ETgMODULE_STATE__INITIALIZED <= s_enConsole_State && s_enConsole_State <= ETgMODULE_STATE__STOPPED ? TgTRUE : TgFALSE);
}


/* ---- tgCN_Query_Boot ------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgEXTN TgBOOL tgCN_Query_Boot( TgVOID )
{
    return (ETgMODULE_STATE__BOOTED == s_enConsole_State ? TgTRUE : TgFALSE);
}


/* ---- tgCN_Query_Fixed_Memory ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgEXTN TgSIZE tgCN_Query_Fixed_Memory( TgVOID )
{
    return (0
             + sizeof( g_sCN_Command_Name_Lock )
             + sizeof( g_apsCN_Command_Hash_Set )
             + sizeof( s_enConsole_State )
             + sizeof( g_apsCommand_Lexical_Set )
         #if TgCOMPILE_CONSOLE
             + sizeof( s_sSystem_Lock )
             + sizeof( s_sOS_Lock )
             + sizeof( s_szOS_Console_Buffer )
             + sizeof( s_iOS_Console_Buffer_Index )
             + sizeof( s_iOS_Console_Cmd_Index )
             + sizeof( s_iOS_Console_Display_Index )
             + sizeof( s_iOS_Console_Cmd_History_Index )
             + sizeof( s_bOS_Console_Render )
             + sizeof( s_iOS_Console_Render_Page_Height )
             + sizeof( s_iOS_Console_Render_Font_Height )
             + sizeof( s_asOS_Log_Data )
             + sizeof( s_psOS_Log_Display )
             + sizeof( s_psOS_Log_Free )
             + sizeof( s_fOS_Log_Default_Life_Time )
             + sizeof( s_asCommand_Function )
             + sizeof( s_sCommand_Function_Stack )
             + sizeof( s_niCommand_Function_Used )
             + sizeof( s_pzOutput_Prefix )
             + sizeof( s_nuiOutput_Prefix )
             + sizeof( s_abOutput_Prefix )
             + sizeof( s_apsOutput )
             + sizeof( s_auiUID_Filter )
             + sizeof( s_auiSeverity_Filter )
             + sizeof( s_sDefault_Output_Break )
             + sizeof( s_sDefault_Output_Abort )
             + sizeof( s_iLOG_Output_File )
             + sizeof( s_sOuput_Std )
             + sizeof( s_szPrefix_Console )
             + sizeof( s_sOuput_Console )
             + sizeof( s_iOuput_Console_File )
             + sizeof( s_szPrefix_Log_Screen )
             + sizeof( s_szPrefix_Log )
             + sizeof( s_sOuput_Log )
             + sizeof( s_iOuput_Log_File )
             + sizeof( s_szPrefix_Log_FCN )
             + sizeof( s_sOuput_Log_FCN )
             + sizeof( s_iOuput_Log_FCN_File )
             + sizeof( s_szPrefix_Log_MEM )
             + sizeof( s_sOuput_Log_Mem )
             + sizeof( s_iOuput_Log_Mem_File )
             + sizeof( s_szPrefix_Message )
             + sizeof( s_sOuput_Msg )
             + sizeof( s_iOuput_Msg_File )
             + sizeof( s_szPrefix_Warning )
             + sizeof( s_sOuput_Wrn )
             + sizeof( s_iOuput_Wrn_File )
             + sizeof( s_szPrefix_Error )
             + sizeof( s_sOuput_Err )
             + sizeof( s_iOuput_Err_File )
             + sizeof( s_szPrefix_Critical )
             + sizeof( s_sOuput_Crt )
             + sizeof( s_iOuput_Crt_File )
             + sizeof( s_szPrefix_Initialize )
             + sizeof( s_sOuput_Int )
             + sizeof( s_iOuput_Int_File )
             + sizeof( s_szPrefix_Loading )
             + sizeof( s_sOuput_Ldn )
             + sizeof( s_iOuput_Ldn_File )
         /*# TgCOMPILE_CONSOLE */
         #endif
    );
}


/* ---- tgCN_Print_Commands --------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Print_Commands( P_STg2_Output psOUT )
{
#if TgCOMPILE_CONSOLE
    tgCN_Print_Command_Functions( psOUT );
#endif
    tgCN_Print_Command_Variables( psOUT );
}


/* ---- tgCN_Execute_Command -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgBOOL tgCN_Execute_Command( CPC_TgCHAR pszCmdLN )
{
    TgSIZE                              uiLength;
    P_TgCHAR                            szCmdLN;
    TgUINT32                            nuiArg;
    CP_TgCHAR                           aszArg[KTgMAX_CMD_LINE_COUNT];
    TgUINTXX                            uiHash;
    P_STg2_CN_Command_Common            psCmd;
    TgBOOL                              bRet;
    TgCN_VAR_ID                         tiCN_Var;
#if TgCOMPILE_CONSOLE
    P_STg2_CN_Command_Function          psCmd_Fcn;
/*# TgCOMPILE_CONSOLE */
#endif

    uiLength = tgSZ_Length( pszCmdLN ) + 1;

    /* Create a copy of the command line on the local stack (parsing modifies the string) */
    TgALLOCA( TgCHAR, uiLength, szCmdLN );
    tgSZ_Copy( szCmdLN, uiLength, pszCmdLN );

    /* Parse the command line (use the global function used to parse the executable command line) */
    nuiArg = tgGB_Parse_Command_Line( aszArg, KTgMAX_CMD_LINE_COUNT, szCmdLN );

    /* Make sure we have a command to execute before taking the critical section */
    if (nuiArg <= 0 || !aszArg[0] || !aszArg[0][0])
    {
        TgFREEA( szCmdLN );
        return (TgFALSE);
    };

    uiHash = tgSZ_Hash( aszArg[0] );

    tgCM_UTM_AM_RW_Enter_Read_Wait_Yield( &g_sCN_Command_Name_Lock );

    do
    {
        bRet = TgFALSE;

        /* Check to see if it exists in the hash set */
        psCmd = tgCN_Find_Command_In_Hash( aszArg[0], uiHash );
        if (nullptr == psCmd)
        {
            break;
        };

    #if TgCOMPILE_CONSOLE
        if (ETgCN_COMMAND__FCN == psCmd->m_uiType)
        {
            psCmd_Fcn = (P_STg2_CN_Command_Function)psCmd;
            if (nullptr != psCmd_Fcn->m_pfnExecute)
            {
                /* This function call must be within the critical section so that removals can be guaranteed that there are no in-flight executions of their functions. */
                /* This means it is safe for a system to remove a console function and then tear down all support for it - without having to worry about possible delay */
                /* execution of the function. */
                psCmd_Fcn->m_pfnExecute( nuiArg, aszArg );
            };

            bRet = TgTRUE;
            break;
        }
    /*# TgCOMPILE_CONSOLE */
    #endif

        tiCN_Var = tgCN_Var_Query_Id_Internal( psCmd );

        if (TgTRUE != tgCN_VAR_ID_Is_Valid( tiCN_Var ))
        {
            break;
        };

        if (ETgCN_COMMAND__VAR_F32_04 == psCmd->m_uiType)
        {
            TgVEC_F32_04                        vValue;

            if (nuiArg == 1)
            {
                bRet = tgCN_Var_Query_F32_04( &vValue, tiCN_Var );
                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: [%f, %f, %f, %f]"),
                                psCmd->m_pzName, (TgFLOAT64)vValue.m.x, (TgFLOAT64)vValue.m.y, (TgFLOAT64)vValue.m.z, (TgFLOAT64)vValue.m.w );
                };
            }
            else if (nuiArg == 5)
            {
                vValue.m.x = tgSZ_To_F32( aszArg[1] );
                vValue.m.y = tgSZ_To_F32( aszArg[2] );
                vValue.m.z = tgSZ_To_F32( aszArg[3] );
                vValue.m.w = tgSZ_To_F32( aszArg[4] );
                bRet = tgCN_Var_Set_F32_04( tiCN_Var, vValue );
                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: [%f, %f, %f, %f]"),
                                psCmd->m_pzName, (TgFLOAT64)vValue.m.x, (TgFLOAT64)vValue.m.y, (TgFLOAT64)vValue.m.z, (TgFLOAT64)vValue.m.w );
                };
            };
            break;
        };

        if (nuiArg > 2)
        {
            break;
        };

        switch (psCmd->m_uiType)
        {
            case ETgCN_COMMAND__VAR_BOOL:
            {
                TgBOOL                              bValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_Bool( &bValue, tiCN_Var );
                }
                else
                {
                    bValue = tgSZ_To_Bool( aszArg[1] );
                    bRet = tgCN_Var_Set_Bool( tiCN_Var, bValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, bValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_S08:
            {
                TgSINT08                            iValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_S08( &iValue, tiCN_Var );
                }
                else
                {
                    iValue = tgSZ_To_S08( aszArg[1] );
                    bRet = tgCN_Var_Set_S08( tiCN_Var, iValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, iValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_S16:
            {
                TgSINT16                            iValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_S16( &iValue, tiCN_Var );
                }
                else
                {
                    iValue = tgSZ_To_S16( aszArg[1] );
                    bRet = tgCN_Var_Set_S16( tiCN_Var, iValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, iValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_S32:
            {
                TgSINT32                            iValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_S32( &iValue, tiCN_Var );
                }
                else
                {
                    iValue = tgSZ_To_S32( aszArg[1] );
                    bRet = tgCN_Var_Set_S32( tiCN_Var, iValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, iValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_S64:
            {
                TgSINT64                            iValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_S64( &iValue, tiCN_Var );
                }
                else
                {
                    iValue = tgSZ_To_S64( aszArg[1] );
                    bRet = tgCN_Var_Set_S64( tiCN_Var, iValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %I64d"), psCmd->m_pzName, iValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_U08:
            {
                TgUINT08                            uiValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_U08( &uiValue, tiCN_Var );
                }
                else
                {
                    uiValue = tgSZ_To_U08( aszArg[1] );
                    bRet = tgCN_Var_Set_U08( tiCN_Var, uiValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, uiValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_U16:
            {
                TgUINT16                            uiValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_U16( &uiValue, tiCN_Var );
                }
                else
                {
                    uiValue = tgSZ_To_U16( aszArg[1] );
                    bRet = tgCN_Var_Set_U16( tiCN_Var, uiValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, uiValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_U32:
            {
                TgUINT32                            uiValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_U32( &uiValue, tiCN_Var );
                }
                else
                {
                    uiValue = tgSZ_To_U32( aszArg[1] );
                    bRet = tgCN_Var_Set_U32( tiCN_Var, uiValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %d"), psCmd->m_pzName, uiValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_U64:
            {
                TgUINT64                            uiValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_U64( &uiValue, tiCN_Var );
                }
                else
                {
                    uiValue = tgSZ_To_U64( aszArg[1] );
                    bRet = tgCN_Var_Set_U64( tiCN_Var, uiValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %I64d"), psCmd->m_pzName, uiValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_F32:
            {
                TgFLOAT32                           fValue;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_F32( &fValue, tiCN_Var );
                }
                else
                {
                    fValue = tgSZ_To_F32( aszArg[1] );
                    bRet = tgCN_Var_Set_F32( tiCN_Var, fValue );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %f"), psCmd->m_pzName, (TgFLOAT64)fValue );
                };
                break;
            };

            case ETgCN_COMMAND__VAR_STRING:
            {
                CP_TgCHAR                           pszString;

                if (nuiArg == 1)
                {
                    bRet = tgCN_Var_Query_String( &pszString, tiCN_Var );
                }
                else
                {
                    pszString = aszArg[1];
                    bRet = tgCN_Var_Set_String( tiCN_Var, pszString );
                };

                if (TgFALSE != bRet)
                {
                    tgCN_PrintF( KTgCN_CHANEL_CONSOLE, TgT("CN VAR %s: %s"), psCmd->m_pzName, pszString );
                };
                break;
            };

            default:
                TgS_NO_DEFAULT( break );
        };

    } while (0);

    tgCM_UTM_AM_RW_Exit_Read( &g_sCN_Command_Name_Lock );
    TgFREEA( szCmdLN );
    return (bRet);
}



/* ---- tgCN_Attach_Output ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* Add the output object to the top of the stack of each of the channel's selected in the mask.  Return the value of all the */
/* channels that the object was successfully added. */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Attach_Output( C_TgUINT32 uiChannel_Mask, PC_STg2_Output psOutput )
{
    TgUINT32                            uiChannel, uiAttached;

    /* Verify function parameters */
    if ((nullptr == psOutput) || (nullptr == psOutput->m_pfnWrite))
    {
        TgCRITICAL_MSG( TgFALSE, TgT("Invalid Arguments") );
        return (0);
    };

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__INITIALIZED == s_enConsole_State || ETgMODULE_STATE__BOOTED == s_enConsole_State);

    /* Primary implementation of the function */
    for (uiChannel = 0, uiAttached = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
    {
        /* Check to see if this channel is in the mask */
        if (0 == (uiChannel_Mask & (1 << (uiChannel + KTgCN_SEVERITY_BITS))))
        {
            continue;
        };

        /* If there is an available slot for the output object, add it to the head of the list */
        if (0 == s_apsOutput[uiChannel][KTgCN_MAX_CHANNEL_OUTPUT - 1])
        {
            memmove( &(s_apsOutput[uiChannel][1]), &(s_apsOutput[uiChannel][0]), sizeof( s_apsOutput[uiChannel][0] )*(KTgCN_MAX_CHANNEL_OUTPUT - 1) );

            s_apsOutput[uiChannel][0] = psOutput;
            uiAttached |= 1 << (uiChannel + KTgCN_SEVERITY_BITS);
        };
    };

    tgCM_MP_CS_Exit( &s_sSystem_Lock );
    return (uiAttached);
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Attach_Default_Break --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Attach_Default_Break( C_TgUINT32 uiChannel_Mask )
{
    return (tgCN_Attach_Output( uiChannel_Mask, &s_sDefault_Output_Break ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Attach_Default_Abort --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Attach_Default_Abort( C_TgUINT32 uiChannel_Mask )
{
    return (tgCN_Attach_Output( uiChannel_Mask, &s_sDefault_Output_Abort ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Remove_Output ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* Remove the output object from each of the channel's selected in the mask.  Return the value of all the channels that the functor */
/* was successfully removed. */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Remove_Output( C_TgUINT32 uiChannel_Mask, PC_STg2_Output psOutput )
{
    TgUINT32                            uiChannel, uiOutput, uiRemoved;

    /* Verify function parameters */
    if (nullptr == psOutput)
    {
        return (0);
    };

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State || ETgMODULE_STATE__FREEING == s_enConsole_State);

    /* Primary implementation of the function */
    for (uiChannel = 0, uiRemoved = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
    {
        /* Check to see if this channel is in the mask */
        if (0 == (uiChannel_Mask & (1 << (uiChannel + KTgCN_SEVERITY_BITS))))
        {
            continue;
        };

        /* Iterate through all of the output objects for the channel - if found, remove and compact the list. */
        for (uiOutput = 0; uiOutput < KTgCN_MAX_CHANNEL_OUTPUT; ++uiOutput)
        {
            if (0 == s_apsOutput[uiChannel][uiOutput])
            {
                break;
            };

            if (psOutput == s_apsOutput[uiChannel][uiOutput])
            {
                for (++uiOutput; uiOutput < KTgCN_MAX_CHANNEL_OUTPUT; ++uiOutput)
                {
                    s_apsOutput[uiChannel][uiOutput - 1] = s_apsOutput[uiChannel][uiOutput];
                };

                s_apsOutput[uiChannel][uiOutput - 1] = 0;

                uiRemoved |= 1 << (uiChannel + KTgCN_SEVERITY_BITS);
                break;
            };
        };
    };

    tgCM_MP_CS_Exit( &s_sSystem_Lock );
    return (uiRemoved);
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Remove_Default_Break --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Remove_Default_Break( C_TgUINT32 uiChannel_Mask )
{
    return (tgCN_Remove_Output( uiChannel_Mask, &s_sDefault_Output_Break ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Remove_Default_Abort --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgUINT32 tgCN_Remove_Default_Abort( C_TgUINT32 uiChannel_Mask )
{
    return (tgCN_Remove_Output( uiChannel_Mask, &s_sDefault_Output_Abort ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Set_Prefix ------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Set_Prefix( C_TgUINT32 uiChannel_Mask, CPC_TgCHAR pszPrefix )
{
    TgUINT32                            uiChannel;

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State);

    for (uiChannel = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
    {
        /* Check to see if this channel is in the mask */
        if (0 == (uiChannel_Mask & (1 << (uiChannel + KTgCN_SEVERITY_BITS))))
        {
            continue;
        };

        s_pzOutput_Prefix[uiChannel] = pszPrefix;
        s_nuiOutput_Prefix[uiChannel] = nullptr == pszPrefix ? 0 : tgSZ_Length( pszPrefix );
    };

    tgCM_MP_CS_Exit( &s_sSystem_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Set_UID_Filter --------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Set_UID_Filter( C_TgUINT32 uiChannel_Mask, C_TgUINT32 uiUID )
{
    TgUINT32                            uiChannel;

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State);

    for (uiChannel = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
    {
        /* Check to see if this channel is in the mask */
        if (0 == (uiChannel_Mask & (1 << (uiChannel + KTgCN_SEVERITY_BITS))))
        {
            continue;
        };

        s_auiUID_Filter[uiChannel] = uiUID;
    };

    tgCM_MP_CS_Exit( &s_sSystem_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Set_Severity_Filter ---------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Set_Severity_Filter( C_TgUINT32 uiChannel_Mask, C_TgUINT32 uiSeverity )
{
    TgUINT32                            uiChannel;

    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    /* Verify the state of the system */
    TgERROR(ETgMODULE_STATE__BOOTED == s_enConsole_State);

    for (uiChannel = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
    {
        /* Check to see if this channel is in the mask */
        if (0 == (uiChannel_Mask & (1 << (uiChannel + KTgCN_SEVERITY_BITS))))
        {
            continue;
        };

        s_auiSeverity_Filter[uiChannel] = tgCM_MIN_U32( uiSeverity, KTgCN_MAX_SEVERITY );
    };

    tgCM_MP_CS_Exit( &s_sSystem_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Print ------------------------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Print( C_TgUINT32 uiChannel_Mask, CP_TgCHAR pszText )
{
    /* Execute the standard print function */
    tgCN_UID_Print_Internal( KTgUID_NONE, uiChannel_Mask, pszText );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_PrintF ----------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_PrintF( C_TgUINT32 uiChannel_Mask, CP_TgCHAR pszText, ... )
{
    TgCHAR                              szBuffer[KTgCN_OSCON_LINE_LENGTH + 1];
    va_list                             argptr;

    /* Create the text string from the printf format */
    va_start( argptr, pszText );
    tgSZ_PrintVF( szBuffer, KTgCN_OSCON_LINE_LENGTH, pszText, argptr );
    va_end( argptr );

    /* Execute the standard print function */
    tgCN_UID_Print_Internal( KTgUID_NONE, uiChannel_Mask, szBuffer );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_UID_Print -------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_UID_Print( C_TgUINT32 uiUID, C_TgUINT32 uiChannel_Mask, CP_TgCHAR pszText )
{
    /* Execute the standard print function */
    tgCN_UID_Print_Internal( uiUID, uiChannel_Mask, pszText );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_UID_PrintF ------------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_UID_PrintF( C_TgUINT32 uiUID, C_TgUINT32 uiChannel_Mask, CP_TgCHAR pszText, ... )
{
    TgCHAR                              szBuffer[KTgCN_OSCON_LINE_LENGTH + 1];
    va_list                             argptr;

    /* Create the text string from the printf format */
    va_start( argptr, pszText );
    tgSZ_PrintVF( szBuffer, KTgCN_OSCON_LINE_LENGTH, pszText, argptr );
    va_end( argptr );

    /* Execute the standard print function */
    tgCN_UID_Print_Internal( uiUID, uiChannel_Mask, szBuffer );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Process_Input ---------------------------------------------------------------------------------------------------------------------------------------------- */
/* This can only be called by a single thread (the input system).  It is not globally multi-thread safe */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Process_Input( TgCHAR tgKey, TgBOOL bCtrl )
{
    /* Enforce the string length limits of the buffer. */
    if (s_iOS_Console_Cmd_Index + 4 > KTgCN_OSCON_LINE_LENGTH)
    {
        return;
    };

    tgCM_MP_CS_Enter_Block( &s_sOS_Lock );

    switch (tgKey)
    {
        case 0x08: /*« Backspace */
            s_iOS_Console_Cmd_Index = tgCM_MAX_S32( s_iOS_Console_Cmd_Index - 1, 2 );
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index] = 0;
            break;
        case 0x09: /*« Tab */
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index++] = ' ';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index++] = ' ';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index++] = ' ';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index++] = ' ';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index] = 0;
            break;
        case 0x0D: /*« Enter */
            tgCN_Execute_Command( s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index] + 2 );
            s_iOS_Console_Display_Index = s_iOS_Console_Buffer_Index;
            s_iOS_Console_Buffer_Index = (s_iOS_Console_Buffer_Index + 1) % KTgCN_OSCON_MAX_LINE;
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][0] = '>';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][1] = ' ';
            s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][2] = 0;
            s_iOS_Console_Cmd_Index = 2;
            s_iOS_Console_Cmd_History_Index = 0;
            break;
        case '`':
            s_bOS_Console_Render = !s_bOS_Console_Render;
            break;

        case 0x21:
            if (bCtrl)
            {
                tgCN_Scroll_Display( 0, -1 );
            }
            else
            {
            };
            break;
        case 0x22:
            if (bCtrl)
            {
                tgCN_Scroll_Display( 0, 1 );
            }
            else
            {
            };
            break;
        case 0x23:
            if (bCtrl)
            {
                s_iOS_Console_Display_Index = s_iOS_Console_Buffer_Index;
            }
            else
            {
            };
            break;
        case 0x24:
            if (bCtrl)
            {
            }
            else
            {
            };
            break;
        case 0x25: /*« Left */
            break;
        case 0x26:
            if (bCtrl)
            {
                tgCN_Scroll_Display( -1, 0 );
            }
            else if (s_iOS_Console_Cmd_History_Index < KTgCN_OSCON_MAX_LINE - 1)
            {
                TgSINT32                            iIndex;

                ++s_iOS_Console_Cmd_History_Index;
                iIndex = (KTgCN_OSCON_MAX_LINE + s_iOS_Console_Buffer_Index - s_iOS_Console_Cmd_History_Index) % KTgCN_OSCON_MAX_LINE;
                tgSZ_Copy( s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index], KTgCN_OSCON_LINE_LENGTH, s_szOS_Console_Buffer[iIndex] );
            };
            break;
        case 0x27: /*« Right */
            break;
        case 0x28:
            if (bCtrl)
            {
                tgCN_Scroll_Display( 1, 0 );
            }
            else if (s_iOS_Console_Cmd_History_Index > 0)
            {
                if (0 == --s_iOS_Console_Cmd_History_Index)
                {
                    s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][0] = 0;
                }
                else
                {
                    TgSINT32                            iIndex;

                    iIndex = (KTgCN_OSCON_MAX_LINE + s_iOS_Console_Buffer_Index - s_iOS_Console_Cmd_History_Index) % KTgCN_OSCON_MAX_LINE;
                    tgSZ_Copy( s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index], KTgCN_OSCON_LINE_LENGTH, s_szOS_Console_Buffer[iIndex] );
                };
            };
            break;

        default:
            if (tgKey >= 0x20)
            {
                s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index++] = tgKey;
                s_szOS_Console_Buffer[s_iOS_Console_Buffer_Index][s_iOS_Console_Cmd_Index] = 0;
            };
            break;
    };

    tgCM_MP_CS_Exit( &s_sOS_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Insert_Command_Function ------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgBOOL tgCN_Insert_Command_Function( CPC_TgCHAR pzName, TgFCN_CONSOLE pfnExecute, CPC_TgCHAR pszDesc )
{
    P_STg2_CN_Command_Function          psCmd_Fcn;
    TgSTRING_DICT_ID                    tiString;
    P_STg2_CN_Command_Common            psCmd_Ret;
    TgRESULT                            iRet;

    TgPARAM_CHECK(nullptr != pzName && pzName[0]);
    TgPARAM_CHECK(nullptr != pfnExecute);

    psCmd_Fcn = (P_STg2_CN_Command_Function)tgCM_UTM_AM_ST_Pop( &s_sCommand_Function_Stack.m_sStack );
    if (nullptr == psCmd_Fcn)
    {
        TgERROR_MSGF( 0, TgT("%-16.16s(%-32.32s): Exceeded number of console command functions.\n"), TgT("Console"), TgT("tgCN_Insert_Command_Function") );
        return (TgFALSE);
    };

    memset( psCmd_Fcn, 0, sizeof( STg2_CN_Command_Function ) );

    psCmd_Fcn->m_sCommon.m_uiHash = tgSZ_Hash( pzName );
    tiString = tgSM_Dict_Insert_String_Hash( pzName, tgSZ_Length( pzName ), psCmd_Fcn->m_sCommon.m_uiHash );
    if (TgTRUE != tgSTRING_DICT_ID_Is_Valid( tiString ))
    {
        tgCM_UTM_AM_ST_Push( &s_sCommand_Function_Stack.m_sStack, (P_STg2_UTM_Node)(psCmd_Fcn) );
        return (nullptr);
    };
    tgSM_Dict_Query_String( &psCmd_Fcn->m_sCommon.m_pzName, nullptr, tiString );
    if (nullptr != pszDesc)
    {
        tiString = tgSM_Dict_Insert_String_Hash( pszDesc, tgSZ_Length( pszDesc ), tgSZ_Hash( pszDesc ) );
        if (TgTRUE == tgSTRING_DICT_ID_Is_Valid( tiString ))
        {
            tgSM_Dict_Query_String( &psCmd_Fcn->m_sCommon.m_pzDesc, nullptr, tiString );
        };
    }
    else
    {
        psCmd_Fcn->m_sCommon.m_pzDesc = nullptr;
    };

    psCmd_Fcn->m_sCommon.m_uiType = ETgCN_COMMAND__FCN;
    psCmd_Fcn->m_pfnExecute = pfnExecute;

    tgCM_UTM_AM_RW_Enter_Write_Wait_Yield( &g_sCN_Command_Name_Lock );

    iRet = tgCN_Insert_Command( &psCmd_Ret, &psCmd_Fcn->m_sCommon );
    if (TgSUCCEEDED( iRet ))
    {
        psCmd_Fcn->m_sCommon.m_uiFlags |= KTgCN_CMD_FLAG_USED;
        tgCM_UTM_AM_RW_Exit_Write( &g_sCN_Command_Name_Lock );
        return (TgTRUE);
    }
    else if (KTgW_DUPLICATE == iRet)
    {
        if (((P_STg2_CN_Command_Function)psCmd_Ret)->m_pfnExecute == pfnExecute)
        {
            tgCM_UTM_AM_RW_Exit_Write( &g_sCN_Command_Name_Lock );
            TgWARNING_MSGF( 0, TgT("%-16.16s(%-32.32s): Duplicate insert of console function.\n"), TgT("Console"), TgT("tgCN_Insert_Command_Function") );

            memset( psCmd_Fcn, 0, sizeof( STg2_CN_Command_Function ) );
            tgCM_UTM_AM_ST_Push( &s_sCommand_Function_Stack.m_sStack, (P_STg2_UTM_Node)(psCmd_Fcn) );
            return (TgTRUE);
        };
    };

    tgCM_UTM_AM_RW_Exit_Write( &g_sCN_Command_Name_Lock );

    TgWARNING_MSGF( 0, TgT("%-16.16s(%-32.32s): Console command name already used.\n"), TgT("Console"), TgT("tgCN_Insert_Command_Function") );
    memset( psCmd_Fcn, 0, sizeof( STg2_CN_Command_Function ) );
    tgCM_UTM_AM_ST_Push( &s_sCommand_Function_Stack.m_sStack, (P_STg2_UTM_Node)(psCmd_Fcn) );

    return (TgFALSE);
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Remove_Command_Function ------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgBOOL tgCN_Remove_Command_Function( CPC_TgCHAR pszCmd )
{
    TgUINTXX                            uiHash;
    TgSINT32                            iHash_Index;
    P_STg2_CN_Command_Common            psHash_Cmd;
    P_STg2_CN_Command_Common            psLexical_Cmd;
    P_STg2_CN_Command_Common            psPrev_Cmd;
    TgSINT32                            iLexical_Index;

    TgPARAM_CHECK(nullptr != pszCmd && 0 != pszCmd[0]);

    uiHash = tgSZ_Hash( pszCmd );
    iHash_Index = uiHash % KTgCN_MAX_COMMAND_HASH_SET;
    TgERROR_INDEX( iHash_Index, g_apsCN_Command_Hash_Set );

    tgCM_UTM_AM_RW_Enter_Write_Wait_Yield( &g_sCN_Command_Name_Lock );

    /* Remove the item from the hash set */
    psHash_Cmd = g_apsCN_Command_Hash_Set[iHash_Index];
    psPrev_Cmd = nullptr;
    while (nullptr != psHash_Cmd)
    {
        if (0 == tgSZ_Compare_NoCase( pszCmd, psHash_Cmd->m_pzName ))
        {
            break;
        };

        psPrev_Cmd = psHash_Cmd;
        psHash_Cmd = psHash_Cmd->m_psNext_Hash;
    };

    if (nullptr == psHash_Cmd || psHash_Cmd->m_uiType != ETgCN_COMMAND__FCN)
    {
        tgCM_UTM_AM_RW_Exit_Write( &g_sCN_Command_Name_Lock );
        return (TgFALSE);
    };

    if (nullptr == psPrev_Cmd)
    {
        g_apsCN_Command_Hash_Set[iHash_Index] = psHash_Cmd->m_psNext_Hash;
    }
    else
    {
        psPrev_Cmd->m_psNext_Hash = psHash_Cmd->m_psNext_Hash;
    };


    /* Calculate the lexical index */
    iLexical_Index = tgCN_Calc_Command_Lexical_Index( pszCmd );
    TgERROR_INDEX( iLexical_Index, g_apsCommand_Lexical_Set );

    /* Remove it into the lexical list */
    psLexical_Cmd = g_apsCommand_Lexical_Set[iLexical_Index];
    psPrev_Cmd = nullptr;
    while (nullptr != psLexical_Cmd)
    {
        if (0 == tgSZ_Compare_NoCase( pszCmd, psLexical_Cmd->m_pzName ))
        {
            break;
        };

        psPrev_Cmd = psLexical_Cmd;
        psLexical_Cmd = psLexical_Cmd->m_psNext_Lexical;
    };

    TgCRITICAL( nullptr != psLexical_Cmd && psHash_Cmd == psLexical_Cmd );

    if (nullptr == psPrev_Cmd)
    {
        g_apsCommand_Lexical_Set[iLexical_Index] = psLexical_Cmd->m_psNext_Lexical;
    }
    else
    {
        psPrev_Cmd->m_psNext_Lexical = psLexical_Cmd->m_psNext_Lexical;
    };

    tgCM_UTM_AM_RW_Exit_Write( &g_sCN_Command_Name_Lock );

    TgWARNING_MSGF( 0, TgT("%-16.16s(%-32.32s): Console command name already used.\n"), TgT("Console"), TgT("tgCN_Insert_Command_Function") );
    memset( psLexical_Cmd, 0, sizeof( STg2_CN_Command_Function ) );
    tgCM_UTM_AM_ST_Push( &s_sCommand_Function_Stack.m_sStack, (P_STg2_UTM_Node)(psLexical_Cmd) );

    return (TgTRUE);
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Print_Command_Functions ------------------------------------------------------------------------------------------------------------------------------------ */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
TgVOID tgCN_Print_Command_Functions( P_STg2_Output psOutput )
{
    TgSINT32                            iIndex;
    P_STg2_CN_Command_Common            psCmd;

    tgCM_UTM_AM_RW_Enter_Read_Wait_Yield( &g_sCN_Command_Name_Lock );

    for (iIndex = 0; iIndex < KTgCN_MAX_COMMAND_FCN; ++iIndex)
    {
        psCmd = &s_asCommand_Function[iIndex].m_sCommon;
        if (0 == (psCmd->m_uiFlags & KTgCN_CMD_FLAG_USED))
        {
            continue;
        };

        tgIO_PrintF( psOutput, TgT("%-16.16s(%-32.32s): %s\n"), TgT("Con Function"), psCmd->m_pzName, psCmd->m_pzDesc );
    };

    tgCM_UTM_AM_RW_Exit_Read( &g_sCN_Command_Name_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Private Functions                                                                                                                                                     */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgCN_Insert_Command --------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgCN_Insert_Command( PP_STg2_CN_Command_Common psCmd_Ret, P_STg2_CN_Command_Common psCmd )
{
    P_STg2_CN_Command_Common            psIter_Cmd;
    TgSINT32                            iLexical_Index;
    P_STg2_CN_Command_Common            psPrev_Cmd;
    TgSINT32                            iHash_Index;

    TgPARAM_CHECK(nullptr != psCmd && nullptr != psCmd->m_pzName && 0 != psCmd->m_pzName[0]);

    /* Check to see if it exists in the hash set */
    psIter_Cmd = tgCN_Find_Command_In_Hash( psCmd->m_pzName, psCmd->m_uiHash );
    if (nullptr != psIter_Cmd)
    {
        if (psCmd->m_uiType == psIter_Cmd->m_uiType)
        {
            if (nullptr != psCmd_Ret)
            {
                *psCmd_Ret = psIter_Cmd;
            };
            return (KTgW_DUPLICATE);
        }
        else
        {
            return (KTgE_FAIL);
        };
    };

    /* Calculate the lexical index */
    iLexical_Index = tgCN_Calc_Command_Lexical_Index( psCmd->m_pzName );
    TgERROR_INDEX( iLexical_Index, g_apsCommand_Lexical_Set );

    /* Insert it into the lexical list */
    psIter_Cmd = g_apsCommand_Lexical_Set[iLexical_Index];
    psPrev_Cmd = nullptr;
    while (nullptr != psIter_Cmd)
    {
        TgSINT32                            niCompare;

        niCompare = tgSZ_Compare_NoCase( psCmd->m_pzName, psIter_Cmd->m_pzName );

        if (niCompare > 0)
        {
            break;
        };

        TgERROR(0 != niCompare);

        psPrev_Cmd = psIter_Cmd;
        psIter_Cmd = psIter_Cmd->m_psNext_Lexical;
    };

    if (nullptr == psPrev_Cmd)
    {
        psCmd->m_psNext_Lexical = psIter_Cmd;
        g_apsCommand_Lexical_Set[iLexical_Index] = psCmd;
    }
    else
    {
        psCmd->m_psNext_Lexical = psPrev_Cmd->m_psNext_Lexical;
        psPrev_Cmd->m_psNext_Lexical = psCmd;
    };

    /* Insert it into the hash set */
    iHash_Index = psCmd->m_uiHash % KTgCN_MAX_COMMAND_HASH_SET;
    TgERROR_INDEX( iHash_Index, g_apsCN_Command_Hash_Set );

    psCmd->m_psNext_Hash = g_apsCN_Command_Hash_Set[iHash_Index];
    g_apsCN_Command_Hash_Set[iHash_Index] = psCmd;

    return (KTgS_OK);
}


/* ---- tgCN_Init_Unit_Test --------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Init_Unit_Test( PP_TgVOID ppOutput, P_TgSIZE puiSize )
{
#if TgCOMPILE_CONSOLE
    *ppOutput = s_apsOutput;
    *puiSize = sizeof( s_apsOutput );
#else
    *ppOutput = nullptr;
    *puiSize = 0;
#endif
}


/* ---- tgCN_Start_Unit_Test -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Start_Unit_Test( TgVOID )
{
#if TgCOMPILE_CONSOLE
    memset( s_apsOutput, 0, sizeof( s_apsOutput ) );
#endif
}


/* ---- tgCN_Stop_Unit_Test --------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgCN_Stop_Unit_Test( P_TgVOID pOutput )
{
#if TgCOMPILE_CONSOLE
    memcpy( s_apsOutput, pOutput, sizeof( s_apsOutput ) );
#endif
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgCN_UID_Print_Internal ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgVOID tgCN_UID_Print_Internal( C_TgUINT32 uiUID, C_TgUINT32 uiChannel_Mask, CP_TgCHAR pszText )
{
    C_TgUINT32                          uiSeverity = uiChannel_Mask & KTgCN_SEVERITY_MASK;
    TgUINT32                            uiChannel, uiOutput, uiLength;
    CP_TgCHAR                           pszStart;
    TgBOOL                              bEmitPrefix;

    if (ETgMODULE_STATE__BOOTED != s_enConsole_State)
    {
        tgPM_DBG_ERR_Write( nullptr, KTgMAX_SIZE, (CP_TgUINT08)pszText, tgSZ_Length( pszText ) );
        return;
    };

    /* Enter the critical sections for the system and output system (if required) */
    if (0 != (uiChannel_Mask & KTgCN_CHANEL_LOG_SCREEN))
    {
        tgCM_MP_CS_Enter_Block( &s_sOS_Lock );
    };
    tgCM_MP_CS_Enter_Block( &s_sSystem_Lock );

    for (pszStart = pszText; TgT('\0') != *pszText; pszStart = pszText)
    {
        /* Calculate the length of the first string up to the end or the first new line character */
        for (uiLength = 1; TgT('\0') != *pszText && TgT('\n') != *pszText; ++uiLength, ++pszText);

        /* Include the nullptr terminator for the string and determine if we should emit a prefix on the next token */
        if (TgT('\0') != *pszText)
        {
            bEmitPrefix = TgTRUE;
            ++pszText;
        }
        else
        {
            bEmitPrefix = TgFALSE;
            --uiLength;
        };

        for (uiChannel = 0; uiChannel < KTgCN_MAX_CHANNEL; ++uiChannel)
        {
            /* Continue if this channel is not part of the output request */
            C_TgUINT32                          uiChannel_ID = 1 << (uiChannel + KTgCN_SEVERITY_BITS);

            /* Skip if the message is not included for this channel */
            if (0 == (uiChannel_Mask & uiChannel_ID))
            {
                continue;
            };

            /* Check to see if the message passes the UID filter */
            if ((KTgUID_NONE != s_auiUID_Filter[uiChannel]) && (uiUID != s_auiUID_Filter[uiChannel]))
            {
                continue;
            };

            /* Check to see if the message passes the severity filter */
            if (s_auiSeverity_Filter[uiChannel] <= uiSeverity)
            {
                continue;
            };

            /* Screen output is kept within a ring buffer log for display purposes as well sent to the output functions */
            if (KTgCN_CHANEL_LOG_SCREEN == uiChannel_ID && nullptr != s_psOS_Log_Free)
            {
                PC_STg2_CN_OnScreen_Line            psOS_Log_Display = s_psOS_Log_Free;

                s_psOS_Log_Free = psOS_Log_Display->m_psNext;

                tgSZ_CopyN( psOS_Log_Display->m_szLog, KTgCN_OSCON_LINE_LENGTH, pszStart, uiLength );
                psOS_Log_Display->m_uiSeverity = uiSeverity;
                psOS_Log_Display->m_uiUID = uiUID;
                psOS_Log_Display->m_fLife_Time = s_fOS_Log_Default_Life_Time;
                psOS_Log_Display->m_psNext = s_psOS_Log_Display;

                s_psOS_Log_Display = psOS_Log_Display;
            };

            /* Iterate through all of the output objects for this channel */
            for (uiOutput = 0; uiOutput < KTgCN_MAX_CHANNEL_OUTPUT; ++uiOutput)
            {
                if (0 == s_apsOutput[uiChannel][uiOutput])
                {
                    break;
                };

                if ((TgTRUE == s_abOutput_Prefix[uiChannel]) && 0 != s_pzOutput_Prefix[uiChannel])
                {
                    s_apsOutput[uiChannel][uiOutput]->m_pfnWrite( s_apsOutput[uiChannel][uiOutput], KTgMAX_SIZE,
                        (CP_TgUINT08)s_pzOutput_Prefix[uiChannel], s_nuiOutput_Prefix[uiChannel] * sizeof( TgCHAR ) );
                };

                s_apsOutput[uiChannel][uiOutput]->m_pfnWrite( s_apsOutput[uiChannel][uiOutput], KTgMAX_SIZE, (CP_TgUINT08)pszStart, uiLength*sizeof( TgCHAR ) );
            };

            s_abOutput_Prefix[uiChannel] = bEmitPrefix;
        };
    };

    /* Exit the critical sections for the system and output system (if required) */
    if (0 != (uiChannel_Mask & KTgCN_CHANEL_LOG_SCREEN))
    {
        tgCM_MP_CS_Exit( &s_sOS_Lock );
    };
    tgCM_MP_CS_Exit( &s_sSystem_Lock );
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Scroll_Display --------------------------------------------------------------------------------------------------------------------------------------------- */
/* NOTE: This should only be called by tgCN_Process_Input due to synchronization on internal variables */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgVOID tgCN_Scroll_Display( C_TgSINT32 niLN, C_TgSINT32 niPG )
{
    C_TgSINT32                          iPageAmount = (s_iOS_Console_Render_Page_Height / s_iOS_Console_Render_Font_Height - 1);
    C_TgSINT32                          iNew_Disp = (s_iOS_Console_Display_Index + (niLN + niPG*iPageAmount)) % KTgCN_OSCON_MAX_LINE;

    s_iOS_Console_Display_Index = iNew_Disp;
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Default_Break_Write ---------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgCN_Default_Break_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID UNUSED_PARAM pszText, C_TgSIZE UNUSED_PARAM niText )
{
    tgPM_Break();
    return (0);
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgCN_Default_Abort_Write ---------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgCN_Default_Abort_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID UNUSED_PARAM pszText, C_TgSIZE UNUSED_PARAM niText )
{
    tgPM_Abort();
    CLANG_COMMAND( return 0;)
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_CON_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_CON_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Console_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_LOG_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_LOG_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iLOG_Output_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_FCN_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_FCN_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Log_FCN_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_MEM_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_MEM_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Log_Mem_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_MSG_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_MSG_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Msg_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_WRN_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_WRN_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Wrn_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_ERR_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_ERR_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Err_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_CRT_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_CRT_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Crt_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_INT_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_INT_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Int_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_LDN_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_LDN_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iOuput_Ldn_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif


/* ---- tgLOG_STD_File_Write -------------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
#if TgCOMPILE_CONSOLE
static TgSIZE tgLOG_STD_File_Write( PC_STg2_Output UNUSED_PARAM psOut, C_TgSIZE UNUSED_PARAM uiOffset, CP_TgVOID pszText, C_TgSIZE _nuiText )
{
    return (tgIO_File_Write( s_iLOG_Output_File, (CPC_TgVOID)pszText, _nuiText ));
}
/*# TgCOMPILE_CONSOLE */
#endif