diff options
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/apps/misc.c b/apps/misc.c index f3a937f76b..cd59dbc40f 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -27,7 +27,10 @@ | |||
27 | #ifdef __PCTOOL__ | 27 | #ifdef __PCTOOL__ |
28 | #include <stdint.h> | 28 | #include <stdint.h> |
29 | #include <stdarg.h> | 29 | #include <stdarg.h> |
30 | #include <unistd.h> | 30 | #include <stdio.h> |
31 | #ifdef WPSEDITOR | ||
32 | #include "string.h" | ||
33 | #endif | ||
31 | #else | 34 | #else |
32 | #include "sprintf.h" | 35 | #include "sprintf.h" |
33 | #include "lang.h" | 36 | #include "lang.h" |
@@ -196,26 +199,6 @@ char *create_numbered_filename(char *buffer, const char *path, | |||
196 | return buffer; | 199 | return buffer; |
197 | } | 200 | } |
198 | 201 | ||
199 | /* Format time into buf. | ||
200 | * | ||
201 | * buf - buffer to format to. | ||
202 | * buf_size - size of buffer. | ||
203 | * t - time to format, in milliseconds. | ||
204 | */ | ||
205 | void format_time(char* buf, int buf_size, long t) | ||
206 | { | ||
207 | if ( t < 3600000 ) | ||
208 | { | ||
209 | snprintf(buf, buf_size, "%d:%02d", | ||
210 | (int) (t / 60000), (int) (t % 60000 / 1000)); | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | snprintf(buf, buf_size, "%d:%02d:%02d", | ||
215 | (int) (t / 3600000), (int) (t % 3600000 / 60000), | ||
216 | (int) (t % 60000 / 1000)); | ||
217 | } | ||
218 | } | ||
219 | 202 | ||
220 | #if CONFIG_RTC | 203 | #if CONFIG_RTC |
221 | /* Create a filename with a date+time part. | 204 | /* Create a filename with a date+time part. |
@@ -1179,6 +1162,28 @@ char *strip_extension(char* buffer, int buffer_size, const char *filename) | |||
1179 | } | 1162 | } |
1180 | #endif /* !defined(__PCTOOL__) */ | 1163 | #endif /* !defined(__PCTOOL__) */ |
1181 | 1164 | ||
1165 | /* Format time into buf. | ||
1166 | * | ||
1167 | * buf - buffer to format to. | ||
1168 | * buf_size - size of buffer. | ||
1169 | * t - time to format, in milliseconds. | ||
1170 | */ | ||
1171 | void format_time(char* buf, int buf_size, long t) | ||
1172 | { | ||
1173 | if ( t < 3600000 ) | ||
1174 | { | ||
1175 | snprintf(buf, buf_size, "%d:%02d", | ||
1176 | (int) (t / 60000), (int) (t % 60000 / 1000)); | ||
1177 | } | ||
1178 | else | ||
1179 | { | ||
1180 | snprintf(buf, buf_size, "%d:%02d:%02d", | ||
1181 | (int) (t / 3600000), (int) (t % 3600000 / 60000), | ||
1182 | (int) (t % 60000 / 1000)); | ||
1183 | } | ||
1184 | } | ||
1185 | |||
1186 | |||
1182 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. | 1187 | /** Open a UTF-8 file and set file descriptor to first byte after BOM. |
1183 | * If no BOM is present this behaves like open(). | 1188 | * If no BOM is present this behaves like open(). |
1184 | * If the file is opened for writing and O_TRUNC is set, write a BOM to | 1189 | * If the file is opened for writing and O_TRUNC is set, write a BOM to |