home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / DISK_CHK / PROBDESC.ZIP / TEST1.C < prev    next >
Text File  |  1992-07-07  |  1KB  |  74 lines

  1.  
  2. #include "stdlib.h"
  3. #include "fcntl.h"
  4. #include "memory.h"
  5. #include "stdio.h"
  6. #include "io.h"
  7. #include "func.h"
  8.  
  9. boolean is386;
  10.  
  11. #define SIZE 16384U
  12. unsigned char buff1[SIZE];
  13. unsigned char buff2[SIZE];
  14.  
  15.  
  16. // Simply compare the two buffers byte by byte,
  17. // and report any mismatches.  The buffers should be identical,
  18. // but do to faulty external caches, the data can become corrupted.
  19.  
  20. void compare(char *p1,char *p2,unsigned size,unsigned long pos)
  21. {
  22. char *save=p1;
  23.  
  24. while (size--)
  25.   { if (*p1 != *p2)
  26.       { printf(
  27. "Mismatch at: %5u  Pos: %7lu  adr1: %4x adr2: %4x  buff1=%3u buff2=%3u\n",
  28.           p1-save,pos+(unsigned)p1-(unsigned)save,p1,p2,*p1,*p2);
  29.       }
  30.     p1++;
  31.     p2++;
  32.   }
  33. }
  34.       
  35.  
  36.  
  37. void do_file(int fh,unsigned size)
  38. {
  39. unsigned count;
  40. unsigned long pos;
  41. char *ptr;
  42. unsigned i;
  43.  
  44. _lseek(fh,pos=0L,SEEK_SET);
  45.  
  46. printf("Buffer: %5u\n",size);
  47.  
  48. while (count=_read(fh,buff1,size))    // standard read routine
  49.   { for (i=0;i<32;i++)
  50.       memcpy(buff2,buff1,count);    // standard memcpy routine
  51.  
  52.     compare(buff1,buff2,count,pos);
  53.     pos += count;
  54.   }
  55. }
  56.  
  57.  
  58.  
  59. unsigned main(unsigned argc,char *argv[])
  60. {
  61. int fh;
  62. unsigned i;
  63.  
  64. if ((fh=_open(argv[1],O_RDONLY|O_BINARY)) == -1)
  65.   { printf("Can't open %s\n",argv[1]);
  66.     return 1;
  67.   }
  68.  
  69. for (i=64; i<=SIZE; i<<=1)
  70.   do_file(fh,i);
  71.  
  72. return 0;
  73. }
  74.