Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: More gz compression

From: oliva:david:seznam:cz at: 2-Aug-2002 12:33

Hello Gabriele, Thursday, July 25, 2002, 4:13:23 PM, you wrote: GS> Hi Henrik, GS> On Monday, July 22, 2002, 4:02:01 AM, you wrote: HMK>> Did anyone make rebol's compress match the one used in gzcompress() with php? GS> I never tried, but maybe PHP's just adding the GZIP header that GS> REBOL does not add? GS> Regards, GS> Gabriele. I've tried it as well and here is result: Rebol produces same output as PHP function: gzcompress($data_to_decompress, 9); but with the uncompressed data size (last 4 bytes) (at least in all my tests there was same result and I was able to compress/decompress data between PHP and Rebol vice versa) For reading/writing *.gz files from Rebol we need to work with the GZIP header... I've written this testing gzip parser - this doesn't solve our problem - see the comments in the file and try to find solution:-) <code> rebol [ title: "GZip test parser" purpose: {Experimental script to test a posibility to decompress *.gz files} author: "Oldes" email: [oliva--david--seznam--cz] specification: http://www.faqs.org/rfcs/rfc1952.html ] ;gzipbin: read/binary %/c/web/fwp/www/test2.gz ;for testing I have already loaded compressed text: "Rebol" gzipbin: #{1F8B080000000000000B0B4A4DCACF0100D2293B6505000000} rebolbin: compress "Rebol" ;comparing these binaries we can see: ;gzipbin: #{1F8B080000000000000B 0B4A4DCACF0100 D2293B65 05000000} ;rebolbin: #{ 789C 0B4A4DCACF0100 05A301F5 05000000} parse/all gzipbin [ ;IDentification: #{1F8B} ;compression method: copy CM 1 skip (probe CM: to-binary CM) ;FLaGs: copy FLG 1 skip (probe FLG: enbase/base FLG 2) ;Modification TIME: copy MTIME 4 skip (probe MTIME: to-integer head reverse to-binary MTIME) ;eXtra FLags: copy XFL 1 skip (probe XFL: to-binary XFL) ;Operating System: copy OS 1 skip (probe OS: to-integer to-binary OS) tmp: ( if FLG/6 = #"1" [ ;eXtra LENgth XLEN: to-integer head reverse to-binary copy/part tmp 2 tmp: skip tmp 2 FEXTRA: copy/part tmp XLEN tmp: skip tmp XLEN ] if FLG/5 = #"1" [ ;...original file name, zero-terminated... parse/all tmp [copy FNAME to #{00} 1 skip tmp: to end] ] if FLG/4 = #"1" [ ;...file comment, zero-terminated... parse/all tmp [copy FCOMMENT to #{00} 1 skip tmp: to end] ] ) :tmp copy rest to end ( probe rest: to-binary rest ;in the REST variable is zlib compressed data 4bytes of CRC32 and 4bytes of size of uncompressed data... ;Can anybody find how to uncompress these data in Rebol??? ;if I insert #{789C} in the head (as it's in the 'rebolbin I get error: ;** Script Error: Invalid compressed data - problem: -3 ;that probably means wrong CRC32 - :(( - RT will have to help us ) ] </code>