117 fprintf(fp,
" (null)\n");
120 for (uint32_t u = 0; u < buflen; u += 16) {
121 fprintf(fp ,
" %04X ", u);
122 for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
123 fprintf(fp,
"%02X ", (uint8_t)buf[u+ch]);
125 if (ch == 7) fprintf(fp,
" ");
127 if (ch == 16) fprintf(fp,
" ");
129 int spaces = (16 - ch) * 3 + 2 + 1;
131 for ( ; s < spaces; s++) fprintf(fp,
" ");
133 int spaces = (16 - ch) * 3 + 2;
135 for ( ; s < spaces; s++) fprintf(fp,
" ");
138 for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
139 fprintf(fp,
"%c", isprint((uint8_t)buf[u+ch]) ? (uint8_t)buf[u+ch] :
'.');
141 if (ch == 7) fprintf(fp,
" ");
142 if (ch == 15) fprintf(fp,
"\n");
150 const uint8_t *src_buf, uint32_t src_buf_len)
154 for (uint32_t u = 0; u < src_buf_len; u += 16) {
157 for (ch = 0; (u + ch) < src_buf_len && ch < 16; ch++) {
159 "%02X ", (uint8_t)src_buf[u + ch]);
167 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
169 int spaces = (16 - ch) * 3 + 2 + 1;
171 for ( ; s < spaces; s++)
172 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
174 int spaces = (16 - ch) * 3 + 2;
176 for ( ; s < spaces; s++)
177 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
180 for (ch = 0; (u+ch) < src_buf_len && ch < 16; ch++) {
183 isprint((uint8_t)src_buf[u + ch]) ? (uint8_t)src_buf[u + ch] :
'.');
186 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
188 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
"\n");
192 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
"\n");
196 const uint8_t *src_buf,
const uint32_t src_buf_len)
198 for (uint32_t ch = 0; ch < src_buf_len && *dst_buf_offset_ptr < dst_buf_size;
199 ch++, (*dst_buf_offset_ptr)++) {
200 if (isprint((uint8_t)src_buf[ch]) || src_buf[ch] ==
'\n' || src_buf[ch] ==
'\r') {
201 dst_buf[*dst_buf_offset_ptr] = src_buf[ch];
203 dst_buf[*dst_buf_offset_ptr] =
'.';
206 dst_buf[dst_buf_size - 1] = 0;
void PrintRawLineHexBuf(char *retbuf, uint32_t retbuflen, const uint8_t *buf, uint32_t buflen)
print a buffer as hex on a single line into retbuf buffer
void PrintBufferRawLineHex(char *nbuf, int *offset, int max_size, const uint8_t *buf, uint32_t buflen)
print a buffer as hex on a single line
void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, uint32_t src_buf_len)
void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len)