5f48c8d2bac1e817b754d109dc8b565d7db8c77f
[platform/core/system/swap-manager.git] / daemon / debug.c
1
2 #include <ctype.h>
3
4 #include "debug.h"
5
6 #ifdef DEB_PRINTBUF
7 //TODO del it or move to debug section
8 void printBuf (char * buf, int len)
9 {
10         int i,j;
11         char local_buf[3*16 + 2*16 + 1 + 8];
12         char * p1, * p2;
13
14         LOGI("BUFFER [%d]:\n", len);
15         for ( i = 0; i < len/16 + 1; i++)
16         {
17                 memset(local_buf, ' ', 5*16 + 8);
18
19                 sprintf(local_buf, "0x%04X: ", i);
20                 p1 = local_buf + 8;
21                 p2 = local_buf + 8 + 3*17;
22                 for ( j = 0; j < 16; j++)
23                         if (i*16+j < len )
24                         {
25                                 sprintf(p1, "%02X ",(unsigned char) *buf);
26                                 p1+=3;
27                                 if (isprint( *buf)){
28                                         sprintf(p2, "%c ",(int)*buf);
29                                 }else{
30                                         sprintf(p2,". ");
31                                 }
32                                 p2+=2;
33                                 buf++;
34                         }
35                 *p1 = ' ';
36                 *p2 = '\0';
37                 LOGI("%s\n",local_buf);
38         }
39 }
40 #endif