SCCS-vsn: usr.bin/last/last.c 5.19
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)last.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)last.c 5.19 (Berkeley) %G%";
*/
#include <sys/param.h>
#include <sys/stat.h>
*/
#include <sys/param.h>
#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <paths.h>
#define SECDAY (24*60*60) /* seconds in a day */
#include <paths.h>
#define SECDAY (24*60*60) /* seconds in a day */
maxrec; /* records to display */
static char *file = _PATH_WTMP; /* wtmp file */
maxrec; /* records to display */
static char *file = _PATH_WTMP; /* wtmp file */
+void addarg __P((int, char *));
+TTY *addtty __P((char *));
+void hostconv __P((char *));
+void onintr __P((int));
+char *ttyconv __P((char *));
+int want __P((struct utmp *, int));
+void wtmp __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
main(argc, argv)
int argc;
char **argv;
extern int optind;
extern char *optarg;
int ch;
extern int optind;
extern char *optarg;
int ch;
- long atol();
- char *p, *ttyconv();
maxrec = -1;
while ((ch = getopt(argc, argv, "0123456789f:h:t:")) != EOF)
maxrec = -1;
while ((ch = getopt(argc, argv, "0123456789f:h:t:")) != EOF)
* wtmp --
* read through the wtmp file
*/
* wtmp --
* read through the wtmp file
*/
wtmp()
{
register struct utmp *bp; /* current structure */
register TTY *T; /* tty list entry */
struct stat stb; /* stat of file for size */
wtmp()
{
register struct utmp *bp; /* current structure */
register TTY *T; /* tty list entry */
struct stat stb; /* stat of file for size */
- long bl, delta, /* time difference */
- lseek(), time();
+ long bl, delta; /* time difference */
- char *ct, *crmsg,
- *asctime(), *ctime(), *strcpy();
- TTY *addtty();
- void onintr();
if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) {
perror(file);
if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) {
perror(file);
* want --
* see if want this entry
*/
* want --
* see if want this entry
*/
want(bp, check)
register struct utmp *bp;
int check;
want(bp, check)
register struct utmp *bp;
int check;
* addarg --
* add an entry to a linked list of arguments
*/
* addarg --
* add an entry to a linked list of arguments
*/
addarg(type, arg)
int type;
char *arg;
{
register ARG *cur;
addarg(type, arg)
int type;
char *arg;
{
register ARG *cur;
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);
char *ttyname;
{
register TTY *cur;
char *ttyname;
{
register TTY *cur;
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);
* has a domain attached that is the same as the current domain, rip
* off the domain suffix since that's what login(1) does.
*/
* has a domain attached that is the same as the current domain, rip
* off the domain suffix since that's what login(1) does.
*/
hostconv(arg)
char *arg;
{
hostconv(arg)
char *arg;
{
ttyconv(arg)
char *arg;
{
ttyconv(arg)
char *arg;
{
- char *mval, *malloc(), *strcpy();
/*
* kludge -- we assume that all tty's end with
/*
* kludge -- we assume that all tty's end with