diff options
Diffstat (limited to 'src/base/cmd')
-rw-r--r-- | src/base/cmd/cmd.c | 360 | ||||
-rw-r--r-- | src/base/cmd/cmd.h | 16 | ||||
-rw-r--r-- | src/base/cmd/cmdAlias.c | 6 | ||||
-rw-r--r-- | src/base/cmd/cmdApi.c | 6 | ||||
-rw-r--r-- | src/base/cmd/cmdFlag.c | 9 | ||||
-rw-r--r-- | src/base/cmd/cmdHist.c | 6 | ||||
-rw-r--r-- | src/base/cmd/cmdInt.h | 4 | ||||
-rw-r--r-- | src/base/cmd/cmdUtils.c | 30 |
8 files changed, 103 insertions, 334 deletions
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index 2dc03d5c..9195554a 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -18,10 +18,6 @@ ***********************************************************************/ -#ifdef WIN32 -#include <process.h> -#endif - #include "mainInt.h" #include "cmdInt.h" #include "abc.h" @@ -49,10 +45,9 @@ static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv #endif static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv ); //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /**Function******************************************************************** @@ -90,7 +85,6 @@ void Cmd_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1); Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1); - Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0); } /**Function******************************************************************** @@ -148,8 +142,8 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv ) { int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -160,7 +154,7 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv ) } } - if ( argc != globalUtilOptind ) + if ( argc != util_optind ) { goto usage; } @@ -168,14 +162,6 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv ) pAbc->TimeTotal += pAbc->TimeCommand; fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n", (float)pAbc->TimeCommand / CLOCKS_PER_SEC, (float)pAbc->TimeTotal / CLOCKS_PER_SEC ); -/* - { - FILE * pTable; - pTable = fopen( "runtimes.txt", "a+" ); - fprintf( pTable, "%4.2f\n", (float)pAbc->TimeCommand / CLOCKS_PER_SEC ); - fclose( pTable ); - } -*/ pAbc->TimeCommand = 0; return 0; @@ -202,8 +188,8 @@ int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv ) int c; int n = 1; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "hn" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "hn" ) ) != EOF ) { switch ( c ) { @@ -218,7 +204,7 @@ int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv ) } } - for ( i = globalUtilOptind; i < argc; i++ ) + for ( i = util_optind; i < argc; i++ ) fprintf( pAbc->Out, "%s ", argv[i] ); if ( n ) fprintf( pAbc->Out, "\n" ); @@ -248,8 +234,8 @@ int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv ) { int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "hs" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "hs" ) ) != EOF ) { switch ( c ) { @@ -264,7 +250,7 @@ int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv ) } } - if ( argc != globalUtilOptind ) + if ( argc != util_optind ) goto usage; return -1; @@ -308,8 +294,8 @@ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv ) int i, c, num, size; num = 20; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -323,8 +309,8 @@ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; // get the number of commands to print - if ( argc == globalUtilOptind + 1 ) - num = atoi(argv[globalUtilOptind]); + if ( argc == util_optind + 1 ) + num = atoi(argv[util_optind]); // print the commands size = pAbc->aHistory->nSize; num = ( num < size ) ? num : size; @@ -356,8 +342,8 @@ int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv ) char *key, *value; int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -413,8 +399,8 @@ int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv ) char *key, *value; int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -464,8 +450,8 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv ) int c; fPrintAll = 0; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "ah" ) ) != EOF ) { switch ( c ) { @@ -482,7 +468,7 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv ) } } - if ( argc != globalUtilOptind ) + if ( argc != util_optind ) goto usage; CmdCommandPrint( pAbc, fPrintAll ); @@ -517,37 +503,38 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) interactive = silent = prompt = echo = 0; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ipsxh" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "hipsx" ) ) != EOF ) { switch ( c ) { + case 'h': + goto usage; + break; case 'i': /* a hack to distinguish EOF from stdin */ interactive = 1; break; case 'p': - prompt ^= 1; + prompt = 1; break; case 's': - silent ^= 1; + silent = 1; break; case 'x': echo ^= 1; break; - case 'h': - goto usage; default: goto usage; } } /* added to avoid core-dumping when no script file is specified */ - if ( argc == globalUtilOptind ) + if ( argc == util_optind ) { goto usage; } - lp_file_index = globalUtilOptind; + lp_file_index = util_optind; lp_count = 0; /* @@ -581,7 +568,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) } else { - prompt_string = NULL; + prompt_string = NIL( char ); } /* clear errors -- e.g., EOF reached from stdin */ @@ -615,7 +602,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) fprintf( pAbc->Out, "abc - > %s", line ); } command = CmdHistorySubstitution( pAbc, line, &did_subst ); - if ( command == NULL ) + if ( command == NIL( char ) ) { status = 1; break; @@ -633,8 +620,8 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) } if ( interactive && *line != '\0' ) { - Cmd_HistoryAddCommand( pAbc, Extra_UtilStrsav(line) ); - if ( pAbc->Hst != NULL ) + Cmd_HistoryAddCommand( pAbc, util_strsav(line) ); + if ( pAbc->Hst != NIL( FILE ) ) { fprintf( pAbc->Hst, "%s\n", line ); ( void ) fflush( pAbc->Hst ); @@ -663,11 +650,11 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) return status; usage: - fprintf( pAbc->Err, "usage: source [-psxh] <file_name>\n" ); - fprintf( pAbc->Err, "\t-p supply prompt before reading each line [default = %s]\n", prompt? "yes": "no" ); - fprintf( pAbc->Err, "\t-s silently ignore nonexistant file [default = %s]\n", silent? "yes": "no" ); - fprintf( pAbc->Err, "\t-x echo each line as it is executed [default = %s]\n", echo? "yes": "no" ); + fprintf( pAbc->Err, "usage: source [-h] [-p] [-s] [-x] file_name\n" ); fprintf( pAbc->Err, "\t-h print the command usage\n" ); + fprintf( pAbc->Err, "\t-p supply prompt before reading each line\n" ); + fprintf( pAbc->Err, "\t-s silently ignore nonexistant file\n" ); + fprintf( pAbc->Err, "\t-x echo each line as it is executed\n" ); return 1; } @@ -687,8 +674,8 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) char *flag_value, *key, *value; int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -716,9 +703,9 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) FREE( value ); } - flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] ); -// flag_value = argc == 2 ? NULL : Extra_UtilStrsav(argv[2]); - st_insert( pAbc->tFlags, Extra_UtilStrsav(argv[1]), flag_value ); + flag_value = argc == 2 ? util_strsav( "" ) : util_strsav( argv[2] ); +// flag_value = argc == 2 ? NULL : util_strsav(argv[2]); + st_insert( pAbc->tFlags, util_strsav(argv[1]), flag_value ); if ( strcmp( argv[1], "abcout" ) == 0 ) { @@ -726,7 +713,7 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pAbc->Out ); if ( strcmp( flag_value, "" ) == 0 ) flag_value = "-"; - pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 ); + pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 ); if ( pAbc->Out == NULL ) pAbc->Out = stdout; #if HAVE_SETVBUF @@ -739,7 +726,7 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pAbc->Err ); if ( strcmp( flag_value, "" ) == 0 ) flag_value = "-"; - pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 ); + pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 ); if ( pAbc->Err == NULL ) pAbc->Err = stderr; #if HAVE_SETVBUF @@ -748,15 +735,15 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) } if ( strcmp( argv[1], "history" ) == 0 ) { - if ( pAbc->Hst != NULL ) + if ( pAbc->Hst != NIL( FILE ) ) fclose( pAbc->Hst ); if ( strcmp( flag_value, "" ) == 0 ) - pAbc->Hst = NULL; + pAbc->Hst = NIL( FILE ); else { - pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 ); + pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 ); if ( pAbc->Hst == NULL ) - pAbc->Hst = NULL; + pAbc->Hst = NIL( FILE ); } } return 0; @@ -787,8 +774,8 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) char *key, *value; int c; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -880,8 +867,8 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv ) } - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -992,8 +979,8 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; } - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + util_getopt_reset(); + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -1034,7 +1021,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv ) Abc_Ntk_t * pNtkTemp; int id, c; - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -1045,12 +1032,12 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } } - if (globalUtilOptind <= argc) { + if (util_optind <= argc) { pNtkTemp = pAbc->pNtk; pAbc->pNtk = pAbc->pNtkSaved; pAbc->pNtkSaved = pNtkTemp; } - id = atoi(argv[globalUtilOptind]); + id = atoi(argv[util_optind]); pNtkTemp = Cmd_HistoryGetSnapshot(pAbc, id); if (!pNtkTemp) fprintf( pAbc->Err, "Snapshot %d does not exist\n", id); @@ -1108,8 +1095,8 @@ int CmdCommandLs( Abc_Frame_t * pAbc, int argc, char **argv ) int fPrintedNewLine; char c; - Extra_UtilGetoptReset(); - while ( (c = Extra_UtilGetopt(argc, argv, "lb") ) != EOF ) + util_getopt_reset(); + while ( (c = util_getopt(argc, argv, "lb") ) != EOF ) { switch (c) { @@ -1217,7 +1204,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) char * pSisName; int i; - pNtk = Abc_FrameReadNtk(pAbc); + pNtk = Abc_FrameReadNet(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); @@ -1258,21 +1245,8 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) } fclose( pFile ); - if ( Abc_NtkIsMappedLogic(pNtk) ) - { - Abc_NtkMapToSop(pNtk); - printf( "The current network is unmapped before calling SIS.\n" ); - } - // write out the current network - if ( Abc_NtkIsLogic(pNtk) ) - Abc_NtkToSop(pNtk, 0); - pNetlist = Abc_NtkToNetlist(pNtk); - if ( pNetlist == NULL ) - { - fprintf( pErr, "Cannot produce the intermediate network.\n" ); - goto usage; - } + pNetlist = Abc_NtkLogicToNetlist(pNtk); Io_WriteBlif( pNetlist, "_sis_in.blif", 1 ); Abc_NtkDelete( pNetlist ); @@ -1309,12 +1283,12 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pFile ); // set the new network - pNtkNew = Io_Read( "_sis_out.blif", IO_FILE_BLIF, 1 ); + pNtkNew = Io_Read( "_sis_out.blif", 1 ); // set the original spec of the new network if ( pNtk->pSpec ) { FREE( pNtkNew->pSpec ); - pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); + pNtkNew->pSpec = util_strsav( pNtk->pSpec ); } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew ); @@ -1360,7 +1334,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) char * pMvsisName; int i; - pNtk = Abc_FrameReadNtk(pAbc); + pNtk = Abc_FrameReadNet(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); @@ -1401,21 +1375,9 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) } fclose( pFile ); - if ( Abc_NtkIsMappedLogic(pNtk) ) - { - Abc_NtkMapToSop(pNtk); - printf( "The current network is unmapped before calling MVSIS.\n" ); - } // write out the current network - if ( Abc_NtkIsLogic(pNtk) ) - Abc_NtkToSop(pNtk, 0); - pNetlist = Abc_NtkToNetlist(pNtk); - if ( pNetlist == NULL ) - { - fprintf( pErr, "Cannot produce the intermediate network.\n" ); - goto usage; - } + pNetlist = Abc_NtkLogicToNetlist(pNtk); Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1 ); Abc_NtkDelete( pNetlist ); @@ -1452,12 +1414,12 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) fclose( pFile ); // set the new network - pNtkNew = Io_Read( "_mvsis_out.blif", IO_FILE_BLIF, 1 ); + pNtkNew = Io_Read( "_mvsis_out.blif", 1 ); // set the original spec of the new network if ( pNtk->pSpec ) { FREE( pNtkNew->pSpec ); - pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); + pNtkNew->pSpec = util_strsav( pNtk->pSpec ); } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew ); @@ -1481,192 +1443,6 @@ usage: } -/**Function******************************************************************** - - Synopsis [Calls Capo internally.] - - Description [] - - SideEffects [] - - SeeAlso [] - -******************************************************************************/ -int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv ) -{ - FILE * pFile; - FILE * pOut, * pErr; - Abc_Ntk_t * pNtk, * pNetlist; - char Command[1000], Buffer[100]; - char * pProgNameCapoWin = "capo.exe"; - char * pProgNameCapoUnix = "capo"; - char * pProgNameGnuplotWin = "wgnuplot.exe"; - char * pProgNameGnuplotUnix = "gnuplot"; - char * pProgNameCapo; - char * pProgNameGnuplot; - char * pPlotFileName; - int i; - - pNtk = Abc_FrameReadNtk(pAbc); - pOut = Abc_FrameReadOut(pAbc); - pErr = Abc_FrameReadErr(pAbc); - - if ( pNtk == NULL ) - { - fprintf( pErr, "Empty network.\n" ); - goto usage; - } - - if ( strcmp( argv[0], "capo" ) != 0 ) - { - fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] ); - goto usage; - } - - if ( argc > 1 ) - { - if ( strcmp( argv[1], "-h" ) == 0 ) - goto usage; - if ( strcmp( argv[1], "-?" ) == 0 ) - goto usage; - } - - // get the names from the resource file - if ( Cmd_FlagReadByName(pAbc, "capowin") ) - pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin"); - if ( Cmd_FlagReadByName(pAbc, "capounix") ) - pProgNameCapoUnix = Cmd_FlagReadByName(pAbc, "capounix"); - - // check if capo is available - if ( (pFile = fopen( pProgNameCapoWin, "r" )) ) - pProgNameCapo = pProgNameCapoWin; - else if ( (pFile = fopen( pProgNameCapoUnix, "r" )) ) - pProgNameCapo = pProgNameCapoUnix; - else if ( pFile == NULL ) - { - fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix ); - goto usage; - } - fclose( pFile ); - - if ( Abc_NtkIsMappedLogic(pNtk) ) - { - Abc_NtkMapToSop(pNtk); - printf( "The current network is unmapped before calling Capo.\n" ); - } - - // write out the current network - if ( Abc_NtkIsLogic(pNtk) ) - Abc_NtkToSop(pNtk, 0); - pNetlist = Abc_NtkToNetlist(pNtk); - if ( pNetlist == NULL ) - { - fprintf( pErr, "Cannot produce the intermediate network.\n" ); - goto usage; - } - Io_WriteBlif( pNetlist, "_capo_in.blif", 1 ); - Abc_NtkDelete( pNetlist ); - - // create the file for Capo - sprintf( Command, "%s -f _capo_in.blif -log out.txt ", pProgNameCapo ); - pPlotFileName = NULL; - for ( i = 1; i < argc; i++ ) - { - sprintf( Buffer, " %s", argv[i] ); - strcat( Command, Buffer ); - if ( !strcmp( argv[i], "-plot" ) ) - pPlotFileName = argv[i+1]; - } - - // call Capo - if ( system( Command ) ) - { - fprintf( pErr, "The following command has returned non-zero exit status:\n" ); - fprintf( pErr, "\"%s\"\n", Command ); - unlink( "_capo_in.blif" ); - goto usage; - } - // remove temporary networks - unlink( "_capo_in.blif" ); - if ( pPlotFileName == NULL ) - return 0; - - // get the file name - sprintf( Buffer, "%s.plt", pPlotFileName ); - pPlotFileName = Buffer; - - // read in the Capo plotting output - if ( (pFile = fopen( pPlotFileName, "r" )) == NULL ) - { - fprintf( pErr, "Cannot open the plot file \"%s\".\n\n", pPlotFileName ); - goto usage; - } - fclose( pFile ); - - // get the names from the plotting software - if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") ) - pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin"); - if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") ) - pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix"); - - // check if Gnuplot is available - if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) ) - pProgNameGnuplot = pProgNameGnuplotWin; - else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) ) - pProgNameGnuplot = pProgNameGnuplotUnix; - else if ( pFile == NULL ) - { - fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix ); - goto usage; - } - fclose( pFile ); - - // spawn the viewer -#ifdef WIN32 - if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 ) - { - fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot ); - goto usage; - } -#else - { - sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName ); - if ( system( Command ) == -1 ) - { - fprintf( stdout, "Cannot execute \"%s\".\n", Command ); - goto usage; - } - } -#endif - - // remove temporary networks -// unlink( pPlotFileName ); - return 0; - -usage: - fprintf( pErr, "\n" ); - fprintf( pErr, "Usage: capo [-h] <com>\n"); - fprintf( pErr, " peforms placement of the current network using Capo\n" ); - fprintf( pErr, " a Capo binary should be present in the same directory\n" ); - fprintf( pErr, " (if plotting, the Gnuplot binary should also be present)\n" ); - fprintf( pErr, " -h : print the command usage\n" ); - fprintf( pErr, " <com> : a Capo command\n" ); - fprintf( pErr, " Example 1: capo\n" ); - fprintf( pErr, " (performs placement with default options)\n" ); - fprintf( pErr, " Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" ); - fprintf( pErr, " (specifies the aspect ratio [default = 1.0] and\n" ); - fprintf( pErr, " the whitespace percentage [0%%; 100%%) [default = 15%%])\n" ); - fprintf( pErr, " Example 3: capo -plot <base_fileName>\n" ); - fprintf( pErr, " (produces <base_fileName.plt> and visualize it using Gnuplot)\n" ); - fprintf( pErr, " Example 4: capo -help\n" ); - fprintf( pErr, " (prints the default usage message of the Capo binary)\n" ); - fprintf( pErr, " Please refer to the Capo webpage for additional information:\n" ); - fprintf( pErr, " http://vlsicad.eecs.umich.edu/BK/PDtools/\n" ); - return 1; // error exit -} - - - //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmd.h b/src/base/cmd/cmd.h index 030b77e8..6389afae 100644 --- a/src/base/cmd/cmd.h +++ b/src/base/cmd/cmd.h @@ -21,10 +21,6 @@ #ifndef __CMD_H__ #define __CMD_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,11 +37,11 @@ typedef struct MvCommand Abc_Command; // one command typedef struct MvAlias Abc_Alias; // one alias //////////////////////////////////////////////////////////////////////// -/// MACRO DEFINITIONS /// +/// MACRO DEFITIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /*=== cmd.c ===========================================================*/ @@ -61,13 +57,9 @@ extern void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * v /*=== cmdHist.c ========================================================*/ extern void Cmd_HistoryAddCommand( Abc_Frame_t * pAbc, char * command ); -#ifdef __cplusplus -} -#endif - -#endif - //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// +#endif + diff --git a/src/base/cmd/cmdAlias.c b/src/base/cmd/cmdAlias.c index 0ec3feea..59a8b87e 100644 --- a/src/base/cmd/cmdAlias.c +++ b/src/base/cmd/cmdAlias.c @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* @@ -45,11 +45,11 @@ void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** arg int fStatus, i; pAlias = ALLOC(Abc_Alias, 1); - pAlias->sName = Extra_UtilStrsav(sName); + pAlias->sName = util_strsav(sName); pAlias->argc = argc; pAlias->argv = ALLOC(char *, pAlias->argc); for(i = 0; i < argc; i++) - pAlias->argv[i] = Extra_UtilStrsav(argv[i]); + pAlias->argv[i] = util_strsav(argv[i]); fStatus = st_insert( pAbc->tAliases, pAlias->sName, (char *) pAlias ); assert(!fStatus); } diff --git a/src/base/cmd/cmdApi.c b/src/base/cmd/cmdApi.c index 7167e22b..8dd67637 100644 --- a/src/base/cmd/cmdApi.c +++ b/src/base/cmd/cmdApi.c @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* @@ -57,8 +57,8 @@ void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFu // create the new command pCommand = ALLOC( Abc_Command, 1 ); - pCommand->sName = Extra_UtilStrsav( sName ); - pCommand->sGroup = Extra_UtilStrsav( sGroup ); + pCommand->sName = util_strsav( sName ); + pCommand->sGroup = util_strsav( sGroup ); pCommand->pFunc = pFunc; pCommand->fChange = fChanges; fStatus = st_insert( pAbc->tCommands, sName, (char *)pCommand ); diff --git a/src/base/cmd/cmdFlag.c b/src/base/cmd/cmdFlag.c index 993f2a49..63a0389d 100644 --- a/src/base/cmd/cmdFlag.c +++ b/src/base/cmd/cmdFlag.c @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// @@ -35,7 +35,8 @@ Description [The command parser maintains a table of named values. These are manipulated using the 'set' and 'unset' commands. The value of the - named flag is returned, or NULL is returned if the flag has not been set.] + named flag is returned, or NIL(char) is returned if the flag has not been + set.] SideEffects [] @@ -64,9 +65,9 @@ void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value ) if ( !key ) return; if ( value ) - newValue = Extra_UtilStrsav(value); + newValue = util_strsav(value); else - newValue = Extra_UtilStrsav(""); + newValue = util_strsav(""); // newValue = NULL; if ( st_delete(pAbc->tFlags, &key, &oldValue) ) FREE(oldValue); diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c index fae9382d..5b46ea00 100644 --- a/src/base/cmd/cmdHist.c +++ b/src/base/cmd/cmdHist.c @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* @@ -43,11 +43,11 @@ ***********************************************************************/ void Cmd_HistoryAddCommand( Abc_Frame_t * p, char * command ) { - static char Buffer[MAX_STR]; + char Buffer[500]; strcpy( Buffer, command ); if ( command[strlen(command)-1] != '\n' ) strcat( Buffer, "\n" ); - Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) ); + Vec_PtrPush( p->aHistory, util_strsav(Buffer) ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdInt.h b/src/base/cmd/cmdInt.h index c082bd94..d110b634 100644 --- a/src/base/cmd/cmdInt.h +++ b/src/base/cmd/cmdInt.h @@ -52,11 +52,11 @@ struct MvAlias }; //////////////////////////////////////////////////////////////////////// -/// MACRO DEFINITIONS /// +/// MACRO DEFITIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /*=== cmdAlias.c =============-========================================*/ diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 47e54bb3..71396d3e 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -30,7 +30,7 @@ static int CmdCommandPrintCompare( Abc_Command ** ppC1, Abc_Command ** ppC2 ); //////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// +/// FUNCTION DEFITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* @@ -121,10 +121,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int argc, char **argv ) } // execute the command - clk = Extra_CpuTime(); + clk = util_cpu_time(); pFunc = (int (*)(Abc_Frame_t *, int, char **))pCommand->pFunc; fError = (*pFunc)( pAbc, argc, argv ); - pAbc->TimeCommand += (Extra_CpuTime() - clk); + pAbc->TimeCommand += (util_cpu_time() - clk); // automatic execution of arbitrary command after each command // usually this is a passive command ... @@ -245,7 +245,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) argc = *argcp; argv = *argvp; stopit = 0; - for ( ; *loop < 200; ( *loop )++ ) + for ( ; *loop < 20; ( *loop )++ ) { if ( argc == 0 ) return 0; @@ -270,7 +270,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) } for ( i = 1; i <= added; i++ ) { - argv[i] = NULL; + argv[i] = NIL( char ); } argc += added; } @@ -278,7 +278,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) for ( i = 0, offset = 0; i < alias->argc; i++, offset++ ) { arg = CmdHistorySubstitution( pAbc, alias->argv[i], &did_subst ); - if ( arg == NULL ) + if ( arg == NIL( char ) ) { *argcp = argc; *argvp = argv; @@ -383,11 +383,11 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi if (strcmp(sFileName, "-") == 0) { if (strcmp(sMode, "w") == 0) { - sRealName = Extra_UtilStrsav( "stdout" ); + sRealName = util_strsav( "stdout" ); pFile = stdout; } else { - sRealName = Extra_UtilStrsav( "stdin" ); + sRealName = util_strsav( "stdin" ); pFile = stdin; } } @@ -403,24 +403,24 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi sPathAll = NULL; } else if ( sPathUsr == NULL ) { - sPathAll = Extra_UtilStrsav( sPathLib ); + sPathAll = util_strsav( sPathLib ); } else if ( sPathLib == NULL ) { - sPathAll = Extra_UtilStrsav( sPathUsr ); + sPathAll = util_strsav( sPathUsr ); } else { sPathAll = ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 ); sprintf( sPathAll, "%s:%s",sPathUsr, sPathLib ); } - if ( sPathAll != NULL ) { - sRealName = Extra_UtilFileSearch(sFileName, sPathAll, "r"); + if ( sPathAll != NIL(char) ) { + sRealName = util_file_search(sFileName, sPathAll, "r"); FREE( sPathAll ); } } - if (sRealName == NULL) { - sRealName = Extra_UtilTildeExpand(sFileName); + if (sRealName == NIL(char)) { + sRealName = util_tilde_expand(sFileName); } - if ((pFile = fopen(sRealName, sMode)) == NULL) { + if ((pFile = fopen(sRealName, sMode)) == NIL(FILE)) { if (! silent) { perror(sRealName); } |