From: Pietro Cerutti Date: Fri, 25 May 2018 12:15:00 +0000 (+0000) Subject: Tidy API: s/group_context/grouplist/ X-Git-Tag: 2019-10-25~442^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7480b163c8260e84f04df57877905ca7ca518ef;p=neomutt Tidy API: s/group_context/grouplist/ --- diff --git a/init.c b/init.c index a45434217..7aa12e2ec 100644 --- a/init.c +++ b/init.c @@ -530,7 +530,7 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s, } /** - * parse_group_context - Parse a group context + * parse_grouplist - Parse a group context * @param ctx GroupList to add to * @param buf Temporary Buffer space * @param s Buffer containing string to be parsed @@ -539,8 +539,8 @@ static int parse_attach_list(struct Buffer *buf, struct Buffer *s, * @retval 0 Success * @retval -1 Error */ -static int parse_group_context(struct GroupList *ctx, struct Buffer *buf, - struct Buffer *s, unsigned long data, struct Buffer *err) +static int parse_grouplist(struct GroupList *ctx, struct Buffer *buf, + struct Buffer *s, unsigned long data, struct Buffer *err) { while (mutt_str_strcasecmp(buf->data, "-group") == 0) { @@ -552,7 +552,7 @@ static int parse_group_context(struct GroupList *ctx, struct Buffer *buf, mutt_extract_token(buf, s, 0); - mutt_group_context_add(ctx, mutt_pattern_group(buf->data)); + mutt_grouplist_add(ctx, mutt_pattern_group(buf->data)); if (!MoreArgs(s)) { @@ -902,7 +902,7 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_extract_token(buf, s, 0); - if (parse_group_context(&gc, buf, s, data, err) == -1) + if (parse_grouplist(&gc, buf, s, data, err) == -1) return -1; /* check to see if an alias with this name already exists */ @@ -943,7 +943,7 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, goto bail; } - mutt_group_context_add_addrlist(&gc, tmp->addr); + mutt_grouplist_add_addrlist(&gc, tmp->addr); mutt_alias_add_reverse(tmp); if (DebugLevel > 2) @@ -957,11 +957,11 @@ static int parse_alias(struct Buffer *buf, struct Buffer *s, unsigned long data, mutt_debug(3, " Group %s\n", a->mailbox); } } - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return 0; bail: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return -1; } @@ -979,7 +979,7 @@ static int parse_alternates(struct Buffer *buf, struct Buffer *s, { mutt_extract_token(buf, s, 0); - if (parse_group_context(&gc, buf, s, data, err) == -1) + if (parse_grouplist(&gc, buf, s, data, err) == -1) goto bail; mutt_regexlist_remove(&UnAlternates, buf->data); @@ -987,15 +987,15 @@ static int parse_alternates(struct Buffer *buf, struct Buffer *s, if (mutt_regexlist_add(&Alternates, buf->data, REG_ICASE, err) != 0) goto bail; - if (mutt_group_context_add_regex(&gc, buf->data, REG_ICASE, err) != 0) + if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0) goto bail; } while (MoreArgs(s)); - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return 0; bail: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return -1; } @@ -1112,12 +1112,12 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data, do { mutt_extract_token(buf, s, 0); - if (parse_group_context(&gc, buf, s, data, err) == -1) + if (parse_grouplist(&gc, buf, s, data, err) == -1) goto bail; if (data == MUTT_UNGROUP && (mutt_str_strcasecmp(buf->data, "*") == 0)) { - mutt_group_context_clear(&gc); + mutt_grouplist_clear(&gc); goto out; } @@ -1136,12 +1136,12 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data, case GS_RX: if (data == MUTT_GROUP && - mutt_group_context_add_regex(&gc, buf->data, REG_ICASE, err) != 0) + mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0) { goto bail; } else if (data == MUTT_UNGROUP && - mutt_group_context_remove_regex(&gc, buf->data) < 0) + mutt_grouplist_remove_regex(&gc, buf->data) < 0) { goto bail; } @@ -1160,9 +1160,9 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data, goto bail; } if (data == MUTT_GROUP) - mutt_group_context_add_addrlist(&gc, addr); + mutt_grouplist_add_addrlist(&gc, addr); else if (data == MUTT_UNGROUP) - mutt_group_context_remove_addrlist(&gc, addr); + mutt_grouplist_remove_addrlist(&gc, addr); mutt_addr_free(&addr); break; } @@ -1170,11 +1170,11 @@ static int parse_group(struct Buffer *buf, struct Buffer *s, unsigned long data, } while (MoreArgs(s)); out: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return 0; bail: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return -1; } @@ -1298,7 +1298,7 @@ static int parse_lists(struct Buffer *buf, struct Buffer *s, unsigned long data, { mutt_extract_token(buf, s, 0); - if (parse_group_context(&gc, buf, s, data, err) == -1) + if (parse_grouplist(&gc, buf, s, data, err) == -1) goto bail; mutt_regexlist_remove(&UnMailLists, buf->data); @@ -1306,15 +1306,15 @@ static int parse_lists(struct Buffer *buf, struct Buffer *s, unsigned long data, if (mutt_regexlist_add(&MailLists, buf->data, REG_ICASE, err) != 0) goto bail; - if (mutt_group_context_add_regex(&gc, buf->data, REG_ICASE, err) != 0) + if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0) goto bail; } while (MoreArgs(s)); - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return 0; bail: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return -1; } @@ -1973,7 +1973,7 @@ static int parse_subscribe(struct Buffer *buf, struct Buffer *s, { mutt_extract_token(buf, s, 0); - if (parse_group_context(&gc, buf, s, data, err) == -1) + if (parse_grouplist(&gc, buf, s, data, err) == -1) goto bail; mutt_regexlist_remove(&UnMailLists, buf->data); @@ -1983,15 +1983,15 @@ static int parse_subscribe(struct Buffer *buf, struct Buffer *s, goto bail; if (mutt_regexlist_add(&SubscribedLists, buf->data, REG_ICASE, err) != 0) goto bail; - if (mutt_group_context_add_regex(&gc, buf->data, REG_ICASE, err) != 0) + if (mutt_grouplist_add_regex(&gc, buf->data, REG_ICASE, err) != 0) goto bail; } while (MoreArgs(s)); - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return 0; bail: - mutt_group_context_destroy(&gc); + mutt_grouplist_destroy(&gc); return -1; } @@ -2787,7 +2787,7 @@ void mutt_free_opts(void) mutt_regexlist_free(&UnMailLists); mutt_regexlist_free(&UnSubscribedLists); - mutt_groups_free(); + mutt_grouplist_free(); mutt_hash_destroy(&ReverseAliases); mutt_hash_destroy(&TagFormats); mutt_hash_destroy(&TagTransforms); @@ -2864,7 +2864,7 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands) err.data = mutt_mem_malloc(err.dsize); err.dptr = err.data; - mutt_groups_init(); + mutt_grouplist_init(); /* reverse alias keys need to be strdup'ed because of idna conversions */ ReverseAliases = mutt_hash_new(1031, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS | MUTT_HASH_ALLOW_DUPS); diff --git a/init.h b/init.h index 9cd4f4640..913c0782d 100644 --- a/init.h +++ b/init.h @@ -4707,9 +4707,6 @@ static int parse_unsubscribe (struct Buffer *buf, struct Buffer *s, unsigned #ifdef USE_IMAP static int parse_unsubscribe_from(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); #endif -/* Parse -group arguments */ -static int parse_group_context (struct GroupList *ctx, - struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); const struct Command Commands[] = { #ifdef USE_SOCKET diff --git a/mutt/group.c b/mutt/group.c index 70fa277fd..858828c7f 100644 --- a/mutt/group.c +++ b/mutt/group.c @@ -41,12 +41,22 @@ static struct Hash *Groups = NULL; -void mutt_groups_init(void) +/** + * mutt_grouplist_init - Initialize the GroupList singleton. + * + * This is called once from init.c when initializing the global structures. + */ +void mutt_grouplist_init(void) { Groups = mutt_hash_new(1031, 0); } -void mutt_groups_free(void) +/** + * mutt_grouplist_free - Free GroupList singleton resource. + * + * This is called once from init.c when deinitializing the global resources. + */ +void mutt_grouplist_free(void) { mutt_hash_destroy(&Groups); } @@ -93,10 +103,10 @@ static void group_remove(struct Group *g) } /** - * mutt_group_context_clear - Clear a GroupList + * mutt_grouplist_clear - Clear a GroupList * @param head GroupList to clear */ -void mutt_group_context_clear(struct GroupList *head) +void mutt_grouplist_clear(struct GroupList *head) { struct GroupNode *np = STAILQ_FIRST(head), *next = NULL; while (np) @@ -122,11 +132,11 @@ static bool empty_group(struct Group *g) } /** - * mutt_group_context_add - Add a Group to a GroupList + * mutt_grouplist_add - Add a Group to a GroupList * @param head GroupList to add to * @param group Group to add */ -void mutt_group_context_add(struct GroupList *head, struct Group *group) +void mutt_grouplist_add(struct GroupList *head, struct Group *group) { struct GroupNode *np = NULL; STAILQ_FOREACH(np, head, entries) @@ -140,10 +150,10 @@ void mutt_group_context_add(struct GroupList *head, struct Group *group) } /** - * mutt_group_context_destroy - Free a GroupList + * mutt_grouplist_destroy - Free a GroupList * @param head GroupList to free */ -void mutt_group_context_destroy(struct GroupList *head) +void mutt_grouplist_destroy(struct GroupList *head) { struct GroupNode *np = STAILQ_FIRST(head), *next = NULL; while (np) @@ -226,11 +236,11 @@ static int group_remove_regex(struct Group *g, const char *s) } /** - * mutt_group_context_add_addrlist - Add Address list to a GroupList + * mutt_grouplist_add_addrlist - Add Address list to a GroupList * @param head GroupList to add to * @param a Address to add */ -void mutt_group_context_add_addrlist(struct GroupList *head, struct Address *a) +void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a) { struct GroupNode *np = NULL; STAILQ_FOREACH(np, head, entries) @@ -240,13 +250,13 @@ void mutt_group_context_add_addrlist(struct GroupList *head, struct Address *a) } /** - * mutt_group_context_remove_addrlist - Remove Address from a GroupList + * mutt_grouplist_remove_addrlist - Remove Address from a GroupList * @param head GroupList to remove from * @param a Address to remove * @retval 0 Success * @retval -1 Error */ -int mutt_group_context_remove_addrlist(struct GroupList *head, struct Address *a) +int mutt_grouplist_remove_addrlist(struct GroupList *head, struct Address *a) { int rc = 0; struct GroupNode *np = NULL; @@ -263,7 +273,7 @@ int mutt_group_context_remove_addrlist(struct GroupList *head, struct Address *a } /** - * mutt_group_context_add_regex - Add matching Addresses to a GroupList + * mutt_grouplist_add_regex - Add matching Addresses to a GroupList * @param head GroupList to add to * @param s Address to match * @param flags Flags, e.g. REG_ICASE @@ -271,7 +281,7 @@ int mutt_group_context_remove_addrlist(struct GroupList *head, struct Address *a * @retval 0 Success * @retval -1 Error */ -int mutt_group_context_add_regex(struct GroupList *head, const char *s, +int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err) { int rc = 0; @@ -287,13 +297,13 @@ int mutt_group_context_add_regex(struct GroupList *head, const char *s, } /** - * mutt_group_context_remove_regex - Remove matching addresses from a GroupList + * mutt_grouplist_remove_regex - Remove matching addresses from a GroupList * @param head GroupList to remove from * @param s Address to match * @retval 0 Success * @retval -1 Error */ -int mutt_group_context_remove_regex(struct GroupList *head, const char *s) +int mutt_grouplist_remove_regex(struct GroupList *head, const char *s) { int rc = 0; struct GroupNode *np = NULL; diff --git a/mutt/group.h b/mutt/group.h index b3043eed7..90aea7f13 100644 --- a/mutt/group.h +++ b/mutt/group.h @@ -54,23 +54,23 @@ struct GroupNode STAILQ_ENTRY(GroupNode) entries; }; +/** + * struct GroupList - A list of GroupNodes + */ STAILQ_HEAD(GroupList, GroupNode); -void mutt_group_context_add(struct GroupList *head, struct Group *group); -void mutt_group_context_destroy(struct GroupList *head); -void mutt_group_context_add_addrlist(struct GroupList *head, struct Address *a); -int mutt_group_context_add_regex(struct GroupList *head, const char *s, - int flags, struct Buffer *err); +void mutt_grouplist_init(void); +void mutt_grouplist_free(void); +void mutt_grouplist_add(struct GroupList *head, struct Group *group); +void mutt_grouplist_add_addrlist(struct GroupList *head, struct Address *a); +int mutt_grouplist_add_regex(struct GroupList *head, const char *s, + int flags, struct Buffer *err); +void mutt_grouplist_destroy(struct GroupList *head); +void mutt_grouplist_clear(struct GroupList *head); +int mutt_grouplist_remove_regex(struct GroupList *head, const char *s); +int mutt_grouplist_remove_addrlist(struct GroupList *head, struct Address *a); bool mutt_group_match(struct Group *g, const char *s); - -void mutt_group_context_clear(struct GroupList *head); -int mutt_group_context_remove_regex(struct GroupList *head, const char *s); -int mutt_group_context_remove_addrlist(struct GroupList *head, struct Address *a); - struct Group *mutt_pattern_group(const char *k); -void mutt_groups_init(void); -void mutt_groups_free(void); - #endif /* MUTT_GROUP_H */