[FEATURE] Implement kernel -> user connection
[platform/core/system/swap-manager.git] / daemon / debug.c
1 /*
2  *  DA manager
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Cherepanov Vitaliy <v.cherepanov@samsung.com>
9  * Nikita Kalyazin    <n.kalyazin@samsung.com>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * Contributors:
24  * - Samsung RnD Institute Russia
25  *
26  */
27
28
29 #include <ctype.h>
30
31 #include "debug.h"
32
33 #ifdef DEB_PRINTBUF
34 //TODO del it or move to debug section
35 void print_buf(char * buf, int len, const char *info)
36 {
37         int i,j;
38         char local_buf[3*17 + 2*16 + 1 + 8];
39         char * p1, * p2;
40
41         LOGI("BUFFER [%d] <%s>:\n", len, info);
42         for ( i = 0; i < len/16 + 1; i++)
43         {
44                 memset(local_buf, ' ', 5*16 + 8);
45
46                 sprintf(local_buf, "0x%04X: ", i);
47                 p1 = local_buf + 8;
48                 p2 = local_buf + 8 + 3*17;
49                 for ( j = 0; j < 16; j++)
50                         if (i*16+j < len )
51                         {
52                                 sprintf(p1, "%02X ",(unsigned char) *buf);
53                                 p1+=3;
54                                 if (isprint( *buf)){
55                                         sprintf(p2, "%c ",(int)*buf);
56                                 }else{
57                                         sprintf(p2,". ");
58                                 }
59                                 p2+=2;
60                                 buf++;
61                         }
62                 *p1 = ' ';
63                 *p2 = '\0';
64                 LOGI("%s\n",local_buf);
65         }
66 }
67 #else
68 inline void print_buf(char * buf, int len, const char *info) {
69         return;
70 }
71 #endif