#ifndef _DEBUG_H #define _DEBUG_H #include "define.h" #include "define_platform.h" //FOPEN #define DEBUG_FUNCTIONSTART 1 //indent++ in file output debug #define DEBUG_BLOCKSTART 2 //indent++ in file output debug #define DEBUG_LINE 4 //no indent, \n\r appended #define DEBUG_CHECK 8 //no indent, ... appended, no \n\r (for checking ...ok\n\r) #define DEBUG_RESULT 16 //no indent, \n\r appended #define DEBUG_BLOCKEND 32 //indent-- in file output debug #define DEBUG_FUNCTIONEND 64 //indent++ in file output debug #define DEBUG_LINE_QUALIFIED 128 //surround string by {} so that the length is evident #define DEBUG_ERROR 256 //error status #define DEBUG_SIZE 100*1024 #ifdef _DEBUG //debug system activated #define DEBUGPRINT0(format, type) DebugPrint(format, type) #define DEBUGPRINT(format, type, ...) {char *debug9 = (char*)malloc(DEBUG_SIZE);_SNPRINTF(debug9, DEBUG_SIZE, format, __VA_ARGS__);DebugPrint(debug9, type);free(debug9);} #define DEBUGINIT DebugInit() #define DEBUGFINALISE DebugFinalise() #define DEBUGERROR0(format) DebugPrint(format, DEBUG_ERROR) #define DEBUGERROR(format, ...) {char *debug9 = (char*)malloc(DEBUG_SIZE);_SNPRINTF(debug9, DEBUG_SIZE, format, __VA_ARGS__);DebugPrint(debug9, DEBUG_ERROR);free(debug9);} #define MSG(format, ...) {char *debug9 = (char*)malloc(DEBUG_SIZE);_SNPRINTF(debug9, DEBUG_SIZE, format, __VA_ARGS__);DebugPrint(debug9, DEBUG_LINE);cout << debug9 << "\n";free(debug9);} #define MSG0(format) {DebugPrint(format, DEBUG_LINE);cout << format << "\n";} #define MSG1(format) {DebugPrint(format, DEBUG_LINE);cout << format;} #define PROGRESS {cout << "."; fflush(stdout);} #define FINISHPROGRESS cout << "\n" #define DEBUG_RESULT_OK DEBUGPRINT("%s", DEBUG_RESULT, "ok") #define DEBUG_RESULT_FAIL DEBUGPRINT("%s", DEBUG_RESULT, "failed") bool DebugPrint(const char *sMessage, const int iType); bool DebugInit(); bool DebugFinalise(); #else //Release system #define DEBUGPRINT0(sMessage, iType) 000 #define DEBUGPRINT(sMessage, iType, ...) 000 #define DEBUGINIT 000 #define DEBUGFINALISE 000 #define DEBUGERROR0(format) {cout << format << "\n"; fflush(stdout);} #define DEBUGERROR(format, ...) {char *debug9 = (char*)malloc(DEBUG_SIZE);_SNPRINTF(debug9, DEBUG_SIZE, format, __VA_ARGS__);cout << debug9 << "\n";free(debug9); fflush(stdout);} #define MSG(format, ...) {char *debug9 = (char*)malloc(DEBUG_SIZE);_SNPRINTF(debug9, DEBUG_SIZE, format, __VA_ARGS__);cout << debug9 << "\n";free(debug9); fflush(stdout);} #define MSG0(format) {cout << format << "\n"; fflush(stdout);} #define MSG1(format) {cout << format; fflush(stdout);} #define PROGRESS {cout << "."; fflush(stdout);} #define FINISHPROGRESS {cout << "\n"; fflush(stdout);} #define DEBUG_RESULT_OK 000 #define DEBUG_RESULT_FAIL 000 #endif #endif