Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/home/groups/n/no/noxwizard/cvs/src/debug.h

Go to the documentation of this file.
00001   /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
00002     || NoX-Wizard UO Server Emulator (NXW) [http://noxwizard.sourceforge.net]  ||
00003     ||                                                                         ||
00004     || This software is free software released under GPL2 license.             ||
00005     || You can find detailed license information in nox-wizard.cpp file.       ||
00006     ||                                                                         ||
00007     || For any question post to NoX-Wizard forums.                             ||
00008     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
00009 
00014 #ifndef DEBUG_H
00015 #define DEBUG_H
00016 
00017 #ifdef _MSC_VER
00018 #pragma warning ( push , 3 )
00019 #endif
00020 
00021 #include <cstdio>
00022 #include <string>
00023 #include <stdarg.h>
00024 #include <time.h>
00025 
00026 #ifdef WIN32
00027  #include <windows.h>
00028 #endif
00029 
00030 #ifdef  _MSC_VER        // when compiling with borland or mingw, can't use asm
00031  bool canBreakpoint();
00032  bool newIsDebuggerPresent();
00033  //defined as macro so bkp happens locally to the prob :]
00034  #define BREAKPOINT { if (canBreakpoint()) { __asm { int 3 } } }
00035 #else
00036  #define BREAKPOINT ;
00037 #endif
00038 
00039 
00040 //---------------------------------------------------------------------------
00041 //     Prototypes of functions
00042 //---------------------------------------------------------------------------
00043  
00044 extern "C" void __CDECL ConOut(char *txt, ...);         
00045 
00046 
00047 #define Xsend(sock,buff,length) \
00048         if( sock==INVALID || sock >=now) \
00049                 ConOut("INVALID socket %d was used in Xsend in %s:%d \n", sock, __FILE__, __LINE__ ); \
00050         else    \
00051                 Network->xSend(sock, buff, length) \
00052 
00053 #define CRASH_IF_INVALID_SOCK(sock) if (sock<0 || sock>=MAXCLIENT) chars[-1000000].x=0
00054 
00055 extern bool g_bExceptionCaught;
00056 
00057 
00058 
00059 #ifdef _MSC_VER
00060 #pragma warning ( pop )
00061 #endif
00062 
00063 
00064 //xan : for FUTURE parameter's validation
00065 #ifdef _DEBUG
00066 #define INVALIDATE assert(0);
00067 #else 
00068 #define INVALIDATE { nInvalidate = __LINE__; throw; }
00069 #endif
00070 
00071 #ifdef WIN32
00072 
00073 #define DBG_INRANGE(A,B,C) if ((A<B)||(A>=C)) INVALIDATE;
00074 #define DBG_WPTR(A,S) if ((A==NULL)||(IsBadWritePtr(A,S))) INVALIDATE;
00075 #define DBG_STR(S) if ((A==NULL)||(IsBadStringPtr(A,0xFFFFFF))) INVALIDATE;
00076 
00077 #else
00078 
00079 #define DBG_INRANGE(A,B,C) if ((A<B)||(A>=C)) INVALIDATE;
00080 #define DBG_WPTR(A,S) if ((A==NULL)) INVALIDATE;
00081 #define DBG_STR(S) if ((A==NULL)) INVALIDATE;
00082 
00083 #endif
00084 
00085 
00086 
00087 
00088 
00089 
00090 #endif
SourceForge.net Logo