aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-09-22 00:22:10 +0000
committerEric Andersen <andersen@codepoet.org>2000-09-22 00:22:10 +0000
commit75610e18b3fb9366e73dec22c15c437b00afc812 (patch)
tree7a34beacf04b11a0392b89b4b69f5a3fa50b0855
parent2c1faecba7140bb5b51ecb544b2420b5fbcc78b5 (diff)
downloadbusybox-w32-75610e18b3fb9366e73dec22c15c437b00afc812.tar.gz
busybox-w32-75610e18b3fb9366e73dec22c15c437b00afc812.tar.bz2
busybox-w32-75610e18b3fb9366e73dec22c15c437b00afc812.zip
Better cross libc compatibility (so Dave Cinege can stop complaining
that I broke it). -Erik
-rw-r--r--dutmp.c19
-rw-r--r--miscutils/dutmp.c19
2 files changed, 34 insertions, 4 deletions
diff --git a/dutmp.c b/dutmp.c
index 5a6eb076b..ec10941d0 100644
--- a/dutmp.c
+++ b/dutmp.c
@@ -8,7 +8,7 @@
8 * versions of 'who', 'last', etc. IP Addr is output in hex, 8 * versions of 'who', 'last', etc. IP Addr is output in hex,
9 * little endian on x86. 9 * little endian on x86.
10 * 10 *
11 * Modified to support all sort of libcs by 11 * Modified to support all sorts of libcs by
12 * Erik Andersen <andersen@lineo.com> 12 * Erik Andersen <andersen@lineo.com>
13 */ 13 */
14 14
@@ -39,6 +39,11 @@ extern int dutmp_main(int argc, char **argv)
39 } 39 }
40 } 40 }
41 41
42/* Kludge around the fact that the binary format for utmp has changed, and the
43 * fact the stupid libc doesn't have a reliable #define to announce that libc5
44 * is being used. sigh.
45 */
46#if ! defined __GLIBC__
42 while (read(file, (void*)&ut, sizeof(struct utmp))) { 47 while (read(file, (void*)&ut, sizeof(struct utmp))) {
43 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n", 48 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
44 ut.ut_type, ut.ut_pid, ut.ut_line, 49 ut.ut_type, ut.ut_pid, ut.ut_line,
@@ -46,6 +51,16 @@ extern int dutmp_main(int argc, char **argv)
46 ctime(&(ut.ut_time)), 51 ctime(&(ut.ut_time)),
47 (long)ut.ut_addr); 52 (long)ut.ut_addr);
48 } 53 }
49 54#else
55 while (read(file, (void*)&ut, sizeof(struct utmp))) {
56 printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
57 ut.ut_type, ut.ut_pid, ut.ut_line,
58 ut.ut_id, ut.ut_user, ut.ut_host,
59 ut.ut_exit.e_termination, ut.ut_exit.e_exit,
60 ut.ut_session,
61 ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
62 ut.ut_addr);
63 }
64#endif
50 return(TRUE); 65 return(TRUE);
51} 66}
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c
index 5a6eb076b..ec10941d0 100644
--- a/miscutils/dutmp.c
+++ b/miscutils/dutmp.c
@@ -8,7 +8,7 @@
8 * versions of 'who', 'last', etc. IP Addr is output in hex, 8 * versions of 'who', 'last', etc. IP Addr is output in hex,
9 * little endian on x86. 9 * little endian on x86.
10 * 10 *
11 * Modified to support all sort of libcs by 11 * Modified to support all sorts of libcs by
12 * Erik Andersen <andersen@lineo.com> 12 * Erik Andersen <andersen@lineo.com>
13 */ 13 */
14 14
@@ -39,6 +39,11 @@ extern int dutmp_main(int argc, char **argv)
39 } 39 }
40 } 40 }
41 41
42/* Kludge around the fact that the binary format for utmp has changed, and the
43 * fact the stupid libc doesn't have a reliable #define to announce that libc5
44 * is being used. sigh.
45 */
46#if ! defined __GLIBC__
42 while (read(file, (void*)&ut, sizeof(struct utmp))) { 47 while (read(file, (void*)&ut, sizeof(struct utmp))) {
43 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n", 48 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
44 ut.ut_type, ut.ut_pid, ut.ut_line, 49 ut.ut_type, ut.ut_pid, ut.ut_line,
@@ -46,6 +51,16 @@ extern int dutmp_main(int argc, char **argv)
46 ctime(&(ut.ut_time)), 51 ctime(&(ut.ut_time)),
47 (long)ut.ut_addr); 52 (long)ut.ut_addr);
48 } 53 }
49 54#else
55 while (read(file, (void*)&ut, sizeof(struct utmp))) {
56 printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
57 ut.ut_type, ut.ut_pid, ut.ut_line,
58 ut.ut_id, ut.ut_user, ut.ut_host,
59 ut.ut_exit.e_termination, ut.ut_exit.e_exit,
60 ut.ut_session,
61 ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
62 ut.ut_addr);
63 }
64#endif
50 return(TRUE); 65 return(TRUE);
51} 66}