2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,21 +1,21 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plStatusLog_SOURCES
plEncryptLogLine.cpp
plLoggable.cpp
plStatusLog.cpp
)
set(plStatusLog_HEADERS
plEncryptLogLine.h
plLoggable.h
plStatusLog.h
)
add_library(plStatusLog STATIC ${plStatusLog_SOURCES} ${plStatusLog_HEADERS})
source_group("Source Files" FILES ${plStatusLog_SOURCES})
source_group("Header Files" FILES ${plStatusLog_HEADERS})
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plStatusLog_SOURCES
plEncryptLogLine.cpp
plLoggable.cpp
plStatusLog.cpp
)
set(plStatusLog_HEADERS
plEncryptLogLine.h
plLoggable.h
plStatusLog.h
)
add_library(plStatusLog STATIC ${plStatusLog_SOURCES} ${plStatusLog_HEADERS})
source_group("Source Files" FILES ${plStatusLog_SOURCES})
source_group("Header Files" FILES ${plStatusLog_HEADERS})

View File

@ -1,79 +1,79 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plEncryptLogLine Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// Broken into a separate file for easy include in utility apps //
// //
//////////////////////////////////////////////////////////////////////////////
#include "plEncryptLogLine.h"
#include <string.h>
void plStatusEncrypt::Encrypt( UInt8 *line, UInt8 hint )
{
// Current encryption scheme: rotate all characters right by 2 bits,
// then rotate the whole damn line by 3 bits to the right
UInt32 i, len = strlen( (char *)line );
UInt8 newHi, hiBits = ( ( line[ len - 1 ] ) << ( 5 - 2 ) ) & 0xe0;
for( i = 0; i < len; i++ )
{
// So each character will be the src char rotated right 2 bits, then shifted
// right 3 bits, or'ed with the last high bits, and the 3 discarded bits
// become the new high bits
// Too bad C doesn't have a bit-rotate op
line[ i ] = ( line[ i ] << 6 ) | ( line[ i ] >> 2 );
newHi = line[ i ] << 5;
line[ i ] = ( line[ i ] >> 3 ) | hiBits;
line[ i ] ^= hint; // Should wrap around
hiBits = newHi;
}
}
void plStatusEncrypt::Decrypt( UInt8 *line, Int32 len, UInt8 hint )
{
// Da reverse, of course!
Int32 i;
UInt8 lastChar = 0, newLo, loBits = ( line[ 0 ] ^ hint ) >> 5;
for( i = len - 1; i >= 0; i-- )
{
lastChar = line[ i ];
line[ i ] ^= hint;
newLo = line[ i ] >> 5;
line[ i ] = ( line[ i ] << 3 ) | loBits;
line[ i ] = ( line[ i ] >> 6 ) | ( line[ i ] << 2 );
loBits = newLo;
}
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plEncryptLogLine Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// Broken into a separate file for easy include in utility apps //
// //
//////////////////////////////////////////////////////////////////////////////
#include "plEncryptLogLine.h"
#include <string.h>
void plStatusEncrypt::Encrypt( UInt8 *line, UInt8 hint )
{
// Current encryption scheme: rotate all characters right by 2 bits,
// then rotate the whole damn line by 3 bits to the right
UInt32 i, len = strlen( (char *)line );
UInt8 newHi, hiBits = ( ( line[ len - 1 ] ) << ( 5 - 2 ) ) & 0xe0;
for( i = 0; i < len; i++ )
{
// So each character will be the src char rotated right 2 bits, then shifted
// right 3 bits, or'ed with the last high bits, and the 3 discarded bits
// become the new high bits
// Too bad C doesn't have a bit-rotate op
line[ i ] = ( line[ i ] << 6 ) | ( line[ i ] >> 2 );
newHi = line[ i ] << 5;
line[ i ] = ( line[ i ] >> 3 ) | hiBits;
line[ i ] ^= hint; // Should wrap around
hiBits = newHi;
}
}
void plStatusEncrypt::Decrypt( UInt8 *line, Int32 len, UInt8 hint )
{
// Da reverse, of course!
Int32 i;
UInt8 lastChar = 0, newLo, loBits = ( line[ 0 ] ^ hint ) >> 5;
for( i = len - 1; i >= 0; i-- )
{
lastChar = line[ i ];
line[ i ] ^= hint;
newLo = line[ i ] >> 5;
line[ i ] = ( line[ i ] << 3 ) | loBits;
line[ i ] = ( line[ i ] >> 6 ) | ( line[ i ] << 2 );
loBits = newLo;
}
}

View File

@ -1,48 +1,48 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plEncryptLogLine Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// Broken into a separate file for easy include in utility apps //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plEncryptLogLine_h
#define _plEncryptLogLine_h
#include "hsTypes.h"
namespace plStatusEncrypt
{
void Encrypt( UInt8 *line, UInt8 hint );
void Decrypt( UInt8 *line, Int32 length, UInt8 hint );
};
#endif //_plEncryptLogLine_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plEncryptLogLine Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// Broken into a separate file for easy include in utility apps //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plEncryptLogLine_h
#define _plEncryptLogLine_h
#include "hsTypes.h"
namespace plStatusEncrypt
{
void Encrypt( UInt8 *line, UInt8 hint );
void Decrypt( UInt8 *line, Int32 length, UInt8 hint );
};
#endif //_plEncryptLogLine_h

View File

@ -1,144 +1,144 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plLoggable.h"
#include "plStatusLog.h"
#include "hsStlUtils.h"
#include "hsTemplates.h"
plLoggable::~plLoggable()
{
IDeleteLog();
}
void plLoggable::IDeleteLog()
{
if ( fWeCreatedLog )
delete fStatusLog;
fWeCreatedLog = false;
fStatusLog = nil;
}
plStatusLog* plLoggable::GetLog() const
{
// create status log if necessary
if(fStatusLog==nil)
{
ICreateStatusLog(); // Usually overridden by derived class
if ( fStatusLog )
fWeCreatedLog = true;
}
#ifdef HS_DEBUGGING
if ( fComplainAboutMissingLog )
{
hsAssert(fStatusLog, "nil fStatusLog. Should override ICreateStatusLog()");
}
#endif
return fStatusLog;
}
void plLoggable::SetLog( plStatusLog * log, bool deleteOnDestruct/*=false */)
{
IDeleteLog();
fStatusLog = log;
fWeCreatedLog = deleteOnDestruct;
}
bool plLoggable::Log( const char * str ) const
{
if ( !str || strlen( str )==0 )
return true;
GetLog();
if ( fStatusLog )
return fStatusLog->AddLine( str );
return true;
}
bool plLoggable::LogF( const char * fmt, ... ) const
{
va_list args;
va_start(args, fmt);
return Log( xtl::formatv( fmt, args ).c_str() );
}
bool plLoggable::LogV( const char * fmt, va_list args ) const
{
return Log( xtl::formatv( fmt, args ).c_str() );
}
bool plLoggable::DebugMsgV(const char* fmt, va_list args) const
{
return LogF("DBG: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::ErrorMsgV(const char* fmt, va_list args) const
{
return LogF("ERR: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::WarningMsgV(const char* fmt, va_list args) const
{
return LogF("WRN: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::AppMsgV(const char* fmt, va_list args) const
{
return LogF("APP: %s", xtl::formatv(fmt,args).c_str());
}
///////////////////////////////////////////////////////////////
bool plLoggable::DebugMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return DebugMsgV(fmt, args);
}
bool plLoggable::ErrorMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return ErrorMsgV(fmt, args);
}
bool plLoggable::WarningMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return WarningMsgV(fmt, args);
}
bool plLoggable::AppMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return AppMsgV(fmt, args);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plLoggable.h"
#include "plStatusLog.h"
#include "hsStlUtils.h"
#include "hsTemplates.h"
plLoggable::~plLoggable()
{
IDeleteLog();
}
void plLoggable::IDeleteLog()
{
if ( fWeCreatedLog )
delete fStatusLog;
fWeCreatedLog = false;
fStatusLog = nil;
}
plStatusLog* plLoggable::GetLog() const
{
// create status log if necessary
if(fStatusLog==nil)
{
ICreateStatusLog(); // Usually overridden by derived class
if ( fStatusLog )
fWeCreatedLog = true;
}
#ifdef HS_DEBUGGING
if ( fComplainAboutMissingLog )
{
hsAssert(fStatusLog, "nil fStatusLog. Should override ICreateStatusLog()");
}
#endif
return fStatusLog;
}
void plLoggable::SetLog( plStatusLog * log, bool deleteOnDestruct/*=false */)
{
IDeleteLog();
fStatusLog = log;
fWeCreatedLog = deleteOnDestruct;
}
bool plLoggable::Log( const char * str ) const
{
if ( !str || strlen( str )==0 )
return true;
GetLog();
if ( fStatusLog )
return fStatusLog->AddLine( str );
return true;
}
bool plLoggable::LogF( const char * fmt, ... ) const
{
va_list args;
va_start(args, fmt);
return Log( xtl::formatv( fmt, args ).c_str() );
}
bool plLoggable::LogV( const char * fmt, va_list args ) const
{
return Log( xtl::formatv( fmt, args ).c_str() );
}
bool plLoggable::DebugMsgV(const char* fmt, va_list args) const
{
return LogF("DBG: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::ErrorMsgV(const char* fmt, va_list args) const
{
return LogF("ERR: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::WarningMsgV(const char* fmt, va_list args) const
{
return LogF("WRN: %s", xtl::formatv(fmt,args).c_str());
}
bool plLoggable::AppMsgV(const char* fmt, va_list args) const
{
return LogF("APP: %s", xtl::formatv(fmt,args).c_str());
}
///////////////////////////////////////////////////////////////
bool plLoggable::DebugMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return DebugMsgV(fmt, args);
}
bool plLoggable::ErrorMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return ErrorMsgV(fmt, args);
}
bool plLoggable::WarningMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return WarningMsgV(fmt, args);
}
bool plLoggable::AppMsg(const char* fmt, ...) const
{
va_list args;
va_start(args, fmt);
return AppMsgV(fmt, args);
}

View File

@ -1,69 +1,69 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plLoggable_inc
#define plLoggable_inc
#include <stdio.h>
#include "hsTypes.h"
//
// An abstract base class which contains a status log and simple functions
// for writing Debug and Error msgs to the log
//
class plStatusLog;
class plLoggable
{
protected:
mutable plStatusLog* fStatusLog;
mutable bool fWeCreatedLog;
mutable bool fComplainAboutMissingLog;
virtual void ICreateStatusLog() const { }; // call plStatusLogMgr::CreateStatusLog with the options you want
void IDeleteLog();
public:
plLoggable() : fStatusLog(nil), fWeCreatedLog(false),fComplainAboutMissingLog(true) { }
virtual ~plLoggable();
plStatusLog* GetLog() const;
void SetLog( plStatusLog * log, bool deleteOnDestruct=false );
// logging
virtual bool Log( const char * str ) const;
virtual bool LogF( const char * fmt, ... ) const;
virtual bool LogV( const char * fmt, va_list args ) const;
virtual bool ErrorMsgV(const char* fmt, va_list args) const ;
virtual bool DebugMsgV(const char* fmt, va_list args) const ;
virtual bool WarningMsgV(const char* fmt, va_list args) const ;
virtual bool AppMsgV(const char* fmt, va_list args) const ;
virtual bool ErrorMsg(const char* fmt, ...) const ;
virtual bool DebugMsg(const char* fmt, ...) const ;
virtual bool WarningMsg(const char* fmt, ...) const ;
virtual bool AppMsg(const char* fmt, ...) const ;
};
#endif // plLoggable_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plLoggable_inc
#define plLoggable_inc
#include <stdio.h>
#include "hsTypes.h"
//
// An abstract base class which contains a status log and simple functions
// for writing Debug and Error msgs to the log
//
class plStatusLog;
class plLoggable
{
protected:
mutable plStatusLog* fStatusLog;
mutable bool fWeCreatedLog;
mutable bool fComplainAboutMissingLog;
virtual void ICreateStatusLog() const { }; // call plStatusLogMgr::CreateStatusLog with the options you want
void IDeleteLog();
public:
plLoggable() : fStatusLog(nil), fWeCreatedLog(false),fComplainAboutMissingLog(true) { }
virtual ~plLoggable();
plStatusLog* GetLog() const;
void SetLog( plStatusLog * log, bool deleteOnDestruct=false );
// logging
virtual bool Log( const char * str ) const;
virtual bool LogF( const char * fmt, ... ) const;
virtual bool LogV( const char * fmt, va_list args ) const;
virtual bool ErrorMsgV(const char* fmt, va_list args) const ;
virtual bool DebugMsgV(const char* fmt, va_list args) const ;
virtual bool WarningMsgV(const char* fmt, va_list args) const ;
virtual bool AppMsgV(const char* fmt, va_list args) const ;
virtual bool ErrorMsg(const char* fmt, ...) const ;
virtual bool DebugMsg(const char* fmt, ...) const ;
virtual bool WarningMsg(const char* fmt, ...) const ;
virtual bool AppMsg(const char* fmt, ...) const ;
};
#endif // plLoggable_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,261 +1,261 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plStatusLog Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// plStatusLogs are our new encapsulated method of outputting text logs //
// for status (or other things, like, say, errors). They do more than just //
// output to the file, though; they maintain a scrolling buffer that //
// can be drawn on to the screen so you can actually view what's being //
// outputted to the log file (you can disable file writing if you wish). //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plStatusLog_h
#define _plStatusLog_h
#include "hsTypes.h"
#include "hsThread.h"
#include <string>
class plPipeline;
//// plStatusLog Definition //////////////////////////////////////////////////
// Currently, they all display in the same location, so only one should
// really be visible at any given time.
class plStatusLogMgr;
class hsMutex;
class plStatusLogDrawerStub;
class plStatusLog
{
friend class plStatusLogMgr;
friend class plStatusLogDrawerStub;
friend class plStatusLogDrawer;
protected:
mutable UInt32 fFlags; // Mutable so we can change it in IPrintLineToFile() internally
UInt32 fOrigFlags;
UInt32 fMaxNumLines;
std::string fCFilename; // used ONLY by GetFileName()
std::wstring fFilename;
char **fLines;
UInt32 *fColors;
hsMutex fMutex; // To make multithreaded-safe
FILE* fFileHandle;
UInt32 fSize;
bool fEncryptMe;
bool fForceLog;
plStatusLog *fNext, **fBack;
plStatusLog **fDisplayPointer; // Inside pfConsole
void IUnlink( void );
void ILink( plStatusLog **back );
bool IAddLine( const char *line, Int32 count, UInt32 color );
bool IPrintLineToFile( const char *line, UInt32 count );
void IParseFileName(wchar* file, wchar* fileNoExt, wchar** ext) const;
void IInit( void );
void IFini( void );
bool IReOpen( void );
plStatusLog( UInt8 numDisplayLines, const wchar *filename, UInt32 flags );
public:
static UInt32 fLoggingOff;
enum StatusFlagType
{
kFilledBackground = 0x00000001,
kAppendToLast = 0x00000002,
kDontWriteFile = 0x00000004,
kDeleteForMe = 0x00000008, // BE CAREFUL USING THIS!!
// kDeleteForMe instructs the statusLogMgr to delete
// this log itself when it destructs, which is at the
// very end of client shutdown (the manager is static).
// Because of this, it's safe to use this so long as you'll
// never reference it at the very end of shutdown (as an
// object is deleted by the resManager, for example, is
// okay because that's done in plClient::Shutdown(), not
// at the very end of app destruction). If you use this
// and your log is deleted before you, your pointer will
// NOT reflect this; it's up to you
kAlignToTop = 0x00000010,
kDebugOutput = 0x00000020, // Also write string to debug console
kTimestamp = 0x00000040, // Write a timestamp in Local time with each entry.
kStdout = 0x00000080, // Also write string to stdout
kTimeInSeconds = 0x00000100, // Write timestamp as seconds since epoch
kTimeAsDouble = 0x00000200, // Write timestamp as seconds.millis
kDontRotateLogs = 0x00000400, // Don't rename/renumber log fileName
kServerTimestamp = 0x00000800, // Timestamp each entry with the server's time
kRawTimeStamp = 0x00001000, // hsTimer::GetSeconds()
kThreadID = 0x00002000, // ID of current thread
kTimestampGMT = 0x00004000, // Write a timestamp in GMT with each entry.
kNonFlushedLog = 0x00008000, // Do not flush the log after each write
};
enum
{
kRed = 0xffff0000,
kGreen = 0xff00ff00,
kBlue = 0xff0000ff,
kYellow = 0xffffff00,
kWhite = 0xffffffff
};
enum
{
kMaxFileSize = 300000000, // 300 megs
};
~plStatusLog();
bool AddLine( const char *line, UInt32 color = kWhite );
/// printf-like functions
bool AddLineF( const char *format, ... );
bool AddLineF( UInt32 color, const char *format, ... );
bool AddLineV( const char *format, va_list arguments );
bool AddLineV( UInt32 color, const char *format, va_list arguments );
/// Static functions that you give a filename to and it searches for a log based on that
/// (or creates one if it isn't available)
static bool AddLineS( const char *filename, const char *format, ... );
static bool AddLineS( const char *filename, UInt32 color, const char *format, ... );
void Clear( void );
// Clear and open a new file.
void Bounce( UInt32 flags=0 );
const char* GetFileName() const {return fCFilename.c_str();}
const wchar* GetFileNameW() const {return fFilename.c_str();}
void SetForceLog(bool force) { fForceLog = force; }
};
//// Manager Class Definition ////////////////////////////////////////////////
class plStatusLogMgr
{
friend class plStatusLog;
private:
plStatusLogMgr();
static plStatusLogMgr fManager;
protected:
plStatusLog *fDisplays;
plStatusLog *fCurrDisplay;
plStatusLogDrawerStub *fDrawer;
double fLastLogChangeTime;
static wchar fBasePath[];
static const wchar *IGetBasePath( void ) { return fBasePath; }
void IEnsurePathExists( const wchar *dirName );
void IPathAppend( wchar *base, const wchar *extra, unsigned maxLen );
hsMutex fMutex; // To make multithreaded-safe
public:
enum
{
kDefaultNumLines = 40
};
~plStatusLogMgr();
static plStatusLogMgr &GetInstance( void );
void Draw( void );
plStatusLog *CreateStatusLog( UInt8 numDisplayLines, const char *filename, UInt32 flags = plStatusLog::kFilledBackground );
plStatusLog *CreateStatusLog( UInt8 numDisplayLines, const wchar *filename, UInt32 flags = plStatusLog::kFilledBackground );
void ToggleStatusLog( plStatusLog *logToDisplay );
void NextStatusLog( void );
void PrevStatusLog( void );
void SetCurrStatusLog( const char *logName );
void SetCurrStatusLog( const wchar *logName );
plStatusLog *FindLog( const char *filename, hsBool createIfNotFound = true );
plStatusLog *FindLog( const wchar *filename, hsBool createIfNotFound = true );
void SetDrawer( plStatusLogDrawerStub *drawer ) { fDrawer = drawer; }
void SetBasePath( const char * path );
void SetBasePath( const wchar * path );
void BounceLogs();
// Create a new folder and copy all log files into it (returns false on failure)
bool DumpLogs( const char *newFolderName );
bool DumpLogs( const wchar *newFolderName );
};
//// plStatusLogDrawerStub Class ////////////////////////////////////////////
// Sometimes, we want to be able to link to plStatusLog without having the
// pipeline-drawing functionality. So we do it this way: we define a single
// class of type plStatusLogDrawerStub. If it's allocated and we're given a
// pointer to it (by, say, the pipeline), then we use it to draw and all
// is happy. If not, we don't draw.
class plStatusLogDrawerStub
{
protected:
UInt32 IGetMaxNumLines( plStatusLog *log ) const { return log->fMaxNumLines; }
char **IGetLines( plStatusLog *log ) const { return log->fLines; }
const char *IGetFilename( plStatusLog *log ) const { return log->GetFileName(); }
const wchar *IGetFilenameW( plStatusLog *log ) const { return log->GetFileNameW(); }
UInt32 *IGetColors( plStatusLog *log ) const { return log->fColors; }
UInt32 IGetFlags( plStatusLog *log ) const { return log->fFlags; }
public:
virtual ~plStatusLogDrawerStub() {}
virtual void Draw(plStatusLog* curLog, plStatusLog* firstLog) {}
};
#endif //_plStatusLog_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
// //
// plStatusLog Header //
// //
//// Description /////////////////////////////////////////////////////////////
// //
// plStatusLogs are our new encapsulated method of outputting text logs //
// for status (or other things, like, say, errors). They do more than just //
// output to the file, though; they maintain a scrolling buffer that //
// can be drawn on to the screen so you can actually view what's being //
// outputted to the log file (you can disable file writing if you wish). //
// //
//////////////////////////////////////////////////////////////////////////////
#ifndef _plStatusLog_h
#define _plStatusLog_h
#include "hsTypes.h"
#include "hsThread.h"
#include <string>
class plPipeline;
//// plStatusLog Definition //////////////////////////////////////////////////
// Currently, they all display in the same location, so only one should
// really be visible at any given time.
class plStatusLogMgr;
class hsMutex;
class plStatusLogDrawerStub;
class plStatusLog
{
friend class plStatusLogMgr;
friend class plStatusLogDrawerStub;
friend class plStatusLogDrawer;
protected:
mutable UInt32 fFlags; // Mutable so we can change it in IPrintLineToFile() internally
UInt32 fOrigFlags;
UInt32 fMaxNumLines;
std::string fCFilename; // used ONLY by GetFileName()
std::wstring fFilename;
char **fLines;
UInt32 *fColors;
hsMutex fMutex; // To make multithreaded-safe
FILE* fFileHandle;
UInt32 fSize;
bool fEncryptMe;
bool fForceLog;
plStatusLog *fNext, **fBack;
plStatusLog **fDisplayPointer; // Inside pfConsole
void IUnlink( void );
void ILink( plStatusLog **back );
bool IAddLine( const char *line, Int32 count, UInt32 color );
bool IPrintLineToFile( const char *line, UInt32 count );
void IParseFileName(wchar* file, wchar* fileNoExt, wchar** ext) const;
void IInit( void );
void IFini( void );
bool IReOpen( void );
plStatusLog( UInt8 numDisplayLines, const wchar *filename, UInt32 flags );
public:
static UInt32 fLoggingOff;
enum StatusFlagType
{
kFilledBackground = 0x00000001,
kAppendToLast = 0x00000002,
kDontWriteFile = 0x00000004,
kDeleteForMe = 0x00000008, // BE CAREFUL USING THIS!!
// kDeleteForMe instructs the statusLogMgr to delete
// this log itself when it destructs, which is at the
// very end of client shutdown (the manager is static).
// Because of this, it's safe to use this so long as you'll
// never reference it at the very end of shutdown (as an
// object is deleted by the resManager, for example, is
// okay because that's done in plClient::Shutdown(), not
// at the very end of app destruction). If you use this
// and your log is deleted before you, your pointer will
// NOT reflect this; it's up to you
kAlignToTop = 0x00000010,
kDebugOutput = 0x00000020, // Also write string to debug console
kTimestamp = 0x00000040, // Write a timestamp in Local time with each entry.
kStdout = 0x00000080, // Also write string to stdout
kTimeInSeconds = 0x00000100, // Write timestamp as seconds since epoch
kTimeAsDouble = 0x00000200, // Write timestamp as seconds.millis
kDontRotateLogs = 0x00000400, // Don't rename/renumber log fileName
kServerTimestamp = 0x00000800, // Timestamp each entry with the server's time
kRawTimeStamp = 0x00001000, // hsTimer::GetSeconds()
kThreadID = 0x00002000, // ID of current thread
kTimestampGMT = 0x00004000, // Write a timestamp in GMT with each entry.
kNonFlushedLog = 0x00008000, // Do not flush the log after each write
};
enum
{
kRed = 0xffff0000,
kGreen = 0xff00ff00,
kBlue = 0xff0000ff,
kYellow = 0xffffff00,
kWhite = 0xffffffff
};
enum
{
kMaxFileSize = 300000000, // 300 megs
};
~plStatusLog();
bool AddLine( const char *line, UInt32 color = kWhite );
/// printf-like functions
bool AddLineF( const char *format, ... );
bool AddLineF( UInt32 color, const char *format, ... );
bool AddLineV( const char *format, va_list arguments );
bool AddLineV( UInt32 color, const char *format, va_list arguments );
/// Static functions that you give a filename to and it searches for a log based on that
/// (or creates one if it isn't available)
static bool AddLineS( const char *filename, const char *format, ... );
static bool AddLineS( const char *filename, UInt32 color, const char *format, ... );
void Clear( void );
// Clear and open a new file.
void Bounce( UInt32 flags=0 );
const char* GetFileName() const {return fCFilename.c_str();}
const wchar* GetFileNameW() const {return fFilename.c_str();}
void SetForceLog(bool force) { fForceLog = force; }
};
//// Manager Class Definition ////////////////////////////////////////////////
class plStatusLogMgr
{
friend class plStatusLog;
private:
plStatusLogMgr();
static plStatusLogMgr fManager;
protected:
plStatusLog *fDisplays;
plStatusLog *fCurrDisplay;
plStatusLogDrawerStub *fDrawer;
double fLastLogChangeTime;
static wchar fBasePath[];
static const wchar *IGetBasePath( void ) { return fBasePath; }
void IEnsurePathExists( const wchar *dirName );
void IPathAppend( wchar *base, const wchar *extra, unsigned maxLen );
hsMutex fMutex; // To make multithreaded-safe
public:
enum
{
kDefaultNumLines = 40
};
~plStatusLogMgr();
static plStatusLogMgr &GetInstance( void );
void Draw( void );
plStatusLog *CreateStatusLog( UInt8 numDisplayLines, const char *filename, UInt32 flags = plStatusLog::kFilledBackground );
plStatusLog *CreateStatusLog( UInt8 numDisplayLines, const wchar *filename, UInt32 flags = plStatusLog::kFilledBackground );
void ToggleStatusLog( plStatusLog *logToDisplay );
void NextStatusLog( void );
void PrevStatusLog( void );
void SetCurrStatusLog( const char *logName );
void SetCurrStatusLog( const wchar *logName );
plStatusLog *FindLog( const char *filename, hsBool createIfNotFound = true );
plStatusLog *FindLog( const wchar *filename, hsBool createIfNotFound = true );
void SetDrawer( plStatusLogDrawerStub *drawer ) { fDrawer = drawer; }
void SetBasePath( const char * path );
void SetBasePath( const wchar * path );
void BounceLogs();
// Create a new folder and copy all log files into it (returns false on failure)
bool DumpLogs( const char *newFolderName );
bool DumpLogs( const wchar *newFolderName );
};
//// plStatusLogDrawerStub Class ////////////////////////////////////////////
// Sometimes, we want to be able to link to plStatusLog without having the
// pipeline-drawing functionality. So we do it this way: we define a single
// class of type plStatusLogDrawerStub. If it's allocated and we're given a
// pointer to it (by, say, the pipeline), then we use it to draw and all
// is happy. If not, we don't draw.
class plStatusLogDrawerStub
{
protected:
UInt32 IGetMaxNumLines( plStatusLog *log ) const { return log->fMaxNumLines; }
char **IGetLines( plStatusLog *log ) const { return log->fLines; }
const char *IGetFilename( plStatusLog *log ) const { return log->GetFileName(); }
const wchar *IGetFilenameW( plStatusLog *log ) const { return log->GetFileNameW(); }
UInt32 *IGetColors( plStatusLog *log ) const { return log->fColors; }
UInt32 IGetFlags( plStatusLog *log ) const { return log->fFlags; }
public:
virtual ~plStatusLogDrawerStub() {}
virtual void Draw(plStatusLog* curLog, plStatusLog* firstLog) {}
};
#endif //_plStatusLog_h