ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmdInt.h File Reference
#include "base/main/mainInt.h"
#include "cmd.h"
Include dependency graph for cmdInt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MvCommand
 INCLUDES ///. More...
 
struct  MvAlias
 

Functions

void CmdCommandAliasAdd (Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
 MACRO DEFINITIONS ///.
 
void CmdCommandAliasPrint (Abc_Frame_t *pAbc, Abc_Alias *pAlias)
 
char * CmdCommandAliasLookup (Abc_Frame_t *pAbc, char *sCommand)
 
void CmdCommandAliasFree (Abc_Alias *p)
 
int CmdCommandDispatch (Abc_Frame_t *pAbc, int *argc, char ***argv)
 
const char * CmdSplitLine (Abc_Frame_t *pAbc, const char *sCommand, int *argc, char ***argv)
 
int CmdApplyAlias (Abc_Frame_t *pAbc, int *argc, char ***argv, int *loop)
 
char * CmdHistorySubstitution (Abc_Frame_t *pAbc, char *line, int *changed)
 
FILE * CmdFileOpen (Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
 
void CmdFreeArgv (int argc, char **argv)
 
char ** CmdAddToArgv (int argc, char **argv)
 
void CmdCommandFree (Abc_Command *pCommand)
 
void CmdCommandPrint (Abc_Frame_t *pAbc, int fPrintAll, int fDetails)
 
void CmdPrintTable (st__table *tTable, int fAliases)
 

Function Documentation

◆ CmdAddToArgv()

char ** CmdAddToArgv ( int argc,
char ** argv )
extern

Function*************************************************************

Synopsis [Frees the previously allocated argv array.]

Description []

SideEffects []

SeeAlso []

Definition at line 516 of file cmdUtils.c.

517{
518 char ** argv2;
519 int i;
520 argv2 = ABC_ALLOC( char *, argc + 1 );
521 argv2[0] = Extra_UtilStrsav( "read" );
522// argv2[0] = Extra_UtilStrsav( "&r" );
523 for ( i = 0; i < argc; i++ )
524 argv2[i+1] = Extra_UtilStrsav( argv[i] );
525 return argv2;
526}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
char * Extra_UtilStrsav(const char *s)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdApplyAlias()

int CmdApplyAlias ( Abc_Frame_t * pAbc,
int * argcp,
char *** argvp,
int * loop )
extern

Function*************************************************************

Synopsis [Replaces parts of the command line string by aliases if given.]

Description []

SideEffects []

SeeAlso []

Definition at line 271 of file cmdUtils.c.

272{
273 int i, argc, stopit, added, offset, did_subst, subst, fError, newc, j;
274 const char *arg;
275 char **argv, **newv;
276 Abc_Alias *alias;
277
278 argc = *argcp;
279 argv = *argvp;
280 stopit = 0;
281 for ( ; *loop < 200; ( *loop )++ )
282 {
283 if ( argc == 0 )
284 return 0;
285 if ( stopit != 0 || st__lookup( pAbc->tAliases, argv[0], (char **) &alias ) == 0 )
286 {
287 return 0;
288 }
289 if ( strcmp( argv[0], alias->argv[0] ) == 0 )
290 {
291 stopit = 1;
292 }
293 ABC_FREE( argv[0] );
294 added = alias->argc - 1;
295
296 /* shift all the arguments to the right */
297 if ( added != 0 )
298 {
299 argv = ABC_REALLOC( char *, argv, argc + added );
300 for ( i = argc - 1; i >= 1; i-- )
301 {
302 argv[i + added] = argv[i];
303 }
304 for ( i = 1; i <= added; i++ )
305 {
306 argv[i] = NULL;
307 }
308 argc += added;
309 }
310 subst = 0;
311 for ( i = 0, offset = 0; i < alias->argc; i++, offset++ )
312 {
313 arg = CmdHistorySubstitution( pAbc, alias->argv[i], &did_subst );
314 if ( arg == NULL )
315 {
316 *argcp = argc;
317 *argvp = argv;
318 return ( 1 );
319 }
320 if ( did_subst != 0 )
321 {
322 subst = 1;
323 }
324 fError = 0;
325 do
326 {
327 arg = CmdSplitLine( pAbc, arg, &newc, &newv );
328 /*
329 * If there's a complete `;' terminated command in `arg',
330 * when split_line() returns arg[0] != '\0'.
331 */
332 if ( arg[0] == '\0' )
333 { /* just a bunch of words */
334 break;
335 }
336 fError = CmdApplyAlias( pAbc, &newc, &newv, loop );
337 if ( fError == 0 )
338 {
339 fError = CmdCommandDispatch( pAbc, &newc, &newv );
340 }
341 CmdFreeArgv( newc, newv );
342 }
343 while ( fError == 0 );
344 if ( fError != 0 )
345 {
346 *argcp = argc;
347 *argvp = argv;
348 return ( 1 );
349 }
350 added = newc - 1;
351 if ( added != 0 )
352 {
353 argv = ABC_REALLOC( char *, argv, argc + added );
354 for ( j = argc - 1; j > offset; j-- )
355 {
356 argv[j + added] = argv[j];
357 }
358 argc += added;
359 }
360 for ( j = 0; j <= added; j++ )
361 {
362 argv[j + offset] = newv[j];
363 }
364 ABC_FREE( newv );
365 offset += added;
366 }
367 if ( subst == 1 )
368 {
369 for ( i = offset; i < argc; i++ )
370 {
371 ABC_FREE( argv[i] );
372 }
373 argc = offset;
374 }
375 *argcp = argc;
376 *argvp = argv;
377 }
378
379 fprintf( pAbc->Err, "** cmd warning: alias loop\n" );
380 return 1;
381}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
#define ABC_FREE(obj)
Definition abc_global.h:267
int CmdCommandDispatch(Abc_Frame_t *pAbc, int *pargc, char ***pargv)
Definition cmdUtils.c:97
const char * CmdSplitLine(Abc_Frame_t *pAbc, const char *sCommand, int *argc, char ***argv)
Definition cmdUtils.c:185
char * CmdHistorySubstitution(Abc_Frame_t *pAbc, char *line, int *changed)
Definition cmdUtils.c:394
int CmdApplyAlias(Abc_Frame_t *pAbc, int *argcp, char ***argvp, int *loop)
Definition cmdUtils.c:271
void CmdFreeArgv(int argc, char **argv)
Definition cmdUtils.c:489
struct MvAlias Abc_Alias
Definition cmd.h:40
int st__lookup(st__table *table, const char *key, char **value)
Definition st.c:114
int strcmp()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdCommandAliasAdd()

void CmdCommandAliasAdd ( Abc_Frame_t * pAbc,
char * sName,
int argc,
char ** argv )
extern

MACRO DEFINITIONS ///.

FUNCTION DEFINITIONS ///

MACRO DEFINITIONS ///.

CFile****************************************************************

FileName [cmdAlias.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures dealing with aliases in the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmdAlias.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file cmdAlias.c.

47{
48 Abc_Alias * pAlias;
49 int fStatus, i;
50
51 pAlias = ABC_ALLOC(Abc_Alias, 1);
52 pAlias->sName = Extra_UtilStrsav(sName);
53 pAlias->argc = argc;
54 pAlias->argv = ABC_ALLOC(char *, pAlias->argc);
55 for(i = 0; i < argc; i++)
56 pAlias->argv[i] = Extra_UtilStrsav(argv[i]);
57 fStatus = st__insert( pAbc->tAliases, pAlias->sName, (char *) pAlias );
58 assert(!fStatus);
59}
int st__insert(st__table *table, const char *key, char *value)
Definition st.c:171
char * sName
Definition cmdInt.h:53
char ** argv
Definition cmdInt.h:55
int argc
Definition cmdInt.h:54
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ CmdCommandAliasFree()

void CmdCommandAliasFree ( Abc_Alias * pAlias)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file cmdAlias.c.

114{
115 CmdFreeArgv( pAlias->argc, pAlias->argv );
116 ABC_FREE(pAlias->sName);
117 ABC_FREE(pAlias);
118}
void CmdFreeArgv(int argc, char **argv)
Definition cmdUtils.c:489
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdCommandAliasLookup()

char * CmdCommandAliasLookup ( Abc_Frame_t * pAbc,
char * sCommand )
extern

Function********************************************************************

Synopsis [required]

Description [optional]

SideEffects [required]

SeeAlso [optional]

Definition at line 92 of file cmdAlias.c.

93{
94 Abc_Alias * pAlias;
95 char * value;
96 if (! st__lookup( pAbc->tAliases, sCommand, &value))
97 return sCommand;
98 pAlias = (Abc_Alias *) value;
99 return pAlias->argv[0];
100}
ABC_NAMESPACE_IMPL_START typedef signed char value
Here is the call graph for this function:

◆ CmdCommandAliasPrint()

void CmdCommandAliasPrint ( Abc_Frame_t * pAbc,
Abc_Alias * pAlias )
extern

Function********************************************************************

Synopsis [required]

Description [optional]

SideEffects [required]

SeeAlso [optional]

Definition at line 72 of file cmdAlias.c.

73{
74 int i;
75 fprintf(pAbc->Out, "%-15s", pAlias->sName);
76 for(i = 0; i < pAlias->argc; i++)
77 fprintf( pAbc->Out, " %s", pAlias->argv[i] );
78 fprintf( pAbc->Out, "\n" );
79}
Here is the caller graph for this function:

◆ CmdCommandDispatch()

int CmdCommandDispatch ( Abc_Frame_t * pAbc,
int * pargc,
char *** pargv )
extern

Function*************************************************************

Synopsis [Executes one command.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file cmdUtils.c.

98{
99 int argc = *pargc;
100 char ** argv = *pargv;
101 char ** argv2;
102
103 Abc_Ntk_t * pNetCopy;
104 int (*pFunc) ( Abc_Frame_t *, int, char ** );
105 Abc_Command * pCommand;
106 char * value;
107 int fError;
108 double clk;
109
110 if ( argc == 0 )
111 return 0;
112
113 if ( cmdCheckShellEscape( pAbc, argc, argv ) == 1 )
114 return 0;
115
116 // get the command
117 if ( ! st__lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) )
118 { // the command is not in the table
119 // if there is only one word with an extension, assume this is file to be read
120 if ( argc == 1 && strstr( argv[0], "." ) )
121 {
122 // add command 'read' assuming that this is the file name
123 argv2 = CmdAddToArgv( argc, argv );
124 CmdFreeArgv( argc, argv );
125 argc = argc+1;
126 argv = argv2;
127 *pargc = argc;
128 *pargv = argv;
129 if ( ! st__lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) )
130 assert( 0 );
131 }
132 else
133 {
134 fprintf( pAbc->Err, "** cmd error: unknown command '%s'\n", argv[0] );
135 fprintf( pAbc->Err, "(this is likely caused by using an alias defined in \"abc.rc\"\n" );
136 fprintf( pAbc->Err, "without having this file in the current or parent directory)\n" );
137 return 1;
138 }
139 }
140
141 // get the backup network if the command is going to change the network
142 if ( pCommand->fChange )
143 {
144 if ( pAbc->pNtkCur && Abc_FrameIsFlagEnabled( "backup" ) )
145 {
146 pNetCopy = Abc_NtkDup( pAbc->pNtkCur );
147 Abc_FrameSetCurrentNetwork( pAbc, pNetCopy );
148 // swap the current network and the backup network
149 // to prevent the effect of resetting the short names
151 }
152 }
153
154 // execute the command
155 clk = Extra_CpuTimeDouble();
156 pFunc = (int (*)(Abc_Frame_t *, int, char **))pCommand->pFunc;
157 fError = (*pFunc)( pAbc, argc, argv );
158 pAbc->TimeCommand += Extra_CpuTimeDouble() - clk;
159
160 // automatic execution of arbitrary command after each command
161 // usually this is a passive command ...
162 if ( fError == 0 && !pAbc->fAutoexac )
163 {
164 if ( st__lookup( pAbc->tFlags, "autoexec", &value ) )
165 {
166 pAbc->fAutoexac = 1;
167 fError = Cmd_CommandExecute( pAbc, value );
168 pAbc->fAutoexac = 0;
169 }
170 }
171 return fError;
172}
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL int Abc_FrameIsFlagEnabled(char *pFlag)
Definition mainFrame.c:138
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition mainFrame.c:441
ABC_DLL void Abc_FrameSwapCurrentAndBackup(Abc_Frame_t *p)
Definition mainFrame.c:496
int cmdCheckShellEscape(Abc_Frame_t *pAbc, int argc, char **argv)
FUNCTION DEFINITIONS ///.
Definition cmdUtils.c:51
char ** CmdAddToArgv(int argc, char **argv)
Definition cmdUtils.c:516
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition cmd.h:39
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
double Extra_CpuTimeDouble()
char * strstr()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CmdCommandFree()

void CmdCommandFree ( Abc_Command * pCommand)
extern

Function*************************************************************

Synopsis [Frees the previously allocated command.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file cmdUtils.c.

540{
541 ABC_FREE( pCommand->sGroup );
542 ABC_FREE( pCommand->sName );
543 ABC_FREE( pCommand );
544}
Here is the caller graph for this function:

◆ CmdCommandPrint()

void CmdCommandPrint ( Abc_Frame_t * pAbc,
int fPrintAll,
int fDetails )
extern

Function*************************************************************

Synopsis [Prints commands alphabetically by group.]

Description []

SideEffects []

SeeAlso []

Definition at line 558 of file cmdUtils.c.

559{
560 const char *key;
561 char *value;
562 st__generator * gen;
563 Abc_Command ** ppCommands;
564 Abc_Command * pCommands;
565 int nCommands, iGroupStart, i, j;
566 char * sGroupCur;
567 int LenghtMax, nColumns, iCom = 0;
568 FILE *backupErr = pAbc->Err;
569
570 // put all commands into one array
571 nCommands = st__count( pAbc->tCommands );
572 ppCommands = ABC_ALLOC( Abc_Command *, nCommands );
573 i = 0;
574 st__foreach_item( pAbc->tCommands, gen, &key, &value )
575 {
576 pCommands = (Abc_Command *)value;
577 if ( fPrintAll || pCommands->sName[0] != '_' )
578 ppCommands[i++] = pCommands;
579 }
580 nCommands = i;
581
582 // sort command by group and then by name, alphabetically
583 qsort( (void *)ppCommands, (size_t)nCommands, sizeof(Abc_Command *),
584 (int (*)(const void *, const void *)) CmdCommandPrintCompare );
585 assert( CmdCommandPrintCompare( ppCommands, ppCommands + nCommands - 1 ) <= 0 );
586
587 // get the longest command name
588 LenghtMax = 0;
589 for ( i = 0; i < nCommands; i++ )
590 if ( LenghtMax < (int)strlen(ppCommands[i]->sName) )
591 LenghtMax = (int)strlen(ppCommands[i]->sName);
592 // get the number of columns
593 nColumns = 79 / (LenghtMax + 2);
594
595 // print the starting message
596 fprintf( pAbc->Out, " Welcome to ABC compiled on %s %s!", __DATE__, __TIME__ );
597
598 // print the command by group
599 sGroupCur = NULL;
600 iGroupStart = 0;
601 pAbc->Err = pAbc->Out;
602 for ( i = 0; i < nCommands; i++ )
603 if ( sGroupCur && strcmp( sGroupCur, ppCommands[i]->sGroup ) == 0 )
604 { // this command belongs to the same group as the previous one
605 if ( iCom++ % nColumns == 0 )
606 fprintf( pAbc->Out, "\n" );
607 // print this command
608 fprintf( pAbc->Out, " %-*s", LenghtMax, ppCommands[i]->sName );
609 }
610 else
611 { // this command starts the new group of commands
612 // start the new group
613 if ( fDetails && i != iGroupStart )
614 { // print help messages for all commands in the previous groups
615 fprintf( pAbc->Out, "\n" );
616 for ( j = iGroupStart; j < i; j++ )
617 {
618 char *tmp_cmd;
619 fprintf( pAbc->Out, "\n" );
620 // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName );
621 tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4);
622 (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName);
623 (void) Cmd_CommandExecute( pAbc, tmp_cmd );
624 ABC_FREE(tmp_cmd);
625 }
626 fprintf( pAbc->Out, "\n" );
627 fprintf( pAbc->Out, " ----------------------------------------------------------------------" );
628 iGroupStart = i;
629 }
630 fprintf( pAbc->Out, "\n" );
631 fprintf( pAbc->Out, "\n" );
632 fprintf( pAbc->Out, "%s commands:\n", ppCommands[i]->sGroup );
633 // print this command
634 fprintf( pAbc->Out, " %-*s", LenghtMax, ppCommands[i]->sName );
635 // remember current command group
636 sGroupCur = ppCommands[i]->sGroup;
637 // reset the command counter
638 iCom = 1;
639 }
640 if ( fDetails && i != iGroupStart )
641 { // print help messages for all commands in the previous groups
642 fprintf( pAbc->Out, "\n" );
643 for ( j = iGroupStart; j < i; j++ )
644 {
645 char *tmp_cmd;
646 fprintf( pAbc->Out, "\n" );
647 // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName );
648 tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4);
649 (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName);
650 (void) Cmd_CommandExecute( pAbc, tmp_cmd );
651 ABC_FREE(tmp_cmd);
652 }
653 }
654 pAbc->Err = backupErr;
655 fprintf( pAbc->Out, "\n" );
656 ABC_FREE( ppCommands );
657}
enum keys key
Definition main.h:25
#define st__count(table)
Definition st.h:71
#define st__foreach_item(table, gen, key, value)
Definition st.h:107
int strlen()
char * sprintf()
Here is the call graph for this function:

◆ CmdFileOpen()

FILE * CmdFileOpen ( Abc_Frame_t * pAbc,
char * sFileName,
char * sMode,
char ** pFileNameReal,
int silent )
extern

Function*************************************************************

Synopsis [Opens the file with path (now, disabled).]

Description []

SideEffects []

SeeAlso []

Definition at line 412 of file cmdUtils.c.

413{
414 char * sRealName, * sPathUsr, * sPathLib, * sPathAll;
415 FILE * pFile;
416
417 if (strcmp(sFileName, "-") == 0) {
418 if (strcmp(sMode, "w") == 0) {
419 sRealName = Extra_UtilStrsav( "stdout" );
420 pFile = stdout;
421 }
422 else {
423 sRealName = Extra_UtilStrsav( "stdin" );
424 pFile = stdin;
425 }
426 }
427 else {
428 sRealName = NULL;
429 if (strcmp(sMode, "r") == 0) {
430
431 /* combine both pathes if exist */
432 sPathUsr = Cmd_FlagReadByName(pAbc,"open_path");
433 sPathLib = Cmd_FlagReadByName(pAbc,"lib_path");
434
435 if ( sPathUsr == NULL && sPathLib == NULL ) {
436 sPathAll = NULL;
437 }
438 else if ( sPathUsr == NULL ) {
439 sPathAll = Extra_UtilStrsav( sPathLib );
440 }
441 else if ( sPathLib == NULL ) {
442 sPathAll = Extra_UtilStrsav( sPathUsr );
443 }
444 else {
445 sPathAll = ABC_ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 );
446 sprintf( sPathAll, "%s:%s",sPathUsr, sPathLib );
447 }
448 if ( sPathAll != NULL ) {
449 sRealName = Extra_UtilFileSearch(sFileName, sPathAll, "r");
450 ABC_FREE( sPathAll );
451 }
452 }
453 if (sRealName == NULL) {
454 sRealName = Extra_UtilTildeExpand(sFileName);
455 }
456
457 if ((pFile = fopen(sRealName, sMode)) == NULL) {
458 if (! silent) {
459// perror(sRealName);
460 Abc_Print( 1, "Cannot open file \"%s\".\n", sRealName );
461 }
462 }
463 else
464 {
465 // print the path/name of the resource file 'abc.rc' that is being loaded
466 if ( !silent && strlen(sRealName) >= 6 && strcmp( sRealName + strlen(sRealName) - 6, "abc.rc" ) == 0 )
467 Abc_Print( 1, "Loading resource file \"%s\".\n", sRealName );
468 }
469 }
470 if ( pFileNameReal )
471 *pFileNameReal = sRealName;
472 else
473 ABC_FREE(sRealName);
474
475 return pFile;
476}
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition cmdFlag.c:47
char * Extra_UtilTildeExpand(char *fname)
char * Extra_UtilFileSearch(char *file, char *path, char *mode)
Here is the call graph for this function:

