ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bar.c
Go to the documentation of this file.
1
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
26#include "base/main/main.h"
27#include "bar.h"
28
30
31
35
37{
38 int nItemsNext; // the number of items for the next update of the progress bar
39 int nItemsTotal; // the total number of items
40 int posTotal; // the total number of positions
41 int posCur; // the current position
42 FILE * pFile; // the output stream
43};
44
45static void Bar_ProgressShow( Bar_Progress_t * p, char * pString );
46static void Bar_ProgressClean( Bar_Progress_t * p );
47
51
66Bar_Progress_t * Bar_ProgressStart( FILE * pFile, int nItemsTotal )
67{
69 Abc_Frame_t * pFrame;
70 pFrame = Abc_FrameReadGlobalFrame();
71 if ( pFrame == NULL )
72 return NULL;
73 if ( !Abc_FrameShowProgress(pFrame) ) return NULL;
75 memset( p, 0, sizeof(Bar_Progress_t) );
76 p->pFile = pFile;
77 p->nItemsTotal = nItemsTotal;
78 p->posTotal = 78;
79 p->posCur = 1;
80 p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
81 Bar_ProgressShow( p, NULL );
82 return p;
83}
84
96void Bar_ProgressUpdate_int( Bar_Progress_t * p, int nItemsCur, char * pString )
97{
98 if ( p == NULL ) return;
99 if ( nItemsCur < p->nItemsNext )
100 return;
101 if ( nItemsCur >= p->nItemsTotal )
102 {
103 p->posCur = 78;
104 p->nItemsNext = 0x7FFFFFFF;
105 }
106 else
107 {
108 p->posCur += 7;
109 p->nItemsNext = (int)((7.0+p->posCur)*p->nItemsTotal/p->posTotal);
110 }
111 Bar_ProgressShow( p, pString );
112}
113
114
127{
128 if ( p == NULL ) return;
129 Bar_ProgressClean( p );
130 ABC_FREE( p );
131}
132
144void Bar_ProgressShow( Bar_Progress_t * p, char * pString )
145{
146 int i;
147 if ( p == NULL )
148 return;
149 if ( Abc_FrameIsBatchMode() )
150 return;
151 if ( pString )
152 fprintf( p->pFile, "%s ", pString );
153 for ( i = (pString? strlen(pString) + 1 : 0); i < p->posCur; i++ )
154 fprintf( p->pFile, "-" );
155 if ( i == p->posCur )
156 fprintf( p->pFile, ">" );
157 for ( i++ ; i <= p->posTotal; i++ )
158 fprintf( p->pFile, " " );
159 fprintf( p->pFile, "\r" );
160 fflush( stdout );
161}
162
174void Bar_ProgressClean( Bar_Progress_t * p )
175{
176 int i;
177 if ( p == NULL )
178 return;
179 if ( Abc_FrameIsBatchMode() )
180 return;
181 for ( i = 0; i <= p->posTotal; i++ )
182 fprintf( p->pFile, " " );
183 fprintf( p->pFile, "\r" );
184 fflush( stdout );
185}
186
190
191
193
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
void Bar_ProgressStop(Bar_Progress_t *p)
Definition bar.c:126
Bar_Progress_t * Bar_ProgressStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition bar.c:66
void Bar_ProgressUpdate_int(Bar_Progress_t *p, int nItemsCur, char *pString)
Definition bar.c:96
struct Bar_Progress_t_ Bar_Progress_t
BASIC TYPES ///.
Definition bar.h:48
ABC_DLL int Abc_FrameShowProgress(Abc_Frame_t *p)
Definition mainFrame.c:310
ABC_DLL Abc_Frame_t * Abc_FrameReadGlobalFrame()
Definition mainFrame.c:666
ABC_DLL int Abc_FrameIsBatchMode()
Definition mainFrame.c:110
Cube * p
Definition exorList.c:222
DECLARATIONS ///.
Definition bar.c:37
int posCur
Definition bar.c:41
FILE * pFile
Definition bar.c:42
int posTotal
Definition bar.c:40
int nItemsTotal
Definition bar.c:39
int nItemsNext
Definition bar.c:38
char * memset()
int strlen()