home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
s-gikan2.maizuru-ct.ac.jp
/
s-gikan2.maizuru-ct.ac.jp.zip
/
s-gikan2.maizuru-ct.ac.jp
/
pub
/
source
/
magdb141su.lzh
/
MagaDbg.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-10-06
|
6KB
|
230 lines
/*
MagaDebug32 âfâoâbâOâcü[âï Ver1.41
âwâbâ_ü[âtâ@âCâï
üiébü^ébü{ü{ïñÆ╩üj
*/
#if !defined(___MAGADBGCLASS_H)
#define ___MAGADBGCLASS_H
/*
VisualC++ é╞ BolandC++ é╔æ╬ë₧
*/
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
#error This debug tool is much with VisualC++ and BorlandC++ only.
#endif
#if defined(__BORLANDC__) && defined(__MT__)
#define _MT
#endif
/*
║░─▐É╢ɼé≡├▐╩▐»╕▐╙░─▐é╔ï¡Éº VC++ Only
(Ver1.41 ê╚ì~é═ ReleaseÉΩùplib é╔é─è╔ÿa)
#if defined(_MSC_VER) && !defined(_DEBUG)
#error This condition requires that the RuntimeLibrary for debug version should be designated.
#endif
*/
#include <windows.h>
/* MagaDbg ╕╫╜û╝ (╥»╛░╝▐é≡Ä≤é»ÄµéΘ╠▀█╕▐╫╤) */
#if !defined(MAGADBGNAME)
#define MAGADBGNAME "MagaDbg"
#endif
/* ╒░╗▐Ägùp╠╫╕▐ (C/C++ïñùp)*/
#define DBG_NOHEADERDUMP 0x0001 /* └▐▌╠▀═»└▐░ö±ò\Ī */
#define DBG_OCTDUMP 0x0002 /* 8╩▐▓─é├é┬ */
#define DBG_NOADDRESSDUMP 0x0004 /* ▒─▐┌╜ö±ò\Ī */
#define DBG_NOCHRDUMP 0x0008 /* ╖¼╫╕└ö±ò\Ī */
#if defined(__cplusplus)
// Aliase of class name
#if defined(_DEBUG)
#if defined(_MT)
#if !defined(_DLL)
#define CMagaDbg CMagaDbg_MT
#define CMagaDbgFile CMagaDbgFile_MT
#define g_MagaDbgMapNumber g_MagaDbgMapNumber_MT
#else
#define CMagaDbg CMagaDbg_MD
#define CMagaDbgFile CMagaDbgFile_MD
#define g_MagaDbgMapNumber g_MagaDbgMapNumber_MD
#endif
#endif
#else // Release
#if defined(_MT)
#if !defined(_DLL)
#define CMagaDbg CMagaDbg_MTR
#define CMagaDbgFile CMagaDbgFile_MTR
#define g_MagaDbgMapNumber g_MagaDbgMapNumber_MTR
#else
#define CMagaDbg CMagaDbg_MDR
#define CMagaDbgFile CMagaDbgFile_MDR
#define g_MagaDbgMapNumber g_MagaDbgMapNumber_MDR
#endif
#else
#define CMagaDbg CMagaDbg_R
#define CMagaDbgFile CMagaDbgFile_R
#define g_MagaDbgMapNumber g_MagaDbgMapNumber_R
#endif
#endif
// ╒░╗▐Ägùp╠╫╕▐ (C++é╠é▌)
const BOOL CR = TRUE; // ò\Īîπëⁿìs
const BOOL CRNO = FALSE; // ò\Īîπö±ëⁿìs
enum dbgColor
{DBG_BLACK = 0, DBG_BLUE, DBG_GREEN, DBG_CYAN,
DBG_RED, DBG_MAGENTA, DBG_YELLOW, DBG_WHITE};
// ò\ĪÉF
//
// èεû{âfâoâbâOâNâëâXÉΘî╛
// ------------------------------
class CMagaDbg {
private:
char* m_lpszHead; // æùÉMé╠ôxé╔òté»éΘâüâbâZü[âWâwâbâ_
int m_iHeadLen; // é╗é╠ò╢ÄÜÆ╖
BOOL m_fSep; // öjèⁿé│éΩéΘé╞é½é╔ïµÉ╪éΦò╢ÄÜé≡ôⁿéΩéΘé⌐
int m_iColor; // ò\ĪÉF(intî^é┼ò█Ä¥)
DWORD m_nInterval; // ò\Īîπé╠âCâôâ^ü[âoâï
COPYDATASTRUCT m_cds; // æùÉMùpì\æóæ╠
LONG m_nMapNumber; // DebugMessage MappingSeq No.
HANDLE m_hDbgMap; // DebugMessage MemoryMappedFile Handle
LPSTR m_lpDbgMap; // DebugMessage Mapping Pointer
private:
void CMagaDbgInit(char*, BOOL, dbgColor, DWORD = 0);
protected:
void SetHeader(char*, CMagaDbg*);
int AddHeader(char**, char*);
HWND MagaDbgFind(void) {
return (FindWindow(MAGADBGNAME, NULL));
}
BOOL GetSeparator(void) {
return m_fSep;
}
DWORD GetInterval(void) {
return m_nInterval;
}
public:
CMagaDbg(void);
CMagaDbg(char*, BOOL = FALSE, dbgColor = DBG_BLACK, DWORD = 0);
CMagaDbg(char*, dbgColor);
CMagaDbg(char*, BOOL);
CMagaDbg(BOOL);
CMagaDbg(dbgColor);
CMagaDbg(BOOL, dbgColor);
virtual ~CMagaDbg();
public:
virtual void print(char*, BOOL = CR); // 127ò╢ÄÜê╚ôαé╠ò╢ÄÜù±é≡ò\Ī
void printf(char*, ...); // 127ò╢ÄÜê╚ôαé╠öCê╙ò╢ÄÜù±ò\Ī
void printStruct(LPRECT, char* = NULL); // éµé¡Ägéñì\æóæ╠âüâôâoé╠ò\Ī
void printStruct(LPSIZE, char* = NULL);
void printStruct(LPPOINT, char* = NULL);
void dump(LPVOID, UINT, DWORD = 0); // â_âôâvò\Ī
BOOL scanf(char*, char* = NULL); // öCê╙ò╢ÄÜù±ôⁿù═
void SetInterval(DWORD n) {
m_nInterval = n;
}
};
#define printRect(LPRECT) printStruct(LPRECT)
#define printSize(LPSIZE) printStruct(LPSIZE)
#define printPoint(LPPOINT) printStruct(LPPOINT)
// CMagaDbgFileùp âIâvâVâçâôÉ▌ÆΦì\æóæ╠
// ------------------------------
struct MAGADBGOPT {
char* lpszFilename; // âìâOâtâ@âCâïû╝
BOOL fOverwrite; // ÅπÅæ:TRUEüCÆ╟ë┴:FALSE
BOOL fDisplay; // ò\Īéα:TRUEüCâtâ@âCâïÅoù═é╠é▌:FALSE
char* lpHead; // ê╚ë║èεû{║▌╜─╫╕└é╞ô»é╢
BOOL fSeparator;
dbgColor eColor;
DWORD nInterval;
};
#define LPMAGADBGOPT MAGADBGOPT*
//
// öhÉ╢âfâoâbâOâNâëâXÉΘî╛
// ------------------------------
class CMagaDbgFile : public CMagaDbg {
private:
void CMagaDbgFileInit(LPMAGADBGOPT);
void ErrorMsg(char*, DWORD);
private:
HANDLE m_hFile; // LogFile Handle
BOOL m_fDisplay; // ò\Īéαìséñé⌐é╟éñé⌐
public:
CMagaDbgFile(LPMAGADBGOPT);
CMagaDbgFile(char*, BOOL = TRUE, BOOL = TRUE, char* = NULL, BOOL = FALSE, dbgColor = DBG_BLACK, DWORD = 0);
~CMagaDbgFile();
public:
void print(char*, BOOL = CR); // ╡░╩▐░╫▓─▐
};
// End of C++ only
#endif
/* Aliase of function name */
#if defined(_DEBUG)
#if defined(_MT)
#if !defined(_DLL)
#define Dbg_printf Dbg_printf_MT
#define Dbg_sep Dbg_sep_MT
#define Dbg_scanf Dbg_scanf_MT
#define Dbg_dump Dbg_dump_MT
#else
#define Dbg_printf Dbg_printf_MD
#define Dbg_sep Dbg_sep_MD
#define Dbg_scanf Dbg_scanf_MD
#define Dbg_dump Dbg_dump_MD
#endif
#endif
#else /* Release */
#if defined(_MT)
#if !defined(_DLL)
#define Dbg_printf Dbg_printf_MTR
#define Dbg_sep Dbg_sep_MTR
#define Dbg_scanf Dbg_scanf_MTR
#define Dbg_dump Dbg_dump_MTR
#else
#define Dbg_printf Dbg_printf_MDR
#define Dbg_sep Dbg_sep_MDR
#define Dbg_scanf Dbg_scanf_MDR
#define Dbg_dump Dbg_dump_MDR
#endif
#else
#define Dbg_printf Dbg_printf_R
#define Dbg_sep Dbg_sep_R
#define Dbg_scanf Dbg_scanf_R
#define Dbg_dump Dbg_dump_R
#endif
#endif
#if defined(__cplusplus)
extern "C" {
#endif
void Dbg_printf(char *, ...);
void Dbg_sep(void);
BOOL Dbg_scanf(char *, char *);
void Dbg_dump(void *, UINT, DWORD);
#if defined(__cplusplus)
}
#endif
#endif