◆ CmdFreeArgv()

void CmdFreeArgv ( int argc,
char ** argv )
extern

Function*************************************************************

Synopsis [Frees the previously allocated argv array.]

Description []

SideEffects []

SeeAlso []

Definition at line 489 of file cmdUtils.c.

490{
491 int i;
492 for ( i = 0; i < argc; i++ )
493 ABC_FREE( argv[i] );
494 ABC_FREE( argv );
495}
Here is the caller graph for this function:

◆ CmdHistorySubstitution()

char * CmdHistorySubstitution ( Abc_Frame_t * pAbc,
char * line,
int * changed )
extern

Function*************************************************************

Synopsis [Performs history substitution (now, disabled).]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file cmdUtils.c.

395{
396 // as of today, no history substitution
397 *changed = 0;
398 return line;
399}
Here is the caller graph for this function:

◆ CmdPrintTable()

void CmdPrintTable ( st__table * tTable,
int fAliases )
extern

Function*************************************************************

Synopsis [Comparision function used for sorting commands.]

Description []

SideEffects []

SeeAlso []

Definition at line 726 of file cmdUtils.c.

727{
728 st__generator * gen;
729 const char ** ppNames;
730 const char * key;
731 char* value;
732 int nNames, i;
733
734 // collect keys in the array
735 ppNames = ABC_ALLOC( const char *, st__count(tTable) );
736 nNames = 0;
737 st__foreach_item( tTable, gen, &key, &value )
738 ppNames[nNames++] = key;
739
740 // sort array by name
741 qsort( (void *)ppNames, (size_t)nNames, sizeof(char *),
742 (int (*)(const void *, const void *))CmdNamePrintCompare );
743
744 // print in this order
745 for ( i = 0; i < nNames; i++ )
746 {
747 st__lookup( tTable, ppNames[i], &value );
748 if ( fAliases )
750 else
751 fprintf( stdout, "%-15s %-15s\n", ppNames[i], value );
752 }
753 ABC_FREE( ppNames );
754}
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
Definition cmdAlias.c:72
int CmdNamePrintCompare(char **ppC1, char **ppC2)
Definition cmdUtils.c:710
Here is the call graph for this function:

