need fmt also
[unix-history] / usr / src / usr.bin / mail / aux.c
index 33991dc..015eb65 100644 (file)
@@ -10,7 +10,7 @@
  * Auxiliary functions.
  */
 
  * Auxiliary functions.
  */
 
-static char *SccsId = "@(#)aux.c       2.4 %G%";
+static char *SccsId = "@(#)aux.c       2.9 %G%";
 
 /*
  * Return a pointer to a dynamic copy of the argument.
 
 /*
  * Return a pointer to a dynamic copy of the argument.
@@ -122,20 +122,6 @@ isdir(name)
        return((sbuf.st_mode & S_IFMT) == S_IFDIR);
 }
 
        return((sbuf.st_mode & S_IFMT) == S_IFDIR);
 }
 
-/*
- * Compute the size in characters of the passed message
- */
-
-unsigned int
-msize(messp)
-       struct message *messp;
-{
-       register struct message *mp;
-
-       mp = messp;
-       return(mp->m_size);
-}
-
 /*
  * Count the number of arguments in the given string raw list.
  */
 /*
  * Count the number of arguments in the given string raw list.
  */
@@ -372,6 +358,21 @@ icequal(s1, s2)
        return(0);
 }
 
        return(0);
 }
 
+/*
+ * Copy a string, lowercasing it as we go.
+ */
+istrcpy(dest, src)
+       char *dest, *src;
+{
+       register char *cp, *cp2;
+
+       cp2 = dest;
+       cp = src;
+       do {
+               *cp2++ = little(*cp);
+       } while (*cp++ != 0);
+}
+
 /*
  * The following code deals with input stacking to do source
  * commands.  All but the current file pointer are saved on
 /*
  * The following code deals with input stacking to do source
  * commands.  All but the current file pointer are saved on
@@ -545,21 +546,29 @@ skin(name)
 
        if (name == NOSTR)
                return(NOSTR);
 
        if (name == NOSTR)
                return(NOSTR);
-       if (index(name, '(') == NOSTR && index(name, '<') == NOSTR)
+       if (index(name, '(') == NOSTR && index(name, '<') == NOSTR
+       && index(name, ' ') == NOSTR)
                return(name);
        gotlt = 0;
        lastsp = 0;
                return(name);
        gotlt = 0;
        lastsp = 0;
-       for (cp = name, cp2 = nbuf, c = *cp++; *cp; c = *cp++) {
+       for (cp = name, cp2 = nbuf; c = *cp++; ) {
                switch (c) {
                case '(':
                        while (*cp != ')' && *cp != 0)
                                cp++;
                        if (*cp)
                                cp++;
                switch (c) {
                case '(':
                        while (*cp != ')' && *cp != 0)
                                cp++;
                        if (*cp)
                                cp++;
+                       lastsp = 0;
                        break;
 
                case ' ':
                        break;
 
                case ' ':
-                       lastsp = 1;
+                       if (cp[0] == 'a' && cp[1] == 't' && cp[2] == ' ')
+                               cp += 3, *cp2++ = '@';
+                       else
+                       if (cp[0] == '@' && cp[1] == ' ')
+                               cp += 2, *cp2++ = '@';
+                       else
+                               lastsp = 1;
                        break;
 
                case '<':
                        break;
 
                case '<':
@@ -607,7 +616,7 @@ name1(mp, reptype)
        register FILE *ibuf;
        int first = 1;
 
        register FILE *ibuf;
        int first = 1;
 
-#ifndef DELIVERMAIL
+#ifndef SENDMAIL
        if ((cp = hfield("from", mp)) != NOSTR)
                return(cp);
        if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR)
        if ((cp = hfield("from", mp)) != NOSTR)
                return(cp);
        if (reptype == 0 && (cp = hfield("sender", mp)) != NOSTR)
@@ -753,3 +762,20 @@ strncmp(as1, as2, an)
        return(n<0 ? 0 : *s1 - *--s2);
 }
 
        return(n<0 ? 0 : *s1 - *--s2);
 }
 
+/*
+ * See if the given header field is supposed to be ignored.
+ */
+isign(field)
+       char *field;
+{
+       char realfld[BUFSIZ];
+       register int h;
+       register struct ignore *igp;
+
+       istrcpy(realfld, field);
+       h = hash(realfld);
+       for (igp = ignore[h]; igp != 0; igp = igp->i_link)
+               if (strcmp(igp->i_field, realfld) == 0)
+                       return(1);
+       return(0);
+}