Analyser/RB_Find_Marker [ Functions ]

NAME

RB_Find_Marker -- Search for header marker in document.

FUNCTION

Read document file line by line, and search each line for any of the headers defined in the array header_markers (OR if using the -rh switch, robo_head)

SYNOPSIS

static struct RB_HeaderType *RB_Find_Marker(
    FILE *document,
    int *is_internal,
    int reuse_previous_line )

INPUTS

document - pointer to the file to be searched. the gobal buffer line_buffer.

OUTPUT

RESULT

BUGS

Bad use of feof(), fgets().

SEE ALSO

Find_End_Marker

SOURCE

{
    int                 found;
    char               *cur_char;
    struct RB_HeaderType *header_type = 0;

    cur_char = NULL;
    found = FALSE;
    while ( !feof( document ) && !found )
    {
        if ( reuse_previous_line )
        {
            /* reuse line in the line_buffer */
            reuse_previous_line = FALSE;
        }
        else
        {
            RB_FreeLineBuffer(  );
            myLine = RB_ReadWholeLine( document, line_buffer, &readChars );
        }
        if ( !feof( document ) )
        {
            line_number++;
            found = RB_Is_Begin_Marker( myLine, &cur_char );
            if ( found )
            {
                header_type = AnalyseHeaderType( &cur_char, is_internal );
                RB_Say( "found header marker of type %s\n", SAY_DEBUG,
                        header_type->indexName );
            }
        }
    }

    return header_type;
}