prettyness police
[unix-history] / usr / src / usr.bin / chpass / util.c
index 64e7ee9..3e06705 100644 (file)
@@ -6,16 +6,20 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
-#include <sys/time.h>
-#include <tzfile.h>
+
+#include <ctype.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <pwd.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <ctype.h>
+#include <time.h>
+#include <tzfile.h>
+#include <unistd.h>
+
 #include "chpass.h"
 #include "pathnames.h"
 
 #include "chpass.h"
 #include "pathnames.h"
 
@@ -25,6 +29,7 @@ static char *months[] =
        { "January", "February", "March", "April", "May", "June",
          "July", "August", "September", "October", "November",
          "December", NULL };
        { "January", "February", "March", "April", "May", "June",
          "July", "August", "September", "October", "November",
          "December", NULL };
+
 char *
 ttoa(tval)
        time_t tval;
 char *
 ttoa(tval)
        time_t tval;
@@ -39,21 +44,22 @@ ttoa(tval)
        }
        else
                *tbuf = '\0';
        }
        else
                *tbuf = '\0';
-       return(tbuf);
+       return (tbuf);
 } 
 
 } 
 
+int
 atot(p, store)
        char *p;
        time_t *store;
 {
 atot(p, store)
        char *p;
        time_t *store;
 {
-       register char *t, **mp;
        static struct tm *lt;
        static struct tm *lt;
-       time_t tval, time();
+       char *t, **mp;
+       time_t tval;
        int day, month, year;
 
        if (!*p) {
                *store = 0;
        int day, month, year;
 
        if (!*p) {
                *store = 0;
-               return(0);
+               return (0);
        }
        if (!lt) {
                unsetenv("TZ");
        }
        if (!lt) {
                unsetenv("TZ");
@@ -81,7 +87,7 @@ atot(p, store)
        if (year < 100)
                year += TM_YEAR_BASE;
        if (year <= EPOCH_YEAR)
        if (year < 100)
                year += TM_YEAR_BASE;
        if (year <= EPOCH_YEAR)
-bad:           return(1);
+bad:           return (1);
        tval = isleap(year) && month > 2;
        for (--year; year >= EPOCH_YEAR; --year)
                tval += isleap(year) ?
        tval = isleap(year) && month > 2;
        for (--year; year >= EPOCH_YEAR; --year)
                tval += isleap(year) ?
@@ -92,23 +98,22 @@ bad:                return(1);
        tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN;
        tval -= lt->tm_gmtoff;
        *store = tval;
        tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN;
        tval -= lt->tm_gmtoff;
        *store = tval;
-       return(0);
+       return (0);
 }
 
 char *
 ok_shell(name)
 }
 
 char *
 ok_shell(name)
-       register char *name;
+       char *name;
 {
 {
-       register char *p, *sh;
-       char *getusershell();
+       char *p, *sh;
 
        setusershell();
        while (sh = getusershell()) {
                if (!strcmp(name, sh))
 
        setusershell();
        while (sh = getusershell()) {
                if (!strcmp(name, sh))
-                       return(name);
+                       return (name);
                /* allow just shell name, but use "real" path */
                /* allow just shell name, but use "real" path */
-               if ((p = rindex(sh, '/')) && !strcmp(name, p + 1))
-                       return(sh);
+               if ((p = strrchr(sh, '/')) && strcmp(name, p + 1) == 0)
+                       return (sh);
        }
        }
-       return(NULL);
+       return (NULL);
 }
 }