/* read a string (i.e., read to EOL) */ static char* afm_stream_read_string( AFM_Stream stream ) { char* str; int ch; afm_stream_skip_spaces( stream ); if ( AFM_STATUS_EOL( stream ) ) return NULL; str = AFM_STREAM_KEY_BEGIN( stream ); /* scan to eol */ while ( 1 ) { ch = AFM_GETC(); if ( AFM_IS_NEWLINE( ch ) ) { stream->status = AFM_STREAM_STATUS_EOL; break; } else if ( AFM_IS_EOF( ch ) ) { stream->status = AFM_STREAM_STATUS_EOF; break; } } return str; }
static int afm_stream_skip_spaces( AFM_Stream stream ) { int ch = 0; /* make stupid compiler happy */ if ( AFM_STATUS_EOC( stream ) ) return ';'; while ( 1 ) { ch = AFM_GETC(); if ( !AFM_IS_SPACE( ch ) ) break; } if ( AFM_IS_NEWLINE( ch ) ) stream->status = AFM_STREAM_STATUS_EOL; else if ( AFM_IS_SEP( ch ) ) stream->status = AFM_STREAM_STATUS_EOC; else if ( AFM_IS_EOF( ch ) ) stream->status = AFM_STREAM_STATUS_EOF; return ch; }
/* read a key or value in current column */ static char* afm_stream_read_one( AFM_Stream stream ) { char* str; afm_stream_skip_spaces( stream ); if ( AFM_STATUS_EOC( stream ) ) return NULL; str = AFM_STREAM_KEY_BEGIN( stream ); while ( 1 ) { int ch = AFM_GETC(); if ( AFM_IS_SPACE( ch ) ) break; else if ( AFM_IS_NEWLINE( ch ) ) { stream->status = AFM_STREAM_STATUS_EOL; break; } else if ( AFM_IS_SEP( ch ) ) { stream->status = AFM_STREAM_STATUS_EOC; break; } else if ( AFM_IS_EOF( ch ) ) { stream->status = AFM_STREAM_STATUS_EOF; break; } } return str; }