cmdAlias.c 3.36 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**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 $]

***********************************************************************/

21
#include "base/abc/abc.h"
Alan Mishchenko committed
22 23
#include "cmdInt.h"

24 25 26
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
27 28 29 30 31
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
32
///                     FUNCTION DEFINITIONS                         ///
Alan Mishchenko committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** argv )
{
    Abc_Alias * pAlias;
    int fStatus, i;

Alan Mishchenko committed
51
    pAlias = ABC_ALLOC(Abc_Alias, 1);
Alan Mishchenko committed
52
    pAlias->sName = Extra_UtilStrsav(sName);
Alan Mishchenko committed
53
    pAlias->argc = argc;
Alan Mishchenko committed
54
    pAlias->argv = ABC_ALLOC(char *, pAlias->argc);
Alan Mishchenko committed
55
    for(i = 0; i < argc; i++) 
Alan Mishchenko committed
56
        pAlias->argv[i] = Extra_UtilStrsav(argv[i]);
57
    fStatus = st__insert( pAbc->tAliases, pAlias->sName, (char *) pAlias );
Alan Mishchenko committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    assert(!fStatus);  
}

/**Function********************************************************************

  Synopsis    [required]

  Description [optional]

  SideEffects [required]

  SeeAlso     [optional]

******************************************************************************/
void CmdCommandAliasPrint( Abc_Frame_t * pAbc, Abc_Alias * pAlias )
{
    int i;
Alan Mishchenko committed
75
    fprintf(pAbc->Out, "%-15s", pAlias->sName);
Alan Mishchenko committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    for(i = 0; i < pAlias->argc; i++) 
        fprintf( pAbc->Out, " %s", pAlias->argv[i] );
    fprintf( pAbc->Out, "\n" );
}

/**Function********************************************************************

  Synopsis    [required]

  Description [optional]

  SideEffects [required]

  SeeAlso     [optional]

******************************************************************************/
char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand )
{
  Abc_Alias * pAlias;
  char * value;
96
  if (! st__lookup( pAbc->tAliases, sCommand, &value)) 
Alan Mishchenko committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    return sCommand;
  pAlias = (Abc_Alias *) value;
  return pAlias->argv[0];
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void CmdCommandAliasFree( Abc_Alias * pAlias )
{
    CmdFreeArgv( pAlias->argc, pAlias->argv );
Alan Mishchenko committed
116 117
    ABC_FREE(pAlias->sName);    
    ABC_FREE(pAlias);
Alan Mishchenko committed
118 119 120 121 122 123 124
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


125 126
ABC_NAMESPACE_IMPL_END