46 for (uint32_t u = 0; u < buflen; u++) {
64 for (uint32_t u = 0; u < buflen; u++) {
71 #define BUFFER_LENGTH 2048
75 for (uint32_t u = 0; u < buflen; u++) {
76 if (isprint(buf[u]) && buf[u] !=
'\"') {
90 fprintf(fp,
"%s", nbuf);
95 for (
size_t u = 0; u < buflen; u++) {
96 if (isprint(buf[u]) && buf[u] !=
'\"') {
116 fprintf(fp,
" (null)\n");
119 for (uint32_t u = 0; u < buflen; u += 16) {
120 fprintf(fp ,
" %04X ", u);
121 for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
122 fprintf(fp,
"%02X ", (uint8_t)buf[u+ch]);
124 if (ch == 7) fprintf(fp,
" ");
126 if (ch == 16) fprintf(fp,
" ");
128 int spaces = (16 - ch) * 3 + 2 + 1;
130 for ( ; s < spaces; s++) fprintf(fp,
" ");
132 int spaces = (16 - ch) * 3 + 2;
134 for ( ; s < spaces; s++) fprintf(fp,
" ");
137 for (ch = 0; (u+ch) < buflen && ch < 16; ch++) {
138 fprintf(fp,
"%c", isprint((uint8_t)buf[u+ch]) ? (uint8_t)buf[u+ch] :
'.');
140 if (ch == 7) fprintf(fp,
" ");
141 if (ch == 15) fprintf(fp,
"\n");
149 const uint8_t *src_buf, uint32_t src_buf_len)
153 for (uint32_t u = 0; u < src_buf_len; u += 16) {
156 for (ch = 0; (u + ch) < src_buf_len && ch < 16; ch++) {
158 "%02X ", (uint8_t)src_buf[u + ch]);
166 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
168 int spaces = (16 - ch) * 3 + 2 + 1;
170 for ( ; s < spaces; s++)
171 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
173 int spaces = (16 - ch) * 3 + 2;
175 for ( ; s < spaces; s++)
176 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
179 for (ch = 0; (u+ch) < src_buf_len && ch < 16; ch++) {
182 isprint((uint8_t)src_buf[u + ch]) ? (uint8_t)src_buf[u + ch] :
'.');
185 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
" ");
187 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
"\n");
191 PrintBufferData((
char *)dst_buf, dst_buf_offset_ptr, dst_buf_size,
"\n");
195 const uint8_t *src_buf,
const uint32_t src_buf_len)
197 for (uint32_t ch = 0; ch < src_buf_len && *dst_buf_offset_ptr < dst_buf_size;
198 ch++, (*dst_buf_offset_ptr)++) {
199 if (isprint((uint8_t)src_buf[ch]) || src_buf[ch] ==
'\n' || src_buf[ch] ==
'\r') {
200 dst_buf[*dst_buf_offset_ptr] = src_buf[ch];
202 dst_buf[*dst_buf_offset_ptr] =
'.';
205 dst_buf[dst_buf_size - 1] = 0;
208 static const char *PrintInetIPv6(
const void *
src,
char *
dst, socklen_t size)
219 memset(
dst, 0, size);
220 for (
int i = 0; i < 8; i++) {
221 snprintf(s_part,
sizeof(s_part),
"%04x:", htons(x[i]));
234 #if defined(OS_WIN32) && NTDDI_VERSION >= NTDDI_VISTA
239 memcpy(&_src,
src,
sizeof(
struct in_addr));
240 return inet_ntop(
af, &_src,
dst, size);
243 return inet_ntop(
af,
src,
dst, size);
247 return PrintInetIPv6(
src,
dst, size);
257 rs_to_hex((uint8_t *)
str, size, buf, buf_len);