diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-03-15 08:29:22 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2004-03-15 08:29:22 +0000 |
commit | b16674f3c1a961e0b5d6a57745f5f749d95c641e (patch) | |
tree | 4c6d2217f4d8306c59cf1096f8664e1cfd167213 /util-linux/hwclock.c | |
parent | e7135df4a650f9197b633784472f45602524855b (diff) | |
download | busybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.tar.gz busybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.tar.bz2 busybox-w32-b16674f3c1a961e0b5d6a57745f5f749d95c641e.zip |
Remove trailing whitespace. Update copyright to include 2004.
git-svn-id: svn://busybox.net/trunk/busybox@8630 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'util-linux/hwclock.c')
-rw-r--r-- | util-linux/hwclock.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index e089b1d81..fae511f9c 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -46,7 +46,7 @@ struct linux_rtc_time { | |||
46 | int tm_yday; | 46 | int tm_yday; |
47 | int tm_isdst; | 47 | int tm_isdst; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #define RTC_SET_TIME _IOW('p', 0x0a, struct linux_rtc_time) /* Set RTC time */ | 50 | #define RTC_SET_TIME _IOW('p', 0x0a, struct linux_rtc_time) /* Set RTC time */ |
51 | #define RTC_RD_TIME _IOR('p', 0x09, struct linux_rtc_time) /* Read RTC time */ | 51 | #define RTC_RD_TIME _IOR('p', 0x09, struct linux_rtc_time) /* Read RTC time */ |
52 | 52 | ||
@@ -71,17 +71,17 @@ static time_t read_rtc(int utc) | |||
71 | if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 ) | 71 | if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 ) |
72 | bb_perror_msg_and_die ( "Could not read time from RTC" ); | 72 | bb_perror_msg_and_die ( "Could not read time from RTC" ); |
73 | tm. tm_isdst = -1; // not known | 73 | tm. tm_isdst = -1; // not known |
74 | 74 | ||
75 | close ( rtc ); | 75 | close ( rtc ); |
76 | 76 | ||
77 | if ( utc ) { | 77 | if ( utc ) { |
78 | oldtz = getenv ( "TZ" ); | 78 | oldtz = getenv ( "TZ" ); |
79 | setenv ( "TZ", "UTC 0", 1 ); | 79 | setenv ( "TZ", "UTC 0", 1 ); |
80 | tzset ( ); | 80 | tzset ( ); |
81 | } | 81 | } |
82 | 82 | ||
83 | t = mktime ( &tm ); | 83 | t = mktime ( &tm ); |
84 | 84 | ||
85 | if ( utc ) { | 85 | if ( utc ) { |
86 | if ( oldtz ) | 86 | if ( oldtz ) |
87 | setenv ( "TZ", oldtz, 1 ); | 87 | setenv ( "TZ", oldtz, 1 ); |
@@ -101,13 +101,13 @@ static void write_rtc(time_t t, int utc) | |||
101 | if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 ) | 101 | if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 ) |
102 | bb_perror_msg_and_die ( "Could not access RTC" ); | 102 | bb_perror_msg_and_die ( "Could not access RTC" ); |
103 | } | 103 | } |
104 | 104 | ||
105 | tm = *( utc ? gmtime ( &t ) : localtime ( &t )); | 105 | tm = *( utc ? gmtime ( &t ) : localtime ( &t )); |
106 | tm. tm_isdst = 0; | 106 | tm. tm_isdst = 0; |
107 | 107 | ||
108 | if ( ioctl ( rtc, RTC_SET_TIME, &tm ) < 0 ) | 108 | if ( ioctl ( rtc, RTC_SET_TIME, &tm ) < 0 ) |
109 | bb_perror_msg_and_die ( "Could not set the RTC time" ); | 109 | bb_perror_msg_and_die ( "Could not set the RTC time" ); |
110 | 110 | ||
111 | close ( rtc ); | 111 | close ( rtc ); |
112 | } | 112 | } |
113 | 113 | ||
@@ -117,16 +117,16 @@ static int show_clock(int utc) | |||
117 | time_t t; | 117 | time_t t; |
118 | char buffer [64]; | 118 | char buffer [64]; |
119 | 119 | ||
120 | t = read_rtc ( utc ); | 120 | t = read_rtc ( utc ); |
121 | ptm = localtime ( &t ); /* Sets 'tzname[]' */ | 121 | ptm = localtime ( &t ); /* Sets 'tzname[]' */ |
122 | 122 | ||
123 | safe_strncpy ( buffer, ctime ( &t ), sizeof( buffer )); | 123 | safe_strncpy ( buffer, ctime ( &t ), sizeof( buffer )); |
124 | if ( buffer [0] ) | 124 | if ( buffer [0] ) |
125 | buffer [bb_strlen ( buffer ) - 1] = 0; | 125 | buffer [bb_strlen ( buffer ) - 1] = 0; |
126 | 126 | ||
127 | //printf ( "%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] )); | 127 | //printf ( "%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] )); |
128 | printf ( "%s %.6f seconds\n", buffer, 0.0 ); | 128 | printf ( "%s %.6f seconds\n", buffer, 0.0 ); |
129 | 129 | ||
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
132 | 132 | ||
@@ -134,7 +134,7 @@ static int to_sys_clock(int utc) | |||
134 | { | 134 | { |
135 | struct timeval tv = { 0, 0 }; | 135 | struct timeval tv = { 0, 0 }; |
136 | const struct timezone tz = { timezone/60 - 60*daylight, 0 }; | 136 | const struct timezone tz = { timezone/60 - 60*daylight, 0 }; |
137 | 137 | ||
138 | tv. tv_sec = read_rtc ( utc ); | 138 | tv. tv_sec = read_rtc ( utc ); |
139 | 139 | ||
140 | if ( settimeofday ( &tv, &tz )) | 140 | if ( settimeofday ( &tv, &tz )) |
@@ -160,18 +160,18 @@ static int check_utc(void) | |||
160 | { | 160 | { |
161 | int utc = 0; | 161 | int utc = 0; |
162 | FILE *f = fopen ( "/var/lib/hwclock/adjtime", "r" ); | 162 | FILE *f = fopen ( "/var/lib/hwclock/adjtime", "r" ); |
163 | 163 | ||
164 | if ( f ) { | 164 | if ( f ) { |
165 | char buffer [128]; | 165 | char buffer [128]; |
166 | 166 | ||
167 | while ( fgets ( buffer, sizeof( buffer ), f )) { | 167 | while ( fgets ( buffer, sizeof( buffer ), f )) { |
168 | int len = bb_strlen ( buffer ); | 168 | int len = bb_strlen ( buffer ); |
169 | 169 | ||
170 | while ( len && isspace ( buffer [len - 1] )) | 170 | while ( len && isspace ( buffer [len - 1] )) |
171 | len--; | 171 | len--; |
172 | 172 | ||
173 | buffer [len] = 0; | 173 | buffer [len] = 0; |
174 | 174 | ||
175 | if ( strncmp ( buffer, "UTC", 3 ) == 0 ) { | 175 | if ( strncmp ( buffer, "UTC", 3 ) == 0 ) { |
176 | utc = 1; | 176 | utc = 1; |
177 | break; | 177 | break; |
@@ -224,6 +224,6 @@ static const struct option hwclock_long_options[] = { | |||
224 | return from_sys_clock ( utc ); | 224 | return from_sys_clock ( utc ); |
225 | } else { | 225 | } else { |
226 | /* default HWCLOCK_OPT_SHOW */ | 226 | /* default HWCLOCK_OPT_SHOW */ |
227 | return show_clock ( utc ); | 227 | return show_clock ( utc ); |
228 | } | 228 | } |
229 | } | 229 | } |