/* This exe removes the Copyright-data (CE and AE) from GIF89a (as written by Gif Construction Set)... Can come in handy when creating CD-roms and stuff. J.Thyssen & H.Zimmerman, TC3, 03-97, DOS commandline, 16bit, PKlited. Operation= RCMGIF FILE.GIF Wildcards can also be used) Following is code (this txt-file is a C-file) */ #include #include #include #include #include #define TEMPFILE "!hallo!" #define MAXBUF 1024 #pragma warn -pia void main(int argc,char*argv[]){ FILE *f1,*f2; char buf[MAXBUF]; int done=0,c; if(argc!=2){ printf("RCMGIF FILE.GIF\n"); exit(1); } if((f1=fopen(argv[1],"rb"))==NULL){ printf("Can't open %s\n",argv[1]); exit(1); } /* header and lsd: */ fread(buf,13,1,f1); c=buf[6]; buf[6]=0; if(strcmpi(buf,"GIF89a")){ fclose(f1); printf("%s is not a GIF89a\n",argv[1]); exit(1); } buf[6]=c; f2=fopen(TEMPFILE,"wb"); fwrite(buf,13,1,f2); /* do we have a GCT?: */ if(buf[10]&0x80){ /* yep */ fread(buf,768,1,f1); fwrite(buf,768,1,f2); } /* rest of GIF has control-bytes: */ while(!done){ c=fgetc(f1); switch(c){ case 0x21:/* 89a-extension */ c=fgetc(f1); switch(c){ case 0xfe:/* CE, throw away! */ case 0xff:/* AE, we hate that one too... */ while(c=fgetc(f1)) /* 0 indicates term-block */ fread(buf,c,1,f1); /* flush c bytes */ break; default:/* sth else (PTE(0x01) or GCE(0xf9) keep it */ fprintf(f2,"%c%c",0x21,c); while(c=fgetc(f1)){ /* 0 indicates term-block */ fputc(c,f2); fread(buf,1,c,f1); /* copy c bytes */ fwrite(buf,1,c,f2); } /* write termblock: */ fputc(0,f2); } break; case 0x2c:/* image-data */ fputc(0x2c,f2); fread(buf,10,1,f1); /* GIF87 formal desc. says 9 bytes !?!?! */ fwrite(buf,10,1,f2); /* do we have an LTC: */ if(buf[8]&0x80){ /* yep */ fread(buf,768,1,f1); fwrite(buf,768,1,f2); } /* copy rasterdata: */ while(c=fgetc(f1)){ /* 0 indicates term-block */ fputc(c,f2); fread(buf,1,c,f1); /* copy c bytes */ fwrite(buf,1,c,f2); } /* write termblock: */ fputc(0,f2); break; case 0x3b:/* GIF-terminator */ fputc(0x3b,f2); done=1; } } fcloseall(); chmod(argv[1],S_IWRITE); unlink(argv[1]); rename(TEMPFILE,argv[1]); }