ABC: A System for Sequential Synthesis and Verification
Loading...
Searching...
No Matches
extraUtilProgress.c
Go to the documentation of this file.
1
20
21
#include <stdio.h>
22
#include "
extra.h
"
23
#include "
base/main/main.h
"
24
25
ABC_NAMESPACE_IMPL_START
26
27
31
32
struct
ProgressBarStruct
33
{
34
int
nItemsNext
;
// the number of items for the next update of the progress bar
35
int
nItemsTotal
;
// the total number of items
36
int
posTotal
;
// the total number of positions
37
int
posCur
;
// the current position
38
FILE *
pFile
;
// the output stream
39
};
40
41
static
void
Extra_ProgressBarShow(
ProgressBar
*
p
,
char
* pString );
42
static
void
Extra_ProgressBarClean(
ProgressBar
*
p
);
43
47
62
ProgressBar
*
Extra_ProgressBarStart
( FILE * pFile,
int
nItemsTotal )
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
}
76
88
void
Extra_ProgressBarUpdate_int
(
ProgressBar
*
p
,
int
nItemsCur,
char
* pString )
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
}
105
106
118
void
Extra_ProgressBarStop
(
ProgressBar
*
p
)
119
{
120
if
(
p
== NULL )
return
;
121
Extra_ProgressBarClean(
p
);
122
ABC_FREE
(
p
);
123
}
124
136
void
Extra_ProgressBarShow(
ProgressBar
*
p
,
char
* pString )
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
}
154
166
void
Extra_ProgressBarClean(
ProgressBar
*
p
)
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
}
178
182
183
184
ABC_NAMESPACE_IMPL_END
185
ABC_ALLOC
#define ABC_ALLOC(type, num)
Definition
abc_global.h:264
ABC_FREE
#define ABC_FREE(obj)
Definition
abc_global.h:267
ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_START
Definition
abc_namespaces.h:54
ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_END
Definition
abc_namespaces.h:55
Abc_FrameGetGlobalFrame
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition
mainFrame.c:643
main.h
Abc_FrameShowProgress
ABC_DLL int Abc_FrameShowProgress(Abc_Frame_t *p)
Definition
mainFrame.c:310
Abc_FrameIsBatchMode
ABC_DLL int Abc_FrameIsBatchMode()
Definition
mainFrame.c:110
ProgressBar
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
Definition
bbrNtbdd.c:27
p
Cube * p
Definition
exorList.c:222
Extra_ProgressBarStop
void Extra_ProgressBarStop(ProgressBar *p)
Definition
extraUtilProgress.c:118
Extra_ProgressBarUpdate_int
void Extra_ProgressBarUpdate_int(ProgressBar *p, int nItemsCur, char *pString)
Definition
extraUtilProgress.c:88
Extra_ProgressBarStart
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition
extraUtilProgress.c:62
extra.h
ProgressBarStruct
DECLARATIONS ///.
Definition
extraUtilProgress.c:33
ProgressBarStruct::nItemsNext
int nItemsNext
Definition
extraUtilProgress.c:34
ProgressBarStruct::posTotal
int posTotal
Definition
extraUtilProgress.c:36
ProgressBarStruct::posCur
int posCur
Definition
extraUtilProgress.c:37
ProgressBarStruct::pFile
FILE * pFile
Definition
extraUtilProgress.c:38
ProgressBarStruct::nItemsTotal
int nItemsTotal
Definition
extraUtilProgress.c:35
memset
char * memset()
strlen
int strlen()
src
misc
extra
extraUtilProgress.c
Generated by Doxygen 1.13.2 © 2025 EPTansuo. All rights reserved.
鲁ICP备2021046540号