begin to work on alias.[hc]
[apps/madmutt.git] / init.c
diff --git a/init.c b/init.c
index ce6054e..f137e35 100644 (file)
--- a/init.c
+++ b/init.c
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/mapping.h>
+#include <lib-lib/debug.h>
+#include <lib-lib/rx.h>
+
+#include <lib-sys/unix.h>
 
 #include <lib-ui/curses.h>
+#include <lib-ui/history.h>
 
 #include "mutt.h"
-#include "history.h"
 #include "keymap.h"
 #include "mbyte.h"
 #include "charset.h"
@@ -34,7 +38,7 @@
 #include "mutt_idna.h"
 
 #if defined(USE_SSL) || defined(USE_GNUTLS)
-#include <lib-network/mutt_ssl.h>
+#include <lib-sys/mutt_ssl.h>
 #endif
 
 #if defined (USE_LIBESMTP) && (defined (USE_SSL) || defined (USE_GNUTLS))
@@ -44,9 +48,7 @@
 #include "mx.h"
 #include "init.h"
 
-#include "lib/rx.h"
 #include "lib/list.h"
-#include "lib/debug.h"
 
 #include <ctype.h>
 #include <stdlib.h>
@@ -671,7 +673,7 @@ static int add_to_rx_list (list2_t** list, const char *s, int flags,
 
   i = rx_lookup ((*list), rx->pattern);
   if (i >= 0)
-    rx_free (&rx);
+    rx_delete(&rx);
   else
     list_push_back (list, rx);
   return 0;
@@ -754,7 +756,7 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
     return 0;
   if (spam->rx && !m_strcmp(spam->rx->pattern, pat)) {
     *list = spam->next;
-    rx_free (&spam->rx);
+    rx_delete(&spam->rx);
     p_delete(&spam->template);
     p_delete(&spam);
     return 1;
@@ -764,7 +766,7 @@ static int remove_from_spam_list (SPAM_LIST ** list, const char *pat)
   for (spam = prev->next; spam;) {
     if (!m_strcmp(spam->rx->pattern, pat)) {
       prev->next = spam->next;
-      rx_free (&spam->rx);
+      rx_delete(&spam->rx);
       p_delete(&spam->template);
       p_delete(&spam);
       spam = prev->next;
@@ -809,14 +811,14 @@ static int remove_from_rx_list (list2_t** l, const char *str)
   int i = 0;
 
   if (m_strcmp("*", str) == 0) {
-    list_del (l, (list_del_t*) rx_free);
+    list_del (l, (list_del_t*) rx_delete);
     return (0);
   }
   else {
     i = rx_lookup ((*l), str);
     if (i >= 0) {
       rx_t* r = list_pop_idx ((*l), i);
-      rx_free (&r);
+      rx_delete(&r);
       return (0);
     }
   }
@@ -1026,7 +1028,7 @@ static int parse_spam_list (BUFFER * buf, BUFFER * s, unsigned long data,
     /* "*" is a special case. */
     if (!m_strcmp(buf->data, "*")) {
       mutt_free_spam_list (&SpamList);
-      list_del (&NoSpamList, (list_del_t*) rx_free);
+      list_del (&NoSpamList, (list_del_t*) rx_delete);
       return 0;
     }
 
@@ -1382,7 +1384,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s,
                           unsigned long data __attribute__ ((unused)),
                           BUFFER * err __attribute__ ((unused)))
 {
-  ALIAS *tmp, *last = NULL;
+  alias_t *tmp, *last = NULL;
 
   do {
     mutt_extract_token (buf, s, 0);
@@ -1394,7 +1396,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s,
         set_option (OPTFORCEREDRAWINDEX);
       }
       else
-        mutt_free_alias (&Aliases);
+        alias_delete(&Aliases);
       break;
     }
     else
@@ -1411,7 +1413,7 @@ static int parse_unalias (BUFFER * buf, BUFFER * s,
           else
             Aliases = tmp->next;
           tmp->next = NULL;
-          mutt_free_alias (&tmp);
+          alias_delete(&tmp);
           break;
         }
         last = tmp;
@@ -1425,8 +1427,8 @@ static int parse_alias (BUFFER * buf, BUFFER * s,
                         unsigned long data __attribute__ ((unused)),
                         BUFFER * err)
 {
-  ALIAS *tmp = Aliases;
-  ALIAS *last = NULL;
+  alias_t *tmp = Aliases;
+  alias_t *last = NULL;
   char *estr = NULL;
 
   if (!MoreArgs (s)) {
@@ -1447,8 +1449,7 @@ static int parse_alias (BUFFER * buf, BUFFER * s,
 
   if (!tmp) {
     /* create a new alias */
-    tmp = p_new(ALIAS, 1);
-    tmp->self = tmp;
+    tmp = alias_new();
     tmp->name = m_strdup(buf->data);
     /* give the main addressbook code a chance */
     if (CurrentMenu == MENU_ALIAS)
@@ -2608,7 +2609,8 @@ void mutt_init (int skip_sys_rc, LIST * commands)
     if (!Homedir)
       Homedir = m_strdup(pw->pw_dir);
 
-    Realname = m_strdup(mutt_gecos_name (rnbuf, sizeof(rnbuf), pw));
+    mutt_gecos_name(rnbuf, sizeof(rnbuf), pw, GecosMask.rx);
+    Realname = m_strdup(rnbuf);
     Shell = m_strdup(pw->pw_shell);
     endpwent ();
   }
@@ -2641,7 +2643,7 @@ void mutt_init (int skip_sys_rc, LIST * commands)
   else
     Hostname = m_strdup(utsname.nodename);
 
-  if (!p && getdnsdomainname (buffer, sizeof(buffer)) == -1)
+  if (!p && getdnsdomainname(buffer, sizeof(buffer)) == -1)
     Fqdn = m_strdup("@");
   else
   if (*buffer != '@') {