00001 00021 #include "cmdInt.h" 00022 00026 00030 00042 void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** argv ) 00043 { 00044 Abc_Alias * pAlias; 00045 int fStatus, i; 00046 00047 pAlias = ALLOC(Abc_Alias, 1); 00048 pAlias->sName = Extra_UtilStrsav(sName); 00049 pAlias->argc = argc; 00050 pAlias->argv = ALLOC(char *, pAlias->argc); 00051 for(i = 0; i < argc; i++) 00052 pAlias->argv[i] = Extra_UtilStrsav(argv[i]); 00053 fStatus = st_insert( pAbc->tAliases, pAlias->sName, (char *) pAlias ); 00054 assert(!fStatus); 00055 } 00056 00068 void CmdCommandAliasPrint( Abc_Frame_t * pAbc, Abc_Alias * pAlias ) 00069 { 00070 int i; 00071 fprintf(pAbc->Out, "%-15s", pAlias->sName); 00072 for(i = 0; i < pAlias->argc; i++) 00073 fprintf( pAbc->Out, " %s", pAlias->argv[i] ); 00074 fprintf( pAbc->Out, "\n" ); 00075 } 00076 00088 char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand ) 00089 { 00090 Abc_Alias * pAlias; 00091 char * value; 00092 if (!st_lookup( pAbc->tAliases, sCommand, &value)) 00093 return sCommand; 00094 pAlias = (Abc_Alias *) value; 00095 return pAlias->argv[0]; 00096 } 00097 00109 void CmdCommandAliasFree( Abc_Alias * pAlias ) 00110 { 00111 CmdFreeArgv( pAlias->argc, pAlias->argv ); 00112 FREE(pAlias->sName); 00113 FREE(pAlias); 00114 } 00115 00119 00120