diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-12 22:26:06 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-12 22:26:06 +0000 |
commit | 3cf52d19581b2077480e7d2e63010baa1f5399c1 (patch) | |
tree | d91b0cb332ebc976126e36a394655dde7a15d8b1 /miscutils | |
parent | 2ce1edcf544ac675e6762c9861a6b918401ea716 (diff) | |
download | busybox-w32-3cf52d19581b2077480e7d2e63010baa1f5399c1.tar.gz busybox-w32-3cf52d19581b2077480e7d2e63010baa1f5399c1.tar.bz2 busybox-w32-3cf52d19581b2077480e7d2e63010baa1f5399c1.zip |
More stuff...
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/dutmp.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c index e92b6700f..2dad7d4a5 100644 --- a/miscutils/dutmp.c +++ b/miscutils/dutmp.c | |||
@@ -9,39 +9,44 @@ | |||
9 | * | 9 | * |
10 | * made against libc6 | 10 | * made against libc6 |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "internal.h" | 13 | #include "internal.h" |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | #include <utmp.h> | 15 | #include <utmp.h> |
16 | 16 | ||
17 | const char dutmp_usage[] = "dutmp\n" | 17 | const char dutmp_usage[] = "dutmp\n" |
18 | "\n" | 18 | "\n" |
19 | "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" | 19 | "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" |
20 | "\tdutmp /var/run/utmp\n"; | 20 | "\tdutmp /var/run/utmp\n"; |
21 | 21 | ||
22 | extern int | 22 | extern int dutmp_fn (int argc, char **argv) |
23 | dutmp_fn(const struct FileInfo * i) | ||
24 | { | 23 | { |
25 | 24 | ||
26 | FILE * f = stdin; | 25 | FILE *f = stdin; |
27 | struct utmp * ut = (struct utmp *) malloc(sizeof(struct utmp) ); | 26 | struct utmp ut; |
28 | 27 | ||
29 | if ( i ) | 28 | if ((argc < 2) || (**(argv + 1) == '-')) { |
30 | if (! (f = fopen(i->source, "r"))) { | 29 | fprintf (stderr, "Usage: %s %s\n", *argv, dutmp_usage); |
31 | name_and_error(i->source); | 30 | exit (FALSE); |
32 | return 1; | 31 | } |
33 | } | 32 | |
34 | 33 | if ( **(++argv) == 0 ) { | |
35 | while (fread (ut, 1, sizeof(struct utmp), f)) { | 34 | f = fopen (*(++argv), "r"); |
36 | //printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n", | 35 | if (f < 0 ) { |
37 | printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", | 36 | perror (*argv); |
38 | ut->ut_type, ut->ut_pid, ut->ut_line, | 37 | exit (FALSE); |
39 | ut->ut_id, ut->ut_user, ut->ut_host, | 38 | } |
40 | ut->ut_exit.e_termination, ut->ut_exit.e_exit, | 39 | } |
41 | ut->ut_session, | 40 | |
42 | ut->ut_tv.tv_sec, ut->ut_tv.tv_usec, | 41 | while (fread (&ut, 1, sizeof (struct utmp), f)) { |
43 | ut->ut_addr); | 42 | // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n", |
44 | } | 43 | printf ("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", |
45 | 44 | ut.ut_type, ut.ut_pid, ut.ut_line, | |
46 | return 0; | 45 | ut.ut_id, ut.ut_user, ut.ut_host, |
46 | ut.ut_exit.e_termination, ut.ut_exit.e_exit, | ||
47 | ut.ut_session, | ||
48 | ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr); | ||
49 | } | ||
50 | |||
51 | exit (TRUE); | ||
47 | } | 52 | } |