From 66c09bf14a06c6eb75c4aa9504d6b7c6db8ed310 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Mon, 3 Jun 2019 00:32:30 +0100 Subject: [PATCH] merge Config and normal Accounts --- Makefile.autosetup | 2 +- account.c | 143 ++++++++++++++++++++++++++++++++++- account.h | 11 +++ config/cfgaccount.c | 163 ---------------------------------------- config/cfgaccount.h | 50 ------------ config/inheritance.h | 7 +- config/lib.h | 2 - po/POTFILES.in | 3 +- test/Makefile.autosetup | 3 +- test/config/account.c | 68 ++++++++++------- test/config/address.c | 6 +- test/config/bool.c | 6 +- test/config/command.c | 6 +- test/config/common.c | 1 + test/config/dump.c | 1 + test/config/initial.c | 1 + test/config/long.c | 6 +- test/config/magic.c | 6 +- test/config/mbtable.c | 6 +- test/config/number.c | 6 +- test/config/path.c | 6 +- test/config/quad.c | 6 +- test/config/regex.c | 6 +- test/config/set.c | 1 + test/config/sort.c | 6 +- test/config/string.c | 6 +- test/config/synonym.c | 1 + 27 files changed, 250 insertions(+), 279 deletions(-) delete mode 100644 config/cfgaccount.c delete mode 100644 config/cfgaccount.h diff --git a/Makefile.autosetup b/Makefile.autosetup index d5cf1d73f..3db9275d7 100644 --- a/Makefile.autosetup +++ b/Makefile.autosetup @@ -224,7 +224,7 @@ ALLOBJS+= $(PGPEWRAPOBJS) ############################################################################### # libconfig LIBCONFIG= libconfig.a -LIBCONFIGOBJS= config/address.o config/bool.o config/cfgaccount.o config/command.o config/dump.o \ +LIBCONFIGOBJS= config/address.o config/bool.o config/command.o config/dump.o \ config/long.o config/magic.o config/mbtable.o config/number.o \ config/path.o config/quad.o config/regex.o config/set.o \ config/sort.o config/string.o diff --git a/account.c b/account.c index 6d181ab62..b8808d345 100644 --- a/account.c +++ b/account.c @@ -44,6 +44,100 @@ struct Account *account_new(void) return a; } +/** + * account_add_config - Add some inherited Config items + * @param a Account to add to + * @param cs Parent Config set + * @param name Account name + * @param var_names Names of Config items + * @retval bool True, if Config was successfully added + */ +bool account_add_config(struct Account *a, const struct ConfigSet *cs, + const char *name, const char *var_names[]) +{ + if (!a || !cs || !name || !var_names) + return false; + + size_t count = 0; + for (; var_names[count]; count++) + ; + + a->name = mutt_str_strdup(name); + a->cs = cs; + a->var_names = var_names; + a->vars = mutt_mem_calloc(count, sizeof(struct HashElem *)); + a->num_vars = count; + + char a_name[64]; + + for (size_t i = 0; i < a->num_vars; i++) + { + struct HashElem *parent = cs_get_elem(cs, a->var_names[i]); + if (!parent) + { + mutt_debug(LL_DEBUG1, "%s doesn't exist\n", a->var_names[i]); + return false; + } + + snprintf(a_name, sizeof(a_name), "%s:%s", name, a->var_names[i]); + a->vars[i] = cs_inherit_variable(cs, parent, a_name); + if (!a->vars[i]) + { + mutt_debug(LL_DEBUG1, "failed to create %s\n", a_name); + return false; + } + } + + return true; +} + +/** + * account_free_config - Remove an Account's Config items + * @param a Account + */ +void account_free_config(struct Account *a) +{ + if (!a) + return; + + char child[128]; + struct Buffer *err = mutt_buffer_alloc(128); + + for (size_t i = 0; i < a->num_vars; i++) + { + snprintf(child, sizeof(child), "%s:%s", a->name, a->var_names[i]); + mutt_buffer_reset(err); + int result = cs_str_reset(a->cs, child, err); + if (CSR_RESULT(result) != CSR_SUCCESS) + mutt_debug(LL_DEBUG1, "reset failed for %s: %s\n", child, mutt_b2s(err)); + mutt_hash_delete(a->cs->hash, child, NULL); + } + + mutt_buffer_free(&err); + FREE(&a->name); + FREE(&a->vars); +} + +/** + * account_free - Free an Account + * @param[out] ptr Account to free + */ +void account_free(struct Account **ptr) +{ + if (!ptr || !*ptr) + return; + + struct Account *a = *ptr; + if (!TAILQ_EMPTY(&AllAccounts)) + TAILQ_REMOVE(&AllAccounts, a, entries); + if (a->free_adata) + a->free_adata(&a->adata); + + account_free_config(a); + + FREE(ptr); +} + /** * account_remove_mailbox - Remove a Mailbox from an Account * @param a Account @@ -63,9 +157,50 @@ void account_remove_mailbox(struct Account *a, struct Mailbox *m) if (STAILQ_EMPTY(&a->mailboxes)) { - TAILQ_REMOVE(&AllAccounts, a, entries); - if (a->free_adata) - a->free_adata(&a->adata); - FREE(&a); + account_free(&a); } } + +/** + * account_set_value - Set an Account-specific config item + * @param a Account + * @param vid Value ID (index into Account's HashElem's) + * @param value Native pointer/value to set + * @param err Buffer for error messages + * @retval num Result, e.g. #CSR_SUCCESS + */ +int account_set_value(const struct Account *a, size_t vid, intptr_t value, struct Buffer *err) +{ + if (!a) + return CSR_ERR_CODE; + if (vid >= a->num_vars) + return CSR_ERR_UNKNOWN; + + struct HashElem *he = a->vars[vid]; + return cs_he_native_set(a->cs, he, value, err); +} + +/** + * account_get_value - Get an Account-specific config item + * @param a Account + * @param vid Value ID (index into Account's HashElem's) + * @param result Buffer for results or error messages + * @retval num Result, e.g. #CSR_SUCCESS + */ +int account_get_value(const struct Account *a, size_t vid, struct Buffer *result) +{ + if (!a) + return CSR_ERR_CODE; + if (vid >= a->num_vars) + return CSR_ERR_UNKNOWN; + + struct HashElem *he = a->vars[vid]; + + if ((he->type & DT_INHERITED) && (DTYPE(he->type) == 0)) + { + struct Inheritance *i = he->data; + he = i->parent; + } + + return cs_he_string_get(a->cs, he, result); +} diff --git a/account.h b/account.h index 36facbc5a..2be4f49cc 100644 --- a/account.h +++ b/account.h @@ -40,12 +40,23 @@ struct Account TAILQ_ENTRY(Account) entries; void *adata; void (*free_adata)(void **); + + char *name; ///< Name of Account + const struct ConfigSet *cs; ///< Parent ConfigSet + const char **var_names; ///< Array of the names of local config items + size_t num_vars; ///< Number of local config items + struct HashElem **vars; ///< Array of the HashElems of local config items }; TAILQ_HEAD(AccountList, Account); extern struct AccountList AllAccounts; ///< List of all Accounts +bool account_add_config(struct Account *a, const struct ConfigSet *cs, const char *name, const char *var_names[]); +void account_free(struct Account **ptr); +void account_free_config(struct Account *a); +int account_get_value(const struct Account *a, size_t vid, struct Buffer *result); struct Account *account_new(void); void account_remove_mailbox(struct Account *a, struct Mailbox *m); +int account_set_value(const struct Account *a, size_t vid, intptr_t value, struct Buffer *err); #endif /* MUTT_ACCOUNT_H */ diff --git a/config/cfgaccount.c b/config/cfgaccount.c deleted file mode 100644 index 39b5eaf94..000000000 --- a/config/cfgaccount.c +++ /dev/null @@ -1,163 +0,0 @@ -/** - * @file - * A collection of account-specific config items - * - * @authors - * Copyright (C) 2017-2018 Richard Russon - * - * @copyright - * 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 the Free Software - * Foundation, either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -/** - * @page config_cfgaccount Account-specific config items - * - * A collection of account-specific config items. - */ - -#include "config.h" -#include -#include -#include "mutt/mutt.h" -#include "cfgaccount.h" -#include "inheritance.h" -#include "set.h" -#include "types.h" - -/** - * ac_new - Create an CfgAccount - * @param cs Config items - * @param name Name of CfgAccount - * @param var_names List of config items (NULL terminated) - * @retval ptr New CfgAccount object - */ -struct CfgAccount *ac_new(const struct ConfigSet *cs, const char *name, - const char *var_names[]) -{ - if (!cs || !name || !var_names) - return NULL; - - int count = 0; - for (; var_names[count]; count++) - ; - - struct CfgAccount *ac = mutt_mem_calloc(1, sizeof(*ac)); - ac->name = mutt_str_strdup(name); - ac->cs = cs; - ac->var_names = var_names; - ac->vars = mutt_mem_calloc(count, sizeof(struct HashElem *)); - ac->num_vars = count; - - bool success = true; - char acname[64]; - - for (size_t i = 0; i < ac->num_vars; i++) - { - struct HashElem *parent = cs_get_elem(cs, ac->var_names[i]); - if (!parent) - { - mutt_debug(LL_DEBUG1, "%s doesn't exist\n", ac->var_names[i]); - success = false; - break; - } - - snprintf(acname, sizeof(acname), "%s:%s", name, ac->var_names[i]); - ac->vars[i] = cs_inherit_variable(cs, parent, acname); - if (!ac->vars[i]) - { - mutt_debug(LL_DEBUG1, "failed to create %s\n", acname); - success = false; - break; - } - } - - if (success) - return ac; - - ac_free(cs, &ac); - return NULL; -} - -/** - * ac_free - Free an CfgAccount object - * @param[in] cs Config items - * @param[out] ac CfgAccount to free - */ -void ac_free(const struct ConfigSet *cs, struct CfgAccount **ac) -{ - if (!cs || !ac || !*ac) - return; - - char child[128]; - struct Buffer *err = mutt_buffer_new(); - - for (size_t i = 0; i < (*ac)->num_vars; i++) - { - snprintf(child, sizeof(child), "%s:%s", (*ac)->name, (*ac)->var_names[i]); - mutt_buffer_reset(err); - int result = cs_str_reset(cs, child, err); - if (CSR_RESULT(result) != CSR_SUCCESS) - mutt_debug(LL_DEBUG1, "reset failed for %s: %s\n", child, mutt_b2s(err)); - mutt_hash_delete(cs->hash, child, NULL); - } - - mutt_buffer_free(&err); - FREE(&(*ac)->name); - FREE(&(*ac)->vars); - FREE(ac); -} - -/** - * ac_set_value - Set an CfgAccount-specific config item - * @param ac CfgAccount-specific config items - * @param vid Value ID (index into CfgAccount's HashElem's) - * @param value Native pointer/value to set - * @param err Buffer for error messages - * @retval num Result, e.g. #CSR_SUCCESS - */ -int ac_set_value(const struct CfgAccount *ac, size_t vid, intptr_t value, struct Buffer *err) -{ - if (!ac) - return CSR_ERR_CODE; - if (vid >= ac->num_vars) - return CSR_ERR_UNKNOWN; - - struct HashElem *he = ac->vars[vid]; - return cs_he_native_set(ac->cs, he, value, err); -} - -/** - * ac_get_value - Get an account-specific config item - * @param ac Account-specific config items - * @param vid Value ID (index into CfgAccount's HashElem's) - * @param result Buffer for results or error messages - * @retval num Result, e.g. #CSR_SUCCESS - */ -int ac_get_value(const struct CfgAccount *ac, size_t vid, struct Buffer *result) -{ - if (!ac) - return CSR_ERR_CODE; - if (vid >= ac->num_vars) - return CSR_ERR_UNKNOWN; - - struct HashElem *he = ac->vars[vid]; - - if ((he->type & DT_INHERITED) && (DTYPE(he->type) == 0)) - { - struct Inheritance *i = he->data; - he = i->parent; - } - - return cs_he_string_get(ac->cs, he, result); -} diff --git a/config/cfgaccount.h b/config/cfgaccount.h deleted file mode 100644 index 3754f43dc..000000000 --- a/config/cfgaccount.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file - * A collection of account-specific config items - * - * @authors - * Copyright (C) 2017-2018 Richard Russon - * - * @copyright - * 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 the Free Software - * Foundation, either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifndef _CONFIG_ACCOUNT_H -#define _CONFIG_ACCOUNT_H - -#include -#include - -struct Buffer; -struct ConfigSet; - -/** - * struct CfgAccount - Account-local config items - */ -struct CfgAccount -{ - char *name; /**< Name of Account */ - const struct ConfigSet *cs; /**< Parent ConfigSet */ - const char **var_names; /**< Array of the names of local config items */ - size_t num_vars; /**< Number of local config items */ - struct HashElem **vars; /**< Array of the HashElems of local config items */ -}; - -struct CfgAccount *ac_new(const struct ConfigSet *cs, const char *name, const char *var_names[]); -void ac_free(const struct ConfigSet *cs, struct CfgAccount **ac); - -int ac_set_value(const struct CfgAccount *ac, size_t vid, intptr_t value, struct Buffer *err); -int ac_get_value(const struct CfgAccount *ac, size_t vid, struct Buffer *result); - -#endif /* _CONFIG_ACCOUNT_H */ diff --git a/config/inheritance.h b/config/inheritance.h index 616f7309e..2b334bd58 100644 --- a/config/inheritance.h +++ b/config/inheritance.h @@ -30,10 +30,9 @@ */ struct Inheritance { - struct HashElem *parent; /**< HashElem of parent config item */ - const char *name; /**< Name of this config item */ - struct CfgAccount *ac; /**< CfgAccount holding this config item */ - intptr_t var; /**< (Pointer to) value, of config item */ + struct HashElem *parent; ///< HashElem of parent config item + const char *name; ///< Name of this config item + intptr_t var; ///< (Pointer to) value, of config item }; #endif /* MUTT_CONFIG_INHERITANCE_H */ diff --git a/config/lib.h b/config/lib.h index a12c21520..5c79eb217 100644 --- a/config/lib.h +++ b/config/lib.h @@ -29,7 +29,6 @@ * | :------------------ | :------------------------- | * | config/address.c | @subpage config_address | * | config/bool.c | @subpage config_bool | - * | config/cfgaccount.c | @subpage config_cfgaccount | * | config/command.c | @subpage config_command | * | config/dump.c | @subpage config_dump | * | config/long.c | @subpage config_long | @@ -49,7 +48,6 @@ #include "address.h" #include "bool.h" -#include "cfgaccount.h" #include "command.h" #include "dump.h" #include "inheritance.h" diff --git a/po/POTFILES.in b/po/POTFILES.in index c1eae3d24..994e26d7b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -13,7 +13,6 @@ compose.c compress.c config/address.c config/bool.c -config/cfgaccount.c config/command.c config/dump.c config/long.c @@ -111,6 +110,7 @@ mutt/mapping.c mutt/mbyte.c mutt/md5.c mutt/memory.c +mutt/notify.c mutt/path.c mutt/pool.c mutt/regex.c @@ -148,6 +148,7 @@ ncrypt/pgplib.c ncrypt/pgpmicalg.c ncrypt/pgppacket.c ncrypt/smime.c +neomutt.c nntp/browse.c nntp/complete.c nntp/newsrc.c diff --git a/test/Makefile.autosetup b/test/Makefile.autosetup index ec472c949..80d059772 100644 --- a/test/Makefile.autosetup +++ b/test/Makefile.autosetup @@ -98,7 +98,8 @@ CONFIG_OBJS = test/config/account.o \ test/config/set.o \ test/config/sort.o \ test/config/string.o \ - test/config/synonym.o + test/config/synonym.o \ + account.o DATE_OBJS = test/date/mutt_date_add_timeout.o \ test/date/mutt_date_check_month.o \ diff --git a/test/config/account.c b/test/config/account.c index 7f5586d9c..bc68c2804 100644 --- a/test/config/account.c +++ b/test/config/account.c @@ -1,6 +1,6 @@ /** * @file - * Test code for the CfgAccount object + * Test code for the Account object * * @authors * Copyright (C) 2017-2018 Richard Russon @@ -28,6 +28,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static short VarApple; static short VarBanana; @@ -68,68 +69,78 @@ void config_account(void) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, BrokenVarStr); - if (TEST_CHECK(!ac)) + struct Account *a = account_new(); + bool result = account_add_config(a, cs, account, BrokenVarStr); + account_free(&a); + + if (TEST_CHECK(!result)) { TEST_MSG("Expected error:\n"); } else { - ac_free(cs, &ac); TEST_MSG("This test should have failed\n"); return; } - const char *CfgAccountVarStr2[] = { + const char *AccountVarStr2[] = { "Apple", "Apple", NULL, }; TEST_MSG("Expect error for next test\n"); - ac = ac_new(cs, account, CfgAccountVarStr2); - if (!TEST_CHECK(!ac)) + a = account_new(); + result = account_add_config(a, cs, account, AccountVarStr2); + account_free(&a); + + if (!TEST_CHECK(!result)) { - ac_free(cs, &ac); TEST_MSG("This test should have failed\n"); return; } account = "fruit"; - const char *CfgAccountVarStr[] = { + const char *AccountVarStr[] = { "Apple", "Cherry", NULL, }; - ac = ac_new(NULL, account, CfgAccountVarStr); - if (!TEST_CHECK(ac == NULL)) + a = account_new(); + + result = account_add_config(NULL, cs, account, AccountVarStr); + if (!TEST_CHECK(!result)) + return; + + result = account_add_config(a, NULL, account, AccountVarStr); + if (!TEST_CHECK(!result)) return; - ac = ac_new(cs, NULL, CfgAccountVarStr); - if (!TEST_CHECK(ac == NULL)) + result = account_add_config(a, cs, NULL, AccountVarStr); + if (!TEST_CHECK(!result)) return; - ac = ac_new(cs, account, NULL); - if (!TEST_CHECK(ac == NULL)) + result = account_add_config(a, cs, account, NULL); + if (!TEST_CHECK(!result)) return; - ac = ac_new(cs, account, CfgAccountVarStr); - if (!TEST_CHECK(ac != NULL)) + result = account_add_config(a, cs, account, AccountVarStr); + if (!TEST_CHECK(result)) return; size_t index = 0; mutt_buffer_reset(&err); - int rc = ac_set_value(NULL, index, 33, &err); + int rc = account_set_value(NULL, index, 33, &err); - rc = ac_set_value(ac, index, 33, &err); + rc = account_set_value(a, index, 33, &err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS)) { TEST_MSG("%s\n", err.data); } mutt_buffer_reset(&err); - rc = ac_set_value(ac, 99, 42, &err); + rc = account_set_value(a, 99, 42, &err); if (TEST_CHECK(CSR_RESULT(rc) == CSR_ERR_UNKNOWN)) { TEST_MSG("Expected error: %s\n", err.data); @@ -141,36 +152,36 @@ void config_account(void) } mutt_buffer_reset(&err); - rc = ac_get_value(NULL, index, &err); + rc = account_get_value(NULL, index, &err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_ERR_CODE)) { TEST_MSG("%s\n", err.data); } - rc = ac_get_value(ac, index, &err); + rc = account_get_value(a, index, &err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS)) { TEST_MSG("%s\n", err.data); } else { - TEST_MSG("%s = %s\n", CfgAccountVarStr[index], err.data); + TEST_MSG("%s = %s\n", AccountVarStr[index], err.data); } index++; mutt_buffer_reset(&err); - rc = ac_get_value(ac, index, &err); + rc = account_get_value(a, index, &err); if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS)) { TEST_MSG("%s\n", err.data); } else { - TEST_MSG("%s = %s\n", CfgAccountVarStr[index], err.data); + TEST_MSG("%s = %s\n", AccountVarStr[index], err.data); } mutt_buffer_reset(&err); - rc = ac_get_value(ac, 99, &err); + rc = account_get_value(a, 99, &err); if (TEST_CHECK(CSR_RESULT(rc) == CSR_ERR_UNKNOWN)) { TEST_MSG("Expected error\n"); @@ -251,10 +262,9 @@ void config_account(void) return; } - ac_free(NULL, &ac); - ac_free(cs, NULL); + account_free(NULL); - ac_free(cs, &ac); + account_free(&a); cs_free(&cs); FREE(&err.data); log_line(__func__); diff --git a/test/config/address.c b/test/config/address.c index 1d1af2aa6..e15cc8436 100644 --- a/test/config/address.c +++ b/test/config/address.c @@ -31,6 +31,7 @@ #include "address/lib.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static struct Address *VarApple; static struct Address *VarBanana; @@ -546,7 +547,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarAddr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarAddr); // set parent mutt_buffer_reset(err); @@ -591,7 +593,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/bool.c b/test/config/bool.c index adc641645..1157120cc 100644 --- a/test/config/bool.c +++ b/test/config/bool.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static bool VarApple; static bool VarBanana; @@ -534,7 +535,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent VarMango = false; @@ -587,7 +589,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/command.c b/test/config/command.c index 516653354..9ffb4b8d5 100644 --- a/test/config/command.c +++ b/test/config/command.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char *VarApple; static char *VarBanana; @@ -573,7 +574,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent mutt_buffer_reset(err); @@ -618,7 +620,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/common.c b/test/config/common.c index 2be588bb4..de07ad011 100644 --- a/test/config/common.c +++ b/test/config/common.c @@ -31,6 +31,7 @@ #include "mutt/mutt.h" #include "config/lib.h" #include "common.h" +#include "account.h" const char *line = "----------------------------------------" "----------------------------------------"; diff --git a/test/config/dump.c b/test/config/dump.c index 227ed8c7a..039b857b7 100644 --- a/test/config/dump.c +++ b/test/config/dump.c @@ -26,6 +26,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static bool VarApple; static bool VarBanana; diff --git a/test/config/initial.c b/test/config/initial.c index be82e403d..571586b3c 100644 --- a/test/config/initial.c +++ b/test/config/initial.c @@ -28,6 +28,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char *VarApple; static char *VarBanana; diff --git a/test/config/long.c b/test/config/long.c index eefa5a5bf..875378fd0 100644 --- a/test/config/long.c +++ b/test/config/long.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static long VarApple; static long VarBanana; @@ -520,7 +521,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent VarOlive = 123; @@ -569,7 +571,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/magic.c b/test/config/magic.c index aa9d5298e..30b9a0d21 100644 --- a/test/config/magic.c +++ b/test/config/magic.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static short VarApple; static short VarBanana; @@ -511,7 +512,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent mutt_buffer_reset(err); @@ -556,7 +558,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/mbtable.c b/test/config/mbtable.c index 9825a74f5..f612a9ea7 100644 --- a/test/config/mbtable.c +++ b/test/config/mbtable.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static struct MbTable *VarApple; static struct MbTable *VarBanana; @@ -562,7 +563,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarMb); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarMb); // set parent mutt_buffer_reset(err); @@ -607,7 +609,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/number.c b/test/config/number.c index fa3603b16..bf3cdd5c4 100644 --- a/test/config/number.c +++ b/test/config/number.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static short VarApple; static short VarBanana; @@ -539,7 +540,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent VarOlive = 123; @@ -588,7 +590,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/path.c b/test/config/path.c index ba7678741..880746867 100644 --- a/test/config/path.c +++ b/test/config/path.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char *VarApple; static char *VarBanana; @@ -573,7 +574,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent mutt_buffer_reset(err); @@ -618,7 +620,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/quad.c b/test/config/quad.c index 040a4ad9e..1651a9768 100644 --- a/test/config/quad.c +++ b/test/config/quad.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char VarApple; static char VarBanana; @@ -532,7 +533,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent mutt_buffer_reset(err); @@ -584,7 +586,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/regex.c b/test/config/regex.c index f8ad60ced..e741b4e10 100644 --- a/test/config/regex.c +++ b/test/config/regex.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static struct Regex *VarApple; static struct Regex *VarBanana; @@ -622,7 +623,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarRegex); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarRegex); // set parent mutt_buffer_reset(err); @@ -667,7 +669,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/set.c b/test/config/set.c index 4892f6ca2..9fb392e1e 100644 --- a/test/config/set.c +++ b/test/config/set.c @@ -30,6 +30,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static short VarApple; static bool VarBanana; diff --git a/test/config/sort.c b/test/config/sort.c index 2a2fef43a..8071c6329 100644 --- a/test/config/sort.c +++ b/test/config/sort.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static short VarApple; static short VarBanana; @@ -636,7 +637,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent VarStrawberry = SORT_SUBJECT; @@ -682,7 +684,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/string.c b/test/config/string.c index bfefd3cbf..3cfb2f020 100644 --- a/test/config/string.c +++ b/test/config/string.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char *VarApple; static char *VarBanana; @@ -573,7 +574,8 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) NULL, }; - struct CfgAccount *ac = ac_new(cs, account, AccountVarStr); + struct Account *a = account_new(); + account_add_config(a, cs, account, AccountVarStr); // set parent mutt_buffer_reset(err); @@ -618,7 +620,7 @@ static bool test_inherit(struct ConfigSet *cs, struct Buffer *err) log_line(__func__); result = true; ti_out: - ac_free(cs, &ac); + account_free(&a); return result; } diff --git a/test/config/synonym.c b/test/config/synonym.c index ef48127eb..cd6918348 100644 --- a/test/config/synonym.c +++ b/test/config/synonym.c @@ -29,6 +29,7 @@ #include "mutt/mutt.h" #include "config/common.h" #include "config/lib.h" +#include "account.h" static char *VarApple; static char *VarCherry; -- 2.40.0