PageRenderTime 25ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/src/zziplib/zzip/__debug.h

https://bitbucket.org/cabalistic/ogredeps/
C++ Header | 89 lines | 75 code | 12 blank | 2 comment | 1 complexity | a01f46b62d6f1199960b7de1fe7fc2e6 MD5 | raw file
 1#ifndef __ZZIP_INTERNAL_DEBUG_H
 2#define __ZZIP_INTERNAL_DEBUG_H
 3
 4#include <zzip/conf.h>
 5#include <zzip/__hints.h>
 6
 7/* perhaps want to show on syslog(3) ?? */
 8
 9#ifdef DEBUG
10#include <stdio.h>
11#define DBG1(X1) ZZIP_FOR1 { \
12        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
13	    ); } ZZIP_END1
14#define DBG2(X1,X2) ZZIP_FOR1 { \
15        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
16		,X2);} ZZIP_END1
17#define DBG3(X1,X2,X3) ZZIP_FOR1 { \
18        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
19		 ,X2,X3); } ZZIP_END1
20#define DBG4(X1,X2,X3,X4)   ZZIP_FOR1 { \
21        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
22		 ,X2,X3,X4); } ZZIP_END1
23#define DBG5(X1,X2,X3,X4,X5)   ZZIP_FOR1 { \
24        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
25		 ,X2,X3,X4,X5); } ZZIP_END1
26#define DBG6(X1,X2,X3,X4,X5,X6)   ZZIP_FOR1 { \
27        fprintf(stderr,"\n%s:%i:"X1"\n", ZZIP_FUNC,__LINE__ \
28		 ,X2,X3,X4,X5,X6); } ZZIP_END1
29
30#else
31#define DBG1(X1) {}
32#define DBG2(X1,X2) {}
33#define DBG3(X1,X2,X3) {}
34#define DBG4(X1,X2,X3,X4) {}
35#define DBG5(X1,X2,X3,X4,X5) {}
36#define DBG6(X1,X2,X3,X4,X5,X6) {}
37#endif
38
39#define HINT1(X1)                     DBG1("HINT: " X1) 
40#define HINT2(X1,X2)                  DBG2("HINT: " X1,X2) 
41#define HINT3(X1,X2,X3)               DBG3("HINT: " X1,X2,X3) 
42#define HINT4(X1,X2,X3,X4)            DBG4("HINT: " X1,X2,X3,X4) 
43#define HINT5(X1,X2,X3,X4,X5)         DBG5("HINT: " X1,X2,X3,X4,X5) 
44#define HINT6(X1,X2,X3,X4,X5,X6)      DBG6("HINT: " X1,X2,X3,X4,X5,X6) 
45
46#define NOTE1(X1)                     DBG1("NOTE: " X1) 
47#define NOTE2(X1,X2)                  DBG2("NOTE: " X1,X2) 
48#define NOTE3(X1,X2,X3)               DBG3("NOTE: " X1,X2,X3) 
49#define NOTE4(X1,X2,X3,X4)            DBG4("NOTE: " X1,X2,X3,X4) 
50#define NOTE5(X1,X2,X3,X4,X5)         DBG5("NOTE: " X1,X2,X3,X4,X5) 
51#define NOTE6(X1,X2,X3,X4,X5,X6)      DBG6("NOTE: " X1,X2,X3,X4,X5,X6) 
52
53#define WARN1(X1)                     DBG1("WARN: " X1) 
54#define WARN2(X1,X2)                  DBG2("WARN: " X1,X2) 
55#define WARN3(X1,X2,X3)               DBG3("WARN: " X1,X2,X3) 
56#define WARN4(X1,X2,X3,X4)            DBG4("WARN: " X1,X2,X3,X4) 
57#define WARN5(X1,X2,X3,X4,X5)         DBG5("WARN: " X1,X2,X3,X4,X5) 
58#define WARN6(X1,X2,X3,X4,X5,X6)      DBG6("WARN: " X1,X2,X3,X4,X5,X6) 
59
60#define FAIL1(X1)                     DBG1("FAIL: " X1) 
61#define FAIL2(X1,X2)                  DBG2("FAIL: " X1,X2) 
62#define FAIL3(X1,X2,X3)               DBG3("FAIL: " X1,X2,X3) 
63#define FAIL4(X1,X2,X3,X4)            DBG4("FAIL: " X1,X2,X3,X4) 
64#define FAIL5(X1,X2,X3,X4,X5)         DBG5("FAIL: " X1,X2,X3,X4,X5) 
65#define FAIL6(X1,X2,X3,X4,X5,X6)      DBG6("FAIL: " X1,X2,X3,X4,X5,X6) 
66
67
68
69#ifdef DEBUG
70_zzip_inline static void zzip_debug_xbuf (unsigned char* p, int l)
71    /* ZZIP_GNUC_UNUSED */
72{
73#   define q(a) ((a&0x7F)<32?32:(a&0x7F))
74    while (l > 0)
75    {
76        fprintf (stderr, 
77		 "%02x %02x %02x %02x  "
78		 "%02x %02x %02x %02x  "
79		 "%c%c%c%c %c%c%c%c\n",
80		 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
81		 q(p[0]), q(p[1]), q(p[2]), q(p[3]), 
82		 q(p[4]), q(p[5]), q(p[6]), q(p[7]));
83        p += 8; l -= 8;
84    }
85#   undef q
86}
87#endif
88
89#endif