mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
utils: Factor out hexdump code used by --enable-packet-dump.
Factor out the common code used to hexdump the protocol when ./configure --enable-packet-dump is used. It's not quite a straight refactor because I had to fix some signedness bugs in the code which were not revealed before because this code is usually disabled.
This commit is contained in:
@@ -115,26 +115,8 @@ main_loop (int _sock)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
#ifdef ENABLE_PACKET_DUMP
|
||||
if (verbose) {
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0; i < len; i += 16) {
|
||||
printf ("%04zx: ", i);
|
||||
for (j = i; j < MIN (i+16, len); ++j)
|
||||
printf ("%02x ", (unsigned char) buf[j]);
|
||||
for (; j < i+16; ++j)
|
||||
printf (" ");
|
||||
printf ("|");
|
||||
for (j = i; j < MIN (i+16, len); ++j)
|
||||
if (c_isprint (buf[j]))
|
||||
printf ("%c", buf[j]);
|
||||
else
|
||||
printf (".");
|
||||
for (; j < i+16; ++j)
|
||||
printf (" ");
|
||||
printf ("|\n");
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
guestfs_int_hexdump (buf, len, stdout);
|
||||
#endif
|
||||
|
||||
gettimeofday (&start_t, NULL);
|
||||
|
||||
Reference in New Issue
Block a user