changes per kurt
[unix-history] / usr / src / usr.bin / mail / optim.c
index ef513cc..eadb38f 100644 (file)
@@ -10,7 +10,7 @@
 #include "configdefs.h"
 #include <ctype.h>
 
 #include "configdefs.h"
 #include <ctype.h>
 
-static char *SccsId = "@(#)optim.c     2.3 %G%";
+static char *SccsId = "@(#)optim.c     2.7 %G%";
 
 /*
  * Map a name into the correct network "view" of the
 
 /*
  * Map a name into the correct network "view" of the
@@ -486,13 +486,13 @@ optim1(netstr, name)
 
        cp = netstr;
        prefer(cp);
 
        cp = netstr;
        prefer(cp);
+       strcpy(name, "");
        /*
         * If the address ultimately points back to us,
         * just return a null network path.
         */
        if (strlen(cp) > 1 && cp[strlen(cp) - 2] == LOCAL)
                return;
        /*
         * If the address ultimately points back to us,
         * just return a null network path.
         */
        if (strlen(cp) > 1 && cp[strlen(cp) - 2] == LOCAL)
                return;
-       strcpy(name, "");
        while (*cp != 0) {
                strcpy(path, "");
                tp = ntype(cp[1]);
        while (*cp != 0) {
                strcpy(path, "");
                tp = ntype(cp[1]);
@@ -534,11 +534,11 @@ optim1(netstr, name)
 ntype(nc)
        register int nc;
 {
 ntype(nc)
        register int nc;
 {
-       register struct nettypetab *np;
+       register struct ntypetab *np;
 
 
-       for (np = nettypetab; np->nt_char != 0; np++)
+       for (np = ntypetab; np->nt_char != 0; np++)
                if (np->nt_char == nc)
                if (np->nt_char == nc)
-                       return(np->nt_type);
+                       return(np->nt_bcode);
        return(0);
 }
 
        return(0);
 }
 
@@ -552,9 +552,9 @@ ntype(nc)
 netkind(nt)
        register int nt;
 {
 netkind(nt)
        register int nt;
 {
-       register struct netkindtab *np;
+       register struct nkindtab *np;
 
 
-       for (np = netkindtab; np->nk_type != 0; np++)
+       for (np = nkindtab; np->nk_type != 0; np++)
                if (np->nk_type == nt)
                        return(np->nk_kind);
        return(0);
                if (np->nk_type == nt)
                        return(np->nk_kind);
        return(0);
@@ -704,6 +704,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.
  */