]> granicus.if.org Git - neomutt/commitdiff
Adding the $rewrite_uucp option.
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 24 Jan 2000 10:34:13 +0000 (10:34 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 24 Jan 2000 10:34:13 +0000 (10:34 +0000)
init.h
mutt.h
rfc822.c

diff --git a/init.h b/init.h
index 66c4911c943bcafd2befd03c13b553f434cf33d4..42d072d6288258e32161100ffe50101b1ec977cf 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1568,6 +1568,12 @@ struct option_t MuttVars[] = {
   ** messages you are replying to.  If the variable is unset, the
   ** \fIFrom:\fP line will use your address on the current machine.
   */
+  { "rewrite_uucp",     DT_BOOL, R_INDEX, OPTREWRITEUUCP, 0 },
+  /*
+  ** .pp
+  ** When this option is set, mutt rewrites uucp-style "bang paths" to
+  ** internet addresses.
+  */
   { "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
   /*
   ** .pp
diff --git a/mutt.h b/mutt.h
index 9e03e71c7f42ff0b7de2230b8aeb8d18c53c3c0e..01885d5ee0cc26dcf0f85ae953c0fe69a89c7e44 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -321,6 +321,7 @@ enum
   OPTRESOLVE,
   OPTREVALIAS,
   OPTREVNAME,
+  OPTREWRITEUUCP,
   OPTRFC2047PARAMS,
   OPTSAVEADDRESS,
   OPTSAVEEMPTY,
index 061fcac0c703f40ee1a2710a53ae73c7b5f74394..023c4c694e5ae6324c56a48fef00a07cab1fc350 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -204,6 +204,8 @@ parse_mailboxdomain (const char *s, const char *nonspecial,
   return s;
 }
 
+  
+
 static const char *
 parse_address (const char *s,
                char *token, size_t *tokenlen, size_t tokenmax,
@@ -229,7 +231,7 @@ parse_address (const char *s,
 
   token[*tokenlen] = 0;
   addr->mailbox = safe_strdup (token);
-
+  
   if (*commentlen && !addr->personal)
   {
     comment[*commentlen] = 0;
@@ -487,6 +489,37 @@ ADDRESS *rfc822_parse_adrlist (ADDRESS *top, const char *s)
   return top;
 }
 
+static short
+rewrite_uucp (char *dest, char *src, size_t destlen)
+{
+  char *domain, *user, *tmp;
+  short quoted, quoted_string;
+
+  if (!src || !*src)
+    return -1;
+
+  for (user = tmp = src, domain = NULL, quoted = quoted_string = 0; *tmp; tmp++)
+  {
+    switch (*tmp)
+    {
+      case '"':                if (!quoted) quoted_string ^= 1; quoted = 0; break;
+      case '@':        return -1;
+      case '\\':       quoted ^= 1; break;
+      case '!':        if (!quoted && !quoted_string) { domain = user; user = tmp + 1; }
+      default:         quoted = 0; break;
+    }
+  }
+  
+  if (domain == NULL)
+    return -1;
+
+  if (destlen <= tmp - domain)
+    return -1;
+
+  snprintf (dest, tmp - domain + 1, "%s@%s", user, domain);
+  return 0;
+}
+
 void rfc822_qualify (ADDRESS *addr, const char *host)
 {
   char *p;
@@ -615,7 +648,9 @@ void rfc822_write_address_single (char *buf, size_t buflen, ADDRESS *addr)
   {
     if (!buflen)
       goto done;
-    strfcpy (pbuf, addr->mailbox, buflen);
+    if (!option (OPTREWRITEUUCP) || 
+       rewrite_uucp (pbuf, addr->mailbox, buflen) == -1)
+      strfcpy (pbuf, addr->mailbox, buflen);
     len = mutt_strlen (pbuf);
     pbuf += len;
     buflen -= len;