Esempio n. 1
0
VIOAPI Status  mni_input_line(
    FILE     *file,
    STRING   *string )
{
    Status   status;
    char     ch;

    *string = create_string( NULL );

    status = input_character( file, &ch );

    while( status == OK && ch != '\n' )
    {
        if (ch != '\r') {       /* Always ignore carriage returns */
            concat_char_to_string( string, ch );
        }

        status = input_character( file, &ch );
    }

    if( status != OK )
    {
        delete_string( *string );
        *string = NULL;
    }

    return( status );
}
Esempio n. 2
0
VIOAPI Status  mni_input_string(
    FILE     *file,
    STRING   *string,
    char     termination_char1,
    char     termination_char2 )
{
    Status   status;
    char     ch;
    BOOLEAN quoted;

    *string = create_string( NULL );

    status = mni_get_nonwhite_character( file, &ch );

    if( status == OK && ch == '"' )
    {
        quoted = TRUE;
        status = mni_get_nonwhite_character( file, &ch );
        termination_char1 = '"';
        termination_char2 = '"';
    }
    else
        quoted = FALSE;

    while( status == OK &&
           ch != termination_char1 && ch != termination_char2 && ch != '\n' )
    {
        if (ch != '\r') {       /* Always ignore carriage returns */
            concat_char_to_string( string, ch );
        }
        status = input_character( file, &ch );
    }

    if( !quoted )
        (void) unget_character( file, ch );

    while( string_length(*string) > 0 &&
           (*string)[string_length(*string)-1] == ' ' )
        (*string)[string_length(*string)-1] = END_OF_STRING;

    if( status != OK )
    {
        delete_string( *string );
        *string = NULL;
    }

    return( status );
}
Esempio n. 3
0
static VIO_STR extract_label(
    VIO_STR     str )
{
    VIO_BOOL  quoted;
    int      i;
    VIO_STR   label;

    i = 0;

    /* --- skip leading space */

    while( str[i] == ' ' || str[i] == '\t' )
        ++i;

    if( str[i] == '"' )
    {
        quoted = TRUE;
        ++i;
    }
    else
        quoted = FALSE;

    /* --- copy characters until either closing quote is found (if quoted),
           or white space or end of string is found */

    label = create_string( NULL );

    while( str[i] != VIO_END_OF_STRING &&
           ( (quoted && str[i] != '"') ||
             (!quoted && str[i] != ' ' && str[i] != '\t') ) )
    {
        concat_char_to_string( &label, str[i] );
        ++i;
    }

    return( label );
}