home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaMiscModsCD3.iso / _PROGRAMME / TOOLS / fixmod.lha / fixmod.c next >
Encoding:
C/C++ Source or Header  |  1996-06-06  |  1.1 KB  |  60 lines

  1. //fixmod
  2.  
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6.  
  7.  
  8. int main(int argc,char *argv[])
  9.  
  10.     {
  11.     FILE *fp;    //pointer to file
  12.     int f,i,a,num;    
  13.     char buff[2],buff2[4];
  14.  
  15.     if (argc < 2 )
  16.       {    
  17.         printf("Usage: fixmod <file1> <file2>... \n");
  18.         return 0;
  19.       }    
  20.     
  21.     for(f = 1 ; f < argc; f++)    //do for all files in arglist
  22.       {    
  23.     
  24.          if((fp = fopen(argv[f],"r+"))==NULL) 
  25.             {
  26.              
  27.              printf("Couldn't open %s",argv[f]);
  28.             return (-1);    //exit if file cant be opened
  29.               }
  30.         
  31.         fseek(fp,951,SEEK_SET);
  32.         a = fread(buff2,4,1,fp);     //check if 31 or 15 inst.
  33.         
  34.         num = 15;            //is it 15
  35.         
  36.         if(strcmp(buff,"M.K.")==0)    
  37.           {
  38.             num = 31;        //nop 31
  39.           }         
  40.  
  41.         for(i = 48 ;i <= 48+30*(num-1) ;i += 30)    //look at all inst.
  42.              {
  43.  
  44.             fseek(fp,i,SEEK_SET);    //position file pointer
  45.             a = fread(buff,2,1,fp); //read one word
  46.         
  47.         
  48.             if (buff[0] == NULL && buff[1] == NULL) //is replen 0
  49.                 {    
  50.                 fseek(fp,-2,SEEK_CUR);        //skip back
  51.                 buff[1] = 1;            //and correct
  52.                 a = fwrite(buff,2,1,fp);    //it to 2                        
  53.                 }        
  54.                     
  55.             }     
  56.         fclose(fp);                //close this file
  57.      }                        //and do next..
  58.  
  59.     }    
  60.