install with -s
[unix-history] / usr / src / usr.bin / mail / optim.c
index cd06387..3960c8a 100644 (file)
@@ -1,4 +1,6 @@
-#
+#ifndef lint
+static char sccsid[] = "@(#)optim.c    2.10 (Berkeley) %G%";
+#endif
 
 /*
  * Mail -- a program for sending and receiving mail.
 
 /*
  * Mail -- a program for sending and receiving mail.
@@ -10,8 +12,6 @@
 #include "configdefs.h"
 #include <ctype.h>
 
 #include "configdefs.h"
 #include <ctype.h>
 
-static char *SccsId = "@(#)optim.c     2.5 %G%";
-
 /*
  * Map a name into the correct network "view" of the
  * name.  This is done by prepending the name with the
 /*
  * Map a name into the correct network "view" of the
  * name.  This is done by prepending the name with the
@@ -29,7 +29,7 @@ netmap(name, from)
        if (strlen(from) == 0)
                return(name);
        if (any('@', name) || any('%', name))
        if (strlen(from) == 0)
                return(name);
        if (any('@', name) || any('%', name))
-               return(arpafix(name, from));
+               return(savestr(arpafix(name, from)));
        cp = revarpa(from);
        if (cp == NOSTR)
                return(name);
        cp = revarpa(from);
        if (cp == NOSTR)
                return(name);
@@ -44,7 +44,7 @@ netmap(name, from)
        optim(nbuf, ret);
        cp = revarpa(ret);
        if (!icequal(name, cp))
        optim(nbuf, ret);
        cp = revarpa(ret);
        if (!icequal(name, cp))
-               return((char *) savestr(cp));
+               return(savestr(cp));
        return(name);
 }
 
        return(name);
 }
 
@@ -92,14 +92,15 @@ netlook(machine, attnet)
 {
        register struct netmach *np;
        register char *cp, *cp2;
 {
        register struct netmach *np;
        register char *cp, *cp2;
-       char nbuf[20];
+       char nbuf[100];
 
        /*
         * Make into lower case.
         */
 
        for (cp = machine, cp2 = nbuf; *cp; *cp2++ = little(*cp++))
 
        /*
         * Make into lower case.
         */
 
        for (cp = machine, cp2 = nbuf; *cp; *cp2++ = little(*cp++))
-               ;
+               if (cp2 >= &nbuf[sizeof(nbuf)-1])
+                       break;
        *cp2 = 0;
 
        /*
        *cp2 = 0;
 
        /*
@@ -704,6 +705,27 @@ best(src, dest)
        return(np->no_char);
 }
 
        return(np->no_char);
 }
 
+#ifdef GETHOST
+/*
+ * Initialize the network name of the current host.
+ */
+inithost()
+{
+       register struct netmach *np;
+       static char host[64];
+
+       gethostname(host, sizeof host);
+       for (np = netmach; np->nt_machine != 0; np++)
+               if (strcmp(np->nt_machine, EMPTY) == 0)
+                       break;
+       if (np->nt_machine == 0) {
+               printf("Cannot find empty slot for dynamic host entry\n");
+               exit(1);
+       }
+       np->nt_machine = host;
+}
+#endif GETHOST
+
 /*
  * Code to twist around arpa net names.
  */
 /*
  * Code to twist around arpa net names.
  */