X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/afaab789954a1b36a5469d52a88c111f36e7ab45..6015bb1f7:/uip/aliasbr.c?ds=inline diff --git a/uip/aliasbr.c b/uip/aliasbr.c index b5add173..1376cad7 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -17,21 +17,17 @@ static char *akerrst; struct aka *akahead = NULL; struct aka *akatail = NULL; -struct home *homehead = NULL; -struct home *hometail = NULL; - /* * prototypes */ int alias (char *); int akvisible (void); -void init_pw (void); char *akresult (struct aka *); char *akvalue (char *); char *akerror (int); static char *akval (struct aka *, char *); -static int aleq (char *, char *); +static bool aleq (char *, char *); static char *scanp (char *); static char *getp (char *); static char *seekp (char *, char *, char **); @@ -39,7 +35,6 @@ static int addfile (struct aka *, char *); static char *getalias (char *); static void add_aka (struct aka *, char *); static struct aka *akalloc (char *); -static struct home *hmalloc (struct passwd *); /* Do mh alias substitution on 's' and return the results. */ @@ -152,16 +147,16 @@ akval (struct aka *ak, char *s) } -static int +static bool aleq (char *string, char *aliasent) { char c; while ((c = *string++)) { if (*aliasent == '*') - return 1; + return true; if (tolower((unsigned char)c) != tolower((unsigned char)*aliasent)) - return 0; + return false; aliasent++; } @@ -199,7 +194,7 @@ alias (char *file) fclose (fp); return i; } - /* FALLTHRU */ + continue; case ':': /* comment */ case ';': case '#': @@ -218,11 +213,11 @@ alias (char *file) } switch (lc) { case ':': - ak->ak_visible = 0; + ak->ak_visible = false; break; case ';': - ak->ak_visible = 1; + ak->ak_visible = true; break; default: @@ -276,10 +271,6 @@ akerror (int i) snprintf (buffer, sizeof(buffer), "out of memory while on '%s'", akerrst); break; - case AK_NOGROUP: - snprintf (buffer, sizeof(buffer), "no such group as '%s'", akerrst); - break; - default: snprintf (buffer, sizeof(buffer), "unknown error (%d)", i); break; @@ -357,9 +348,8 @@ getalias (char *addrs) if (cp == NULL) cp = addrs; - else - if (*cp == 0) - return (cp = NULL); + else if (*cp == 0) + return (cp = NULL); /* Remove leading any space from the address. */ for (pp = cp; isspace ((unsigned char) *pp); pp++) @@ -404,31 +394,6 @@ add_aka (struct aka *ak, char *pp) } -void -init_pw (void) -{ - struct passwd *pw; - static int init; - - if (!init) - { - /* if the list has yet to be initialized */ - /* zap the list, and rebuild from scratch */ - homehead=NULL; - hometail=NULL; - init++; - - setpwent (); - - while ((pw = getpwent ())) - if (!hmalloc (pw)) - break; - - endpwent (); - } -} - - static struct aka * akalloc (char *id) { @@ -436,7 +401,7 @@ akalloc (char *id) NEW(p); p->ak_name = getcpy (id); - p->ak_visible = 0; + p->ak_visible = false; p->ak_addr = NULL; p->ak_next = NULL; if (akatail != NULL) @@ -447,26 +412,3 @@ akalloc (char *id) return p; } - - -static struct home * -hmalloc (struct passwd *pw) -{ - struct home *p; - - NEW(p); - p->h_name = getcpy (pw->pw_name); - p->h_uid = pw->pw_uid; - p->h_gid = pw->pw_gid; - p->h_home = getcpy (pw->pw_dir); - p->h_shell = getcpy (pw->pw_shell); - p->h_ngrps = 0; - p->h_next = NULL; - if (hometail != NULL) - hometail->h_next = p; - if (homehead == NULL) - homehead = p; - hometail = p; - - return p; -}