ctlseqs/man/ctlseqs_read.3

87 lines
2.4 KiB
Groff

.TH CTLSEQS_READ 3 "Sep 01, 2020" 0.1.0 "Ctlseqs Library Manual"
.
.SH NAME
ctlseqs_read - read control sequence
.
.SH SYNOPSYS
.nf
.B #include <ctlseqs.h>
.PP
.BI "ssize_t ctlseqs_read(struct ctlseqs_reader *" reader ,
.BI " struct ctlseqs_matcher const *" matcher ", int " timeout );
.fi
.
.SH DESCRIPTION
Attempts to read a terminal control sequence, and extract values according to given patterns.
.PP
The
.I reader
argument specifies the behaviour of the read operation, which can be configured with
.BR ctlseqs_reader_config ().
.PP
The
.I matcher
argument specifies the expected patterns of control sequences to be matched upon after a successful read, which can be configured with
.BR ctlseqs_matcher_config ().
A NULL
.I matcher
is allowed, acting as if
.I npatterns
is 0.
.PP
Argument
.I timeout
is the maximum duration of time (in milliseconds) to wait until any data can be read.
If
.I timeout
is -1, the function blocks indefinitely. If option
.B CTLSEQS_READER_NO_POLL
is enabled, this argument has no effect.
.
.SH RETURN VALUE
If a control sequence is successfully read, and matches at least one pattern in
.IR matcher ,
returns a non-negative integer representing the offset of a matching pattern.
.PP
Otherwise, returns a negative value:
.TP
.B CTLSEQS_NOMATCH
A control sequence is successfully read, but fails to match any pattern in
.IR matcher .
.TP
.B 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.
.TP
.B CTLSEQS_NOSEQ
Data is read successfully, but cannot be recognized as a valid control sequence.
.TP
.B CTLSEQS_TIMEOUT
The specified
.I timeout
has expired, and no data is read.
.TP
.B CTLSEQS_NOMEM
Like
.BR CTLSEQS_PARTIAL ,
but the internal read buffer is full, and no data can be further read.
.TP
.B CTLSEQS_EOF
End-of-file is encountered, and no data is read.
.TP
.B CTLSEQS_ERROR
An unexpected error occurs during a system call within the function.
.TP
.B CTLSEQS_INTR
A system call within the function is interrupted by a signal, and no data is read.
.
.SH SEE ALSO
.BR ctlseqs_matcher_config (3),
.BR ctlseqs_reader_config (3)
.
.SH COPYRIGHT
Copyright (c) 2020 CismonX <admin@cismon.net>
.PP
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.