abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
extraUtilProgress.c File Reference
#include <stdio.h>
#include "extra.h"
#include "base/main/main.h"

Go to the source code of this file.

Data Structures

struct  ProgressBarStruct
 DECLARATIONS ///. More...
 

Functions

static void Extra_ProgressBarShow (ProgressBar *p, char *pString)
 
static void Extra_ProgressBarClean (ProgressBar *p)
 
ProgressBarExtra_ProgressBarStart (FILE *pFile, int nItemsTotal)
 FUNCTION DEFINITIONS ///. More...
 
void Extra_ProgressBarUpdate_int (ProgressBar *p, int nItemsCur, char *pString)
 
void Extra_ProgressBarStop (ProgressBar *p)
 

Function Documentation

void Extra_ProgressBarClean ( ProgressBar p)
static

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

Synopsis [Cleans the progress bar before quitting.]

Description []

SideEffects []

SeeAlso []

Definition at line 166 of file extraUtilProgress.c.

167 {
168  int i;
169  if ( p == NULL )
170  return;
171  if ( Abc_FrameIsBatchMode() )
172  return;
173  for ( i = 0; i <= p->posTotal; i++ )
174  fprintf( p->pFile, " " );
175  fprintf( p->pFile, "\r" );
176  fflush( stdout );
177 }
ABC_DLL int Abc_FrameIsBatchMode()
Definition: mainFrame.c:92
void Extra_ProgressBarShow ( ProgressBar p,
char *  pString 
)
static

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 136 of file extraUtilProgress.c.

137 {
138  int i;
139  if ( p == NULL )
140  return;
141  if ( Abc_FrameIsBatchMode() )
142  return;
143  if ( pString )
144  fprintf( p->pFile, "%s ", pString );
145  for ( i = (pString? strlen(pString) + 1 : 0); i < p->posCur; i++ )
146  fprintf( p->pFile, "-" );
147  if ( i == p->posCur )
148  fprintf( p->pFile, ">" );
149  for ( i++ ; i <= p->posTotal; i++ )
150  fprintf( p->pFile, " " );
151  fprintf( p->pFile, "\r" );
152  fflush( stdout );
153 }
ABC_DLL int Abc_FrameIsBatchMode()
Definition: mainFrame.c:92
int strlen()
ProgressBar* Extra_ProgressBarStart ( 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 62 of file extraUtilProgress.c.

63 {
64  ProgressBar * p;
65  if ( !Abc_FrameShowProgress(Abc_FrameGetGlobalFrame()) ) return NULL;
66  p = ABC_ALLOC( ProgressBar, 1 );
67  memset( p, 0, sizeof(ProgressBar) );
68  p->pFile = pFile;
69  p->nItemsTotal = nItemsTotal;
70  p->posTotal = 78;
71  p->posCur = 1;
72  p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
73  Extra_ProgressBarShow( p, NULL );
74  return p;
75 }
static void Extra_ProgressBarShow(ProgressBar *p, char *pString)
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DECLARATIONS ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
ABC_DLL int Abc_FrameShowProgress(Abc_Frame_t *p)
Definition: mainFrame.c:265
void Extra_ProgressBarStop ( ProgressBar p)

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

Synopsis [Stops the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file extraUtilProgress.c.

119 {
120  if ( p == NULL ) return;
122  ABC_FREE( p );
123 }
static void Extra_ProgressBarClean(ProgressBar *p)
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Extra_ProgressBarUpdate_int ( ProgressBar p,
int  nItemsCur,
char *  pString 
)

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

Synopsis [Updates the progress bar.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file extraUtilProgress.c.

89 {
90  if ( p == NULL ) return;
91  if ( nItemsCur < p->nItemsNext )
92  return;
93  if ( nItemsCur >= p->nItemsTotal )
94  {
95  p->posCur = 78;
96  p->nItemsNext = 0x7FFFFFFF;
97  }
98  else
99  {
100  p->posCur += 7;
101  p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
102  }
103  Extra_ProgressBarShow( p, pString );
104 }
static void Extra_ProgressBarShow(ProgressBar *p, char *pString)