89{
91 Vec_Str_t* sCommandUsr = Vec_StrAlloc(1000);
92 char sCommandTmp[
ABC_MAX_STR], sReadCmd[1000], sWriteCmd[1000];
93 const char * sOutFile, * sInFile;
94 char * sCommand;
95 int fStatus = 0;
96 int c, fInitSource, fInitRead, fFinalWrite;
97
98 enum {
99 INTERACTIVE,
100 BATCH,
101 BATCH_THEN_INTERACTIVE,
102 BATCH_QUIET,
103 BATCH_QUIET_THEN_INTERACTIVE,
104 BATCH_SMT
105 } fBatch;
106
107
108
109
110#if defined(_DEBUG) && defined(_MSC_VER)
111 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
112#endif
113
114
115
117 pAbc->sBinary = argv[0];
118
119
120 fBatch = INTERACTIVE;
121 fInitSource = 1;
122 fInitRead = 0;
123 fFinalWrite = 0;
124 sInFile = sOutFile = NULL;
127
129 while ((c =
Extra_UtilGetopt(argc, argv,
"dm:l:c:q:C:Q:S:hf:F:o:st:T:xb")) != EOF) {
130 switch(c) {
131
132 case 'd':
134 break;
135
136 case 'm': {
137#if !defined(WIN32) && !defined(ABC_NO_RLIMIT)
139 printf("Limiting memory use to %d MB\n", maxMb);
140 struct rlimit limit = {
141 maxMb * (1llu << 20),
142 maxMb * (1llu << 20)
143 };
144 setrlimit(RLIMIT_AS, &limit);
145#endif
146 break;
147 }
148 case 'l': {
149#if !defined(WIN32) && !defined(ABC_NO_RLIMIT)
151 printf("Limiting time to %d seconds\n", (int)maxTime);
152 struct rlimit limit = {
153 maxTime,
154 maxTime
155 };
156 setrlimit(RLIMIT_CPU, &limit);
157#endif
158 break;
159 }
160 case 'c':
161 if( Vec_StrSize(sCommandUsr) > 0 )
162 {
163 Vec_StrAppend(sCommandUsr, " ; ");
164 }
166 fBatch = BATCH;
167 break;
168
169 case 'q':
170 if( Vec_StrSize(sCommandUsr) > 0 )
171 {
172 Vec_StrAppend(sCommandUsr, " ; ");
173 }
175 fBatch = BATCH_QUIET;
176 break;
177
178 case 'Q':
179 if( Vec_StrSize(sCommandUsr) > 0 )
180 {
181 Vec_StrAppend(sCommandUsr, " ; ");
182 }
184 fBatch = BATCH_QUIET_THEN_INTERACTIVE;
185 break;
186
187 case 'C':
188 if( Vec_StrSize(sCommandUsr) > 0 )
189 {
190 Vec_StrAppend(sCommandUsr, " ; ");
191 }
193 fBatch = BATCH_THEN_INTERACTIVE;
194 break;
195
196 case 'S':
197 if( Vec_StrSize(sCommandUsr) > 0 )
198 {
199 Vec_StrAppend(sCommandUsr, " ; ");
200 }
202 fBatch = BATCH_SMT;
203 break;
204
205 case 'f':
206 if( Vec_StrSize(sCommandUsr) > 0 )
207 {
208 Vec_StrAppend(sCommandUsr, " ; ");
209 }
211 fBatch = BATCH;
212 break;
213
214 case 'F':
215 if( Vec_StrSize(sCommandUsr) > 0 )
216 {
217 Vec_StrAppend(sCommandUsr, " ; ");
218 }
220 fBatch = BATCH;
221 break;
222
223 case 'h':
225 break;
226
227 case 'o':
229 fFinalWrite = 1;
230 break;
231
232 case 's':
233 fInitSource = 0;
234 break;
235
236 case 't':
238 {
240 {
241 fInitRead = 1;
243 }
244 }
245 else {
247 }
248 fBatch = BATCH;
249 break;
250
251 case 'T':
253 {
255 {
256 fFinalWrite = 1;
258 }
259 }
260 else {
262 }
263 fBatch = BATCH;
264 break;
265
266 case 'x':
267 fFinalWrite = 0;
268 fInitRead = 0;
269 fBatch = BATCH;
270 break;
271
272 case 'b':
274 break;
275
276 default:
278 }
279 }
280
281 Vec_StrPush(sCommandUsr, '\0');
282
283 if ( fBatch == BATCH_SMT )
284 {
287 return 0;
288 }
289
291 {
294 }
295 else if ( fBatch!=INTERACTIVE && fBatch!=BATCH_QUIET && fBatch!=BATCH_QUIET_THEN_INTERACTIVE && Vec_StrSize(sCommandUsr)>0 )
296 Abc_Print( 1, "ABC command line: \"%s\".\n\n", Vec_StrArray(sCommandUsr) );
297
298 if ( fBatch!=INTERACTIVE )
299 {
300 pAbc->fBatchMode = 1;
301
303 {
304 sInFile = NULL;
305 }
307 {
308 fInitRead = 1;
310 }
311 else
312 {
314 }
315
316
317 if ( fInitSource )
318 {
320 }
321
322 fStatus = 0;
323 if ( fInitRead && sInFile )
324 {
325 sprintf( sCommandTmp,
"%s %s", sReadCmd, sInFile );
327 }
328
329 if ( fStatus == 0 )
330 {
331
333 if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile )
334 {
335 sprintf( sCommandTmp,
"%s %s", sWriteCmd, sOutFile );
337 }
338 }
339
340 if (fBatch == BATCH_THEN_INTERACTIVE || fBatch == BATCH_QUIET_THEN_INTERACTIVE){
341 fBatch = INTERACTIVE;
342 pAbc->fBatchMode = 0;
343 }
344 }
345
346 Vec_StrFreeP(&sCommandUsr);
347
348 if ( fBatch==INTERACTIVE )
349 {
350
351
352
354
356
357
358 if ( fInitSource )
359 {
361 }
362
363
364 while ( !feof(stdin) )
365 {
366
367
369
370
372
373
374 if ( fStatus == -1 || fStatus == -2 )
375 break;
376 }
377 }
378
379
380
381 {
383 }
384 return 0;
385
389 return 1;
390}
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
ABC_DLL void Abc_FrameSetBridgeMode()
ABC_DLL int Abc_FrameIsBridgeMode()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
void Cmd_HistoryPrint(Abc_Frame_t *p, int Limit)
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
struct Gia_Man_t_ Gia_Man_t
ABC_DLL void Abc_UtilsPrintUsage(Abc_Frame_t *pAbc, char *ProgName)
ABC_DLL void Abc_UtilsPrintHello(Abc_Frame_t *pAbc)
ABC_DLL void Abc_UtilsSource(Abc_Frame_t *pAbc)
ABC_DLL char * Abc_UtilsGetUsersInput(Abc_Frame_t *pAbc)
unsigned enable_dbg_outs
FUNCTION DEFINITIONS ///.
Gia_Man_t * Gia_ManFromBridge(FILE *pFile, Vec_Int_t **pvInit)
int Wlc_StdinProcessSmt(Abc_Frame_t *pAbc, char *pCmd)