diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-03-15 08:29:22 +0000 |
commit | c7bda1ce659294d6e22c06e087f6f265983c7578 (patch) | |
tree | 4c6d2217f4d8306c59cf1096f8664e1cfd167213 /coreutils/who.c | |
parent | 8854004b41065b3d081af7f3df13a100b0c8bfbe (diff) | |
download | busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2 busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip |
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'coreutils/who.c')
-rw-r--r-- | coreutils/who.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/coreutils/who.c b/coreutils/who.c index 1bf552056..9561db132 100644 --- a/coreutils/who.c +++ b/coreutils/who.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /*---------------------------------------------------------------------- | 2 | /*---------------------------------------------------------------------- |
3 | * Mini who is used to display user name, login time, | 3 | * Mini who is used to display user name, login time, |
4 | * idle time and host name. | 4 | * idle time and host name. |
5 | * | 5 | * |
6 | * Author: Da Chen <dchen@ayrnetworks.com> | 6 | * Author: Da Chen <dchen@ayrnetworks.com> |
@@ -10,7 +10,7 @@ | |||
10 | * as published by the Free Software Foundation: | 10 | * as published by the Free Software Foundation: |
11 | * http://www.gnu.org/copyleft/gpl.html | 11 | * http://www.gnu.org/copyleft/gpl.html |
12 | * | 12 | * |
13 | * Copyright (c) 2002 AYR Networks, Inc. | 13 | * Copyright (c) 2002 AYR Networks, Inc. |
14 | *---------------------------------------------------------------------- | 14 | *---------------------------------------------------------------------- |
15 | */ | 15 | */ |
16 | 16 | ||
@@ -30,21 +30,21 @@ extern int who_main(int argc, char **argv) | |||
30 | struct utmp *ut; | 30 | struct utmp *ut; |
31 | struct stat st; | 31 | struct stat st; |
32 | int devlen, len; | 32 | int devlen, len; |
33 | time_t now, idle; | 33 | time_t now, idle; |
34 | 34 | ||
35 | if (argc > 1) | 35 | if (argc > 1) |
36 | bb_show_usage(); | 36 | bb_show_usage(); |
37 | 37 | ||
38 | setutent(); | 38 | setutent(); |
39 | devlen = sizeof("/dev/") - 1; | 39 | devlen = sizeof("/dev/") - 1; |
40 | printf("USER TTY IDLE FROM HOST\n"); | 40 | printf("USER TTY IDLE FROM HOST\n"); |
41 | 41 | ||
42 | while ((ut = getutent()) != NULL) { | 42 | while ((ut = getutent()) != NULL) { |
43 | char name[40]; | 43 | char name[40]; |
44 | 44 | ||
45 | if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) { | 45 | if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) { |
46 | len = strlen(ut->ut_line); | 46 | len = strlen(ut->ut_line); |
47 | if (ut->ut_line[0] == '/') { | 47 | if (ut->ut_line[0] == '/') { |
48 | strncpy(name, ut->ut_line, len); | 48 | strncpy(name, ut->ut_line, len); |
49 | name[len] = '\0'; | 49 | name[len] = '\0'; |
50 | strcpy(ut->ut_line, ut->ut_line + devlen); | 50 | strcpy(ut->ut_line, ut->ut_line + devlen); |
@@ -53,27 +53,27 @@ extern int who_main(int argc, char **argv) | |||
53 | strncpy(name+devlen, ut->ut_line, len); | 53 | strncpy(name+devlen, ut->ut_line, len); |
54 | name[devlen+len] = '\0'; | 54 | name[devlen+len] = '\0'; |
55 | } | 55 | } |
56 | 56 | ||
57 | printf("%-10s %-8s ", ut->ut_user, ut->ut_line); | 57 | printf("%-10s %-8s ", ut->ut_user, ut->ut_line); |
58 | 58 | ||
59 | if (stat(name, &st) == 0) { | 59 | if (stat(name, &st) == 0) { |
60 | now = time(NULL); | 60 | now = time(NULL); |
61 | idle = now - st.st_atime; | 61 | idle = now - st.st_atime; |
62 | 62 | ||
63 | if (idle < 60) | 63 | if (idle < 60) |
64 | printf("00:00m "); | 64 | printf("00:00m "); |
65 | else if (idle < (60 * 60)) | 65 | else if (idle < (60 * 60)) |
66 | printf("00:%02dm ", (int)(idle / 60)); | 66 | printf("00:%02dm ", (int)(idle / 60)); |
67 | else if (idle < (24 * 60 * 60)) | 67 | else if (idle < (24 * 60 * 60)) |
68 | printf("%02d:%02dm ", (int)(idle / (60 * 60)), | 68 | printf("%02d:%02dm ", (int)(idle / (60 * 60)), |
69 | (int)(idle % (60 * 60)) / 60); | 69 | (int)(idle % (60 * 60)) / 60); |
70 | else if (idle < (24 * 60 * 60 * 365)) | 70 | else if (idle < (24 * 60 * 60 * 365)) |
71 | printf("%03ddays ", (int)(idle / (24 * 60 * 60))); | 71 | printf("%03ddays ", (int)(idle / (24 * 60 * 60))); |
72 | else | 72 | else |
73 | printf("%02dyears ", (int) (idle / (24 * 60 * 60 * 365))); | 73 | printf("%02dyears ", (int) (idle / (24 * 60 * 60 * 365))); |
74 | } else | 74 | } else |
75 | printf("%-8s ", "?"); | 75 | printf("%-8s ", "?"); |
76 | 76 | ||
77 | printf("%-12.12s %s\n", ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); | 77 | printf("%-12.12s %s\n", ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host); |
78 | } | 78 | } |
79 | } | 79 | } |