74 char * pFileNameOther;
83 pFile = fopen( pFileNameOther,
"r" );
84 if ( pFile == NULL && pS2 )
87 pFile = fopen( pFileNameOther,
"r" );
88 if ( pFile == NULL && pS3 )
91 pFile = fopen( pFileNameOther,
"r" );
92 if ( pFile == NULL && pS4 )
95 pFile = fopen( pFileNameOther,
"r" );
96 if ( pFile == NULL && pS5 )
99 pFile = fopen( pFileNameOther,
"r" );
108 return pFileNameOther;
129 for ( pDot = FileName +
strlen(FileName)-1; pDot >= FileName; pDot-- )
148 static char Buffer[500];
150 sprintf( Buffer,
"%s%s", pBase, pSuffix );
169 if ( (pDot =
strrchr( pRes,
'.' )) )
187 static char Buffer[1000];
191 if ( (pDot =
strrchr( Buffer,
'.' )) )
193 strcat( Buffer, pSuffix );
212 for ( pStart = FileName; *pStart; pStart++ )
213 if ( *pStart ==
'>' || *pStart ==
'\\' )
231 for ( pRes = FileName +
strlen(FileName) - 1; pRes >= FileName; pRes-- )
232 if ( *pRes ==
'\\' || *pRes ==
'/' )
240 for ( pRes = FileName +
strlen(FileName) - 1; pRes >= FileName; pRes-- )
241 if ( *pRes ==
'\\' || *pRes ==
'/' )
252 char * pBeg, * pEnd, * pStore, * pCur;
254 for ( pEnd = pFileName; *pEnd; pEnd++ )
258 for ( pBeg = pEnd - 1; pBeg >= pFileName; pBeg-- )
259 if ( !((*pBeg >=
'a' && *pBeg <=
'z') || (*pBeg >=
'A' && *pBeg <=
'Z') || (*pBeg >=
'0' && *pBeg <=
'9') || *pBeg ==
'_') )
263 pStore =
ABC_ALLOC(
char, pEnd - pBeg + 1 );
264 for ( pCur = pStore; pBeg < pEnd; pBeg++, pCur++ )
284 pFile = fopen( pFileName,
"rb" );
287 printf(
"Extra_FileCheck(): File \"%s\" does not exist.\n", pFileName );
291 if ( ftell( pFile ) == 0 )
292 printf(
"Extra_FileCheck(): File \"%s\" is empty.\n", pFileName );
312 pFile = fopen( pFileName,
"rb" );
315 printf(
"Extra_FileSize(): The file is unavailable (absent or open).\n" );
319 nFileSize = ftell( pFile );
343 nFileSize = ftell( pFile );
347 pBuffer =
ABC_ALLOC(
char, nFileSize + 3 );
348 RetValue = fread( pBuffer, nFileSize, 1, pFile );
350 pBuffer[ nFileSize + 0] =
'\n';
351 pBuffer[ nFileSize + 1] =
'\0';
361 nSize = ftell( pFile );
365 nSize2 = ftell( pFile2 );
368 pBuffer =
ABC_ALLOC(
char, nSize + nSize2 + 3 );
369 RetValue = fread( pBuffer, nSize, 1, pFile );
370 RetValue = fread( pBuffer + nSize, nSize2, 1, pFile2 );
372 pBuffer[ nSize + nSize2 + 0] =
'\n';
373 pBuffer[ nSize + nSize2 + 1] =
'\0';
392 pFile = fopen( pFileName,
"rb" );
394 if ( pFile ) fclose( pFile );
399 FILE * pFile, * pFile2;
401 pFile = fopen( pFileName,
"rb" );
402 pFile2 = fopen( pFileName2,
"rb" );
404 if ( pFile ) fclose( pFile );
405 if ( pFile2 ) fclose( pFile2 );
422 int lenS, lenF =
strlen(pFileName);
423 lenS = pS1 ?
strlen(pS1) : 0;
424 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS1, lenS ) )
426 lenS = pS2 ?
strlen(pS2) : 0;
427 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS2, lenS ) )
429 lenS = pS3 ?
strlen(pS3) : 0;
430 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS3, lenS ) )
448 static char Buffer[100];
453 TimeStamp = asctime( localtime( <ime ) );
454 TimeStamp[
strlen(TimeStamp) - 1 ] = 0;
455 strcpy( Buffer, TimeStamp );
476 for ( i = 0; Buffer[i]; i++ )
477 if ( Buffer[i] ==
'0' || Buffer[i] ==
'1' )
478 Result = Result * 2 + Buffer[i] -
'0';
502 Remainder = (nBits%(
sizeof(unsigned)*8));
503 nWords = (nBits/(
sizeof(unsigned)*8)) + (Remainder>0);
505 for ( w = nWords-1; w >= 0; w-- )
506 for ( i = ((w == nWords-1 && Remainder)? Remainder-1: 31); i >= 0; i-- )
507 fprintf( pFile,
"%c",
'0' + (
int)((Sign[w] & (1<<i)) > 0) );
526 for ( k = 0; k < nDigits; k++ )
529 if ( pString[c] >=
'0' && pString[c] <=
'9' )
530 Digit = pString[c] -
'0';
531 else if ( pString[c] >=
'A' && pString[c] <=
'F' )
532 Digit = pString[c] -
'A' + 10;
533 else if ( pString[c] >=
'a' && pString[c] <=
'f' )
534 Digit = pString[c] -
'a' + 10;
535 else {
assert( 0 );
return 0; }
536 Sign[k/8] |= ( (Digit & 15) << ((k%8) * 4) );
544 for ( k = 0; k <
nWords; k++ )
547 nDigits = (1 << nVars) / 4;
567 int nDigits, Digit, k;
569 nDigits = (1 << nVars) / 4;
570 for ( k = nDigits - 1; k >= 0; k-- )
572 Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
574 fprintf( pFile,
"%d", Digit );
576 fprintf( pFile,
"%c",
'a' + Digit-10 );
594 int nDigits, Digit, k;
596 nDigits = (1 << nVars) / 4;
597 for ( k = nDigits - 1; k >= 0; k-- )
599 Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
601 *pString++ =
'0' + Digit;
603 *pString++ =
'a' + Digit-10;
622 int nMints, nDigits, Digit, k;
625 fprintf( pFile,
"0x" );
626 nMints = (1 << nVars);
627 nDigits = nMints / 4 + ((nMints % 4) > 0);
628 for ( k = nDigits - 1; k >= 0; k-- )
630 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
632 fprintf( pFile,
"%d", Digit );
634 fprintf( pFile,
"%c",
'A' + Digit-10 );
640 int nMints, nDigits, Digit, k;
643 fprintf( pFile,
"0x" );
644 nMints = (1 << nVars);
645 nDigits = nMints / 4 + ((nMints % 4) > 0);
646 for ( k = 0; k < nDigits; k++ )
648 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
650 fprintf( pFile,
"%d", Digit );
652 fprintf( pFile,
"%c",
'A' + Digit-10 );
671 for ( i = 0; i < nTimes; i++ )
672 printf(
"%c", Char );
696 sprintf( pTemp,
"%s%s", pStrGiven, pStrAdd );
717 char * pTemp, * pChar, * pSave = pStrGiven;
718 for ( pTemp = pStrGiven; *pTemp; pTemp++ )
720 for ( pChar = pCharKeep; *pChar; pChar++ )
721 if ( *pTemp == *pChar )
743 return strcmp(*(
char **)pp1, *(
char **)pp2);
762 int i, nLines, Begin;
763 pFile = fopen( pFileName,
"rb" );
766 printf(
"Extra_FileSort(): Cannot open file \"%s\".\n", pFileName );
771 if ( pContents == NULL )
773 printf(
"Extra_FileSort(): Cannot read contents of file \"%s\".\n", pFileName );
777 for ( nLines = 0, i = 0; pContents[i]; i++ )
778 nLines += (pContents[i] ==
'\n');
780 pLines = (
char **)
malloc(
sizeof(
char *) * nLines );
782 for ( nLines = 0, i = 0; pContents[i]; i++ )
783 if ( pContents[i] ==
'\n' )
786 pLines[nLines++] = pContents + Begin;
790 qsort( pLines, nLines,
sizeof(
char *), (
int(*)(
const void *,
const void *))
Extra_StringCompare );
792 pFile = fopen( pFileNameOut,
"wb" );
793 for ( i = 0; i < nLines; i++ )
795 fprintf( pFile,
"%s\n", pLines[i] );
801 printf(
"The file after sorting is \"%s\".\n", pFileNameOut );
822 pFile = fopen( pFileName,
"rb" );
825 printf(
"Extra_FileLineNumAdd(): Cannot open file \"%s\".\n", pFileName );
828 pFile2 = fopen( pFileNameOut,
"wb" );
829 if ( pFile2 == NULL )
832 printf(
"Extra_FileLineNumAdd(): Cannot open file \"%s\".\n", pFileNameOut );
835 for ( iLine = 0; fgets( Buffer, 1000, pFile ); iLine++ )
837 sprintf( Buffer +
strlen(Buffer) - 2,
"%03d\n%c", iLine, 0 );
838 fputs( Buffer, pFile2 );
843 printf(
"The resulting file is \"%s\".\n", pFileNameOut );
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
char * Abc_UtilStrsav(char *s)