home *** CD-ROM | disk | FTP | other *** search
- //fixmod
-
-
- #include <stdio.h>
- #include <string.h>
-
-
- int main(int argc,char *argv[])
-
- {
- FILE *fp; //pointer to file
- int f,i,a,num;
- char buff[2],buff2[4];
-
- if (argc < 2 )
- {
- printf("Usage: fixmod <file1> <file2>... \n");
- return 0;
- }
-
- for(f = 1 ; f < argc; f++) //do for all files in arglist
- {
-
- if((fp = fopen(argv[f],"r+"))==NULL)
- {
-
- printf("Couldn't open %s",argv[f]);
- return (-1); //exit if file cant be opened
- }
-
- fseek(fp,951,SEEK_SET);
- a = fread(buff2,4,1,fp); //check if 31 or 15 inst.
-
- num = 15; //is it 15
-
- if(strcmp(buff,"M.K.")==0)
- {
- num = 31; //nop 31
- }
-
- for(i = 48 ;i <= 48+30*(num-1) ;i += 30) //look at all inst.
- {
-
- fseek(fp,i,SEEK_SET); //position file pointer
- a = fread(buff,2,1,fp); //read one word
-
-
- if (buff[0] == NULL && buff[1] == NULL) //is replen 0
- {
- fseek(fp,-2,SEEK_CUR); //skip back
- buff[1] = 1; //and correct
- a = fwrite(buff,2,1,fp); //it to 2
- }
-
- }
- fclose(fp); //close this file
- } //and do next..
-
- }
-