# include<io.h>
# include<stdio.h>
# include<string.h>
# include<stdlib.h>
# define FNSIZE 128
# define FNSIZE2 32

/* Revolutionaly Compressing Software FZSS
Maximum compressor FZMX
C Source for (perhaps) almost all the Machines
Copyright of source cord is reserved by
F.T.L.(Fujiki Total Laboratory),
but please feel free to use, change (enhancement welcome!)
this without F.T.L.'s agreement.
*/

int FNCHK(char *p) ;

main()
{
FILE *fp1,*fp2 ;
unsigned char b;
unsigned char FNI [ FNSIZE ] , FNO [ FNSIZE2 ];
int i;
puts("Input File Name");
/* security patch for Linux -- not using gets() -- */
fgets(FNI,FNSIZE,stdin);
rewind(stdin);
i=0;
while((FNI[i]>=0x20) && i< (FNSIZE-1))
{
i++;
}
FNI[i]='\0';
/* End of Patch */
fp1=fopen(FNI,"r");
if(fp1 == 0)
{
puts("File Open Error!!");
fclose(fp1);
exit(EXIT_FAILURE);
}
if ( FNCHK(FNI) == 0 )
{
strcpy(FNO,"test2.fzz");
}
else
{
strcpy(FNO,"test.fzz");
}
fp2=fopen(FNO,"wb");
/*Compressing started */
if ( filelength(fileno(fp1)) == 0 )
{
fputc(0x00,fp2);
puts("vacant file");
fclose(fp2);
fclose(fp1);
exit(EXIT_SUCCESS);
}
else while ( i <= filelength(fileno(fp1)) )
{
i ++;
b=fgetc(fp1);
if (b != 0 )
{
fputc(0x01,fp2);
fclose(fp2);
fclose(fp1);
puts("End of duty");
exit(EXIT_SUCCESS);
}
}
fclose(fp1);
puts("End of duty(0)");
fputc(0x00,fp2);
fclose(fp2);
}

/* End of Main routine */
/* Sub Routine for Filename check */
int FNCHK(char *p)
{
int ii=0,j,zfg=(*p) ;
char pp[9]="test.fzz",pp2[9];
while (zfg != 0)
{
ii ++;
zfg = (*(p+ii));
}
if(ii<8)
{
zfg=1;
return(zfg);
}
else
{
ii=ii-8;
for (j=0;j<=7;j++)
{
pp2[j]=(*(p+ii+j));
}
pp2[8]='\0';
zfg=(strcmp(pp,pp2));
return(zfg);
}

}
Back to FZSS Page