home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 February / PCWorld_2002-02_cd.bin / Software / Vyzkuste / ranish / SOURCES.ZIP / S_UNKNWN.C < prev   
C/C++ Source or Header  |  1998-05-12  |  960b  |  55 lines

  1. #include "part.h"
  2.  
  3. void hex_dump_line(long,unsigned char*);
  4.  
  5.  
  6. int print_unknown(struct part_long *p)
  7. {
  8.  int i;
  9.  char tmp1[20], tmp2[20];
  10.  
  11.  if( disk_read_rel(p,0,tmp,1)==-1 )
  12.    {
  13.     fprintf(stderr,"Error reading boot sector.\n");
  14.     return FAILED;
  15.    }
  16.  
  17.  printf("Boot sector dump of an unknown system:\n\n");
  18.  
  19.  for( i=0 ; i<SECT_SIZE ; i+=16 )
  20.   hex_dump_line(i,tmp+i);
  21.  
  22.  return OK;
  23. }/* print_unknown */
  24.  
  25.  
  26. void hex_dump_line(long l, unsigned char *buf)
  27. {
  28.  int i;
  29.  unsigned char *tmp1=tmp+SECT_SIZE;
  30.  unsigned char *tmp2=tmp1+8;
  31.  
  32.  sprintf(tmp1, "0x%04lX  ",l);
  33.  
  34.  for( i=0 ; i<16 ; i++ )
  35.     {
  36.      sprintf( tmp2, "%02X ", buf[i]);
  37.      tmp2+=3;
  38.      if( i==3 || i==7 || i==11 ) { *tmp2='|'; tmp2++; *tmp2=' '; tmp2++; }
  39.     }
  40.  
  41.  *tmp2=' ';
  42.  tmp2++;
  43.  
  44.  for( i=0 ; i<16 ; i++ )
  45.     {
  46.      *tmp2=(buf[i]>=32 && buf[i]<128) ? buf[i] : '.';
  47.      tmp2++;
  48.     }
  49.  
  50.  *tmp2=0;
  51.  
  52.  puts(tmp1);
  53.  
  54. }/* hex_dump_line */
  55.