summaryrefslogtreecommitdiffstats
path: root/src/base/cmd/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/cmd/cmd.c')
-rw-r--r--src/base/cmd/cmd.c360
1 files changed, 68 insertions, 292 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 ///
////////////////////////////////////////////////////////////////////////