#ifdef WIN32

#ifndef false
#define false 0
#define true 1
#endif

int trace_main(int x, int (*myprint)(int myx, const char *format, ...), HANDLE xhThread, CONTEXT *xc );
int win32_set_nominidump(int t);

int trace_msg(int x, const char *format, ...);
DWORD Filter( EXCEPTION_POINTERS *ep );
void filter_cleanup(void);
/* Disabled by chrisp, trying to find a bug and it never seems to catch the stack with
this code enabled 
*/
// Chrisp trying enabling this again to see if it causes problems
//#define DISABLE_STACK 1

#ifdef DISABLE_STACK
#define WIN32_EXCEPTIONFILTER_START
#define WIN32_EXCEPTIONFILTER_END
#else
#define WIN32_EXCEPTIONFILTER_START	__try {

#define WIN32_EXCEPTIONFILTER_END	}								\
__except( Filter( GetExceptionInformation() ) )						\
{ 									/*maybe try a tidy shutdown*/	\
	filter_cleanup(); \
	printf("Exception caught - not taking any further action.\n");	\
	emsg("Exception caught - not taking any further action.\n");	\
	exit(1);	\
}
#endif


// Individual threads must be intrumented for stack dump on unhandled exceptions
// currently instrumented: main thread (mail_main), smtp thread (smtp_link), pop thread (pcmd_link), imap thread(imap_link), 
//							ppd_link, smgr_main  

/* Code to use exception trappping in thread

#include "mail.h"		 (to #include "win32bt.h")

#ifdef WIN32
	WIN32_EXCEPTIONFILTER_START
#endif

#ifdef WIN32
	WIN32_EXCEPTIONFILTER_END
#endif

*/
#else /* and here we define them as nothing for non windows*/
#define WIN32_EXCEPTIONFILTER_START
#define WIN32_EXCEPTIONFILTER_END
        
#endif /* WIN32 */
