diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-02-08 19:58:47 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-02-08 19:58:47 +0000 |
commit | e49d5ecbbe51718fa925b6890a735e5937cc2aa2 (patch) | |
tree | c90bda10731ad9333ce3b404f993354c9fc104b8 /miscutils/dutmp.c | |
parent | c0bf817bbc5c7867fbe8fb76d5c39f8ee802692f (diff) | |
download | busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.gz busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.bz2 busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.zip |
Some formatting updates (ran the code through indent)
-Erik
Diffstat (limited to 'miscutils/dutmp.c')
-rw-r--r-- | miscutils/dutmp.c | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/miscutils/dutmp.c b/miscutils/dutmp.c index a9e879daf..45eab8ae7 100644 --- a/miscutils/dutmp.c +++ b/miscutils/dutmp.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> | 3 | * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com> |
3 | * | 4 | * |
@@ -15,37 +16,38 @@ | |||
15 | #include <utmp.h> | 16 | #include <utmp.h> |
16 | 17 | ||
17 | static const char dutmp_usage[] = "dutmp\n" | 18 | static const char dutmp_usage[] = "dutmp\n" |
18 | "\n" | 19 | "\n" |
19 | "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" | ||
20 | "\tdutmp /var/run/utmp\n"; | ||
21 | 20 | ||
22 | extern int dutmp_main (int argc, char **argv) | 21 | "\tDump file or stdin utmp file format to stdout, pipe delimited.\n" |
22 | "\tdutmp /var/run/utmp\n"; | ||
23 | |||
24 | extern int dutmp_main(int argc, char **argv) | ||
23 | { | 25 | { |
24 | 26 | ||
25 | FILE *f = stdin; | 27 | FILE *f = stdin; |
26 | struct utmp ut; | 28 | struct utmp ut; |
27 | 29 | ||
28 | if ((argc < 2) || (**(argv + 1) == '-')) { | 30 | if ((argc < 2) || (**(argv + 1) == '-')) { |
29 | usage( dutmp_usage); | 31 | usage(dutmp_usage); |
30 | } | 32 | } |
31 | 33 | ||
32 | if ( **(++argv) == 0 ) { | 34 | if (**(++argv) == 0) { |
33 | f = fopen (*(++argv), "r"); | 35 | f = fopen(*(++argv), "r"); |
34 | if (f < 0 ) { | 36 | if (f < 0) { |
35 | perror (*argv); | 37 | perror(*argv); |
36 | exit (FALSE); | 38 | exit(FALSE); |
37 | } | 39 | } |
38 | } | 40 | } |
39 | 41 | ||
40 | while (fread (&ut, 1, sizeof (struct utmp), f)) { | 42 | while (fread(&ut, 1, sizeof(struct utmp), f)) { |
41 | // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n", | 43 | // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n", |
42 | printf ("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", | 44 | printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n", |
43 | ut.ut_type, ut.ut_pid, ut.ut_line, | 45 | ut.ut_type, ut.ut_pid, ut.ut_line, |
44 | ut.ut_id, ut.ut_user, ut.ut_host, | 46 | ut.ut_id, ut.ut_user, ut.ut_host, |
45 | ut.ut_exit.e_termination, ut.ut_exit.e_exit, | 47 | ut.ut_exit.e_termination, ut.ut_exit.e_exit, |
46 | ut.ut_session, | 48 | ut.ut_session, |
47 | ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr); | 49 | ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr); |
48 | } | 50 | } |
49 | 51 | ||
50 | exit (TRUE); | 52 | exit(TRUE); |
51 | } | 53 | } |