Debian Codegraph @

modules/lsp-runtime-lib/src/main/protocol/osc/debug.cpp

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 29 мая 2019 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #define __LSP_PROTOCOL_OSC_IMPL
23
24 #include <lsp-plug.in/common/endian.h>
25 #include <lsp-plug.in/common/debug.h>
26 #include <lsp-plug.in/protocol/osc.h>
27 #include <lsp-plug.in/stdlib/string.h>
28
29 #include <stdint.h>
30 #include <stdlib.h>
31 #include <stdarg.h>
32
33 namespace lsp
34 {
35 namespace osc
36 {
37 #ifdef LSP_TRACE
38 void dump_packet(const packet_t *packet)
39 {
40 if (packet != NULL)
41 dump_packet(packet->data, packet->size);
42 }
43
44 void dump_packet(const void *data, size_t size)
45 {
46 const uint8_t *ddump = reinterpret_cast<const uint8_t *>(data);
47 lsp_trace("OSC packet dump (%d bytes):", int(size));
48
49 for (size_t offset=0; offset < size; offset += 16)
50 {
51 // Print HEX dump
52 lsp_nprintf("%08x: ", int(offset));
53 for (size_t i=0; i<0x10; ++i)
54 {
55 if ((offset + i) < size)
56 lsp_nprintf("%02x ", int(ddump[i]));
57 else
58 lsp_nprintf(" ");
59 }
60 lsp_nprintf(" ");
61
62 // Print character dump
63 for (size_t i=0; i<0x10; ++i)
64 {
65 if ((offset + i) < size)
66 {
67 uint8_t c = ddump[i];
68 if ((c < 0x20) || (c >= 0x80))
69 c = '.';
70 lsp_nprintf("%c", c);
71 }
72 else
73 lsp_nprintf(" ");
74 }
75 lsp_printf("");
76
77 // Move pointer
78 ddump += 0x10;
79 }
80 }
81 #endif /* LSP_TRACE */
82 }
83 }
84
85
86
87
88
89
90
91