begin to work on alias.[hc]
[apps/madmutt.git] / muttlib.c
index d8f2d44..27cbdbd 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
 # include "config.h"
 #endif
 
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <sys/types.h>
+#include <utime.h>
+
 #include <lib-lib/mem.h>
 #include <lib-lib/ascii.h>
 #include <lib-lib/str.h>
 #include <lib-lib/macros.h>
 #include <lib-lib/buffer.h>
 #include <lib-lib/file.h>
+#include <lib-lib/debug.h>
+#include <lib-lib/url.h>
 
 #include <lib-mime/mime.h>
 
 #include <lib-ui/curses.h>
+#include <lib-ui/enter.h>
 
 #include "mutt.h"
-#include "enter.h"
 #include "mx.h"
-#include "url.h"
 #include "attach.h"
 
 #include "version.h"
 
 #include <lib-crypt/crypt.h>
 
-#include "lib/debug.h"
-
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <time.h>
-#include <sys/types.h>
-#include <utime.h>
-
 #define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
 
 BODY *mutt_new_body (void)
@@ -323,7 +322,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx)
         HEADER *h;
         address_t *alias;
 
-        if ((alias = mutt_lookup_alias (s + 1))) {
+        if ((alias = alias_lookup(Aliases, s + 1))) {
           h = header_new();
           h->env = envelope_new();
           h->env->from = h->env->to = alias;
@@ -388,7 +387,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx)
     }
 
     if (rx && *p && !recurse) {
-      mutt_rx_sanitize_string (q, sizeof (q), p);
+      rx_sanitize_string (q, sizeof (q), p);
       snprintf (tmp, sizeof (tmp), "%s%s", q, tail);
     }
     else
@@ -401,51 +400,6 @@ char *_mutt_expand_path (char *s, size_t slen, int rx)
   return (s);
 }
 
-/* Extract the real name from /etc/passwd's GECOS field.
- * When set, honor the regular expression in GecosMask,
- * otherwise assume that the GECOS field is a 
- * comma-separated list.
- * Replace "&" by a capitalized version of the user's login
- * name.
- */
-
-char *mutt_gecos_name (char *dest, ssize_t destlen, struct passwd *pw)
-{
-  regmatch_t pat_match[1];
-  ssize_t pwnl;
-  int idx;
-  char *p;
-
-  if (!pw || !pw->pw_gecos)
-    return NULL;
-
-  p_clear(dest, destlen);
-
-  if (GecosMask.rx) {
-    if (regexec (GecosMask.rx, pw->pw_gecos, 1, pat_match, 0) == 0)
-      m_strcpy(dest, MIN(pat_match[0].rm_eo - pat_match[0].rm_so + 1, destlen),
-               pw->pw_gecos + pat_match[0].rm_so);
-  }
-  else if ((p = strchr (pw->pw_gecos, ',')))
-    m_strcpy(dest, MIN(destlen, p - pw->pw_gecos + 1), pw->pw_gecos);
-  else
-    m_strcpy(dest, destlen, pw->pw_gecos);
-
-  pwnl = m_strlen(pw->pw_name);
-
-  for (idx = 0; dest[idx]; idx++) {
-    if (dest[idx] == '&') {
-      memmove (&dest[idx + pwnl], &dest[idx + 1],
-               MAX (destlen - idx - pwnl - 1, 0));
-      memcpy (&dest[idx], pw->pw_name, MIN (destlen - idx - 1, pwnl));
-      dest[idx] = toupper ((unsigned char) dest[idx]);
-    }
-  }
-
-  return dest;
-}
-
-
 char *mutt_get_parameter (const char *s, PARAMETER * p)
 {
   for (; p; p = p->next)
@@ -598,19 +552,6 @@ void _mutt_mktemp (char *s, const char *src, int line)
   unlink (s);
 }
 
-void mutt_free_alias (ALIAS ** p)
-{
-  ALIAS *t;
-
-  while (*p) {
-    t = *p;
-    *p = (*p)->next;
-    p_delete(&t->name);
-    address_delete (&t->addr);
-    p_delete(&t);
-  }
-}
-
 /* collapse the pathname using ~ or = when possible */
 void mutt_pretty_mailbox (char *s)
 {
@@ -1237,7 +1178,7 @@ void mutt_free_spam_list (SPAM_LIST ** list)
   while (*list) {
     p = *list;
     *list = (*list)->next;
-    rx_free (&p->rx);
+    rx_delete(&p->rx);
     p_delete(&p->template);
     p_delete(&p);
   }