Rename configuration functions.
This commit is contained in:
parent
510fae5b0a
commit
823544151e
|
@ -148,11 +148,11 @@ sixdraw_init(struct sixdraw_ctx *ctx, int argc, char **argv)
|
||||||
CTLSEQS_RESP_PRIMARY_DA(CTLSEQS_PH_NUMS),
|
CTLSEQS_RESP_PRIMARY_DA(CTLSEQS_PH_NUMS),
|
||||||
CTLSEQS_RESP_DECRQM(CTLSEQS_PH_NUM, CTLSEQS_PH_NUM)
|
CTLSEQS_RESP_DECRQM(CTLSEQS_PH_NUM, CTLSEQS_PH_NUM)
|
||||||
};
|
};
|
||||||
struct ctlseqs_matcher_opts options = {
|
struct ctlseqs_matcher_options matcher_options = {
|
||||||
.patterns = patterns,
|
.patterns = patterns,
|
||||||
.npatterns = sizeof(patterns) / sizeof(char const *),
|
.npatterns = sizeof(patterns) / sizeof(char const *),
|
||||||
};
|
};
|
||||||
if (ctlseqs_matcher_setopt(ctx->matcher, &options) != 0) {
|
if (ctlseqs_matcher_config(ctx->matcher, &matcher_options) != 0) {
|
||||||
sixdraw_print_error(ctx, "failed to set matcher options");
|
sixdraw_print_error(ctx, "failed to set matcher options");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -163,12 +163,12 @@ sixdraw_init(struct sixdraw_ctx *ctx, int argc, char **argv)
|
||||||
sixdraw_print_error(ctx, "failed to initialize reader");
|
sixdraw_print_error(ctx, "failed to initialize reader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
struct ctlseqs_reader_opts reader_opts = {
|
struct ctlseqs_reader_options reader_options = {
|
||||||
.buffer = ctx->buffer,
|
.buffer = ctx->buffer,
|
||||||
.fd = ctx->in_fd,
|
.fd = ctx->in_fd,
|
||||||
.maxlen = 32,
|
.maxlen = 32,
|
||||||
};
|
};
|
||||||
if (ctlseqs_reader_setopt(ctx->reader, &reader_opts) != CTLSEQS_OK) {
|
if (ctlseqs_reader_config(ctx->reader, &reader_options) != CTLSEQS_OK) {
|
||||||
sixdraw_print_error(ctx, "failed to set reader options");
|
sixdraw_print_error(ctx, "failed to set reader options");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
dist_man3_MANS = \
|
dist_man3_MANS = \
|
||||||
ctlseqs_matcher_init.3 \
|
ctlseqs_matcher_init.3 \
|
||||||
ctlseqs_matcher_setopt.3 \
|
ctlseqs_matcher_config.3 \
|
||||||
ctlseqs_matcher_free.3 \
|
ctlseqs_matcher_free.3 \
|
||||||
ctlseqs_reader_init.3 \
|
ctlseqs_reader_init.3 \
|
||||||
ctlseqs_reader_setopt.3 \
|
ctlseqs_reader_config.3 \
|
||||||
ctlseqs_read.3 \
|
ctlseqs_read.3 \
|
||||||
ctlseqs_purge.3 \
|
ctlseqs_purge.3 \
|
||||||
ctlseqs_reader_free.3
|
ctlseqs_reader_free.3
|
||||||
|
|
|
@ -47,11 +47,11 @@ C1 (8-bit) control characters are not supported.
|
||||||
.BR ncurses (3X)
|
.BR ncurses (3X)
|
||||||
.PP
|
.PP
|
||||||
.BR ctlseqs_matcher_init (3),
|
.BR ctlseqs_matcher_init (3),
|
||||||
.BR ctlseqs_matcher_setopt (3),
|
.BR ctlseqs_matcher_config (3),
|
||||||
.BR ctlseqs_matcher_free (3)
|
.BR ctlseqs_matcher_free (3)
|
||||||
.PP
|
.PP
|
||||||
.BR ctlseqs_reader_init (3),
|
.BR ctlseqs_reader_init (3),
|
||||||
.BR ctlseqs_reader_setopt (3),
|
.BR ctlseqs_reader_config (3),
|
||||||
.BR ctlseqs_reader_free (3)
|
.BR ctlseqs_reader_free (3)
|
||||||
.PP
|
.PP
|
||||||
.BR ctlseqs_read (3)
|
.BR ctlseqs_read (3)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
.TH CTLSEQS_MATCHER_SETOPT 3 "Sep 01, 2020" 0.1.0 "Ctlseqs Library Manual"
|
.TH CTLSEQS_MATCHER_CONFIG 3 "Sep 01, 2020" 0.1.0 "Ctlseqs Library Manual"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ctlseqs_matcher_setopt - set control sequence matcher options
|
ctlseqs_matcher_config - configure control sequence matcher
|
||||||
.
|
.
|
||||||
.SH SYNOPSYS
|
.SH SYNOPSYS
|
||||||
.nf
|
.nf
|
||||||
.B #include <ctlseqs.h>
|
.B #include <ctlseqs.h>
|
||||||
.PP
|
.PP
|
||||||
.BI "int ctlseqs_matcher_setopt(struct ctlseqs_matcher *" matcher ,
|
.BI "int ctlseqs_matcher_config(struct ctlseqs_matcher *" matcher ,
|
||||||
.BI " struct ctlseqs_matcher_opts const *" options );
|
.BI " struct ctlseqs_matcher_options const *" options );
|
||||||
.fi
|
.fi
|
||||||
.
|
.
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -18,13 +18,13 @@ Changes the properties of the given
|
||||||
The
|
The
|
||||||
.I options
|
.I options
|
||||||
argument is a pointer to a
|
argument is a pointer to a
|
||||||
.BR "struct ctlseqs_matcher_opts" ,
|
.BR "struct ctlseqs_matcher_options" ,
|
||||||
whose definition is shown below:
|
whose definition is shown below:
|
||||||
.PP
|
.PP
|
||||||
.nf
|
.nf
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
struct ctlseqs_matcher_opts {
|
struct ctlseqs_matcher_options {
|
||||||
char const *const *patterns;
|
char const *const *patterns;
|
||||||
size_t npatterns;
|
size_t npatterns;
|
||||||
};
|
};
|
|
@ -12,7 +12,7 @@ ctlseqs_matcher_init - initialize control sequence matcher
|
||||||
.
|
.
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Creates a control sequence matcher, which can be configured with
|
Creates a control sequence matcher, which can be configured with
|
||||||
.BR ctlseqs_matcher_setopt ().
|
.BR ctlseqs_matcher_config ().
|
||||||
.PP
|
.PP
|
||||||
Instance of a control sequence matcher should be freed with
|
Instance of a control sequence matcher should be freed with
|
||||||
.BR ctlseqs_matcher_free ().
|
.BR ctlseqs_matcher_free ().
|
||||||
|
@ -25,7 +25,7 @@ holding the matcher instance.
|
||||||
If the function fails to allocate sufficient memory, returns NULL.
|
If the function fails to allocate sufficient memory, returns NULL.
|
||||||
.
|
.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR ctlseqs_matcher_setopt (3),
|
.BR ctlseqs_matcher_config (3),
|
||||||
.BR ctlseqs_matcher_free (3)
|
.BR ctlseqs_matcher_free (3)
|
||||||
.
|
.
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
|
|
|
@ -17,12 +17,12 @@ Attempts to read a terminal control sequence, and extract values according to gi
|
||||||
The
|
The
|
||||||
.I reader
|
.I reader
|
||||||
argument specifies the behaviour of the read operation, which can be configured with
|
argument specifies the behaviour of the read operation, which can be configured with
|
||||||
.BR ctlseqs_reader_setopt ().
|
.BR ctlseqs_reader_config ().
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I matcher
|
.I matcher
|
||||||
argument specifies the expected patterns of control sequences to be matched upon after a successful read, which can be configured with
|
argument specifies the expected patterns of control sequences to be matched upon after a successful read, which can be configured with
|
||||||
.BR ctlseqs_matcher_setopt ().
|
.BR ctlseqs_matcher_config ().
|
||||||
A NULL
|
A NULL
|
||||||
.I matcher
|
.I matcher
|
||||||
is allowed, acting as if
|
is allowed, acting as if
|
||||||
|
@ -95,8 +95,8 @@ The byte following a single-shift should be a printable character.
|
||||||
.B SOS [chrstr] ST
|
.B SOS [chrstr] ST
|
||||||
Character string can be any bit combination which does not represent SOS or ST.
|
Character string can be any bit combination which does not represent SOS or ST.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR ctlseqs_matcher_setopt (3),
|
.BR ctlseqs_matcher_config (3),
|
||||||
.BR ctlseqs_reader_setopt (3)
|
.BR ctlseqs_reader_config (3)
|
||||||
.
|
.
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright (c) 2020 CismonX <admin@cismon.net>
|
Copyright (c) 2020 CismonX <admin@cismon.net>
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
.TH CTLSEQS_READER_SETOPT 3 "Sep 01, 2020" 0.1.0 "Ctlseqs Library Manual"
|
.TH CTLSEQS_READER_CONFIG 3 "Sep 01, 2020" 0.1.0 "Ctlseqs Library Manual"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ctlseqs_reader_setopt - set control sequence reader options
|
ctlseqs_reader_config - configure control sequence reader
|
||||||
.
|
.
|
||||||
.SH SYNOPSYS
|
.SH SYNOPSYS
|
||||||
.nf
|
.nf
|
||||||
.B #include <ctlseqs.h>
|
.B #include <ctlseqs.h>
|
||||||
.PP
|
.PP
|
||||||
.BI "int ctlseqs_reader_setopt(struct ctlseqs_reader *" reader ,
|
.BI "int ctlseqs_reader_config(struct ctlseqs_reader *" reader ,
|
||||||
.BI " struct ctlseqs_reader_opts const *" options );
|
.BI " struct ctlseqs_reader_options const *" options );
|
||||||
.fi
|
.fi
|
||||||
.
|
.
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Function
|
Function
|
||||||
.BR ctlseqs_reader_setopt ()
|
.BR ctlseqs_reader_config ()
|
||||||
changes the properties of the given
|
changes the properties of the given
|
||||||
.IR reader .
|
.IR reader .
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I options
|
.I options
|
||||||
argument is a pointer to a
|
argument is a pointer to a
|
||||||
.BR "struct ctlseqs_reader_opts" ,
|
.BR "struct ctlseqs_reader_options" ,
|
||||||
as shown below:
|
as shown below:
|
||||||
.PP
|
.PP
|
||||||
.nf
|
.nf
|
||||||
.in +4n
|
.in +4n
|
||||||
.EX
|
.EX
|
||||||
struct ctlseqs_reader_opts {
|
struct ctlseqs_reader_options {
|
||||||
union ctlseqs_value *buffer;
|
union ctlseqs_value *buffer;
|
||||||
size_t maxlen;
|
size_t maxlen;
|
||||||
int fd;
|
int fd;
|
|
@ -12,7 +12,7 @@ ctlseqs_reader_init - initialize control sequence reader
|
||||||
.
|
.
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Creates a control sequence reader, which can be configured with
|
Creates a control sequence reader, which can be configured with
|
||||||
.BR ctlseqs_reader_setopt ().
|
.BR ctlseqs_reader_config ().
|
||||||
.PP
|
.PP
|
||||||
Instance of a control sequence reader should be freed with
|
Instance of a control sequence reader should be freed with
|
||||||
.BR ctlseqs_reader_free ().
|
.BR ctlseqs_reader_free ().
|
||||||
|
@ -25,7 +25,7 @@ holding the reader instance.
|
||||||
If the function fails to allocate sufficient memory, returns NULL.
|
If the function fails to allocate sufficient memory, returns NULL.
|
||||||
.
|
.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR ctlseqs_reader_setopt (3),
|
.BR ctlseqs_reader_config (3),
|
||||||
.BR ctlseqs_reader_free (3)
|
.BR ctlseqs_reader_free (3)
|
||||||
.
|
.
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
|
|
|
@ -389,7 +389,7 @@ ctlseqs_matcher_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ctlseqs_matcher_setopt(struct ctlseqs_matcher *matcher, struct ctlseqs_matcher_opts const *options)
|
ctlseqs_matcher_config(struct ctlseqs_matcher *matcher, struct ctlseqs_matcher_options const *options)
|
||||||
{
|
{
|
||||||
size_t node_pool_idx = 0, max_format_size = 0;
|
size_t node_pool_idx = 0, max_format_size = 0;
|
||||||
if (matcher->node_pool == NULL) {
|
if (matcher->node_pool == NULL) {
|
||||||
|
@ -470,7 +470,7 @@ ctlseqs_reader_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ctlseqs_reader_setopt(struct ctlseqs_reader *reader, struct ctlseqs_reader_opts const *options)
|
ctlseqs_reader_config(struct ctlseqs_reader *reader, struct ctlseqs_reader_options const *options)
|
||||||
{
|
{
|
||||||
size_t readlen = options->maxlen;
|
size_t readlen = options->maxlen;
|
||||||
if (reader->readlen != readlen) {
|
if (reader->readlen != readlen) {
|
||||||
|
|
|
@ -367,12 +367,12 @@ struct ctlseqs_matcher;
|
||||||
|
|
||||||
struct ctlseqs_reader;
|
struct ctlseqs_reader;
|
||||||
|
|
||||||
struct ctlseqs_matcher_opts {
|
struct ctlseqs_matcher_options {
|
||||||
char const *const *patterns;
|
char const *const *patterns;
|
||||||
size_t npatterns;
|
size_t npatterns;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ctlseqs_reader_opts {
|
struct ctlseqs_reader_options {
|
||||||
union ctlseqs_value *buffer;
|
union ctlseqs_value *buffer;
|
||||||
size_t maxlen;
|
size_t maxlen;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -394,7 +394,7 @@ struct ctlseqs_matcher *
|
||||||
ctlseqs_matcher_init();
|
ctlseqs_matcher_init();
|
||||||
|
|
||||||
int
|
int
|
||||||
ctlseqs_matcher_setopt(struct ctlseqs_matcher *matcher, struct ctlseqs_matcher_opts const *options);
|
ctlseqs_matcher_config(struct ctlseqs_matcher *matcher, struct ctlseqs_matcher_options const *options);
|
||||||
|
|
||||||
void
|
void
|
||||||
ctlseqs_matcher_free(struct ctlseqs_matcher *matcher);
|
ctlseqs_matcher_free(struct ctlseqs_matcher *matcher);
|
||||||
|
@ -403,7 +403,7 @@ struct ctlseqs_reader *
|
||||||
ctlseqs_reader_init();
|
ctlseqs_reader_init();
|
||||||
|
|
||||||
int
|
int
|
||||||
ctlseqs_reader_setopt(struct ctlseqs_reader *reader, struct ctlseqs_reader_opts const *options);
|
ctlseqs_reader_config(struct ctlseqs_reader *reader, struct ctlseqs_reader_options const *options);
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
ctlseqs_read(struct ctlseqs_reader *reader, struct ctlseqs_matcher const *matcher, int timeout);
|
ctlseqs_read(struct ctlseqs_reader *reader, struct ctlseqs_matcher const *matcher, int timeout);
|
||||||
|
|
|
@ -325,11 +325,11 @@ main(int argc, char **argv)
|
||||||
for (size_t idx = 0; idx < npatterns; ++idx) {
|
for (size_t idx = 0; idx < npatterns; ++idx) {
|
||||||
patterns[idx] = seqs[idx].pattern;
|
patterns[idx] = seqs[idx].pattern;
|
||||||
}
|
}
|
||||||
struct ctlseqs_matcher_opts matcher_opts = {
|
struct ctlseqs_matcher_options matcher_options = {
|
||||||
.patterns = patterns,
|
.patterns = patterns,
|
||||||
.npatterns = npatterns,
|
.npatterns = npatterns,
|
||||||
};
|
};
|
||||||
if (ctlseqs_matcher_setopt(matcher, &matcher_opts) != CTLSEQS_OK) {
|
if (ctlseqs_matcher_config(matcher, &matcher_options) != CTLSEQS_OK) {
|
||||||
print_error(&ctx, "matcher setopt failed");
|
print_error(&ctx, "matcher setopt failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -339,12 +339,12 @@ main(int argc, char **argv)
|
||||||
print_error(&ctx, "failed to initialize reader");
|
print_error(&ctx, "failed to initialize reader");
|
||||||
}
|
}
|
||||||
union ctlseqs_value buffer[16];
|
union ctlseqs_value buffer[16];
|
||||||
struct ctlseqs_reader_opts reader_opts = {
|
struct ctlseqs_reader_options reader_options = {
|
||||||
.fd = STDIN_FILENO,
|
.fd = STDIN_FILENO,
|
||||||
.maxlen = ctx.limit,
|
.maxlen = ctx.limit,
|
||||||
.buffer = buffer
|
.buffer = buffer
|
||||||
};
|
};
|
||||||
if (ctlseqs_reader_setopt(reader, &reader_opts) != CTLSEQS_OK) {
|
if (ctlseqs_reader_config(reader, &reader_options) != CTLSEQS_OK) {
|
||||||
print_error(&ctx, "reader setopt failed");
|
print_error(&ctx, "reader setopt failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue