CTLSEQS_READ(3) ctlseqs CTLSEQS_READ(3)

ctlseqs_read - read control sequence

#include <ctlseqs.h>
ssize_t ctlseqs_read(
    struct ctlseqs_reader        *reader,
    struct ctlseqs_matcher const *matcher,
    int                           timeout
);

Attempts to read a control sequence with given reader, and match it against the patterns in matcher, similar to ctlseqs_match.

When match fails, the number of characters read will be stored into the result field in reader at offset 0, and the pointer to the first character stored at offset 1. If option CTLSEQS_READER_SAVE_MATCHED_SEQS is enabled, also save those values when the match is successful.

Argument timeout is the maximum duration of time (in milliseconds) to wait until any data can be read. If timeout is -1, the function blocks indefinitely. If option CTLSEQS_READER_NO_POLL is enabled, this argument has no effect.

For a successful match, the extracted values are stored in result like ctlseqs_match, but starting at offset 0 unless CTLSEQS_READER_SAVE_MATCHED_SEQS is enabled.

If a control sequence is successfully read, and matches at least one pattern in matcher, returns a non-negative integer representing the offset of a matching pattern.

Otherwise, returns a negative value:

CTLSEQS_NOMATCH
A control sequence is successfully read, but fails to match any pattern in matcher.
CTLSEQS_PARTIAL
Data is read successfully and can be recognized as part of a control sequence, but is not yet terminated. Partial sequence is not consumed from the read buffer.
CTLSEQS_NOSEQ
Data is read successfully, but cannot be recognized as a valid control sequence.
CTLSEQS_TIMEOUT
The specified timeout has expired, and no data is read.
CTLSEQS_NOMEM
Like CTLSEQS_PARTIAL, but the internal read buffer is full, and no data can be further read.
CTLSEQS_EOF
End-of-file is encountered, and no data is read.
CTLSEQS_ERROR
An unexpected error occurs during a system call within the function.
CTLSEQS_INTR
A system call within the function is interrupted by a signal, and no data is read.

Copyright (c) 2020,2021 CismonX <admin@cismon.net>

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty, provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

ctlseqs_match(3), ctlseqs_matcher_config(3), ctlseqs_reader_config(3)
September 1, 2020 0.1.0