Ticket #30: patch

File patch, 1.2 KB (added by Dan Lukes, 15 years ago)
  • ataprint.cpp

    old new  
    10061006}
    10071007
    10081008// Print hexdump of log pages.
    1009 // Format is compatible with 'xxd -r'.
     1009// Format is compatible with output of 'hd'.
    10101010static void PrintLogPages(const char * type, const unsigned char * data,
    10111011                          unsigned char logaddr, unsigned page,
    10121012                          unsigned num_pages, unsigned max_pages)
     
    10161016  for (unsigned i = 0; i < num_pages * 512; i += 16) {
    10171017    const unsigned char * p = data+i;
    10181018    pout("%07x: %02x %02x %02x %02x %02x %02x %02x %02x "
    1019                "%02x %02x %02x %02x %02x %02x %02x %02x\n",
     1019               "%02x %02x %02x %02x %02x %02x %02x %02x ",
    10201020         (page * 512) + i,
    10211021         p[ 0], p[ 1], p[ 2], p[ 3], p[ 4], p[ 5], p[ 6], p[ 7],
    10221022         p[ 8], p[ 9], p[10], p[11], p[12], p[13], p[14], p[15]);
     1023#define P(n) (isprint((int)(p[n]))?(int)(p[n]):'.')
     1024    pout("|%c%c%c%c%c%c%c%c"
     1025          "%c%c%c%c%c%c%c%c|\n",
     1026         P( 0), P( 1), P( 2), P( 3), P( 4), P( 5), P( 6), P( 7),
     1027         P( 8), P( 9), P(10), P(11), P(12), P(13), P(14), P(15));
     1028#undef P
    10231029    if ((i & 0x1ff) == 0x1f0)
    10241030      pout("\n");
    10251031  }