diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2008-07-02 20:01:00 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2008-07-02 20:01:00 -0700 |
commit | 17ab7c7135befeb4e1d33385496959a16bd55054 (patch) | |
tree | c0135fd307af8f24860be6b52c82d1f0ba59a21e /src/aig/ntl/ntlReadBlif.c | |
parent | 303baf27cf34c2a57db97c4c567fd744241fa14b (diff) | |
download | abc-17ab7c7135befeb4e1d33385496959a16bd55054.tar.gz abc-17ab7c7135befeb4e1d33385496959a16bd55054.tar.bz2 abc-17ab7c7135befeb4e1d33385496959a16bd55054.zip |
Version abc80702_2
Diffstat (limited to 'src/aig/ntl/ntlReadBlif.c')
-rw-r--r-- | src/aig/ntl/ntlReadBlif.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/aig/ntl/ntlReadBlif.c b/src/aig/ntl/ntlReadBlif.c index e1b351b3..105f4c4a 100644 --- a/src/aig/ntl/ntlReadBlif.c +++ b/src/aig/ntl/ntlReadBlif.c @@ -22,6 +22,7 @@ #include "ntl.h" #include "bzlib.h" +#include "zlib.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -84,6 +85,7 @@ static Ioa_ReadMod_t * Ioa_ReadModAlloc(); static void Ioa_ReadModFree( Ioa_ReadMod_t * p ); static char * Ioa_ReadLoadFile( char * pFileName ); static char * Ioa_ReadLoadFileBz2( char * pFileName ); +static char * Ioa_ReadLoadFileGz( char * pFileName ); static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p ); static int Ioa_ReadReadInterfaces( Ioa_ReadMan_t * p ); static Ntl_Man_t * Ioa_ReadParse( Ioa_ReadMan_t * p ); @@ -137,6 +139,8 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck ) p->pFileName = pFileName; if ( !strncmp(pFileName+strlen(pFileName)-4,".bz2",4) ) p->pBuffer = Ioa_ReadLoadFileBz2( pFileName ); + else if ( !strncmp(pFileName+strlen(pFileName)-3,".gz",3) ) + p->pBuffer = Ioa_ReadLoadFileGz( pFileName ); else p->pBuffer = Ioa_ReadLoadFile( pFileName ); if ( p->pBuffer == NULL ) @@ -541,6 +545,39 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName ) /**Function************************************************************* + Synopsis [Reads the file into a character buffer.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static char * Ioa_ReadLoadFileGz( char * pFileName ) +{ + const int READ_BLOCK_SIZE = 100000; + FILE * pFile; + char * pContents; + int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE; + pFile = gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen + pContents = ALLOC( char, nFileSize ); + readBlock = 0; + while ((amtRead = gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) { + //printf("%d: read %d bytes\n", readBlock, amtRead); + nFileSize += READ_BLOCK_SIZE; + pContents = REALLOC(char, pContents, nFileSize); + ++readBlock; + } + //printf("%d: read %d bytes\n", readBlock, amtRead); + assert( amtRead != -1 ); // indicates a zlib error + nFileSize -= (READ_BLOCK_SIZE - amtRead); + gzclose(pFile); + return pContents; +} + +/**Function************************************************************* + Synopsis [Prepares the parsing.] Description [Performs several preliminary operations: |