src/base/main/mainUtils.c File Reference

#include "mainInt.h"
#include "readline/readline.h"
Include dependency graph for mainUtils.c:

Go to the source code of this file.

Functions

static char * DateReadFromDateString (char *datestr)
char * Abc_UtilsGetVersion (Abc_Frame_t *pAbc)
char * Abc_UtilsGetUsersInput (Abc_Frame_t *pAbc)
void Abc_UtilsPrintHello (Abc_Frame_t *pAbc)
void Abc_UtilsPrintUsage (Abc_Frame_t *pAbc, char *ProgName)
void Abc_UtilsSource (Abc_Frame_t *pAbc)

Function Documentation

char* Abc_UtilsGetUsersInput ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 65 of file mainUtils.c.

00066 {
00067     static char Buffer[1000], Prompt[1000];
00068     sprintf( Prompt, "abc %02d> ", pAbc->nSteps );
00069 #ifdef _WIN32
00070     fprintf( pAbc->Out, "%s", Prompt );
00071     fgets( Buffer, 999, stdin );
00072     return Buffer;
00073 #else
00074     static char* line = NULL;
00075     if (line != NULL) free(line);
00076     line = readline(Prompt);  
00077     if (line == NULL){ printf("***EOF***\n"); exit(0); }
00078     add_history(line);
00079     return line;
00080 #endif
00081 }

char* Abc_UtilsGetVersion ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file mainUtils.c.

00048 {
00049     static char Version[1000];
00050     sprintf(Version, "%s (compiled %s %s)", ABC_VERSION, __DATE__, __TIME__);
00051     return Version;
00052 }

void Abc_UtilsPrintHello ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 94 of file mainUtils.c.

00095 {
00096     fprintf( pAbc->Out, "%s\n", pAbc->sVersion );
00097 }

