386BSD 0.1 development
[unix-history] / usr / src / usr.bin / finger / lprint.c
index 53dcd44..25ea256 100644 (file)
@@ -2,21 +2,40 @@
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * This code is derived from software contributed to Berkeley by
+ * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lprint.c   5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)lprint.c   5.13 (Berkeley) 10/31/90";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -26,8 +45,8 @@ static char sccsid[] = "@(#)lprint.c  5.8 (Berkeley) %G%";
 #include <tzfile.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <tzfile.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <paths.h>
 #include "finger.h"
 #include "finger.h"
-#include "pathnames.h"
 
 #define        LINE_LEN        80
 #define        TAB_LEN         8               /* 8 spaces between tabs */
 
 #define        LINE_LEN        80
 #define        TAB_LEN         8               /* 8 spaces between tabs */
@@ -59,9 +78,10 @@ lprint(pn)
        register struct tm *delta;
        register WHERE *w;
        register int cpr, len, maxlen;
        register struct tm *delta;
        register WHERE *w;
        register int cpr, len, maxlen;
+       struct tm *tp;
        int oddfield;
        time_t time();
        int oddfield;
        time_t time();
-       char *t, *ctime(), *prphone();
+       char *t, *tzn, *prphone();
 
        /*
         * long format --
 
        /*
         * long format --
@@ -124,8 +144,11 @@ lprint(pn)
        for (w = pn->whead; w != NULL; w = w->next) {
                switch (w->info) {
                case LOGGEDIN:
        for (w = pn->whead; w != NULL; w = w->next) {
                switch (w->info) {
                case LOGGEDIN:
-                       cpr = printf("On since %16.16s on %s",
-                           ctime(&w->loginat), w->tty);
+                       tp = localtime(&w->loginat);
+                       t = asctime(tp);
+                       tzn = tp->tm_zone;
+                       cpr = printf("On since %.16s (%s) on %s",
+                           t, tzn, w->tty);
                        /*
                         * idle time is tough; if have one, print a comma,
                         * then spaces to pad out the device name, then the
                        /*
                         * idle time is tough; if have one, print a comma,
                         * then spaces to pad out the device name, then the
@@ -155,13 +178,16 @@ lprint(pn)
                                (void)printf("Never logged in.");
                                break;
                        }
                                (void)printf("Never logged in.");
                                break;
                        }
-                       t = ctime(&w->loginat);
+                       tp = localtime(&w->loginat);
+                       t = asctime(tp);
+                       tzn = tp->tm_zone;
                        if (now - w->loginat > SECSPERDAY * DAYSPERNYEAR / 2)
                        if (now - w->loginat > SECSPERDAY * DAYSPERNYEAR / 2)
-                               cpr = printf("Last login %10.10s, %4.4s on %s",
-                                   t, t + 20, w->tty);
+                               cpr =
+                                   printf("Last login %.16s %.4s (%s) on %s",
+                                   t, t + 20, tzn, w->tty);
                        else
                        else
-                               cpr = printf("Last login %16.16s on %s",
-                                       t, w->tty);
+                               cpr = printf("Last login %.16s (%s) on %s",
+                                   t, tzn, w->tty);
                        break;
                }
                if (*w->host) {
                        break;
                }
                if (*w->host) {