From b30791ba622cd9b4f5eed1caf8a9567f2b3ad3a4 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 29 Feb 2012 16:43:28 -0800 Subject: Updating 'print_library' to write GENLIB library into a file. --- src/map/mio/mio.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/map/mio') diff --git a/src/map/mio/mio.c b/src/map/mio/mio.c index a4596c9f..30ad63e9 100644 --- a/src/map/mio/mio.c +++ b/src/map/mio/mio.c @@ -419,8 +419,9 @@ usage: ***********************************************************************/ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) { - FILE * pOut, * pErr; + FILE * pOut, * pErr, * pFile; Abc_Ntk_t * pNet; + char * FileName; int fVerbose; int c; @@ -445,22 +446,31 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } } - - - if ( argc != globalUtilOptind ) + FileName = argv[globalUtilOptind]; + if ( argc == globalUtilOptind + 1 ) { - goto usage; + pFile = fopen( FileName, "w" ); + if ( pFile == NULL ) + { + printf( "Error! Cannot open file \"%s\" for writing the library.\n", FileName ); + return 1; + } + Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); + fclose( pFile ); + printf( "The current GENLIB library is written into file \"%s\".\n", FileName ); } - - // set the new network - Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); + else if ( argc == globalUtilOptind ) + Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 ); + else + goto usage; return 0; usage: - fprintf( pErr, "\nusage: print_library [-vh]\n"); + fprintf( pErr, "\nusage: print_library [-vh] \n"); fprintf( pErr, "\t print the current genlib library\n" ); - fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); + fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" ); fprintf( pErr, "\t-h : print the command usage\n"); + fprintf( pErr, "\t : optional file name to write the library\n"); return 1; /* error exit */ } -- cgit v1.2.3