void Abc_UtilsPrintUsage ( Abc_Frame_t pAbc,
char *  ProgName 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file mainUtils.c.

00111 {
00112     fprintf( pAbc->Err, "\n" );
00113     fprintf( pAbc->Err,
00114              "usage: %s [-c cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [file]\n", 
00115              ProgName);
00116     fprintf( pAbc->Err, "    -c cmd\texecute commands `cmd'\n");
00117     fprintf( pAbc->Err, "    -F script\texecute commands from a script file and echo commands\n");
00118     fprintf( pAbc->Err, "    -f script\texecute commands from a script file\n");
00119     fprintf( pAbc->Err, "    -h\t\tprint the command usage\n");
00120     fprintf( pAbc->Err, "    -o file\tspecify output filename to store the result\n");
00121     fprintf( pAbc->Err, "    -s\t\tdo not read any initialization file\n");
00122     fprintf( pAbc->Err, "    -t type\tspecify input type (blif_mv (default), blif_mvs, blif, or none)\n");
00123     fprintf( pAbc->Err, "    -T type\tspecify output type (blif_mv (default), blif_mvs, blif, or none)\n");
00124     fprintf( pAbc->Err, "    -x\t\tequivalent to '-t none -T none'\n");
00125     fprintf( pAbc->Err, "\n" );
00126 }

void Abc_UtilsSource ( Abc_Frame_t pAbc  ) 

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file mainUtils.c.

00140 {  
00141 #ifdef WIN32
00142     if ( Cmd_CommandExecute(pAbc, "source abc.rc") )
00143     {
00144         if ( Cmd_CommandExecute(pAbc, "source ..\\abc.rc") == 0 )
00145             printf( "Loaded \"abc.rc\" from the parent directory.\n" );
00146         else if ( Cmd_CommandExecute(pAbc, "source ..\\..\\abc.rc") == 0 )
00147             printf( "Loaded \"abc.rc\" from the grandparent directory.\n" );
00148     }
00149 #else
00150 
00151 #if 0
00152     {
00153         char * sPath1, * sPath2;
00154 
00155          // If .rc is present in both the home and current directories, then read
00156          // it from the home directory.  Otherwise, read it from wherever it's located.
00157         sPath1 = Extra_UtilFileSearch(".rc", "~/", "r");
00158         sPath2 = Extra_UtilFileSearch(".rc", ".",  "r");
00159   
00160         if ( sPath1 && sPath2 ) {
00161             /* ~/.rc == .rc : Source the file only once */
00162             (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
00163         }
00164         else {
00165             if (sPath1) {
00166                 (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
00167             }
00168             if (sPath2) {
00169                 (void) Cmd_CommandExecute(pAbc, "source -s .rc");
00170             }
00171         }
00172         if ( sPath1 ) FREE(sPath1);
00173         if ( sPath2 ) FREE(sPath2);
00174     
00175         /* execute the abc script which can be open with the "open_path" */
00176         Cmd_CommandExecute( pAbc, "source -s abc.rc" );
00177     }
00178 #endif
00179 
00180     {
00181         char * sPath1, * sPath2;
00182         char * home;
00183 
00184          // If .rc is present in both the home and current directories, then read
00185          // it from the home directory.  Otherwise, read it from wherever it's located.
00186         home = getenv("HOME");
00187         if (home){
00188             char * sPath3 = ALLOC(char, strlen(home) + 2);
00189             (void) sprintf(sPath3, "%s/", home);
00190             sPath1 = Extra_UtilFileSearch(".abc.rc", sPath3, "r");
00191             FREE(sPath3);
00192         }else
00193             sPath1 = NULL;
00194 
00195         sPath2 = Extra_UtilFileSearch(".abc.rc", ".",  "r");
00196 
00197         if ( sPath1 && sPath2 ) {
00198             /* ~/.rc == .rc : Source the file only once */
00199             (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
00200         }
00201         else {
00202             if (sPath1) {
00203                 (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
00204             }
00205             if (sPath2) {
00206                 (void) Cmd_CommandExecute(pAbc, "source -s .abc.rc");
00207             }
00208         }
00209         if ( sPath1 ) FREE(sPath1);
00210         if ( sPath2 ) FREE(sPath2);
00211 
00212         /* execute the abc script which can be open with the "open_path" */
00213         Cmd_CommandExecute( pAbc, "source -s abc.rc" );
00214     }
00215 
00216 #endif //WIN32
00217     {
00218         // reset command history
00219         char * pName; 
00220         int i;
00221         Vec_PtrForEachEntry( pAbc->aHistory, pName, i )
00222             free( pName );
00223         pAbc->aHistory->nSize = 0;
00224     }
00225 }

char * DateReadFromDateString ( char *  datestr  )  [static]

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

FileName [mainUtils.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The main package.]

Synopsis [Miscellaneous utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] DECLARATIONS ///

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

Synopsis [Returns the date in a brief format assuming its coming from the program `date'.]

Description [optional]

SideEffects []

Definition at line 238 of file mainUtils.c.

00240 {
00241   static char result[25];
00242   char        day[10];
00243   char        month[10];
00244   char        zone[10];
00245   char       *at;
00246   int         date;
00247   int         hour;
00248   int         minute;
00249   int         second;
00250   int         year;
00251 
00252   if (sscanf(datestr, "%s %s %2d %2d:%2d:%2d %s %4d",
00253              day, month, &date, &hour, &minute, &second, zone, &year) == 8) {
00254     if (hour >= 12) {
00255       if (hour >= 13) hour -= 12;
00256       at = "PM";
00257     }
00258     else {
00259       if (hour == 0) hour = 12;
00260       at = "AM";
00261     }
00262     (void) sprintf(result, "%d-%3s-%02d at %d:%02d %s", 
00263                    date, month, year % 100, hour, minute, at);
00264     return result;
00265   }
00266   else {
00267     return datestr;
00268   }
00269 }


Generated on Tue Jan 5 12:18:49 2010 for abc70930 by  doxygen 1.6.1