Changed msg_style and msg_delim to be file static to m_getfld.c
[mmh] / sbr / addrsbr.c
index 9edb139..929b491 100644 (file)
@@ -77,9 +77,6 @@ static char err[BUFSIZ];
 static char adr[BUFSIZ];
 
 
-extern boolean  username_extension_masquerading;  /* defined in mts.c */
-
-
 char *
 getname (char *addrs)
 {
@@ -172,37 +169,30 @@ getm (char *str, char *dfhost, int dftype, int wanthost, char *eresult)
     if (host) {
        mp->m_mbox = getcpy (mbox);
        mp->m_host = getcpy (host);
-    }
-    else {
+       mp->m_type =
+           mh_strcasecmp (LocalName(0), mp->m_host) ? NETHOST : LOCALHOST;
+    } else {
        if ((pp = strchr(mbox, '!'))) {
            *pp++ = '\0';
            mp->m_mbox = getcpy (pp);
            mp->m_host = getcpy (mbox);
            mp->m_type = UUCPHOST;
-       }
-       else {
+       } else {
            mp->m_nohost = 1;
            mp->m_mbox = getcpy (mbox);
            if (route == NULL && dftype == LOCALHOST) {
                mp->m_host = NULL;
                mp->m_type = dftype;
-           }
-           else
-           {
+           } else {
                mp->m_host = route ? NULL : getcpy (dfhost);
                mp->m_type = route ? NETHOST : dftype;
            }
        }
-       goto got_host;
     }
 
-    if (wanthost == AD_NHST)
-       mp->m_type = !mh_strcasecmp (LocalName (0), mp->m_host)
-           ? LOCALHOST : NETHOST;
-    else
-       mp->m_type = mh_strcasecmp (LocalName(0), mp->m_host) ?  NETHOST : LOCALHOST;
+    /* For alternate mailboxes, m_type gets overwritten in ismymbox ()
+       to support wild-card matching. */
 
-got_host: ;
     if (route)
        mp->m_path = getcpy (route);
     mp->m_ingrp = ingrp;
@@ -291,47 +281,11 @@ auxformat (struct mailname *mp, int extras)
 char *
 getlocaladdr(void)
 {
-    int          snprintf_return;
-    char        *username, *domain;
-    static char  addr[BUFSIZ];
+    char        *username;
 
     username = getusername();
 
-    if (username_extension_masquerading) {
-       /* mts.conf contains "masquerade:[...]username_extension[...]", so tack
-          on the value of the $USERNAME_EXTENSION environment variable, if set,
-          to username. */
-       char*        extension = getenv("USERNAME_EXTENSION");
-       static char  username_with_extension[BUFSIZ];
-
-       if (extension != NULL && *extension != '\0') {
-           snprintf_return = snprintf(username_with_extension,
-                                      sizeof(username_with_extension),
-                                      "%s%s", username, extension);
-           
-           if (snprintf_return < 0 ||
-               snprintf_return >= (int) sizeof(username_with_extension))
-               adios(NULL, "snprintf() error writing username (%d chars) and"
-                     " $USERNAME_EXTENSION (%d chars) to array of BUFSIZ (%d)"
-                     " chars",
-                     strlen(username), strlen(extension), BUFSIZ);
-           
-           username = username_with_extension;
-       }
-    }
-
     return username;
-
-    domain = LocalName(0);
-
-    snprintf_return = snprintf (addr, sizeof(addr), "%s@%s", username, domain);
-
-    if (snprintf_return < 0 || snprintf_return >= (int) sizeof(addr))
-       adios(NULL, "snprintf() error writing username (%d chars), domain (%d"
-             " chars), and 1 separator char to array of BUFSIZ (%d) chars",
-             strlen(username), strlen(domain), BUFSIZ);
-    
-    return addr;
 }
 
 
@@ -395,7 +349,7 @@ ismymbox (struct mailname *np)
        if ((am = context_find ("alternate-mailboxes")) == NULL)
            am = getusername();
        else {
-           mp = &mq;
+           mp = mq.m_next ? mq.m_next : &mq;
            oops = 0;
            while ((cp = getname (am))) {
                if ((mp->m_next = getm (cp, NULL, 0, AD_NAME, NULL)) == NULL) {
@@ -422,16 +376,23 @@ ismymbox (struct mailname *np)
                            *cp = '\0';
                        }
                    }
-                   if ((cp = getenv ("MHWDEBUG")) && *cp)
-                       fprintf (stderr, "mbox=\"%s\" host=\"%s\" %s\n",
-                           mp->m_mbox, mp->m_host,
-                           snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type, WBITS));
                }
            }
            if (oops)
                advise (NULL, "please fix the %s: entry in your %s file",
                        "alternate-mailboxes", mh_profile);
        }
+
+       if ((cp = getenv ("MHWDEBUG")) && *cp) {
+           for (mp = &mq; mp; mp = mp->m_next) {
+             fprintf (stderr, "Local- or Alternate-Mailbox: text=\"%s\" "
+                      "mbox=\"%s\" host=\"%s\" %s\n",
+                      mp->m_text ? mp->m_text : "", mp->m_mbox,
+                      mp->m_host ? mp->m_host : "",
+                      snprintb (buffer, sizeof(buffer), (unsigned) mp->m_type,
+                                WBITS));
+           }
+       }
     }
 
     if (np == NULL) /* XXX */