/src/bluez/gobex/gobex-debug.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2 | | /* |
3 | | * OBEX library with GLib integration |
4 | | * |
5 | | * Copyright (C) 2011 Intel Corporation. All rights reserved. |
6 | | * |
7 | | */ |
8 | | |
9 | | #ifndef __GOBEX_DEBUG_H |
10 | | #define __GOBEX_DEBUG_H |
11 | | |
12 | | #include <glib.h> |
13 | | #include <stdio.h> |
14 | | #include <ctype.h> |
15 | | |
16 | 0 | #define G_OBEX_DEBUG_NONE 1 |
17 | | #define G_OBEX_DEBUG_ERROR (1 << 1) |
18 | | #define G_OBEX_DEBUG_COMMAND (1 << 2) |
19 | | #define G_OBEX_DEBUG_TRANSFER (1 << 3) |
20 | | #define G_OBEX_DEBUG_HEADER (1 << 4) |
21 | | #define G_OBEX_DEBUG_PACKET (1 << 5) |
22 | 0 | #define G_OBEX_DEBUG_DATA (1 << 6) |
23 | | #define G_OBEX_DEBUG_APPARAM (1 << 7) |
24 | | |
25 | | extern guint gobex_debug; |
26 | | |
27 | | #define g_obex_debug(level, format, ...) \ |
28 | 11.5k | if (gobex_debug & level) \ |
29 | 11.5k | g_log("gobex", G_LOG_LEVEL_DEBUG, "%s:%s() " format, __FILE__, \ |
30 | 0 | __func__, ## __VA_ARGS__) |
31 | | |
32 | | static inline void g_obex_dump(guint level, const char *prefix, |
33 | | const void *buf, gsize len) |
34 | 0 | { |
35 | 0 | const guint8 *data = buf; |
36 | 0 | int n = 0; |
37 | |
|
38 | 0 | if (!(gobex_debug & level)) |
39 | 0 | return; |
40 | | |
41 | 0 | while (len > 0) { |
42 | 0 | int i, size; |
43 | |
|
44 | 0 | printf("%s %04x:", prefix, n); |
45 | |
|
46 | 0 | size = len > 16 ? 16 : len; |
47 | |
|
48 | 0 | for (i = 0; i < size; i++) |
49 | 0 | printf("%02x%s", data[i], (i + 1) % 8 ? " " : " "); |
50 | |
|
51 | 0 | for (; i < 16; i++) |
52 | 0 | printf(" %s", (i + 1) % 8 ? " " : " "); |
53 | |
|
54 | 0 | for (i = 0; i < size; i++) |
55 | 0 | printf("%1c", isprint(data[i]) ? data[i] : '.'); |
56 | |
|
57 | 0 | printf("\n"); |
58 | |
|
59 | 0 | data += size; |
60 | 0 | len -= size; |
61 | 0 | n += size; |
62 | 0 | } |
63 | 0 | } Unexecuted instantiation: gobex-apparam.c:g_obex_dump Unexecuted instantiation: gobex-header.c:g_obex_dump Unexecuted instantiation: gobex-packet.c:g_obex_dump Unexecuted instantiation: gobex-transfer.c:g_obex_dump Unexecuted instantiation: gobex.c:g_obex_dump |
64 | | |
65 | | #endif /* __GOBEX_DEBUG_H */ |