summaryrefslogtreecommitdiffstats
path: root/usr.bin/last
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-12-29 09:27:57 +0000
committerphk <phk@FreeBSD.org>2000-12-29 09:27:57 +0000
commita31c18820da584825003d184e0f579a6070ad63a (patch)
treebe3fc6e9fcf6c9aaefd8a16dafe62d274931fbf9 /usr.bin/last
parent17ba2140980343f6298e96bd96d2e0c16b9dfb46 (diff)
downloadFreeBSD-src-a31c18820da584825003d184e0f579a6070ad63a.zip
FreeBSD-src-a31c18820da584825003d184e0f579a6070ad63a.tar.gz
Used macro-API to <sys/queue.h>.
Submitted by: ben
Diffstat (limited to 'usr.bin/last')
-rw-r--r--usr.bin/last/last.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index a0c6f39..2908898 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -208,10 +208,10 @@ wtmp()
*/
if (bp->ut_line[0] == '~' && !bp->ut_line[1]) {
/* everybody just logged out */
- for (tt = ttylist.lh_first; tt;) {
+ for (tt = LIST_FIRST(&ttylist); tt;) {
LIST_REMOVE(tt, list);
ttx = tt;
- tt = tt->list.le_next;
+ tt = LIST_NEXT(tt, list);
free(ttx);
}
currentout = -bp->ut_time;
@@ -252,20 +252,20 @@ wtmp()
}
if (bp->ut_name[0] == '\0' || want(bp)) {
/* find associated tty */
- for (tt = ttylist.lh_first; ; tt = tt->list.le_next) {
- if (tt == NULL) {
- /* add new one */
- tt = malloc(sizeof(struct ttytab));
- if (tt == NULL)
- err(1, "malloc failure");
- tt->logout = currentout;
- strncpy(tt->tty, bp->ut_line, UT_LINESIZE);
- LIST_INSERT_HEAD(&ttylist, tt, list);
- break;
- }
+ LIST_FOREACH(tt, &ttylist, list)
if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE))
break;
+
+ if (tt == NULL) {
+ /* add new one */
+ tt = malloc(sizeof(struct ttytab));
+ if (tt == NULL)
+ err(1, "malloc failure");
+ tt->logout = currentout;
+ strncpy(tt->tty, bp->ut_line, UT_LINESIZE);
+ LIST_INSERT_HEAD(&ttylist, tt, list);
}
+
if (bp->ut_name[0]) {
/*
* when uucp and ftp log in over a network, the entry in
OpenPOWER on IntegriCloud