|
18 | 18 | #include "parser_impl.h" |
19 | 19 | #include "zxformat.h" |
20 | 20 |
|
21 | | -// void print_buffer(bytes_t *buffer, const char *title) { |
22 | | -// #if defined(LEDGER_SPECIFIC) |
23 | | -// ZEMU_LOGF(50, "%s\n", title); |
24 | | -// char print[1000] = {0}; |
25 | | -// array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
26 | | -// ZEMU_LOGF(1000, "%s\n", print); |
27 | | -// #else |
28 | | -// printf("%s %d: ", title, buffer->len); |
29 | | -// for (uint16_t i = 0; i < buffer->len; i++) { |
30 | | -// printf("%02x", buffer->ptr[i]); |
31 | | -// } |
32 | | -// printf("\n"); |
33 | | -// #endif |
34 | | -// } |
| 21 | +void print_buffer(bytes_t *buffer, const char *title) { |
| 22 | +#if defined(LEDGER_SPECIFIC) |
| 23 | + char print[1000] = {0}; |
| 24 | + MEMCPY(print, title, strlen(title)); |
| 25 | + ZEMU_LOGF(50, "%s\n", print); |
| 26 | + MEMZERO(print, sizeof(print)); |
| 27 | + array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
| 28 | + ZEMU_LOGF(1000, "%s\n", print); |
| 29 | +#else |
| 30 | + printf("%s %d: ", title, buffer->len); |
| 31 | + for (uint16_t i = 0; i < buffer->len; i++) { |
| 32 | + printf("%02x", buffer->ptr[i]); |
| 33 | + } |
| 34 | + printf("\n"); |
| 35 | +#endif |
| 36 | +} |
35 | 37 |
|
36 | | -// void print_buffer_u8(bytes_t *buffer, const char *title) { |
37 | | -// #if defined(LEDGER_SPECIFIC) |
38 | | -// ZEMU_LOGF(50, "%s\n", title); |
39 | | -// char print[1000] = {0}; |
40 | | -// array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
41 | | -// ZEMU_LOGF(1000, "%s\n", print); |
42 | | -// #else |
43 | | -// printf("%s %d: [", title, buffer->len); |
44 | | -// for (uint16_t i = 0; i < buffer->len; i++) { |
45 | | -// printf("%d, ", buffer->ptr[i]); |
46 | | -// } |
47 | | -// printf("]\n"); |
48 | | -// #endif |
49 | | -// } |
| 38 | +void print_buffer_u8(bytes_t *buffer, const char *title) { |
| 39 | +#if defined(LEDGER_SPECIFIC) |
| 40 | + char print[1000] = {0}; |
| 41 | + MEMCPY(print, title, strlen(title)); |
| 42 | + ZEMU_LOGF(50, "%s\n", print); |
| 43 | + MEMZERO(print, sizeof(print)); |
| 44 | + array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
| 45 | + ZEMU_LOGF(1000, "%s\n", print); |
| 46 | +#else |
| 47 | + printf("%s %d: [", title, buffer->len); |
| 48 | + for (uint16_t i = 0; i < buffer->len; i++) { |
| 49 | + printf("%d, ", buffer->ptr[i]); |
| 50 | + } |
| 51 | + printf("]\n"); |
| 52 | +#endif |
| 53 | +} |
50 | 54 |
|
51 | | -// void print_buffer_str(bytes_t *buffer, const char *title) { |
52 | | -// #if defined(LEDGER_SPECIFIC) |
53 | | -// ZEMU_LOGF(50, "%s\n", title); |
54 | | -// char print[1000] = {0}; |
55 | | -// array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
56 | | -// ZEMU_LOGF(1000, "%s\n", print); |
57 | | -// #else |
58 | | -// uint8_t buff[1000] = {0}; |
59 | | -// memcpy(buff, buffer->ptr, buffer->len); |
60 | | -// printf("%s %s\n", title, buff); |
61 | | -// #endif |
62 | | -// } |
| 55 | +void print_buffer_str(bytes_t *buffer, const char *title) { |
| 56 | +#if defined(LEDGER_SPECIFIC) |
| 57 | + char print[1000] = {0}; |
| 58 | + MEMCPY(print, title, strlen(title)); |
| 59 | + ZEMU_LOGF(50, "%s\n", print); |
| 60 | + MEMZERO(print, sizeof(print)); |
| 61 | + array_to_hexstr(print, sizeof(print), buffer->ptr, buffer->len); |
| 62 | + ZEMU_LOGF(1000, "%s\n", print); |
| 63 | +#else |
| 64 | + uint8_t buff[1000] = {0}; |
| 65 | + memcpy(buff, buffer->ptr, buffer->len); |
| 66 | + printf("%s %s\n", title, buff); |
| 67 | +#endif |
| 68 | +} |
63 | 69 |
|
64 | 70 | void print_string(const char *str) { |
65 | 71 | #if defined(LEDGER_SPECIFIC) |
66 | 72 | char print[1000] = {0}; |
67 | 73 | MEMCPY(print, str, strlen(str)); |
68 | | - ZEMU_LOGF(100, "%s\n", str); |
| 74 | + ZEMU_LOGF(100, "%s\n", print); |
69 | 75 | #else |
70 | 76 | printf("%s\n", str); |
71 | 77 | #endif |
72 | 78 | } |
73 | 79 |
|
74 | | -// void print_string_title(const char *str, const char *title) { |
75 | | -// #if defined(LEDGER_SPECIFIC) |
76 | | -// ZEMU_LOGF(100, "%s: %s\n", title, str); |
77 | | -// #else |
78 | | -// printf("%s: %s\n", title, str); |
79 | | -// #endif |
80 | | -// } |
| 80 | +void print_string_title(const char *str, const char *title) { |
| 81 | +#if defined(LEDGER_SPECIFIC) |
| 82 | + char print[1000] = {0}; |
| 83 | + MEMCPY(print, title, strlen(title)); |
| 84 | + MEMCPY(print + strlen(title), str, strlen(str)); |
| 85 | + ZEMU_LOGF(100, "%s\n", print); |
| 86 | +#else |
| 87 | + printf("%s: %s\n", title, str); |
| 88 | +#endif |
| 89 | +} |
81 | 90 |
|
82 | | -// void print_u8(const char *str, uint8_t val) { |
83 | | -// #if defined(LEDGER_SPECIFIC) |
84 | | -// ZEMU_LOGF(100, "%s: %d\n", str, val); |
85 | | -// #else |
86 | | -// printf("%s: %d\n", str, val); |
87 | | -// #endif |
88 | | -// } |
| 91 | +void print_u8(const char *str, uint8_t val) { |
| 92 | +#if defined(LEDGER_SPECIFIC) |
| 93 | + char print[1000] = {0}; |
| 94 | + MEMCPY(print, str, strlen(str)); |
| 95 | + MEMCPY(print + strlen(str), ": ", 2); |
| 96 | + MEMCPY(print + strlen(str) + 2, &val, sizeof(val)); |
| 97 | + ZEMU_LOGF(100, "%s\n", print); |
| 98 | +#else |
| 99 | + printf("%s: %d\n", str, val); |
| 100 | +#endif |
| 101 | +} |
89 | 102 |
|
90 | | -// void print_u16(const char *str, uint16_t val) { |
91 | | -// #if defined(LEDGER_SPECIFIC) |
92 | | -// ZEMU_LOGF(100, "%s: %d\n", str, val); |
93 | | -// #else |
94 | | -// printf("%s: %d\n", str, val); |
95 | | -// #endif |
96 | | -// } |
| 103 | +void print_u16(const char *str, uint16_t val) { |
| 104 | +#if defined(LEDGER_SPECIFIC) |
| 105 | + char print[1000] = {0}; |
| 106 | + MEMCPY(print, str, strlen(str)); |
| 107 | + MEMCPY(print + strlen(str), ": ", 2); |
| 108 | + MEMCPY(print + strlen(str) + 2, &val, sizeof(val)); |
| 109 | + ZEMU_LOGF(100, "%s\n", print); |
| 110 | +#else |
| 111 | + printf("%s: %d\n", str, val); |
| 112 | +#endif |
| 113 | +} |
97 | 114 |
|
98 | | -// void print_u32(const char *str, uint32_t val) { |
99 | | -// #if defined(LEDGER_SPECIFIC) |
100 | | -// ZEMU_LOGF(100, "%s: %d\n", str, val); |
101 | | -// #else |
102 | | -// printf("%s: %u\n", str, val); |
103 | | -// #endif |
104 | | -// } |
| 115 | +void print_u32(const char *str, uint32_t val) { |
| 116 | +#if defined(LEDGER_SPECIFIC) |
| 117 | + char print[1000] = {0}; |
| 118 | + MEMCPY(print, str, strlen(str)); |
| 119 | + MEMCPY(print + strlen(str), ": ", 2); |
| 120 | + MEMCPY(print + strlen(str) + 2, &val, sizeof(val)); |
| 121 | + ZEMU_LOGF(100, "%s\n", print); |
| 122 | +#else |
| 123 | + printf("%s: %u\n", str, val); |
| 124 | +#endif |
| 125 | +} |
105 | 126 |
|
106 | | -// void print_u64(const char *str, uint64_t val) { |
107 | | -// #if defined(LEDGER_SPECIFIC) |
108 | | -// ZEMU_LOGF(100, "%s: %lu\n", str, val); |
109 | | -// #else |
110 | | -// printf("%s: %llu\n", str, val); |
111 | | -// #endif |
112 | | -// } |
| 127 | +void print_u64(const char *str, uint64_t val) { |
| 128 | +#if defined(LEDGER_SPECIFIC) |
| 129 | + char print[1000] = {0}; |
| 130 | + MEMCPY(print, str, strlen(str)); |
| 131 | + MEMCPY(print + strlen(str), ": ", 2); |
| 132 | + MEMCPY(print + strlen(str) + 2, &val, sizeof(val)); |
| 133 | + ZEMU_LOGF(100, "%s\n", print); |
| 134 | +#else |
| 135 | + printf("%s: %llu\n", str, val); |
| 136 | +#endif |
| 137 | +} |
113 | 138 |
|
114 | | -// void print_u64_hex(const char *str, uint64_t val) { |
115 | | -// #if defined(LEDGER_SPECIFIC) |
116 | | -// ZEMU_LOGF(100, "%s: %lu\n", str, val); |
117 | | -// #else |
118 | | -// printf("%s: 0x%llx\n", str, val); |
119 | | -// #endif |
120 | | -// } |
| 139 | +void print_u64_hex(const char *str, uint64_t val) { |
| 140 | +#if defined(LEDGER_SPECIFIC) |
| 141 | + char print[1000] = {0}; |
| 142 | + MEMCPY(print, str, strlen(str)); |
| 143 | + MEMCPY(print + strlen(str), ": ", 2); |
| 144 | + MEMCPY(print + strlen(str) + 2, &val, sizeof(val)); |
| 145 | + ZEMU_LOGF(100, "%s\n", print); |
| 146 | +#else |
| 147 | + printf("%s: 0x%llx\n", str, val); |
| 148 | +#endif |
| 149 | +} |
0 commit comments