readOneSectionFromDumpfile


readOneSectionFromDumpfile(fopen( filename, "r" ))

static int readOneSectionFromDumpfile( FILE* dumpFile )
{
    memset( dumpFileSection, 0, sizeof(dumpFileSection) );
    numLineForSection = 0;

    while (1)
    {
        if (feof( dumpFile ) || ferror( dumpFile ))
        {
            break;
        }
        char *pLine = dumpFileSection[numLineForSection];
        fgets( pLine, MAX_LINE_SIZE, dumpFile );
        trimString( pLine );
        if (!stringIsPrintable( pLine ))
        {
            if (numLineForSection > 0)
            {
                printf( "non-printable character found in %s line %d {%s}\n",
                     dumpFileSection[0], numLineForSection, pLine );
            }
            else
            {
                printf( "non-printable character found in name {%s}\n",
                     pLine );
            }
            exit( -1 );
        }
        size_t ll = strlen( pLine );
        if (ll > 0)
        {
            ++numLineForSection;
            if (numLineForSection > MAX_NUM_LINE)
            {
                printf( "exceed max number of lines per section" );
                exit( -1 );
            }
        }
        else
        {
            if (numLineForSection)
            {
                break;
            }
        }
    }
    return numLineForSection;
}

posted @ 2011-10-20 22:47  greencolor  阅读(137)  评论(0编辑  收藏  举报