- pto = (struct passwd *) malloc(sizeof *pto);
-#define savestr(s) strcpy(malloc(strlen(s) + 1), s)
- pto->pw_name = savestr(pfrom->pw_name);
- pto->pw_uid = pfrom->pw_uid;
- pto->pw_gecos = savestr(pfrom->pw_gecos);
- pto->pw_dir = savestr(pfrom->pw_dir);
- pto->pw_shell = savestr(pfrom->pw_shell);
-#undef savestr
- return pto;
-}
-
-/*
- * print out information on quick format giving just name, tty, login time
- * and idle time if idle is set.
- */
-quickprint(pers)
- register struct person *pers;
-{
- printf("%-*.*s ", NMAX, NMAX, pers->name);
- if (pers->loggedin) {
- if (idle) {
- findidle(pers);
- printf("%c%-*s %-16.16s", pers->writable ? ' ' : '*',
- LMAX, pers->tty, ctime(&pers->loginat));
- ltimeprint(" ", &pers->idletime, "");
- } else
- printf(" %-*s %-16.16s", LMAX,
- pers->tty, ctime(&pers->loginat));
- putchar('\n');
- } else
- printf(" Not Logged In\n");
-}
-
-/*
- * print out information in short format, giving login name, full name,
- * tty, idle time, login time, office location and phone.
- */
-shortprint(pers)
- register struct person *pers;
-{
- char *p;
- char dialup;
-
- if (pers->pwd == 0) {
- printf("%-15s ???\n", pers->name);
- return;
- }
- printf("%-*s", NMAX, pers->pwd->pw_name);
- dialup = 0;
- if (wide) {
- if (pers->realname)
- printf(" %-20.20s", pers->realname);
- else
- printf(" ??? ");
- }
- putchar(' ');
- if (pers->loggedin && !pers->writable)
- putchar('*');
- else
- putchar(' ');
- if (*pers->tty) {
- if (pers->tty[0] == 't' && pers->tty[1] == 't' &&
- pers->tty[2] == 'y') {
- if (pers->tty[3] == 'd' && pers->loggedin)
- dialup = 1;
- printf("%-2.2s ", pers->tty + 3);
- } else
- printf("%-2.2s ", pers->tty);
- } else
- printf(" ");
- p = ctime(&pers->loginat);
- if (pers->loggedin) {
- stimeprint(&pers->idletime);
- printf(" %3.3s %-5.5s ", p, p + 11);
- } else if (pers->loginat == 0)
- printf(" < . . . . >");
- else if (tloc - pers->loginat >= 180 * 24 * 60 * 60)
- printf(" <%-6.6s, %-4.4s>", p + 4, p + 20);
- else
- printf(" <%-12.12s>", p + 4);
- if (dialup && pers->homephone)
- printf(" %20s", pers->homephone);
- else {
- if (pers->office)
- printf(" %-11.11s", pers->office);
- else if (pers->officephone || pers->homephone)
- printf(" ");
- if (pers->officephone)
- printf(" %s", pers->officephone);
- else if (pers->homephone)
- printf(" %s", pers->homephone);
- }
- putchar('\n');
-}
-
-/*
- * print out a person in long format giving all possible information.
- * directory and shell are inhibited if unbrief is clear.
- */
-personprint(pers)
- register struct person *pers;
-{
- if (pers->pwd == 0) {
- printf("Login name: %-10s\t\t\tIn real life: ???\n",
- pers->name);
- return;
- }
- printf("Login name: %-10s", pers->pwd->pw_name);
- if (pers->loggedin && !pers->writable)
- printf(" (messages off) ");
- else
- printf(" ");
- if (pers->realname)
- printf("In real life: %s", pers->realname);
- if (pers->office) {
- printf("\nOffice: %-.11s", pers->office);
- if (pers->officephone) {
- printf(", %s", pers->officephone);
- if (pers->homephone)
- printf("\t\tHome phone: %s", pers->homephone);
- else if (pers->random)
- printf("\t\t%s", pers->random);
- } else
- if (pers->homephone)
- printf("\t\t\tHome phone: %s", pers->homephone);
- else if (pers->random)
- printf("\t\t\t%s", pers->random);
- } else if (pers->officephone) {
- printf("\nPhone: %s", pers->officephone);
- if (pers->homephone)
- printf(", %s", pers->homephone);
- if (pers->random)
- printf(", %s", pers->random);
- } else if (pers->homephone) {
- printf("\nPhone: %s", pers->homephone);
- if (pers->random)
- printf(", %s", pers->random);
- } else if (pers->random)
- printf("\n%s", pers->random);
- if (unbrief) {
- printf("\nDirectory: %-25s", pers->pwd->pw_dir);
- if (*pers->pwd->pw_shell)
- printf("\tShell: %-s", pers->pwd->pw_shell);
- }
- if (pers->loggedin) {
- register char *ep = ctime(&pers->loginat);
- if (*pers->host) {
- printf("\nOn since %15.15s on %s from %s",
- &ep[4], pers->tty, pers->host);
- ltimeprint("\n", &pers->idletime, " Idle Time");
- } else {
- printf("\nOn since %15.15s on %-*s",
- &ep[4], LMAX, pers->tty);
- ltimeprint("\t", &pers->idletime, " Idle Time");
- }
- } else if (pers->loginat == 0)
- printf("\nNever logged in.");
- else if (tloc - pers->loginat > 180 * 24 * 60 * 60) {
- register char *ep = ctime(&pers->loginat);
- printf("\nLast login %10.10s, %4.4s on %s",
- ep, ep+20, pers->tty);
- if (*pers->host)
- printf(" from %s", pers->host);
- } else {
- register char *ep = ctime(&pers->loginat);
- printf("\nLast login %16.16s on %s", ep, pers->tty);
- if (*pers->host)
- printf(" from %s", pers->host);