]> granicus.if.org Git - neomutt/commitdiff
Tidy API: s/group_context/grouplist/ 1187/head
authorPietro Cerutti <gahr@gahr.ch>
Fri, 25 May 2018 12:15:00 +0000 (12:15 +0000)
committerRichard Russon <rich@flatcap.org>
Wed, 12 Dec 2018 15:10:17 +0000 (15:10 +0000)
init.c
init.h
mutt/group.c
mutt/group.h

diff --git a/init.c b/init.c
index a45434217e18be11b23a3e5db0cf7ec9a61df79d..7aa12e2ecc66303a9de7821a90bf536187bfdcbd 100644 (file)
--- 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 9cd4f46400a12b8361678cf9742ec48f9343580b..913c0782d2d909042744691e478bfd02353c3ae0 100644 (file)
--- 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
index 70fa277fd401daf84f5cb2b57cac63861789bfb0..858828c7f2f7cc38ddf53186b526d9228ad85464 100644 (file)
 
 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;
index b3043eed7fefeccedd79488e18b032650dcd16c1..90aea7f135e2a79d9d1e6a98a3b887f90a1cce4c 100644 (file)
@@ -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 */