X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/b24a1b1ac51ca3bbacc82700dd1388b7dae2633d..a23477eb:/uip/ali.c?ds=sidebyside diff --git a/uip/ali.c b/uip/ali.c index dda0a2c1..fe57ef3e 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -1,6 +1,4 @@ - -/* - * ali.c -- list nmh mail aliases +/* ali.c -- list nmh mail aliases * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -15,7 +13,7 @@ #define ALI_SWITCHES \ X("alias aliasfile", 0, ALIASW) \ - X("noalias", -7, NALIASW) \ + X("noalias", 0, NALIASW) \ X("list", 0, LISTSW) \ X("nolist", 0, NLISTSW) \ X("user", 0, USERSW) \ @@ -53,15 +51,9 @@ main (int argc, char **argv) char **vec = mh_xmalloc (argc * sizeof (char *)), **arguments; struct aka *ak; -#ifdef LOCALE - setlocale(LC_ALL, ""); -#endif - invo_name = r1bindex (argv[0], '/'); - - /* read user profile/context */ - context_read(); + if (nmh_init(argv[0], 1)) { return 1; } - mts_init (invo_name); + mts_init (); arguments = getarguments (invo_name, argc, argv, 1); argp = arguments; @@ -123,11 +115,10 @@ main (int argc, char **argv) if ((cp = context_find ("Aliasfile"))) { char *dp = NULL; - for (ap = brkstring(dp = getcpy(cp), " ", "\n"); ap && *ap; ap++) + for (ap = brkstring(dp = mh_xstrdup(cp), " ", "\n"); ap && *ap; ap++) if ((i = alias (*ap)) != AK_OK) adios (NULL, "aliasing error in %s - %s", *ap, akerror (i)); - if (dp) - free(dp); + mh_xfree(dp); } alias (AliasFile); } @@ -150,9 +141,13 @@ main (int argc, char **argv) } else { /* print them all */ for (ak = akahead; ak; ak = ak->ak_next) { + char *res; + printf ("%s: ", ak->ak_name); pos += strlen (ak->ak_name) + 1; - print_aka (akresult (ak), list, pos); + res = akresult(ak); + print_aka(res, list, pos); + free(res); } } } @@ -168,7 +163,7 @@ print_aka (char *p, int list, int margin) char c; if (p == NULL) { - printf ("\n"); + puts(""); return; } @@ -205,9 +200,9 @@ print_aka (char *p, int list, int margin) static void print_usr (char *s, int list) { - register char *cp, *pp, *vp; - register struct aka *ak; - register struct mailname *mp, *np; + char *cp, *pp, *vp; + struct aka *ak; + struct mailname *mp, *np; if ((pp = getname (s)) == NULL) adios (NULL, "no address in \"%s\"", s); @@ -240,6 +235,5 @@ print_usr (char *s, int list) print_aka (vp ? vp : s, list, 0); - if (vp) - free (vp); + mh_xfree(vp); }