Renamed -version switch to -Version to remove the conflict with -verbose.
[mmh] / uip / ali.c
index a4ab295..73f7166 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -9,7 +9,6 @@
 #include <h/mh.h>
 #include <h/addrsbr.h>
 #include <h/aliasbr.h>
-#include <h/mts.h>
 #include <h/utils.h>
 
 /*
@@ -35,7 +34,7 @@ static struct swit switches[] = {
 #define NUSERSW    7
        { "nouser", 0 },
 #define VERSIONSW  8
-       { "version", 0 },
+       { "Version", 0 },
 #define HELPSW     9
        { "help", 0 },
        { NULL, 0 }
@@ -69,58 +68,57 @@ main(int argc, char **argv)
        /* read user profile/context */
        context_read();
 
-       mts_init(invo_name);
        arguments = getarguments(invo_name, argc, argv, 1);
        argp = arguments;
 
        while ((cp = *argp++)) {
                if (*cp == '-') {
                        switch (smatch(++cp, switches)) {
-                               case AMBIGSW:
-                                       ambigsw(cp, switches);
-                                       done(1);
-                               case UNKWNSW:
-                                       adios(NULL, "-%s unknown", cp);
-
-                               case HELPSW:
-                                       snprintf(buf, sizeof(buf), "%s [switches] aliases ...",
-                                               invo_name);
-                                       print_help(buf, switches, 1);
-                                       done(1);
-                               case VERSIONSW:
-                                       print_version(invo_name);
-                                       done(1);
-
-                               case ALIASW:
-                                       if (!(cp = *argp++) || *cp == '-')
-                                               adios(NULL, "missing argument to %s", argp[-2]);
-                                       if ((i = alias(cp)) != AK_OK)
-                                               adios(NULL, "aliasing error in %s - %s", cp, akerror(i));
-                                       continue;
-                               case NALIASW:
-                                       noalias++;
-                                       continue;
+                       case AMBIGSW:
+                               ambigsw(cp, switches);
+                               done(1);
+                       case UNKWNSW:
+                               adios(NULL, "-%s unknown", cp);
+
+                       case HELPSW:
+                               snprintf(buf, sizeof(buf), "%s [switches] aliases ...",
+                                       invo_name);
+                               print_help(buf, switches, 1);
+                               done(1);
+                       case VERSIONSW:
+                               print_version(invo_name);
+                               done(1);
+
+                       case ALIASW:
+                               if (!(cp = *argp++) || *cp == '-')
+                                       adios(NULL, "missing argument to %s", argp[-2]);
+                               if ((i = alias(cp)) != AK_OK)
+                                       adios(NULL, "aliasing error in %s - %s", cp, akerror(i));
+                               continue;
+                       case NALIASW:
+                               noalias++;
+                               continue;
 
-                               case LISTSW:
-                                       list++;
-                                       continue;
-                               case NLISTSW:
-                                       list = 0;
-                                       continue;
+                       case LISTSW:
+                               list++;
+                               continue;
+                       case NLISTSW:
+                               list = 0;
+                               continue;
 
-                               case NORMSW:
-                                       normalize = AD_HOST;
-                                       continue;
-                               case NNORMSW:
-                                       normalize = AD_NHST;
-                                       continue;
+                       case NORMSW:
+                               normalize = AD_HOST;
+                               continue;
+                       case NNORMSW:
+                               normalize = AD_NHST;
+                               continue;
 
-                               case USERSW:
-                                       inverted++;
-                                       continue;
-                               case NUSERSW:
-                                       inverted = 0;
-                                       continue;
+                       case USERSW:
+                               inverted++;
+                               continue;
+                       case NUSERSW:
+                               inverted = 0;
+                               continue;
                        }
                }
                vec[vecp++] = cp;
@@ -132,12 +130,11 @@ main(int argc, char **argv)
                        char *dp = NULL;
 
                        for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++)
-                               if ((i = alias(*ap)) != AK_OK)
+                               if ((i = alias(etcpath(*ap))) != AK_OK)
                                        adios(NULL, "aliasing error in %s - %s", *ap, akerror(i));
                        if (dp)
                                free(dp);
                }
-               alias(AliasFile);
        }
 
        /*
@@ -183,27 +180,27 @@ print_aka(char *p, int list, int margin)
 
        while ((c = *p++)) {
                switch (c) {
-                       case ',':
-                               if (*p) {
-                                       if (list)
-                                               printf("\n%*s", margin, "");
-                                       else {
-                                               if (pos >= 68) {
-                                                       printf(",\n ");
-                                                       pos = 2;
-                                               } else {
-                                                       printf(", ");
-                                                       pos += 2;
-                                               }
+               case ',':
+                       if (*p) {
+                               if (list)
+                                       printf("\n%*s", margin, "");
+                               else {
+                                       if (pos >= 68) {
+                                               printf(",\n ");
+                                               pos = 2;
+                                       } else {
+                                               printf(", ");
+                                               pos += 2;
                                        }
                                }
+                       }
 
-                       case 0:
-                               break;
+               case 0:
+                       break;
 
-                       default:
-                               pos++;
-                               putchar(c);
+               default:
+                       pos++;
+                       putchar(c);
                }
        }
 
@@ -245,12 +242,7 @@ print_usr(char *s, int list, int norm)
        }
        mnfree(mp);
 
-#if 0
-       printf("%s: ", s);
-       print_aka(vp ? vp : s, list, pos += strlen(s) + 1);
-#else
        print_aka(vp ? vp : s, list, 0);
-#endif
 
        if (vp)
                free(vp);