src/aig/bar/bar.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bar.h"
Include dependency graph for bar.c:

Go to the source code of this file.

Data Structures

struct  Bar_Progress_t_

Functions

static void Bar_ProgressShow (Bar_Progress_t *p, char *pString)
static void Bar_ProgressClean (Bar_Progress_t *p)
Bar_Progress_tBar_ProgressStart (FILE *pFile, int nItemsTotal)
void Bar_ProgressUpdate_int (Bar_Progress_t *p, int nItemsCur, char *pString)
void Bar_ProgressStop (Bar_Progress_t *p)

Function Documentation

void Bar_ProgressClean ( Bar_Progress_t p  )  [static]

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

Synopsis [Cleans the progress bar before quitting.]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file bar.c.

00164 {
00165     int i;
00166     if ( p == NULL ) return;
00167     for ( i = 0; i <= p->posTotal; i++ )
00168         fprintf( p->pFile, " " );
00169     fprintf( p->pFile, "\r" );
00170     fflush( stdout );
00171 }

void Bar_ProgressShow ( Bar_Progress_t p,
char *  pString 
) [static]

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

Synopsis [Prints the progress bar of the given size.]

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file bar.c.

00137 {
00138     int i;
00139     if ( p == NULL ) return;
00140     if ( pString )
00141         fprintf( p->pFile, "%s ", pString );
00142     for ( i = (pString? strlen(pString) + 1 : 0); i < p->posCur; i++ )
00143         fprintf( p->pFile, "-" );
00144     if ( i == p->posCur )
00145         fprintf( p->pFile, ">" );
00146     for ( i++  ; i <= p->posTotal; i++ )
00147         fprintf( p->pFile, " " );
00148     fprintf( p->pFile, "\r" );
00149     fflush( stdout );
00150 }

Bar_Progress_t* Bar_ProgressStart ( FILE *  pFile,
int  nItemsTotal 
)

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

Synopsis [Starts the progress bar.]

Description [The first parameter is the output stream (pFile), where the progress is printed. The current printing position should be the first one on the given line. The second parameters is the total number of items that correspond to 100% position of the progress bar.]

SideEffects []

SeeAlso []

Definition at line 60 of file bar.c.

00061 {
00062     Bar_Progress_t * p;
00063 //    extern int Abc_FrameShowProgress( void * p );
00064 //    extern void * Abc_FrameGetGlobalFrame();
00065 //    if ( !Abc_FrameShowProgress(Abc_FrameGetGlobalFrame()) ) return NULL;
00066     p = (Bar_Progress_t *) malloc(sizeof(Bar_Progress_t));
00067     memset( p, 0, sizeof(Bar_Progress_t) );
00068     p->pFile       = pFile;
00069     p->nItemsTotal = nItemsTotal;
00070     p->posTotal    = 78;
00071     p->posCur      = 1;
00072     p->nItemsNext  = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
00073     Bar_ProgressShow( p, NULL );
00074     return p;
00075 }

void Bar_ProgressStop ( Bar_Progress_t p  ) 

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

Synopsis [Stops the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file bar.c.

00119 {
00120     if ( p == NULL ) return;
00121     Bar_ProgressClean( p );
00122     free( p );
00123 }

void Bar_ProgressUpdate_int ( Bar_Progress_t p,
int  nItemsCur,
char *  pString 
)

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

Synopsis [Updates the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file bar.c.

00089 {
00090     if ( p == NULL ) return;
00091     if ( nItemsCur < p->nItemsNext )
00092         return;
00093     if ( nItemsCur >= p->nItemsTotal )
00094     {
00095         p->posCur = 78;
00096         p->nItemsNext = 0x7FFFFFFF;
00097     }
00098     else
00099     {
00100         p->posCur += 7;
00101         p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
00102     }
00103     Bar_ProgressShow( p, pString );
00104 }


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