common.io/read_line [ Functions ]

[ Top ] [ Functions ]

SYNOPSIS

198  *   line = read_line(buff, STDIN_FILENO, &iptr_ext, &len_out, 0)

FUNCTION

The read_line function does line oriented input. It manages the buffer and returns index to the line.

Data is fetched by block read function and are buffered. The new line character is searched. If there is the need to read more data, firstly free space in the buffer is used. If free space is not available, it might be freed by moving the begin of the line over older (already processed) lines. If neither one is the option, buffer grows.

User can lock data in the buffer by setting mark.

INPUTS

buff - buffer to manage fd - file descriptor to read from iptr_ext - state stored between subsequent calls;

                It is MORFO_EOF or position index to the first unused byte.

len_out - NULL or pointer to store the length of the line mark - index of the first byte that can be replaced with shifted

                data

RESULT

line - the index to the first byte of the line or MORFO_EOF if no

                further line is in the file