Browse Source

Improve hexadecimal output

master
Damien Goutte-Gattat 9 years ago
parent
commit
9b7e7ebe24
  1. 31
      src/asysex.c

31
src/asysex.c

@ -163,14 +163,29 @@ typedef void (*print_midi_fn_t)(FILE *, unsigned char *, size_t);
static void
print_midi_hex(FILE *out, unsigned char *buffer, size_t len)
{
int i;
static int j = 0;
for ( i = 0; i < len; i++, j++ ) {
if ( j % 16 == 0 )
fprintf(out, "%s%08x:", j > 0 ? "\n" : "", j);
fprintf(out, " %s%02X", j % 8 == 0 ? " " : "", buffer[i]);
int i, j;
static int n = 0;
for ( i = 0; i < len; i += 16, n += 16 ) {
fprintf(out, "%08x ", n);
for ( j = i; j < i + 8; j++ )
if ( j < len )
fprintf(out, " %02x", buffer[j]);
else
fprintf(out, " ");
fprintf(out, " ");
for ( ; j < i + 16; j++ )
if ( j < len )
fprintf(out, " %02x", buffer[j]);
else
fprintf(out, " ");
fprintf(out, " |");
for ( j = i; j < i + 16 && j < len; j++ )
fprintf(out, "%c", isprint(buffer[j]) ? buffer[j] : '.');
fprintf(out, "|\n");
}
}

Loading…
Cancel
Save