image28

Incremental Diff

Jun 25th, 2016
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. // This is pretty old now, have newer versions somewhere without the fake basic like syntax
  2.  
  3. #include "defines.h"
  4.  
  5. struct files
  6. {
  7.     FILE *input;
  8. };
  9.  
  10. MAIN;
  11.     //ARG_CHECK(2);
  12.    
  13.     UCHAR inbyte[argc];
  14.     ULONG pos=0;
  15.     struct files pointer[argc];
  16.     UINT d=0;
  17.     UINT change=0;
  18.     ULONG fs=0;
  19.     UINT e=0;
  20.  
  21.     for (d=0; d < argc; d++ )
  22.     {
  23.         inbyte[d]='\0';
  24.     }
  25.  
  26.  
  27.     for(d=0; d < argc-1; d++)
  28.     {
  29.         if ( ( pointer[d].input = fopen(argv[d+1],"r") ) == NULL )
  30.         {
  31.  
  32.             printf("File %s open failed\n",argv[d+1]);
  33.             exit(-1);
  34.         }else{
  35.             printf("File %s opened for r\n",argv[d+1]);
  36.         }
  37.     }
  38.  
  39.     fseek(pointer[0].input,0L,SEEK_END);
  40.     fs=ftell(pointer[0].input);
  41.     fseek(pointer[0].input,0L,SEEK_SET);
  42.  
  43.     while ( pos < fs )
  44.     {
  45.         for(d=0; d < argc-1; d++ )
  46.         {
  47.             fread(&inbyte[d],1,1,pointer[d].input);
  48.             //printf("Read %d from file %s\n",inbyte[d],argv[d+1]);
  49.         }
  50.  
  51.         for(d=0; d < argc-1; d++ )
  52.         {
  53.             for(e=0; e < argc-1; e++)
  54.             {
  55.                 if ( inbyte[d] != inbyte[e] )
  56.                 {
  57.                     change++;
  58.                 }
  59.             }
  60.         }
  61.  
  62.         if ( change >= (argc-1)*2 )// *(argc-1) )
  63.         {
  64.             printf("%d: ", pos );
  65.             for(d=0; d < argc-1; d++ )
  66.             {
  67.                 if ( d == argc-2 )
  68.                 {
  69.                     printf("%d",inbyte[d]);
  70.                 }else{
  71.                     printf("%d -> ",inbyte[d]);
  72.                 }
  73.             }
  74.             printf("\n");
  75.         }
  76.  
  77.         for (d=0; d < argc-1; d++ )
  78.         {
  79.             inbyte[d]='\0';
  80.         }
  81.  
  82.         pos++;
  83.  
  84.         change=0;
  85.     END;
  86.  
  87.     for(d=0; d < argc-1; d++)
  88.     {
  89.         CLOSE(pointer[d].input);
  90.     }
  91.    
  92.     RET;
  93. END;
Advertisement
Add Comment
Please, Sign In to add comment