Hello, Here comes a patch (removing some unnecessary size limitations). Rl
--- PRES/pres.c.ori 2015-04-27 22:04:01.705132713 +0200 +++ PRES/pres.c 2015-04-27 22:11:45.855097441 +0200 @@ -3,6 +3,14 @@ * * A library (prem/malprem) and a cli frontend to it (pres) * + * version 0.2015-04-27 + * removed undue data stream size limitations, + * now it should work for up to 2GB files, + * bigger streams will be compressed alright but + * the diagnostic messages could become wrong after 2GB + * version 0.2015-04-26 + * initial public release + * * Usage: pres [-dcfFqii] [file ...] * Flags: * -d: Decompress instead of compressing @@ -246,8 +254,8 @@ exit(exit_stat); } -long int enk; /* input data length */ -long int elk; /* compressed length */ +unsigned long int enk; /* input data length */ +unsigned long int elk; /* compressed length */ /* * Compressing input to output (one file) @@ -267,9 +275,10 @@ exit( 1 ); } enk = elk = 0; - for( ;; ){ + b_n = 0; + for( ;; ++b_n ){ + /* in output we roll over every 2^16 blocks regardless the b_n type size */ d = enb; - b_n = enk / BLON; /* the future block number */ /* fill the output buffer */ while( d - enb < BLON && (c=getchar()) != EOF ){ ++enk; @@ -311,10 +320,10 @@ /* * tell the result */ - if(wcat_flg == 0 && !quiet) { - fprintf( stderr, "Compression: %d%%", - enk > 0 ? - ( (100 * ( enk - elk )) / enk ) : + if(wcat_flg == 0 && !quiet) { long dif = (long)enk-(long)elk; + fprintf( stderr, "Compression: %d%%", + enk ? + (int)((dif>21474836)?(dif/((long)enk/100)):(100*dif/(long)enk)) : 0 ); } if(elk > enk) /* exit(2) if no compression */ @@ -439,12 +448,13 @@ continue; } } - oblk = it_blk + 1; + oblk = (it_blk + 1)&65535; /* ensure rolling over every 2^16 blocks */ lon = it_lon; if( lon == BLON ){ /* not the last block */ - if( (i=serch()) == EOF /* end ??? */ - || it_blk != oblk ) /* out of order */ - continue; /* do not trust this block */ + if( ((i=serch()) == EOF /* end ??? */ + || it_blk != oblk) /* out of order */ + && !ignore ) + continue; /* do not trust the freshly uncompressed block */ } else { /* looks like the last one */ if( ignore && (i=serch()) != EOF ){ /* not last, look further! */ @@ -457,8 +467,8 @@ continue; /* ignoring the "last" block indication */ } } - if( (j=oblk-b_blk-1) != 0 ){ - /* the next block number in order, but here there was a skip */ + if( (j=oblk-((b_blk+1)&65535)) != 0 ){ + /* there was a skip */ if( fseek( stdout, (long)oblk*(long)BLON, 0 ) < 0 ) /* can not seek (pipe) */ if( j > 0 && j <= 10 ) /* skipped blocks --- PRES/flparc.c.ori 2015-04-27 22:04:06.568430732 +0200 +++ PRES/flparc.c 2015-04-27 22:14:26.303900666 +0200 @@ -2,6 +2,14 @@ * FLPARC - recording/reading data on removable data, with compression * (c) RL 1990-2015 * + * version 0.2015-04-27 + * removed undue data stream size limitations, + * now it should work for up to 2GB, + * bigger streams will be compressed alright but + * the diagnostic messages would become wrong after 2GB + * version 0.2015-04-26 + * initial public release + * * $Header: flparc.c,v 1.2 91/01/24 14:11:35 pro Exp $ * $Log: flparc.c,v $ * Revision 1.2 91/01/24 14:11:35 pro @@ -36,7 +44,7 @@ int bi = 0; /* Index in the blocking buffer */ unsigned int bimaks; /* Size of the blocking buffer */ long skp = 0; /* Pointer in the archive file */ -long num = 0; /* Number of the bytes input for compression */ +unsigned long num = 0; /* Number of the bytes input for compression */ int flp = -1; /* Number of the filled media */ int verb = 0; /* Tell the current compression ratio */ int ignore = 0; /* Ignore read errors at decompression */ @@ -295,11 +303,14 @@ " Skriberaro! Bloko %d\n"), skp/B_LON ); exit_stat = 5; } - if( num > 0 && verb ) fprintf( stderr, ediag( - " Compressed: %d%%\n", - " Kunpremite: %d%%\n"), - (100*(num-((long)flp*dlon*B_LON+skp+bi)))/num ); -/* note this works up to ca 21MB of size reduction (overflow of 100*(long)) */ + if( num > 0 && verb ){ long dif = (long)num-((long)flp*dlon*B_LON+skp+bi); + fprintf( stderr, ediag( + " Compressed: %d%%\n", + " Kunpremite: %d%%\n"), + num ? + (int)((dif>21474836)?(dif/((long)num/100)):(100*dif/(long)num)) : + 0 ); + } skp = 0; bi = 0; } @@ -310,12 +321,13 @@ char c, d; ++flp; - if( premado && verb && flp > 0 ){ + if( premado && verb && flp > 0 ){ long dif = (long)num-(long)flp*dlon*B_LON; fprintf( stderr, ediag( - " Currently compressed %d%%\n", - " Nuntempa premado %d%%\n"), - (100*(num-((long)flp*dlon*B_LON)))/num ); -/* note this works up to ca 21MB of size reduction (overflow of 100*(long)) */ + " Currently compressed %d%%\n", + " Nuntempa premado %d%%\n"), + num ? + (int)((dif>21474836)?(dif/((long)num/100)):(100*dif/(long)num)) : + 0 ); } fprintf( stderr, ediag( "\ @@ -375,9 +387,10 @@ exit_stat = 5; return; } - for( ;; ){ + b_n = 0; + for( ;; ++b_n ){ + /* in output we roll over every 2^16 blocks regardless the b_n type size */ d = enb; - b_n = num / BLON; /* the future block number */ /* fill the input buffer */ while( d - enb < BLON && (c=getchar()) != EOF ){ ++num; @@ -541,12 +554,13 @@ continue; } } - oblk = it_blk + 1; + oblk = (it_blk + 1)&65535; /* ensure rolling over every 2^16 blocks */ lon = it_lon; if( lon == BLON ){ /* not the last block */ - if( (i=serch()) == EOF /* error */ - || it_blk != oblk ) /* out of order */ - continue; /* don't trust this block */ + if( ((i=serch()) == EOF /* error */ + || it_blk != oblk ) /* out of order */ + && !ignore ) + continue; /* do not trust the freshly uncompressed block */ } else { /* looks like the last block */ if( ignore ){ /* not the last, we may need to look further! */ @@ -566,8 +580,8 @@ } } } - if( (j=oblk-b_blk-1) != 0 ){ - /* the next block number in order, but here there was a skip */ + if( (j=oblk-((b_blk+1)&65535)) != 0 ){ + /* there was a skip */ if( fseek( stdout, (long)oblk*(long)BLON, 0 ) < 0 ) /* can not seek (pipe) */ if( j > 0 && j <= 10 ) /* skipped blocks