}
/**
- * 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
* @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)
{
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))
{
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 */
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)
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;
}
{
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);
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;
}
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;
}
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;
}
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;
}
} 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;
}
{
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);
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;
}
{
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);
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;
}
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);
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);
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);
}
}
/**
- * 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)
}
/**
- * 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)
}
/**
- * 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)
}
/**
- * 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)
}
/**
- * 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;
}
/**
- * 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
* @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;
}
/**
- * 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;
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 */