aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-22 21:56:26 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-05-22 21:56:26 +0000
commit69d5ba2f95287a59fb31583b014474859b22025b (patch)
tree5743f607901b6f3f6a9d2e4b0be06489b8cf109d
parenta959a2abdd5bef3dadcf653665831a14f404240c (diff)
downloadbusybox-w32-69d5ba2f95287a59fb31583b014474859b22025b.tar.gz
busybox-w32-69d5ba2f95287a59fb31583b014474859b22025b.tar.bz2
busybox-w32-69d5ba2f95287a59fb31583b014474859b22025b.zip
- untangle the implementation of the small and huge last applets
-rw-r--r--miscutils/Config.in16
-rw-r--r--miscutils/Kbuild3
-rw-r--r--miscutils/last.c8
-rw-r--r--miscutils/last_fancy.c7
4 files changed, 22 insertions, 12 deletions
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 427906ff8..dffde34db 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -229,13 +229,23 @@ config LAST
229 help 229 help
230 'last' displays a list of the last users that logged into the system. 230 'last' displays a list of the last users that logged into the system.
231 231
232config FEATURE_LAST_FANCY 232choice
233 bool "Fancy output" 233 prompt "Choose last implementation"
234 default n
235 depends on LAST 234 depends on LAST
235 default FEATURE_LAST_SMALL
236
237config FEATURE_LAST_SMALL
238 bool "small"
239 help
240 This is a small version of last with just the basic set of
241 features.
242
243config FEATURE_LAST_FANCY
244 bool "huge"
236 help 245 help
237 'last' displays detailed information about the last users that 246 'last' displays detailed information about the last users that
238 logged into the system (mimics sysvinit last). +900 bytes. 247 logged into the system (mimics sysvinit last). +900 bytes.
248endchoice
239 249
240config LESS 250config LESS
241 bool "less" 251 bool "less"
diff --git a/miscutils/Kbuild b/miscutils/Kbuild
index ba2a0dc14..96e754e1b 100644
--- a/miscutils/Kbuild
+++ b/miscutils/Kbuild
@@ -16,7 +16,8 @@ lib-$(CONFIG_DEVFSD) += devfsd.o
16lib-$(CONFIG_EJECT) += eject.o 16lib-$(CONFIG_EJECT) += eject.o
17lib-$(CONFIG_FBSPLASH) += fbsplash.o 17lib-$(CONFIG_FBSPLASH) += fbsplash.o
18lib-$(CONFIG_HDPARM) += hdparm.o 18lib-$(CONFIG_HDPARM) += hdparm.o
19lib-$(CONFIG_LAST) += last.o 19lib-$(CONFIG_FEATURE_LAST_SMALL)+= last.o
20lib-$(CONFIG_FEATURE_LAST_FANCY)+= last_fancy.o
20lib-$(CONFIG_LESS) += less.o 21lib-$(CONFIG_LESS) += less.o
21lib-$(CONFIG_MAKEDEVS) += makedevs.o 22lib-$(CONFIG_MAKEDEVS) += makedevs.o
22lib-$(CONFIG_MAN) += man.o 23lib-$(CONFIG_MAN) += man.o
diff --git a/miscutils/last.c b/miscutils/last.c
index 2199d7524..af92e50cf 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -26,12 +26,6 @@
26#error struct utmp member char[] size(s) have changed! 26#error struct utmp member char[] size(s) have changed!
27#endif 27#endif
28 28
29#if ENABLE_FEATURE_LAST_FANCY
30
31#include "last_fancy.c"
32
33#else
34
35#if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \ 29#if EMPTY != 0 || RUN_LVL != 1 || BOOT_TIME != 2 || NEW_TIME != 3 || \
36 OLD_TIME != 4 30 OLD_TIME != 4
37#error Values for the ut_type field of struct utmp changed 31#error Values for the ut_type field of struct utmp changed
@@ -131,5 +125,3 @@ int last_main(int argc, char **argv ATTRIBUTE_UNUSED)
131 125
132 fflush_stdout_and_exit(EXIT_SUCCESS); 126 fflush_stdout_and_exit(EXIT_SUCCESS);
133} 127}
134
135#endif
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c
index 03df8dcdd..91315d338 100644
--- a/miscutils/last_fancy.c
+++ b/miscutils/last_fancy.c
@@ -7,6 +7,13 @@
7 * Licensed under the GPLv2 or later, see the file LICENSE in this tarball. 7 * Licensed under the GPLv2 or later, see the file LICENSE in this tarball.
8 */ 8 */
9 9
10#include "libbb.h"
11#include <utmp.h>
12
13#ifndef SHUTDOWN_TIME
14# define SHUTDOWN_TIME 254
15#endif
16
10#define HEADER_FORMAT "%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n" 17#define HEADER_FORMAT "%-8.8s %-12.12s %-*.*s %-16.16s %-7.7s %s\n"
11#define HEADER_LINE "USER", "TTY", \ 18#define HEADER_LINE "USER", "TTY", \
12 INET_ADDRSTRLEN, INET_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" 19 INET_ADDRSTRLEN, INET_ADDRSTRLEN, "HOST", "LOGIN", " TIME", ""