From 823544151e96f18f1d770b82a8f59744f7a3428f Mon Sep 17 00:00:00 2001 From: CismonX Date: Fri, 11 Dec 2020 12:47:14 +0800 Subject: [PATCH] Rename configuration functions. --- examples/sixdraw.c | 8 ++++---- man/Makefile.am | 4 ++-- man/ctlseqs.7 | 4 ++-- ...s_matcher_setopt.3 => ctlseqs_matcher_config.3} | 12 ++++++------ man/ctlseqs_matcher_init.3 | 4 ++-- man/ctlseqs_read.3 | 8 ++++---- ...eqs_reader_setopt.3 => ctlseqs_reader_config.3} | 14 +++++++------- man/ctlseqs_reader_init.3 | 4 ++-- src/ctlseqs.c | 4 ++-- src/ctlseqs.h | 8 ++++---- tests/tcsgrep.c | 8 ++++---- 11 files changed, 39 insertions(+), 39 deletions(-) rename man/{ctlseqs_matcher_setopt.3 => ctlseqs_matcher_config.3} (76%) rename man/{ctlseqs_reader_setopt.3 => ctlseqs_reader_config.3} (90%) diff --git a/examples/sixdraw.c b/examples/sixdraw.c index a442140..ec8047d 100644 --- a/examples/sixdraw.c +++ b/examples/sixdraw.c @@ -148,11 +148,11 @@ sixdraw_init(struct sixdraw_ctx *ctx, int argc, char **argv) CTLSEQS_RESP_PRIMARY_DA(CTLSEQS_PH_NUMS), CTLSEQS_RESP_DECRQM(CTLSEQS_PH_NUM, CTLSEQS_PH_NUM) }; - struct ctlseqs_matcher_opts options = { + struct ctlseqs_matcher_options matcher_options = { .patterns = patterns, .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"); return false; } @@ -163,12 +163,12 @@ sixdraw_init(struct sixdraw_ctx *ctx, int argc, char **argv) sixdraw_print_error(ctx, "failed to initialize reader"); return false; } - struct ctlseqs_reader_opts reader_opts = { + struct ctlseqs_reader_options reader_options = { .buffer = ctx->buffer, .fd = ctx->in_fd, .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"); return false; } diff --git a/man/Makefile.am b/man/Makefile.am index 3162f91..881cf0e 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -8,10 +8,10 @@ dist_man3_MANS = \ ctlseqs_matcher_init.3 \ - ctlseqs_matcher_setopt.3 \ + ctlseqs_matcher_config.3 \ ctlseqs_matcher_free.3 \ ctlseqs_reader_init.3 \ - ctlseqs_reader_setopt.3 \ + ctlseqs_reader_config.3 \ ctlseqs_read.3 \ ctlseqs_purge.3 \ ctlseqs_reader_free.3 diff --git a/man/ctlseqs.7 b/man/ctlseqs.7 index f8db1a1..c4bc9e8 100644 --- a/man/ctlseqs.7 +++ b/man/ctlseqs.7 @@ -47,11 +47,11 @@ C1 (8-bit) control characters are not supported. .BR ncurses (3X) .PP .BR ctlseqs_matcher_init (3), -.BR ctlseqs_matcher_setopt (3), +.BR ctlseqs_matcher_config (3), .BR ctlseqs_matcher_free (3) .PP .BR ctlseqs_reader_init (3), -.BR ctlseqs_reader_setopt (3), +.BR ctlseqs_reader_config (3), .BR ctlseqs_reader_free (3) .PP .BR ctlseqs_read (3) diff --git a/man/ctlseqs_matcher_setopt.3 b/man/ctlseqs_matcher_config.3 similarity index 76% rename from man/ctlseqs_matcher_setopt.3 rename to man/ctlseqs_matcher_config.3 index 989dfc1..73b046b 100644 --- a/man/ctlseqs_matcher_setopt.3 +++ b/man/ctlseqs_matcher_config.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 -ctlseqs_matcher_setopt - set control sequence matcher options +ctlseqs_matcher_config - configure control sequence matcher . .SH SYNOPSYS .nf .B #include .PP -.BI "int ctlseqs_matcher_setopt(struct ctlseqs_matcher *" matcher , -.BI " struct ctlseqs_matcher_opts const *" options ); +.BI "int ctlseqs_matcher_config(struct ctlseqs_matcher *" matcher , +.BI " struct ctlseqs_matcher_options const *" options ); .fi . .SH DESCRIPTION @@ -18,13 +18,13 @@ Changes the properties of the given The .I options argument is a pointer to a -.BR "struct ctlseqs_matcher_opts" , +.BR "struct ctlseqs_matcher_options" , whose definition is shown below: .PP .nf .in +4n .EX -struct ctlseqs_matcher_opts { +struct ctlseqs_matcher_options { char const *const *patterns; size_t npatterns; }; diff --git a/man/ctlseqs_matcher_init.3 b/man/ctlseqs_matcher_init.3 index c779507..11a6f47 100644 --- a/man/ctlseqs_matcher_init.3 +++ b/man/ctlseqs_matcher_init.3 @@ -12,7 +12,7 @@ ctlseqs_matcher_init - initialize control sequence matcher . .SH DESCRIPTION Creates a control sequence matcher, which can be configured with -.BR ctlseqs_matcher_setopt (). +.BR ctlseqs_matcher_config (). .PP Instance of a control sequence matcher should be freed with .BR ctlseqs_matcher_free (). @@ -25,7 +25,7 @@ holding the matcher instance. If the function fails to allocate sufficient memory, returns NULL. . .SH SEE ALSO -.BR ctlseqs_matcher_setopt (3), +.BR ctlseqs_matcher_config (3), .BR ctlseqs_matcher_free (3) . .SH COPYRIGHT diff --git a/man/ctlseqs_read.3 b/man/ctlseqs_read.3 index 66c9d6a..39f789e 100644 --- a/man/ctlseqs_read.3 +++ b/man/ctlseqs_read.3 @@ -17,12 +17,12 @@ Attempts to read a terminal control sequence, and extract values according to gi The .I reader argument specifies the behaviour of the read operation, which can be configured with -.BR ctlseqs_reader_setopt (). +.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_setopt (). +.BR ctlseqs_matcher_config (). A NULL .I matcher is allowed, acting as if @@ -95,8 +95,8 @@ The byte following a single-shift should be a printable character. .B SOS [chrstr] ST Character string can be any bit combination which does not represent SOS or ST. .SH SEE ALSO -.BR ctlseqs_matcher_setopt (3), -.BR ctlseqs_reader_setopt (3) +.BR ctlseqs_matcher_config (3), +.BR ctlseqs_reader_config (3) . .SH COPYRIGHT Copyright (c) 2020 CismonX diff --git a/man/ctlseqs_reader_setopt.3 b/man/ctlseqs_reader_config.3 similarity index 90% rename from man/ctlseqs_reader_setopt.3 rename to man/ctlseqs_reader_config.3 index e7abdf8..3c5261a 100644 --- a/man/ctlseqs_reader_setopt.3 +++ b/man/ctlseqs_reader_config.3 @@ -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 -ctlseqs_reader_setopt - set control sequence reader options +ctlseqs_reader_config - configure control sequence reader . .SH SYNOPSYS .nf .B #include .PP -.BI "int ctlseqs_reader_setopt(struct ctlseqs_reader *" reader , -.BI " struct ctlseqs_reader_opts const *" options ); +.BI "int ctlseqs_reader_config(struct ctlseqs_reader *" reader , +.BI " struct ctlseqs_reader_options const *" options ); .fi . .SH DESCRIPTION Function -.BR ctlseqs_reader_setopt () +.BR ctlseqs_reader_config () changes the properties of the given .IR reader . .PP The .I options argument is a pointer to a -.BR "struct ctlseqs_reader_opts" , +.BR "struct ctlseqs_reader_options" , as shown below: .PP .nf .in +4n .EX -struct ctlseqs_reader_opts { +struct ctlseqs_reader_options { union ctlseqs_value *buffer; size_t maxlen; int fd; diff --git a/man/ctlseqs_reader_init.3 b/man/ctlseqs_reader_init.3 index 6075ddd..4aa1fe4 100644 --- a/man/ctlseqs_reader_init.3 +++ b/man/ctlseqs_reader_init.3 @@ -12,7 +12,7 @@ ctlseqs_reader_init - initialize control sequence reader . .SH DESCRIPTION Creates a control sequence reader, which can be configured with -.BR ctlseqs_reader_setopt (). +.BR ctlseqs_reader_config (). .PP Instance of a control sequence reader should be freed with .BR ctlseqs_reader_free (). @@ -25,7 +25,7 @@ holding the reader instance. If the function fails to allocate sufficient memory, returns NULL. . .SH SEE ALSO -.BR ctlseqs_reader_setopt (3), +.BR ctlseqs_reader_config (3), .BR ctlseqs_reader_free (3) . .SH COPYRIGHT diff --git a/src/ctlseqs.c b/src/ctlseqs.c index a167637..e5a8836 100644 --- a/src/ctlseqs.c +++ b/src/ctlseqs.c @@ -389,7 +389,7 @@ ctlseqs_matcher_init() } 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; if (matcher->node_pool == NULL) { @@ -470,7 +470,7 @@ ctlseqs_reader_init() } 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; if (reader->readlen != readlen) { diff --git a/src/ctlseqs.h b/src/ctlseqs.h index 6da1625..b53b17b 100644 --- a/src/ctlseqs.h +++ b/src/ctlseqs.h @@ -367,12 +367,12 @@ struct ctlseqs_matcher; struct ctlseqs_reader; -struct ctlseqs_matcher_opts { +struct ctlseqs_matcher_options { char const *const *patterns; size_t npatterns; }; -struct ctlseqs_reader_opts { +struct ctlseqs_reader_options { union ctlseqs_value *buffer; size_t maxlen; int fd; @@ -394,7 +394,7 @@ struct ctlseqs_matcher * ctlseqs_matcher_init(); 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 ctlseqs_matcher_free(struct ctlseqs_matcher *matcher); @@ -403,7 +403,7 @@ struct ctlseqs_reader * ctlseqs_reader_init(); 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 ctlseqs_read(struct ctlseqs_reader *reader, struct ctlseqs_matcher const *matcher, int timeout); diff --git a/tests/tcsgrep.c b/tests/tcsgrep.c index eed020f..5005c28 100644 --- a/tests/tcsgrep.c +++ b/tests/tcsgrep.c @@ -325,11 +325,11 @@ main(int argc, char **argv) for (size_t idx = 0; idx < npatterns; ++idx) { patterns[idx] = seqs[idx].pattern; } - struct ctlseqs_matcher_opts matcher_opts = { + struct ctlseqs_matcher_options matcher_options = { .patterns = patterns, .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"); return 1; } @@ -339,12 +339,12 @@ main(int argc, char **argv) print_error(&ctx, "failed to initialize reader"); } union ctlseqs_value buffer[16]; - struct ctlseqs_reader_opts reader_opts = { + struct ctlseqs_reader_options reader_options = { .fd = STDIN_FILENO, .maxlen = ctx.limit, .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"); return 1; }