◆ CmdSplitLine()

const char * CmdSplitLine ( Abc_Frame_t * pAbc,
const char * sCommand,
int * argc,
char *** argv )
extern

Function*************************************************************

Synopsis [Splits the command line string into individual commands.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file cmdUtils.c.

186{
187 const char *p, *start;
188 char c;
189 int i, j;
190 char *new_arg;
191 Vec_Ptr_t * vArgs;
192 int single_quote, double_quote;
193
194 vArgs = Vec_PtrAlloc( 10 );
195
196 p = sCommand;
197 for ( ;; )
198 {
199 // skip leading white space
200 while ( isspace( ( int ) *p ) )
201 {
202 p++;
203 }
204
205 // skip until end of this token
206 single_quote = double_quote = 0;
207 for ( start = p; ( c = *p ) != '\0'; p++ )
208 {
209 if ( c == ';' || c == '#' || isspace( ( int ) c ) )
210 {
211 if ( !single_quote && !double_quote )
212 {
213 break;
214 }
215 }
216 if ( c == '\'' )
217 {
218 single_quote = !single_quote;
219 }
220 if ( c == '"' )
221 {
222 double_quote = !double_quote;
223 }
224 }
225 if ( single_quote || double_quote )
226 {
227 ( void ) fprintf( pAbc->Err, "** cmd warning: ignoring unbalanced quote ...\n" );
228 }
229 if ( start == p )
230 break;
231
232 new_arg = ABC_ALLOC( char, p - start + 1 );
233 j = 0;
234 for ( i = 0; i < p - start; i++ )
235 {
236 c = start[i];
237 if ( ( c != '\'' ) && ( c != '\"' ) )
238 {
239 new_arg[j++] = isspace( ( int ) c ) ? ' ' : start[i];
240 }
241 }
242 new_arg[j] = '\0';
243 Vec_PtrPush( vArgs, new_arg );
244 }
245
246 *argc = vArgs->nSize;
247 *argv = (char **)Vec_PtrReleaseArray( vArgs );
248 Vec_PtrFree( vArgs );
249 if ( *p == ';' )
250 {
251 p++;
252 }
253 else if ( *p == '#' )
254 {
255 for ( ; *p != 0; p++ ); // skip to end of line
256 }
257 return p;
258}
Cube * p
Definition exorList.c:222
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the caller graph for this function: