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

Efficient techniques to parse binary files ?

 [1/2] from: jasonic::panix::com at: 14-Nov-2001 1:22


hmm.. having fun exploring binary PNG files to detect specific characters, chunks and strings. Using an external tool, TweakPNG I have embedded a REBOL test script inside the image. What are some recommended techniques for doing this efficiently? Looking for general REBOL guidance, but examples are always welcome.. buddha: read/binary %buddha.png file-length: length? buddha ; == 292962 ; starting at position: 292858 here is the test script I want: { tEXtScript REBOL [] message: "hello from rebol png!" send [jasonic--nomadics--org] message } So I have been writing mickey-mouse functions with iterations to check values via to-char buddha/:position till I find what looks like the begining of text chunk, then store it in 'chunk and test if chunk = "tEXt" etc Feels like there must be better way[s].. is sloow too Here the Problem: 1: Scan through a binary file looking for a chunk = "tEXt" 2: When I do find one, then check if there is special keyword string Script following it 3: Check if the next string = "REBOL [" if it then bingo! I want that script for however long it is... else keep looking for another chunk = "tEXt" any suggestions ? thanks - Jason

 [2/2] from: g:santilli:tiscalinet:it at: 15-Nov-2001 11:27


Jason Cunliffe wrote:
> ; starting at position: 292858 here is the test script I want: > { > tEXtScript REBOL [] > message: "hello from rebol png!" > send [jasonic--nomadics--org] message > }
BTW, did you try to enclose the script in a block: [REBOL [] ; etc. ] and then DO the file? I don't recall if this works for binary files too. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/