[6a7162]: jprdebug.h  Maximize  Restore  History

Download this file

76 lines (63 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Copyright (c) 2003-2008 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License 2.0 terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
// jprdebug.h
//-----------------------------------------------------------------------------
#if !defined(jprdebug_h)
#define jprdebug_h
#if defined(JPRDEBUG)
#define DBGMSG(x) ::OutputDebugString(x)
inline void
DBGDUMP(const char* mem, size_t len)
{
const int wrapsize = 20;
char hexbuf[3];
int wrap = 0;
char ascbuf[wrapsize+1];
size_t ix;
DBGMSG("* DEBUGDUMP BEGIN *\n");
for (ix = 0; ix < len; ix++) {
_stprintf(hexbuf, "%02.2X", mem[ix]);
DBGMSG(hexbuf);
if (ix % 2) DBGMSG(" ");
if (mem[ix] != 0)
ascbuf[wrap] = mem[ix];
else
ascbuf[wrap] = '.';
wrap++;
if (wrap == wrapsize) {
ascbuf[wrap] = 0;
DBGMSG(" *");
DBGMSG(ascbuf);
DBGMSG("*\n");
wrap = 0;
}
}
if (wrap == 0) {
DBGMSG("* DEBUGDUMP END *\n");
return;
}
for (ix = wrap; ix < wrapsize; ix++) {
DBGMSG(" ");
if (ix % 2) DBGMSG(" ");
ascbuf[ix]=' ';
}
ascbuf[wrapsize]=0;
DBGMSG(" *");
DBGMSG(ascbuf);
DBGMSG("*\n");
DBGMSG("* DEBUGDUMP END *\n");
}
#else
# define DBGMSG(x)
# define DEBUGDUMP(mem, len)
#endif
#endif // jprdebug_h
//-----------------------------------------------------------------------------
// Local variables:
// mode: c++
// End:

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks