Hans Aberg | 28 Dec 15:51

Re: parsing compressed files with flex & bison

Flex was not built to generate lexers for essentially binary files,  
though you may try it. And one can easily pipe streams under UNIX- 
like OS's.

   Hans Aberg

On 28 Dec 2006, at 14:27, Aïmen Troudi wrote:

> I want to parse files in one pass for 2 reasons :
>
> 1- size of (5) files is important (>200MO).
> 2- it is more sophistical (execution time and I/O).
>
> The problem is that flex needs FILE* stream, and Zlib needs gzFile  
> stream.
>
> I find these 2 solutions :
>
> 1) - find the type of compressed file (gzip or bunzip2 or Z).
>     - switch the type i execute FILE* yyin = popen(cmd,"r"), cmd :  
> "/usr/bin/bunzip2 -dfc file.bz2" or ...
>
> -> - this solution don't use zlib library, it use shell.
>     - easy to implement than 2).
>
> 2) - find the type of compressed file (gzip or bunzip2 or Z).
>     - open a pipe, fork.
>     - the father process use zlib library to read compressed files  
> and put them in pipe,
>       gzFile stream = gzopen(); ... gzread(buffer); ... gzwrite(pipe 
(Continue reading)


Gmane