#ifndef DEBUG_H
#define DEBUG_H

/*
** $PROJECT: C debugging macros
**
** $VER: debug.h 1.1 (02.09.95)
**
** by
**
** Stefan Ruppert , Windthorststrasse 5 , 65439 Floersheim , GERMANY
**
** (C) Copyright 1994,1995
** All Rights Reserved !
**
** $HISTORY:
**
** 02.09.95 : 001.001 : added assert like macro DA()
** 31.03.94 : 000.001 : initial
*/

#ifdef __cplusplus
extern "C" {
#endif

#define bug      KPrintF

#ifdef DEBUG

#ifndef PROJECTNAME
#define PROJECTNAME
#endif

extern void KPrintF(char *fmt,...);

#define D(x)     x
#define DBLINE    bug(PROJECTNAME __FILE__ "(%4ld):" __FUNC__ "() :",__LINE__)
#define DB(x)   { DBLINE; \
						bug x; \
					 }

#define DTL(x)  { struct TagItem *tstate = x; \
						struct TagItem *tag; \
						bug(__FILE__ "(%4ld):" __FUNC__ "() TagList :\n",__LINE__); \
						while((tag = NextTagItem(&tstate))) \
						  bug("{0x%08lx,0x%08lx}\n",tag->ti_Tag,tag->ti_Data); \
					 }
#define DDL(x)  { struct Node *node; \
						bug(__FILE__ "(%4ld):" __FUNC__ "() ExecList :\n",__LINE__); \
						for(node = (x)->lh_Head; node->ln_Succ != NULL; node = node->ln_Succ) \
							bug("%lx : %s\n",node,node->ln_Name); \
					 }

/* assert like macro */
#define DA(x,expr)   { if(!(expr)) { DBLINE; bug("Fault: "); bug x; } }

#define DELAY(x)     Delay(x)

#define ENTERING  bug("entering " __FUNC__ "()\n")
#define LEAVING   bug("leaving " __FUNC__ "()\n")

#else

#define D(x)
#define DB(x)
#define DA(x,expr)
#define DELAY(x)
#define DTL(x)
#define DDL(x)
#define ENTERING
#define LEAVING

#endif

#ifdef __cplusplus
};
#endif

#endif   /* DEBUG_H */

