diff options
author | Daniel Salzman <daniel.salzman@nic.cz> | 2024-09-19 12:03:53 +0200 |
---|---|---|
committer | Daniel Salzman <daniel.salzman@nic.cz> | 2024-09-24 17:10:22 +0200 |
commit | abafc9af9a0b4875e3b2eb45b65bb34203afb0cd (patch) | |
tree | 9c6172f12d61464ff47d05cbab2f6b07d30812dd /src | |
parent | Merge branch 'dnskey_sync_log' into 'master' (diff) | |
download | knot-abafc9af9a0b4875e3b2eb45b65bb34203afb0cd.tar.xz knot-abafc9af9a0b4875e3b2eb45b65bb34203afb0cd.zip |
ctl: move command-specific flags to filters
This affects conf-list, conf-diff, zone-diff, and zone-status.
Diffstat (limited to 'src')
-rw-r--r-- | src/knot/ctl/commands.c | 36 | ||||
-rw-r--r-- | src/knot/ctl/commands.h | 18 | ||||
-rw-r--r-- | src/utils/knotc/commands.c | 42 | ||||
-rw-r--r-- | src/utils/knotc/interactive.c | 24 |
4 files changed, 60 insertions, 60 deletions
diff --git a/src/knot/ctl/commands.c b/src/knot/ctl/commands.c index c62d8ab1c..5eb5d4a63 100644 --- a/src/knot/ctl/commands.c +++ b/src/knot/ctl/commands.c @@ -256,23 +256,23 @@ static int zone_status(zone_t *zone, ctl_args_t *args) return KNOT_EINVAL; } - char flags[16] = ""; + char filters[16] = ""; knot_ctl_data_t data = { [KNOT_CTL_IDX_ZONE] = name, - [KNOT_CTL_IDX_FLAGS] = flags + [KNOT_CTL_IDX_FILTER] = filters, }; const bool slave = zone_is_slave(conf(), zone); if (slave) { - strlcat(flags, CTL_FLAG_STATUS_SLAVE, sizeof(flags)); + strlcat(filters, CTL_FILTER_STATUS_SLAVE_R, sizeof(filters)); } const bool empty = (zone->contents == NULL); if (empty) { - strlcat(flags, CTL_FLAG_STATUS_EMPTY, sizeof(flags)); + strlcat(filters, CTL_FILTER_STATUS_EMPTY_R, sizeof(filters)); } const bool member = (zone->flags & ZONE_IS_CAT_MEMBER); if (member) { - strlcat(flags, CTL_FLAG_STATUS_MEMBER, sizeof(flags)); + strlcat(filters, CTL_FILTER_STATUS_MEMBER_R, sizeof(filters)); } int ret; @@ -436,7 +436,7 @@ static int zone_status(zone_t *zone, ctl_args_t *args) knot_time_print_t format = TIME_PRINT_HUMAN_MIXED; if (ctl_has_flag(args->data[KNOT_CTL_IDX_FLAGS], - CTL_FLAG_STATUS_UNIXTIME)) { + CTL_FILTER_STATUS_UNIXTIME)) { format = TIME_PRINT_UNIX; } @@ -1225,7 +1225,7 @@ static int zone_txn_get(zone_t *zone, ctl_args_t *args) static int send_changeset_part(changeset_t *ch, send_ctx_t *ctx, bool from) { - ctx->data[KNOT_CTL_IDX_FLAGS] = from ? CTL_FLAG_DIFF_REM : CTL_FLAG_DIFF_ADD; + ctx->data[KNOT_CTL_IDX_FILTER] = from ? CTL_FILTER_DIFF_REM_R : CTL_FILTER_DIFF_ADD_R; // Send SOA only if explicitly changed. if (ch->soa_to != NULL) { @@ -1292,7 +1292,7 @@ static int zone_txn_diff_l(zone_t *zone, ctl_args_t *args) // FULL update has no changeset to print, do a 'get' instead. if (zone->control_update->flags & UPDATE_FULL) { - return zone_flag_txn_get(zone, args, CTL_FLAG_DIFF_ADD); + return zone_flag_txn_get(zone, args, CTL_FILTER_DIFF_ADD_R); } send_ctx_t *ctx = &ctl_globals[args->thread_idx].send_ctx; @@ -2100,8 +2100,8 @@ static int send_block(conf_io_t *io) // Get the item prefix. switch (io->type) { - case NEW: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_DIFF_ADD; break; - case OLD: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_DIFF_REM; break; + case NEW: data[KNOT_CTL_IDX_FILTER] = CTL_FILTER_DIFF_ADD_R; break; + case OLD: data[KNOT_CTL_IDX_FILTER] = CTL_FILTER_DIFF_REM_R; break; default: break; } @@ -2213,14 +2213,14 @@ static int ctl_conf_list(ctl_args_t *args, ctl_cmd_t cmd) int ret = KNOT_EOK; while (true) { - const char *key0 = args->data[KNOT_CTL_IDX_SECTION]; - const char *key1 = args->data[KNOT_CTL_IDX_ITEM]; - const char *id = args->data[KNOT_CTL_IDX_ID]; - const char *flags = args->data[KNOT_CTL_IDX_FLAGS]; - - bool schema = ctl_has_flag(flags, CTL_FLAG_LIST_SCHEMA); - bool current = !ctl_has_flag(flags, CTL_FLAG_LIST_TXN); - bool zones = ctl_has_flag(flags, CTL_FLAG_LIST_ZONES); + const char *key0 = args->data[KNOT_CTL_IDX_SECTION]; + const char *key1 = args->data[KNOT_CTL_IDX_ITEM]; + const char *id = args->data[KNOT_CTL_IDX_ID]; + const char *filters = args->data[KNOT_CTL_IDX_FILTER]; + + bool schema = ctl_has_flag(filters, CTL_FILTER_LIST_SCHEMA); + bool current = !ctl_has_flag(filters, CTL_FILTER_LIST_TXN); + bool zones = ctl_has_flag(filters, CTL_FILTER_LIST_ZONES); if (zones) { ret = list_zones(args->server->zone_db, args->ctl); diff --git a/src/knot/ctl/commands.h b/src/knot/ctl/commands.h index b0f33d8a2..c82c61a90 100644 --- a/src/knot/ctl/commands.h +++ b/src/knot/ctl/commands.h @@ -22,17 +22,17 @@ #define CTL_FLAG_FORCE "F" #define CTL_FLAG_BLOCKING "B" -#define CTL_FLAG_DIFF_ADD "+" -#define CTL_FLAG_DIFF_REM "-" +#define CTL_FILTER_DIFF_ADD_R "+" +#define CTL_FILTER_DIFF_REM_R "-" -#define CTL_FLAG_LIST_SCHEMA "s" -#define CTL_FLAG_LIST_TXN "t" -#define CTL_FLAG_LIST_ZONES "z" +#define CTL_FILTER_LIST_SCHEMA "s" +#define CTL_FILTER_LIST_TXN "t" +#define CTL_FILTER_LIST_ZONES "z" -#define CTL_FLAG_STATUS_EMPTY "e" -#define CTL_FLAG_STATUS_SLAVE "s" -#define CTL_FLAG_STATUS_MEMBER "m" -#define CTL_FLAG_STATUS_UNIXTIME "u" +#define CTL_FILTER_STATUS_EMPTY_R "e" +#define CTL_FILTER_STATUS_SLAVE_R "s" +#define CTL_FILTER_STATUS_MEMBER_R "m" +#define CTL_FILTER_STATUS_UNIXTIME "u" #define CTL_FILTER_FLUSH_OUTDIR 'd' diff --git a/src/utils/knotc/commands.c b/src/utils/knotc/commands.c index 5cc1a1452..97c30f6ea 100644 --- a/src/utils/knotc/commands.c +++ b/src/utils/knotc/commands.c @@ -206,16 +206,16 @@ static int get_conf_key(const char *key, knot_ctl_data_t *data) static void format_data(cmd_args_t *args, knot_ctl_type_t data_type, knot_ctl_data_t *data, bool *empty) { - const char *error = (*data)[KNOT_CTL_IDX_ERROR]; - const char *flags = (*data)[KNOT_CTL_IDX_FLAGS]; - const char *key0 = (*data)[KNOT_CTL_IDX_SECTION]; - const char *key1 = (*data)[KNOT_CTL_IDX_ITEM]; - const char *id = (*data)[KNOT_CTL_IDX_ID]; - const char *zone = (*data)[KNOT_CTL_IDX_ZONE]; - const char *owner = (*data)[KNOT_CTL_IDX_OWNER]; - const char *ttl = (*data)[KNOT_CTL_IDX_TTL]; - const char *type = (*data)[KNOT_CTL_IDX_TYPE]; - const char *value = (*data)[KNOT_CTL_IDX_DATA]; + const char *error = (*data)[KNOT_CTL_IDX_ERROR]; + const char *filters = (*data)[KNOT_CTL_IDX_FILTER]; + const char *key0 = (*data)[KNOT_CTL_IDX_SECTION]; + const char *key1 = (*data)[KNOT_CTL_IDX_ITEM]; + const char *id = (*data)[KNOT_CTL_IDX_ID]; + const char *zone = (*data)[KNOT_CTL_IDX_ZONE]; + const char *owner = (*data)[KNOT_CTL_IDX_OWNER]; + const char *ttl = (*data)[KNOT_CTL_IDX_TTL]; + const char *type = (*data)[KNOT_CTL_IDX_TYPE]; + const char *value = (*data)[KNOT_CTL_IDX_DATA]; bool col = false; char status_col[32] = ""; @@ -223,10 +223,10 @@ static void format_data(cmd_args_t *args, knot_ctl_type_t data_type, static bool first_status_item = true; const char *sign = NULL; - if (ctl_has_flag(flags, CTL_FLAG_DIFF_ADD)) { - sign = CTL_FLAG_DIFF_ADD; - } else if (ctl_has_flag(flags, CTL_FLAG_DIFF_REM)) { - sign = CTL_FLAG_DIFF_REM; + if (ctl_has_flag(filters, CTL_FILTER_DIFF_ADD_R)) { + sign = CTL_FILTER_DIFF_ADD_R; + } else if (ctl_has_flag(filters, CTL_FILTER_DIFF_REM_R)) { + sign = CTL_FILTER_DIFF_REM_R; } switch (args->desc->cmd) { @@ -253,15 +253,15 @@ static void format_data(cmd_args_t *args, knot_ctl_type_t data_type, if (error == NULL) { col = args->extended ? args->color_force : args->color; } - if (!ctl_has_flag(flags, CTL_FLAG_STATUS_EMPTY)) { + if (!ctl_has_flag(filters, CTL_FILTER_STATUS_EMPTY_R)) { strlcat(status_col, COL_BOLD(col), sizeof(status_col)); } - if (ctl_has_flag(flags, CTL_FLAG_STATUS_SLAVE)) { + if (ctl_has_flag(filters, CTL_FILTER_STATUS_SLAVE_R)) { strlcat(status_col, COL_RED(col), sizeof(status_col)); } else { strlcat(status_col, COL_GRN(col), sizeof(status_col)); } - if (ctl_has_flag(flags, CTL_FLAG_STATUS_MEMBER)) { + if (ctl_has_flag(filters, CTL_FILTER_STATUS_MEMBER_R)) { strlcat(status_col, COL_UNDR(col), sizeof(status_col)); } // FALLTHROUGH @@ -1233,15 +1233,15 @@ static int cmd_conf_ctl(cmd_args_t *args) return ret; } - char flags[16] = ""; - strlcat(flags, args->flags, sizeof(flags)); + char filters[16] = ""; + strlcat(filters, args->flags, sizeof(filters)); if (args->desc->flags & CMD_FLIST_SCHEMA) { - strlcat(flags, CTL_FLAG_LIST_SCHEMA, sizeof(flags)); + strlcat(filters, CTL_FILTER_LIST_SCHEMA, sizeof(filters)); } knot_ctl_data_t data = { [KNOT_CTL_IDX_CMD] = ctl_cmd_to_str(args->desc->cmd), - [KNOT_CTL_IDX_FLAGS] = flags, + [KNOT_CTL_IDX_FILTER] = filters, }; // Send the command without parameters. diff --git a/src/utils/knotc/interactive.c b/src/utils/knotc/interactive.c index a03b8d336..a0db57ee6 100644 --- a/src/utils/knotc/interactive.c +++ b/src/utils/knotc/interactive.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2024 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -126,7 +126,7 @@ static void list_separators(EditLine *el, const char *separators) static bool rmt_lookup(EditLine *el, const char *str, size_t str_len, const char *section, const char *item, const char *id, - dup_check_ctx_t *check_ctx, bool add_space, const char *flags, + dup_check_ctx_t *check_ctx, bool add_space, const char *filters, knot_ctl_idx_t idx) { const cmd_desc_t *desc = cmd_table; @@ -140,7 +140,7 @@ static bool rmt_lookup(EditLine *el, const char *str, size_t str_len, [KNOT_CTL_IDX_SECTION] = section, [KNOT_CTL_IDX_ITEM] = item, [KNOT_CTL_IDX_ID] = id, - [KNOT_CTL_IDX_FLAGS] = flags + [KNOT_CTL_IDX_FILTER] = filters, }; lookup_t lookup; @@ -196,37 +196,37 @@ static bool id_lookup(EditLine *el, const char *str, size_t str_len, const char *section, const cmd_desc_t *cmd_desc, dup_check_ctx_t *ctx, bool add_space, bool zones) { - char flags[4] = ""; + char filters[4] = ""; if (zones) { - strlcat(flags, CTL_FLAG_LIST_ZONES, sizeof(flags)); + strlcat(filters, CTL_FILTER_LIST_ZONES, sizeof(filters)); } else if (cmd_desc->flags & CMD_FREQ_TXN) { - strlcat(flags, CTL_FLAG_LIST_TXN, sizeof(flags)); + strlcat(filters, CTL_FILTER_LIST_TXN, sizeof(filters)); } return rmt_lookup(el, str, str_len, section, NULL, NULL, ctx, add_space, - flags, KNOT_CTL_IDX_ID); + filters, KNOT_CTL_IDX_ID); } static void val_lookup(EditLine *el, const char *str, size_t str_len, const char *section, const char *item, const char *id, dup_check_ctx_t *ctx, bool list_schema) { - char flags[4] = CTL_FLAG_LIST_TXN; + char filters[4] = CTL_FILTER_LIST_TXN; if (list_schema) { - strlcat(flags, CTL_FLAG_LIST_SCHEMA, sizeof(flags)); + strlcat(filters, CTL_FILTER_LIST_SCHEMA, sizeof(filters)); } (void)rmt_lookup(el, str, str_len, section, item, id, ctx, true, - flags, KNOT_CTL_IDX_DATA); + filters, KNOT_CTL_IDX_DATA); } static bool list_lookup(EditLine *el, const char *str, const char *section) { - const char *flags = CTL_FLAG_LIST_SCHEMA; + const char *filters = CTL_FILTER_LIST_SCHEMA; knot_ctl_idx_t idx = (section == NULL) ? KNOT_CTL_IDX_SECTION : KNOT_CTL_IDX_ITEM; return rmt_lookup(el, str, strlen(str), section, NULL, NULL, NULL, - section != NULL, flags, idx); + section != NULL, filters, idx); } static void item_lookup(EditLine *el, const char *str, const cmd_desc_t *cmd_desc) |