SCCS-vsn: usr.bin/last/last.c 5.14
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)last.c 5.13 (Berkeley) %G%";
+static char sccsid[] = "@(#)last.c 5.14 (Berkeley) %G%";
static char *file = "/usr/adm/wtmp"; /* wtmp file */
main(argc, argv)
static char *file = "/usr/adm/wtmp"; /* wtmp file */
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
- extern int optind;
- extern char *optarg;
- int ch;
- long atol();
- char *ttyconv();
+ extern int optind;
+ extern char *optarg;
+ int ch;
+ long atol();
+ char *p, *ttyconv();
while ((ch = getopt(argc, argv, "0123456789f:h:t:")) != EOF)
switch((char)ch) {
case '0': case '1': case '2': case '3': case '4':
while ((ch = getopt(argc, argv, "0123456789f:h:t:")) != EOF)
switch((char)ch) {
case '0': case '1': case '2': case '3': case '4':
* kludge: last was originally designed to take
* a number after a dash.
*/
* kludge: last was originally designed to take
* a number after a dash.
*/
- if (!maxrec)
- maxrec = atol(argv[optind - 1] + 1);
+ if (maxrec == -1) {
+ p = argv[optind - 1];
+ if (p[0] == '-' && p[1] == ch && !p[2])
+ maxrec = atol(++p);
+ else
+ maxrec = atol(argv[optind] + 1);
+ if (!maxrec)
+ exit(0);
+ }
break;
case 'f':
file = optarg;
break;
case 'f':
file = optarg;
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, UT_LINESIZE, UT_LINESIZE, bp->ut_line, UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, ct, ct + 11);
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, UT_LINESIZE, UT_LINESIZE, bp->ut_line, UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, ct, ct + 11);
- if (maxrec && !--maxrec)
+ if (maxrec != -1 && !--maxrec)
*/
static
want(bp, check)
*/
static
want(bp, check)
- register struct utmp *bp;
- int check;
+ register struct utmp *bp;
+ int check;
*/
static
addarg(type, arg)
*/
static
addarg(type, arg)
- register ARG *cur;
- char *malloc();
+ register ARG *cur;
+ char *malloc();
if (!(cur = (ARG *)malloc((u_int)sizeof(ARG)))) {
fputs("last: malloc failure.\n", stderr);
if (!(cur = (ARG *)malloc((u_int)sizeof(ARG)))) {
fputs("last: malloc failure.\n", stderr);
*/
static TTY *
addtty(ttyname)
*/
static TTY *
addtty(ttyname)
- register TTY *cur;
- char *malloc();
+ register TTY *cur;
+ char *malloc();
if (!(cur = (TTY *)malloc((u_int)sizeof(TTY)))) {
fputs("last: malloc failure.\n", stderr);
if (!(cur = (TTY *)malloc((u_int)sizeof(TTY)))) {
fputs("last: malloc failure.\n", stderr);
- static int first = 1;
- static char *hostdot,
- name[MAXHOSTNAMELEN];
- char *argdot, *index();
+ static int first = 1;
+ static char *hostdot, name[MAXHOSTNAMELEN];
+ char *argdot, *index();
if (!(argdot = index(arg, '.')))
return;
if (!(argdot = index(arg, '.')))
return;
*/
static char *
ttyconv(arg)
*/
static char *
ttyconv(arg)
- char *mval,
- *malloc(), *strcpy();
+ char *mval, *malloc(), *strcpy();
/*
* kludge -- we assume that all tty's end with
/*
* kludge -- we assume that all tty's end with
ct = ctime(&buf[0].ut_time);
printf("\ninterrupted %10.10s %5.5s \n", ct, ct + 11);
ct = ctime(&buf[0].ut_time);
printf("\ninterrupted %10.10s %5.5s \n", ct, ct + 11);