#ifndef _COM_DEBUG_H_
#define _COM_DEBUG_H_
#ifdef __cplusplus
extern "C" {
#endif
#define COM_DEBUG 0
#if COM_DEBUG
#include <stdio.h>
#define ddprintf(x) printf x
#else
#define ddprintf(x)
#endif
#define COM_SCAN_DEBUG 0
#if COM_SCAN_DEBUG
#define scprintf(x) printf x
#else
#define scprintf(x)
#endif
#define LEVEL2_DEBUG 0
#if LEVEL2_DEBUG
#include <stdio.h>
#define l2printf(x) printf x
#else
#define l2printf(x)
#endif
#define COM_LA_DEBUG 0
#define COM_LA_PRINTF 0
#if COM_LA_PRINTF
#define laprintf(x) printf x
#else
#define laprintf(x)
#endif
#if COM_DEBUG
#define COM_STATS 0
#else
#define COM_STATS 0
#endif
#if COM_STATS
typedef struct {
unsigned level1blocks;
unsigned plaintextBytes;
unsigned ciphertextBytes;
unsigned oneByteFrags; unsigned twoByteFrags; unsigned level2oneByteFrags; unsigned level2twoByteFrags; unsigned level2byteCode; unsigned level2cipherText; unsigned level2blocks; unsigned level2jmatch; } comStats;
extern comStats _comStats;
#define incrComStat(stat, num) _comStats.stat += num;
#define incr1byteFrags(recursLevel) { \
if(recursLevel == 1) { \
incrComStat(level2oneByteFrags, 1); \
} \
else { \
incrComStat(oneByteFrags, 1); \
} \
}
#define incr2byteFrags(recursLevel) { \
if(recursLevel == 1) { \
incrComStat(level2twoByteFrags, 1); \
} \
else { \
incrComStat(twoByteFrags, 1); \
} \
}
extern void resetComStats();
extern void getComStats(comStats *stats);
#else
#define incrComStat(stat, num)
#define incr1byteFrags(recursLevel)
#define incr2byteFrags(recursLevel)
#endif
#if COM_DEBUG
#define COM_PROFILE 0
#else
#define COM_PROFILE 0
#endif
#if COM_PROFILE
#include <kern/time_stamp.h>
extern unsigned comProfEnable;
typedef unsigned comprof_t;
extern comprof_t cmcTotal;
extern comprof_t cmcQueSearch;
extern comprof_t cmcQueMatchMove;
extern comprof_t cmcQueMissMove;
extern comprof_t cmcPerWordOhead;
extern comprof_t cmcLevel2;
#define COMPROF_LOCALS \
struct tsval _profStartTime; \
struct tsval _profEndTime;
#define COMPROF_START \
if(comProfEnable) { \
kern_timestamp(&_profStartTime); \
}
#define COMPROF_END(accum) \
if(comProfEnable) { \
kern_timestamp(&_profEndTime); \
accum += (_profEndTime.low_val - _profStartTime.low_val); \
}
#else
#define COMPROF_LOCALS
#define COMPROF_START
#define COMPROF_END(accum)
#endif
#if COM_DEBUG
#define COM_PARAM_ENABLE 1
#else
#define COM_PARAM_ENABLE 0
#endif
#if COM_PARAM_ENABLE
extern unsigned getF1(comcryptObj cobj);
extern void setF1(comcryptObj cobj, unsigned f1);
extern unsigned getF2(comcryptObj cobj);
extern void setF2(comcryptObj cobj, unsigned f2);
extern unsigned getJmatchThresh(comcryptObj cobj);
extern void setJmatchThresh(comcryptObj cobj, unsigned jmatchThresh);
extern unsigned getMinByteCode(comcryptObj cobj);
extern void setMinByteCode(comcryptObj cobj, unsigned minByteCode);
#endif
#ifdef __cplusplus
}
#endif
#endif