int do_test (int argc, char ** argv) { const struct a64l_test *at; long int l; const char *s; int status = 0; for (at = tests; at->base64 != NULL; ++at) { printf ("a64l (\"%s\")", at->base64); l = a64l (at->base64); if (l == at->value) puts ("\tOK"); else { printf ("\tBAD\n returns %ld, expected %ld\n", l, at->value); status = 1; } printf ("l64a (%ld)", at->value); s = l64a (at->value); if (strcmp (s, at->base64) == 0) puts ("\tOK"); else { printf ("\tBAD\n returns \"%s\", expected \"%s\"\n", s, at->base64); status = 1; } } return status ? EXIT_FAILURE : EXIT_SUCCESS; }
struct spwd * pwd_to_spwd(const struct passwd *pw) { static struct spwd sp; /* * Nice, easy parts first. The name and passwd map directly * from the old password structure to the new one. */ sp.sp_namp = pw->pw_name; sp.sp_pwdp = pw->pw_passwd; #ifdef ATT_AGE /* * AT&T-style password aging maps the sp_min, sp_max, and * sp_lstchg information from the pw_age field, which appears * after the encrypted password. */ if (pw->pw_age[0]) { sp.sp_max = (c64i(pw->pw_age[0]) * WEEK) / SCALE; if (pw->pw_age[1]) sp.sp_min = (c64i(pw->pw_age[1]) * WEEK) / SCALE; else sp.sp_min = (10000L * DAY) / SCALE; if (pw->pw_age[1] && pw->pw_age[2]) sp.sp_lstchg = (a64l(pw->pw_age + 2) * WEEK) / SCALE; else sp.sp_lstchg = time((time_t *) 0) / SCALE; } else #endif { /* * Defaults used if there is no pw_age information. */ sp.sp_min = 0; sp.sp_max = (10000L * DAY) / SCALE; sp.sp_lstchg = time((time_t *) 0) / SCALE; } /* * These fields have no corresponding information in the password * file. They are set to uninitialized values. */ sp.sp_warn = -1; sp.sp_expire = -1; sp.sp_inact = -1; sp.sp_flag = -1; return &sp; }