/src/libewf/libewf/libewf_date_time_values.c
Line | Count | Source |
1 | | /* |
2 | | * Date and time values functions |
3 | | * |
4 | | * Copyright (C) 2006-2026, Joachim Metz <joachim.metz@gmail.com> |
5 | | * |
6 | | * Refer to AUTHORS for acknowledgements. |
7 | | * |
8 | | * This program is free software: you can redistribute it and/or modify |
9 | | * it under the terms of the GNU Lesser General Public License as published by |
10 | | * the Free Software Foundation, either version 3 of the License, or |
11 | | * (at your option) any later version. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | * GNU General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include <common.h> |
23 | | #include <memory.h> |
24 | | #include <narrow_string.h> |
25 | | #include <types.h> |
26 | | |
27 | | #if defined( HAVE_SYS_TIME_H ) |
28 | | #include <sys/time.h> |
29 | | #endif |
30 | | |
31 | | #include <time.h> |
32 | | |
33 | | #include "libewf_date_time.h" |
34 | | #include "libewf_date_time_values.h" |
35 | | #include "libewf_definitions.h" |
36 | | #include "libewf_libcerror.h" |
37 | | #include "libewf_libfvalue.h" |
38 | | |
39 | | /* Copies date and time values string from a timestamp |
40 | | * The string must be at least 20 characters + the length of the timezone string and/or timezone name of size including the end of string character |
41 | | * Returns 1 if successful or -1 on error |
42 | | */ |
43 | | int libewf_date_time_values_copy_from_timestamp( |
44 | | uint8_t *date_time_values_string, |
45 | | size_t date_time_values_string_size, |
46 | | time_t timestamp, |
47 | | libcerror_error_t **error ) |
48 | 1.87k | { |
49 | 1.87k | struct tm time_elements; |
50 | | |
51 | 1.87k | static char *function = "libewf_date_time_values_copy_from_timestamp"; |
52 | 1.87k | size_t string_index = 0; |
53 | | |
54 | 1.87k | if( date_time_values_string == NULL ) |
55 | 0 | { |
56 | 0 | libcerror_error_set( |
57 | 0 | error, |
58 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
59 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
60 | 0 | "%s: invalid date time values string.", |
61 | 0 | function ); |
62 | |
|
63 | 0 | return( -1 ); |
64 | 0 | } |
65 | 1.87k | if( date_time_values_string_size > (size_t) SSIZE_MAX ) |
66 | 0 | { |
67 | 0 | libcerror_error_set( |
68 | 0 | error, |
69 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
70 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
71 | 0 | "%s: invalid date time values string size.", |
72 | 0 | function ); |
73 | |
|
74 | 0 | return( -1 ); |
75 | 0 | } |
76 | 1.87k | if( date_time_values_string_size < 20 ) |
77 | 0 | { |
78 | 0 | libcerror_error_set( |
79 | 0 | error, |
80 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
81 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
82 | 0 | "%s: date time values string too small.", |
83 | 0 | function ); |
84 | |
|
85 | 0 | return( -1 ); |
86 | 0 | } |
87 | 1.87k | if( libewf_date_time_localtime( |
88 | 1.87k | ×tamp, |
89 | 1.87k | &time_elements, |
90 | 1.87k | error ) != 1 ) |
91 | 17 | { |
92 | 17 | libcerror_error_set( |
93 | 17 | error, |
94 | 17 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
95 | 17 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
96 | 17 | "%s: unable to create time elements.", |
97 | 17 | function ); |
98 | | |
99 | 17 | return( -1 ); |
100 | 17 | } |
101 | 1.85k | if( ( time_elements.tm_year + 1900 ) > 10000 ) |
102 | 58 | { |
103 | 58 | libcerror_error_set( |
104 | 58 | error, |
105 | 58 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
106 | 58 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
107 | 58 | "%s: unsupported year value.", |
108 | 58 | function ); |
109 | | |
110 | 58 | return( -1 ); |
111 | 58 | } |
112 | 1.80k | if( ( time_elements.tm_mon < 0 ) |
113 | 1.80k | || ( time_elements.tm_mon > 11 ) ) |
114 | 0 | { |
115 | 0 | libcerror_error_set( |
116 | 0 | error, |
117 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
118 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
119 | 0 | "%s: unsupported month.", |
120 | 0 | function ); |
121 | |
|
122 | 0 | return( -1 ); |
123 | 0 | } |
124 | 1.80k | if( ( time_elements.tm_mday < 1 ) |
125 | 1.80k | || ( time_elements.tm_mday > 31 ) ) |
126 | 0 | { |
127 | 0 | libcerror_error_set( |
128 | 0 | error, |
129 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
130 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
131 | 0 | "%s: unsupported day of month.", |
132 | 0 | function ); |
133 | |
|
134 | 0 | return( -1 ); |
135 | 0 | } |
136 | 1.80k | if( ( time_elements.tm_hour < 0 ) |
137 | 1.80k | || ( time_elements.tm_hour > 23 ) ) |
138 | 0 | { |
139 | 0 | libcerror_error_set( |
140 | 0 | error, |
141 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
142 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
143 | 0 | "%s: unsupported hours.", |
144 | 0 | function ); |
145 | |
|
146 | 0 | return( -1 ); |
147 | 0 | } |
148 | 1.80k | if( ( time_elements.tm_min < 0 ) |
149 | 1.80k | || ( time_elements.tm_min > 59 ) ) |
150 | 0 | { |
151 | 0 | libcerror_error_set( |
152 | 0 | error, |
153 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
154 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
155 | 0 | "%s: unsupported minutes.", |
156 | 0 | function ); |
157 | |
|
158 | 0 | return( -1 ); |
159 | 0 | } |
160 | | /* Note a value of 60 is used for a leap-second |
161 | | */ |
162 | 1.80k | if( ( time_elements.tm_sec < 0 ) |
163 | 1.80k | || ( time_elements.tm_sec > 60 ) ) |
164 | 0 | { |
165 | 0 | libcerror_error_set( |
166 | 0 | error, |
167 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
168 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
169 | 0 | "%s: unsupported seconds.", |
170 | 0 | function ); |
171 | |
|
172 | 0 | return( -1 ); |
173 | 0 | } |
174 | 1.80k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
175 | 1.80k | date_time_values_string, |
176 | 1.80k | date_time_values_string_size, |
177 | 1.80k | &string_index, |
178 | 1.80k | (uint64_t) time_elements.tm_year + 1900, |
179 | 1.80k | 16, |
180 | 1.80k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
181 | 1.80k | error ) != 1 ) |
182 | 20 | { |
183 | 20 | libcerror_error_set( |
184 | 20 | error, |
185 | 20 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
186 | 20 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
187 | 20 | "%s: unable to copy year to date time values string.", |
188 | 20 | function ); |
189 | | |
190 | 20 | return( -1 ); |
191 | 20 | } |
192 | 1.78k | date_time_values_string[ string_index - 1 ] = (uint8_t) ' '; |
193 | | |
194 | 1.78k | if( ( time_elements.tm_mon + 1 ) < 10 ) |
195 | 1.74k | { |
196 | 1.74k | date_time_values_string[ string_index++ ] = (uint8_t) '0'; |
197 | 1.74k | } |
198 | 1.78k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
199 | 1.78k | date_time_values_string, |
200 | 1.78k | date_time_values_string_size, |
201 | 1.78k | &string_index, |
202 | 1.78k | (uint64_t) time_elements.tm_mon + 1, |
203 | 1.78k | 8, |
204 | 1.78k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
205 | 1.78k | error ) != 1 ) |
206 | 0 | { |
207 | 0 | libcerror_error_set( |
208 | 0 | error, |
209 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
210 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
211 | 0 | "%s: unable to copy month to date time values string.", |
212 | 0 | function ); |
213 | |
|
214 | 0 | return( -1 ); |
215 | 0 | } |
216 | 1.78k | date_time_values_string[ string_index - 1 ] = (uint8_t) ' '; |
217 | | |
218 | 1.78k | if( time_elements.tm_mday < 10 ) |
219 | 1.64k | { |
220 | 1.64k | date_time_values_string[ string_index++ ] = (uint8_t) '0'; |
221 | 1.64k | } |
222 | 1.78k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
223 | 1.78k | date_time_values_string, |
224 | 1.78k | date_time_values_string_size, |
225 | 1.78k | &string_index, |
226 | 1.78k | (uint64_t) time_elements.tm_mday, |
227 | 1.78k | 8, |
228 | 1.78k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
229 | 1.78k | error ) != 1 ) |
230 | 0 | { |
231 | 0 | libcerror_error_set( |
232 | 0 | error, |
233 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
234 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
235 | 0 | "%s: unable to copy day of month to date time values string.", |
236 | 0 | function ); |
237 | |
|
238 | 0 | return( -1 ); |
239 | 0 | } |
240 | 1.78k | date_time_values_string[ string_index - 1 ] = (uint8_t) ' '; |
241 | | |
242 | 1.78k | if( time_elements.tm_hour < 10 ) |
243 | 1.66k | { |
244 | 1.66k | date_time_values_string[ string_index++ ] = (uint8_t) '0'; |
245 | 1.66k | } |
246 | 1.78k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
247 | 1.78k | date_time_values_string, |
248 | 1.78k | date_time_values_string_size, |
249 | 1.78k | &string_index, |
250 | 1.78k | (uint64_t) time_elements.tm_hour, |
251 | 1.78k | 8, |
252 | 1.78k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
253 | 1.78k | error ) != 1 ) |
254 | 0 | { |
255 | 0 | libcerror_error_set( |
256 | 0 | error, |
257 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
258 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
259 | 0 | "%s: unable to copy hours to date time values string.", |
260 | 0 | function ); |
261 | |
|
262 | 0 | return( -1 ); |
263 | 0 | } |
264 | 1.78k | date_time_values_string[ string_index - 1 ] = (uint8_t) ' '; |
265 | | |
266 | 1.78k | if( time_elements.tm_min < 10 ) |
267 | 780 | { |
268 | 780 | date_time_values_string[ string_index++ ] = (uint8_t) '0'; |
269 | 780 | } |
270 | 1.78k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
271 | 1.78k | date_time_values_string, |
272 | 1.78k | date_time_values_string_size, |
273 | 1.78k | &string_index, |
274 | 1.78k | (uint64_t) time_elements.tm_min, |
275 | 1.78k | 8, |
276 | 1.78k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
277 | 1.78k | error ) != 1 ) |
278 | 0 | { |
279 | 0 | libcerror_error_set( |
280 | 0 | error, |
281 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
282 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
283 | 0 | "%s: unable to copy minutes to date time values string.", |
284 | 0 | function ); |
285 | |
|
286 | 0 | return( -1 ); |
287 | 0 | } |
288 | 1.78k | date_time_values_string[ string_index - 1 ] = (uint8_t) ' '; |
289 | | |
290 | 1.78k | if( time_elements.tm_sec < 10 ) |
291 | 1.53k | { |
292 | 1.53k | date_time_values_string[ string_index++ ] = (uint8_t) '0'; |
293 | 1.53k | } |
294 | 1.78k | if( libfvalue_utf8_string_with_index_copy_from_integer( |
295 | 1.78k | date_time_values_string, |
296 | 1.78k | date_time_values_string_size, |
297 | 1.78k | &string_index, |
298 | 1.78k | (uint64_t) time_elements.tm_sec, |
299 | 1.78k | 8, |
300 | 1.78k | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
301 | 1.78k | error ) != 1 ) |
302 | 0 | { |
303 | 0 | libcerror_error_set( |
304 | 0 | error, |
305 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
306 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
307 | 0 | "%s: unable to copy seconds to date time values string.", |
308 | 0 | function ); |
309 | |
|
310 | 0 | return( -1 ); |
311 | 0 | } |
312 | 1.78k | date_time_values_string[ string_index - 1 ] = 0; |
313 | | |
314 | 1.78k | return( 1 ); |
315 | 1.78k | } |
316 | | |
317 | | /* Copies date and time values string to a timestamp |
318 | | * Returns 1 if successful or -1 on error |
319 | | */ |
320 | | int libewf_date_time_values_copy_to_timestamp( |
321 | | const uint8_t *date_time_values_string, |
322 | | size_t date_time_values_string_size, |
323 | | time_t *timestamp, |
324 | | libcerror_error_t **error ) |
325 | 0 | { |
326 | 0 | struct tm time_elements; |
327 | |
|
328 | 0 | libfvalue_split_utf8_string_t *date_time_values = NULL; |
329 | 0 | uint8_t *date_time_value_string = NULL; |
330 | 0 | static char *function = "libewf_date_time_values_copy_to_timestamp"; |
331 | 0 | size_t date_time_value_string_size = 0; |
332 | 0 | int number_of_date_time_values = 0; |
333 | |
|
334 | 0 | if( date_time_values_string == NULL ) |
335 | 0 | { |
336 | 0 | libcerror_error_set( |
337 | 0 | error, |
338 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
339 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
340 | 0 | "%s: invalid date time values string.", |
341 | 0 | function ); |
342 | |
|
343 | 0 | return( -1 ); |
344 | 0 | } |
345 | 0 | if( date_time_values_string_size > (size_t) SSIZE_MAX ) |
346 | 0 | { |
347 | 0 | libcerror_error_set( |
348 | 0 | error, |
349 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
350 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
351 | 0 | "%s: invalid date time values string size.", |
352 | 0 | function ); |
353 | |
|
354 | 0 | return( -1 ); |
355 | 0 | } |
356 | 0 | if( timestamp == NULL ) |
357 | 0 | { |
358 | 0 | libcerror_error_set( |
359 | 0 | error, |
360 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
361 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
362 | 0 | "%s: invalid timestamp.", |
363 | 0 | function ); |
364 | |
|
365 | 0 | return( -1 ); |
366 | 0 | } |
367 | 0 | if( libfvalue_utf8_string_split( |
368 | 0 | date_time_values_string, |
369 | 0 | date_time_values_string_size, |
370 | 0 | (uint8_t) ' ', |
371 | 0 | &date_time_values, |
372 | 0 | error ) != 1 ) |
373 | 0 | { |
374 | 0 | libcerror_error_set( |
375 | 0 | error, |
376 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
377 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
378 | 0 | "%s: unable to split date time values string.", |
379 | 0 | function ); |
380 | |
|
381 | 0 | goto on_error; |
382 | 0 | } |
383 | 0 | if( libfvalue_split_utf8_string_get_number_of_segments( |
384 | 0 | date_time_values, |
385 | 0 | &number_of_date_time_values, |
386 | 0 | error ) != 1 ) |
387 | 0 | { |
388 | 0 | libcerror_error_set( |
389 | 0 | error, |
390 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
391 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
392 | 0 | "%s: unable to retrieve number of date time values.", |
393 | 0 | function ); |
394 | |
|
395 | 0 | goto on_error; |
396 | 0 | } |
397 | 0 | if( number_of_date_time_values < 6 ) |
398 | 0 | { |
399 | 0 | libcerror_error_set( |
400 | 0 | error, |
401 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
402 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
403 | 0 | "%s: unsupported number of date time values in string.", |
404 | 0 | function ); |
405 | |
|
406 | 0 | goto on_error; |
407 | 0 | } |
408 | | /* Set the year |
409 | | */ |
410 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
411 | 0 | date_time_values, |
412 | 0 | 0, |
413 | 0 | &date_time_value_string, |
414 | 0 | &date_time_value_string_size, |
415 | 0 | error ) != 1 ) |
416 | 0 | { |
417 | 0 | libcerror_error_set( |
418 | 0 | error, |
419 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
420 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
421 | 0 | "%s: unable to retrieve date time value string: 0.", |
422 | 0 | function ); |
423 | |
|
424 | 0 | goto on_error; |
425 | 0 | } |
426 | 0 | if( libewf_utf8_string_year_copy_to_time_elements( |
427 | 0 | date_time_value_string, |
428 | 0 | date_time_value_string_size, |
429 | 0 | &time_elements, |
430 | 0 | error ) != 1 ) |
431 | 0 | { |
432 | 0 | libcerror_error_set( |
433 | 0 | error, |
434 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
435 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
436 | 0 | "%s: unable to copy year value.", |
437 | 0 | function ); |
438 | |
|
439 | 0 | goto on_error; |
440 | 0 | } |
441 | | /* Set the month |
442 | | */ |
443 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
444 | 0 | date_time_values, |
445 | 0 | 1, |
446 | 0 | &date_time_value_string, |
447 | 0 | &date_time_value_string_size, |
448 | 0 | error ) != 1 ) |
449 | 0 | { |
450 | 0 | libcerror_error_set( |
451 | 0 | error, |
452 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
453 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
454 | 0 | "%s: unable to retrieve date time value string: 1.", |
455 | 0 | function ); |
456 | |
|
457 | 0 | goto on_error; |
458 | 0 | } |
459 | 0 | if( date_time_value_string_size != 3 ) |
460 | 0 | { |
461 | 0 | libcerror_error_set( |
462 | 0 | error, |
463 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
464 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
465 | 0 | "%s: unsupported date time value string: 1 size.", |
466 | 0 | function ); |
467 | |
|
468 | 0 | goto on_error; |
469 | 0 | } |
470 | 0 | if( libewf_utf8_string_month_copy_to_time_elements( |
471 | 0 | date_time_value_string, |
472 | 0 | date_time_value_string_size, |
473 | 0 | &time_elements, |
474 | 0 | error ) != 1 ) |
475 | 0 | { |
476 | 0 | libcerror_error_set( |
477 | 0 | error, |
478 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
479 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
480 | 0 | "%s: unable to copy month value.", |
481 | 0 | function ); |
482 | |
|
483 | 0 | goto on_error; |
484 | 0 | } |
485 | | /* Set the day of the month |
486 | | */ |
487 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
488 | 0 | date_time_values, |
489 | 0 | 2, |
490 | 0 | &date_time_value_string, |
491 | 0 | &date_time_value_string_size, |
492 | 0 | error ) != 1 ) |
493 | 0 | { |
494 | 0 | libcerror_error_set( |
495 | 0 | error, |
496 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
497 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
498 | 0 | "%s: unable to retrieve date time value string: 2.", |
499 | 0 | function ); |
500 | |
|
501 | 0 | goto on_error; |
502 | 0 | } |
503 | 0 | if( date_time_value_string_size != 3 ) |
504 | 0 | { |
505 | 0 | libcerror_error_set( |
506 | 0 | error, |
507 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
508 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
509 | 0 | "%s: unsupported date time value string: 2 size.", |
510 | 0 | function ); |
511 | |
|
512 | 0 | goto on_error; |
513 | 0 | } |
514 | 0 | if( libewf_utf8_string_day_of_month_copy_to_time_elements( |
515 | 0 | date_time_value_string, |
516 | 0 | date_time_value_string_size, |
517 | 0 | &time_elements, |
518 | 0 | error ) != 1 ) |
519 | 0 | { |
520 | 0 | libcerror_error_set( |
521 | 0 | error, |
522 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
523 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
524 | 0 | "%s: unable to copy day of month value.", |
525 | 0 | function ); |
526 | |
|
527 | 0 | goto on_error; |
528 | 0 | } |
529 | | /* Set the hours |
530 | | */ |
531 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
532 | 0 | date_time_values, |
533 | 0 | 3, |
534 | 0 | &date_time_value_string, |
535 | 0 | &date_time_value_string_size, |
536 | 0 | error ) != 1 ) |
537 | 0 | { |
538 | 0 | libcerror_error_set( |
539 | 0 | error, |
540 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
541 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
542 | 0 | "%s: unable to retrieve date time value string: 3.", |
543 | 0 | function ); |
544 | |
|
545 | 0 | goto on_error; |
546 | 0 | } |
547 | 0 | if( date_time_value_string_size != 3 ) |
548 | 0 | { |
549 | 0 | libcerror_error_set( |
550 | 0 | error, |
551 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
552 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
553 | 0 | "%s: unsupported date time value string: 3 size.", |
554 | 0 | function ); |
555 | |
|
556 | 0 | goto on_error; |
557 | 0 | } |
558 | 0 | if( libewf_utf8_string_hours_copy_to_time_elements( |
559 | 0 | date_time_value_string, |
560 | 0 | date_time_value_string_size, |
561 | 0 | &time_elements, |
562 | 0 | error ) != 1 ) |
563 | 0 | { |
564 | 0 | libcerror_error_set( |
565 | 0 | error, |
566 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
567 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
568 | 0 | "%s: unable to copy hours value.", |
569 | 0 | function ); |
570 | |
|
571 | 0 | goto on_error; |
572 | 0 | } |
573 | | /* Set the minutes |
574 | | */ |
575 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
576 | 0 | date_time_values, |
577 | 0 | 4, |
578 | 0 | &date_time_value_string, |
579 | 0 | &date_time_value_string_size, |
580 | 0 | error ) != 1 ) |
581 | 0 | { |
582 | 0 | libcerror_error_set( |
583 | 0 | error, |
584 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
585 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
586 | 0 | "%s: unable to retrieve date time value string: 4.", |
587 | 0 | function ); |
588 | |
|
589 | 0 | goto on_error; |
590 | 0 | } |
591 | 0 | if( date_time_value_string_size != 3 ) |
592 | 0 | { |
593 | 0 | libcerror_error_set( |
594 | 0 | error, |
595 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
596 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
597 | 0 | "%s: unsupported date time value string: 4 size.", |
598 | 0 | function ); |
599 | |
|
600 | 0 | goto on_error; |
601 | 0 | } |
602 | 0 | if( libewf_utf8_string_minutes_copy_to_time_elements( |
603 | 0 | date_time_value_string, |
604 | 0 | date_time_value_string_size, |
605 | 0 | &time_elements, |
606 | 0 | error ) != 1 ) |
607 | 0 | { |
608 | 0 | libcerror_error_set( |
609 | 0 | error, |
610 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
611 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
612 | 0 | "%s: unable to copy minutes value.", |
613 | 0 | function ); |
614 | |
|
615 | 0 | goto on_error; |
616 | 0 | } |
617 | | /* Set the seconds |
618 | | */ |
619 | 0 | if( libfvalue_split_utf8_string_get_segment_by_index( |
620 | 0 | date_time_values, |
621 | 0 | 5, |
622 | 0 | &date_time_value_string, |
623 | 0 | &date_time_value_string_size, |
624 | 0 | error ) != 1 ) |
625 | 0 | { |
626 | 0 | libcerror_error_set( |
627 | 0 | error, |
628 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
629 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
630 | 0 | "%s: unable to retrieve date time value string: 5.", |
631 | 0 | function ); |
632 | |
|
633 | 0 | goto on_error; |
634 | 0 | } |
635 | 0 | if( date_time_value_string_size != 3 ) |
636 | 0 | { |
637 | 0 | libcerror_error_set( |
638 | 0 | error, |
639 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
640 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
641 | 0 | "%s: unsupported date time value string: 5 size.", |
642 | 0 | function ); |
643 | |
|
644 | 0 | goto on_error; |
645 | 0 | } |
646 | 0 | if( libewf_utf8_string_seconds_copy_to_time_elements( |
647 | 0 | date_time_value_string, |
648 | 0 | date_time_value_string_size, |
649 | 0 | &time_elements, |
650 | 0 | error ) != 1 ) |
651 | 0 | { |
652 | 0 | libcerror_error_set( |
653 | 0 | error, |
654 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
655 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
656 | 0 | "%s: unable to copy seconds value.", |
657 | 0 | function ); |
658 | |
|
659 | 0 | goto on_error; |
660 | 0 | } |
661 | | /* Set to ignore the daylight saving time |
662 | | */ |
663 | 0 | time_elements.tm_isdst = -1; |
664 | |
|
665 | 0 | if( libfvalue_split_utf8_string_free( |
666 | 0 | &date_time_values, |
667 | 0 | error ) != 1 ) |
668 | 0 | { |
669 | 0 | libcerror_error_set( |
670 | 0 | error, |
671 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
672 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
673 | 0 | "%s: unable to free split date time elements.", |
674 | 0 | function ); |
675 | |
|
676 | 0 | goto on_error; |
677 | 0 | } |
678 | | /* Create a timestamp |
679 | | */ |
680 | 0 | *timestamp = libewf_date_time_mktime( |
681 | 0 | &time_elements ); |
682 | |
|
683 | 0 | if( *timestamp == (time_t) -1 ) |
684 | 0 | { |
685 | 0 | libcerror_error_set( |
686 | 0 | error, |
687 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
688 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
689 | 0 | "%s: unable to create timestamp.", |
690 | 0 | function ); |
691 | |
|
692 | 0 | goto on_error; |
693 | 0 | } |
694 | 0 | return( 1 ); |
695 | | |
696 | 0 | on_error: |
697 | 0 | if( date_time_values != NULL ) |
698 | 0 | { |
699 | 0 | libfvalue_split_utf8_string_free( |
700 | 0 | &date_time_values, |
701 | 0 | NULL ); |
702 | 0 | } |
703 | 0 | return( -1 ); |
704 | 0 | } |
705 | | |
706 | | /* Copies an UTF-8 encoded string of a day of week from time elements |
707 | | * Returns 1 if successful or -1 on error |
708 | | */ |
709 | | int libewf_utf8_string_day_of_week_copy_from_time_elements( |
710 | | uint8_t *utf8_string, |
711 | | size_t utf8_string_size, |
712 | | size_t *utf8_string_index, |
713 | | struct tm *time_elements, |
714 | | libcerror_error_t **error ) |
715 | 0 | { |
716 | 0 | const char *day_of_week = NULL; |
717 | 0 | static char *function = "libewf_utf8_string_day_of_week_copy_from_time_elements"; |
718 | 0 | size_t string_index = 0; |
719 | |
|
720 | 0 | if( utf8_string == NULL ) |
721 | 0 | { |
722 | 0 | libcerror_error_set( |
723 | 0 | error, |
724 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
725 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
726 | 0 | "%s: invalid UTF-8 string.", |
727 | 0 | function ); |
728 | |
|
729 | 0 | return( -1 ); |
730 | 0 | } |
731 | 0 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
732 | 0 | { |
733 | 0 | libcerror_error_set( |
734 | 0 | error, |
735 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
736 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
737 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
738 | 0 | function ); |
739 | |
|
740 | 0 | return( -1 ); |
741 | 0 | } |
742 | 0 | if( utf8_string_index == NULL ) |
743 | 0 | { |
744 | 0 | libcerror_error_set( |
745 | 0 | error, |
746 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
747 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
748 | 0 | "%s: invalid UTF-8 string index.", |
749 | 0 | function ); |
750 | |
|
751 | 0 | return( -1 ); |
752 | 0 | } |
753 | 0 | if( *utf8_string_index >= utf8_string_size ) |
754 | 0 | { |
755 | 0 | libcerror_error_set( |
756 | 0 | error, |
757 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
758 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
759 | 0 | "%s: invalid UTF-8 string index value out of bounds.", |
760 | 0 | function ); |
761 | |
|
762 | 0 | return( -1 ); |
763 | 0 | } |
764 | 0 | if( ( *utf8_string_index + 3 ) >= utf8_string_size ) |
765 | 0 | { |
766 | 0 | libcerror_error_set( |
767 | 0 | error, |
768 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
769 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
770 | 0 | "%s: UTF-8 string too small.", |
771 | 0 | function ); |
772 | |
|
773 | 0 | return( -1 ); |
774 | 0 | } |
775 | 0 | if( time_elements == NULL ) |
776 | 0 | { |
777 | 0 | libcerror_error_set( |
778 | 0 | error, |
779 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
780 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
781 | 0 | "%s: invalid time elements.", |
782 | 0 | function ); |
783 | |
|
784 | 0 | return( -1 ); |
785 | 0 | } |
786 | 0 | if( ( time_elements->tm_wday < 0 ) |
787 | 0 | || ( time_elements->tm_wday > 6 ) ) |
788 | 0 | { |
789 | 0 | libcerror_error_set( |
790 | 0 | error, |
791 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
792 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
793 | 0 | "%s: unsupported day of week.", |
794 | 0 | function ); |
795 | |
|
796 | 0 | return( -1 ); |
797 | 0 | } |
798 | 0 | string_index = *utf8_string_index; |
799 | | |
800 | 0 | switch( time_elements->tm_wday ) |
801 | 0 | { |
802 | 0 | case 0: |
803 | 0 | day_of_week = "Sun"; |
804 | 0 | break; |
805 | 0 | case 1: |
806 | 0 | day_of_week = "Mon"; |
807 | 0 | break; |
808 | 0 | case 2: |
809 | 0 | day_of_week = "Tue"; |
810 | 0 | break; |
811 | 0 | case 3: |
812 | 0 | day_of_week = "Wed"; |
813 | 0 | break; |
814 | 0 | case 4: |
815 | 0 | day_of_week = "Thu"; |
816 | 0 | break; |
817 | 0 | case 5: |
818 | 0 | day_of_week = "Fri"; |
819 | 0 | break; |
820 | 0 | case 6: |
821 | 0 | day_of_week = "Sat"; |
822 | 0 | break; |
823 | 0 | } |
824 | 0 | utf8_string[ string_index++ ] = (uint8_t) day_of_week[ 0 ]; |
825 | 0 | utf8_string[ string_index++ ] = (uint8_t) day_of_week[ 1 ]; |
826 | 0 | utf8_string[ string_index++ ] = (uint8_t) day_of_week[ 2 ]; |
827 | |
|
828 | 0 | *utf8_string_index = string_index; |
829 | |
|
830 | 0 | return( 1 ); |
831 | 0 | } |
832 | | |
833 | | /* Copies an UTF-8 encoded string of a day of week to time elements |
834 | | * Returns 1 if successful or -1 on error |
835 | | */ |
836 | | int libewf_utf8_string_day_of_week_copy_to_time_elements( |
837 | | uint8_t *utf8_string, |
838 | | size_t utf8_string_size, |
839 | | struct tm *time_elements, |
840 | | libcerror_error_t **error ) |
841 | 0 | { |
842 | 0 | static char *function = "libewf_utf8_string_day_of_week_copy_to_time_elements"; |
843 | |
|
844 | 0 | if( utf8_string == NULL ) |
845 | 0 | { |
846 | 0 | libcerror_error_set( |
847 | 0 | error, |
848 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
849 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
850 | 0 | "%s: invalid UTF-8 string.", |
851 | 0 | function ); |
852 | |
|
853 | 0 | return( -1 ); |
854 | 0 | } |
855 | 0 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
856 | 0 | { |
857 | 0 | libcerror_error_set( |
858 | 0 | error, |
859 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
860 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
861 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
862 | 0 | function ); |
863 | |
|
864 | 0 | return( -1 ); |
865 | 0 | } |
866 | 0 | if( time_elements == NULL ) |
867 | 0 | { |
868 | 0 | libcerror_error_set( |
869 | 0 | error, |
870 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
871 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
872 | 0 | "%s: invalid time elements.", |
873 | 0 | function ); |
874 | |
|
875 | 0 | return( -1 ); |
876 | 0 | } |
877 | 0 | if( utf8_string_size < 4 ) |
878 | 0 | { |
879 | 0 | libcerror_error_set( |
880 | 0 | error, |
881 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
882 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
883 | 0 | "%s: UTF-8 string too small.", |
884 | 0 | function ); |
885 | |
|
886 | 0 | return( -1 ); |
887 | 0 | } |
888 | 0 | if( narrow_string_compare( |
889 | 0 | utf8_string, |
890 | 0 | "Sun", |
891 | 0 | 3 ) == 0 ) |
892 | 0 | { |
893 | 0 | time_elements->tm_wday = 0; |
894 | 0 | } |
895 | 0 | else if( narrow_string_compare( |
896 | 0 | utf8_string, |
897 | 0 | "Mon", |
898 | 0 | 3 ) == 0 ) |
899 | 0 | { |
900 | 0 | time_elements->tm_wday = 1; |
901 | 0 | } |
902 | 0 | else if( narrow_string_compare( |
903 | 0 | utf8_string, |
904 | 0 | "Tue", |
905 | 0 | 3 ) == 0 ) |
906 | 0 | { |
907 | 0 | time_elements->tm_wday = 2; |
908 | 0 | } |
909 | 0 | else if( narrow_string_compare( |
910 | 0 | utf8_string, |
911 | 0 | "Wed", |
912 | 0 | 3 ) == 0 ) |
913 | 0 | { |
914 | 0 | time_elements->tm_wday = 3; |
915 | 0 | } |
916 | 0 | else if( narrow_string_compare( |
917 | 0 | utf8_string, |
918 | 0 | "Thu", |
919 | 0 | 3 ) == 0 ) |
920 | 0 | { |
921 | 0 | time_elements->tm_wday = 4; |
922 | 0 | } |
923 | 0 | else if( narrow_string_compare( |
924 | 0 | utf8_string, |
925 | 0 | "Fri", |
926 | 0 | 3 ) == 0 ) |
927 | 0 | { |
928 | 0 | time_elements->tm_wday = 5; |
929 | 0 | } |
930 | 0 | else if( narrow_string_compare( |
931 | 0 | utf8_string, |
932 | 0 | "Sat", |
933 | 0 | 3 ) == 0 ) |
934 | 0 | { |
935 | 0 | time_elements->tm_wday = 6; |
936 | 0 | } |
937 | 0 | else |
938 | 0 | { |
939 | 0 | libcerror_error_set( |
940 | 0 | error, |
941 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
942 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
943 | 0 | "%s: unsupported day of week value.", |
944 | 0 | function ); |
945 | |
|
946 | 0 | return( -1 ); |
947 | 0 | } |
948 | 0 | return( 1 ); |
949 | 0 | } |
950 | | |
951 | | /* Copies an UTF-8 encoded string of a day of the month to time elements |
952 | | * Returns 1 if successful or -1 on error |
953 | | */ |
954 | | int libewf_utf8_string_day_of_month_copy_to_time_elements( |
955 | | uint8_t *utf8_string, |
956 | | size_t utf8_string_size, |
957 | | struct tm *time_elements, |
958 | | libcerror_error_t **error ) |
959 | 480 | { |
960 | 480 | static char *function = "libewf_utf8_string_day_of_month_copy_to_time_elements"; |
961 | 480 | uint64_t value_64bit = 0; |
962 | | |
963 | 480 | if( utf8_string == NULL ) |
964 | 0 | { |
965 | 0 | libcerror_error_set( |
966 | 0 | error, |
967 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
968 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
969 | 0 | "%s: invalid UTF-8 string.", |
970 | 0 | function ); |
971 | |
|
972 | 0 | return( -1 ); |
973 | 0 | } |
974 | 480 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
975 | 0 | { |
976 | 0 | libcerror_error_set( |
977 | 0 | error, |
978 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
979 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
980 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
981 | 0 | function ); |
982 | |
|
983 | 0 | return( -1 ); |
984 | 0 | } |
985 | 480 | if( time_elements == NULL ) |
986 | 0 | { |
987 | 0 | libcerror_error_set( |
988 | 0 | error, |
989 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
990 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
991 | 0 | "%s: invalid time elements.", |
992 | 0 | function ); |
993 | |
|
994 | 0 | return( -1 ); |
995 | 0 | } |
996 | 480 | if( utf8_string_size < 2 ) |
997 | 0 | { |
998 | 0 | libcerror_error_set( |
999 | 0 | error, |
1000 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1001 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1002 | 0 | "%s: UTF-8 string too small.", |
1003 | 0 | function ); |
1004 | |
|
1005 | 0 | return( -1 ); |
1006 | 0 | } |
1007 | 480 | if( libfvalue_utf8_string_copy_to_integer( |
1008 | 480 | utf8_string, |
1009 | 480 | utf8_string_size, |
1010 | 480 | &value_64bit, |
1011 | 480 | 8, |
1012 | 480 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1013 | 480 | error ) != 1 ) |
1014 | 10 | { |
1015 | 10 | libcerror_error_set( |
1016 | 10 | error, |
1017 | 10 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1018 | 10 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1019 | 10 | "%s: unable to UTF-8 string to 8-bit value.", |
1020 | 10 | function ); |
1021 | | |
1022 | 10 | return( -1 ); |
1023 | 10 | } |
1024 | 470 | if( ( value_64bit < 1 ) |
1025 | 464 | || ( value_64bit >= 32 ) ) |
1026 | 16 | { |
1027 | 16 | libcerror_error_set( |
1028 | 16 | error, |
1029 | 16 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1030 | 16 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1031 | 16 | "%s: unsupported day of the month value.", |
1032 | 16 | function ); |
1033 | | |
1034 | 16 | return( -1 ); |
1035 | 16 | } |
1036 | 454 | time_elements->tm_mday = (int) value_64bit; |
1037 | | |
1038 | 454 | return( 1 ); |
1039 | 470 | } |
1040 | | |
1041 | | /* Copies an UTF-8 encoded string of a month from time elements |
1042 | | * Returns 1 if successful or -1 on error |
1043 | | */ |
1044 | | int libewf_utf8_string_month_copy_from_time_elements( |
1045 | | uint8_t *utf8_string, |
1046 | | size_t utf8_string_size, |
1047 | | size_t *utf8_string_index, |
1048 | | struct tm *time_elements, |
1049 | | libcerror_error_t **error ) |
1050 | 0 | { |
1051 | 0 | const char *month = NULL; |
1052 | 0 | static char *function = "libewf_utf8_string_month_copy_from_time_elements"; |
1053 | 0 | size_t string_index = 0; |
1054 | |
|
1055 | 0 | if( utf8_string == NULL ) |
1056 | 0 | { |
1057 | 0 | libcerror_error_set( |
1058 | 0 | error, |
1059 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1060 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1061 | 0 | "%s: invalid UTF-8 string.", |
1062 | 0 | function ); |
1063 | |
|
1064 | 0 | return( -1 ); |
1065 | 0 | } |
1066 | 0 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1067 | 0 | { |
1068 | 0 | libcerror_error_set( |
1069 | 0 | error, |
1070 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1071 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1072 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1073 | 0 | function ); |
1074 | |
|
1075 | 0 | return( -1 ); |
1076 | 0 | } |
1077 | 0 | if( utf8_string_index == NULL ) |
1078 | 0 | { |
1079 | 0 | libcerror_error_set( |
1080 | 0 | error, |
1081 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1082 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1083 | 0 | "%s: invalid UTF-8 string index.", |
1084 | 0 | function ); |
1085 | |
|
1086 | 0 | return( -1 ); |
1087 | 0 | } |
1088 | 0 | if( *utf8_string_index >= utf8_string_size ) |
1089 | 0 | { |
1090 | 0 | libcerror_error_set( |
1091 | 0 | error, |
1092 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1093 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1094 | 0 | "%s: invalid UTF-8 string index value out of bounds.", |
1095 | 0 | function ); |
1096 | |
|
1097 | 0 | return( -1 ); |
1098 | 0 | } |
1099 | 0 | if( ( *utf8_string_index + 3 ) >= utf8_string_size ) |
1100 | 0 | { |
1101 | 0 | libcerror_error_set( |
1102 | 0 | error, |
1103 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1104 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1105 | 0 | "%s: UTF-8 string too small.", |
1106 | 0 | function ); |
1107 | |
|
1108 | 0 | return( -1 ); |
1109 | 0 | } |
1110 | 0 | if( time_elements == NULL ) |
1111 | 0 | { |
1112 | 0 | libcerror_error_set( |
1113 | 0 | error, |
1114 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1115 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1116 | 0 | "%s: invalid time elements.", |
1117 | 0 | function ); |
1118 | |
|
1119 | 0 | return( -1 ); |
1120 | 0 | } |
1121 | 0 | if( ( time_elements->tm_mon < 0 ) |
1122 | 0 | || ( time_elements->tm_mon >= 12 ) ) |
1123 | 0 | { |
1124 | 0 | libcerror_error_set( |
1125 | 0 | error, |
1126 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1127 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
1128 | 0 | "%s: unsupported month.", |
1129 | 0 | function ); |
1130 | |
|
1131 | 0 | return( -1 ); |
1132 | 0 | } |
1133 | 0 | string_index = *utf8_string_index; |
1134 | |
|
1135 | 0 | switch( time_elements->tm_mon ) |
1136 | 0 | { |
1137 | 0 | case 0: |
1138 | 0 | month = "Jan"; |
1139 | 0 | break; |
1140 | 0 | case 1: |
1141 | 0 | month = "Feb"; |
1142 | 0 | break; |
1143 | 0 | case 2: |
1144 | 0 | month = "Mar"; |
1145 | 0 | break; |
1146 | 0 | case 3: |
1147 | 0 | month = "Apr"; |
1148 | 0 | break; |
1149 | 0 | case 4: |
1150 | 0 | month = "May"; |
1151 | 0 | break; |
1152 | 0 | case 5: |
1153 | 0 | month = "Jun"; |
1154 | 0 | break; |
1155 | 0 | case 6: |
1156 | 0 | month = "Jul"; |
1157 | 0 | break; |
1158 | 0 | case 7: |
1159 | 0 | month = "Aug"; |
1160 | 0 | break; |
1161 | 0 | case 8: |
1162 | 0 | month = "Sep"; |
1163 | 0 | break; |
1164 | 0 | case 9: |
1165 | 0 | month = "Oct"; |
1166 | 0 | break; |
1167 | 0 | case 10: |
1168 | 0 | month = "Nov"; |
1169 | 0 | break; |
1170 | 0 | case 11: |
1171 | 0 | month = "Dec"; |
1172 | 0 | break; |
1173 | 0 | } |
1174 | 0 | utf8_string[ string_index++ ] = (uint8_t) month[ 0 ]; |
1175 | 0 | utf8_string[ string_index++ ] = (uint8_t) month[ 1 ]; |
1176 | 0 | utf8_string[ string_index++ ] = (uint8_t) month[ 2 ]; |
1177 | |
|
1178 | 0 | *utf8_string_index = string_index; |
1179 | |
|
1180 | 0 | return( 1 ); |
1181 | 0 | } |
1182 | | |
1183 | | /* Copies an UTF-8 encoded string of a month to time elements |
1184 | | * Returns 1 if successful or -1 on error |
1185 | | */ |
1186 | | int libewf_utf8_string_month_copy_to_time_elements( |
1187 | | uint8_t *utf8_string, |
1188 | | size_t utf8_string_size, |
1189 | | struct tm *time_elements, |
1190 | | libcerror_error_t **error ) |
1191 | 540 | { |
1192 | 540 | static char *function = "libewf_utf8_string_month_copy_to_time_elements"; |
1193 | 540 | uint64_t value_64bit = 0; |
1194 | | |
1195 | 540 | if( utf8_string == NULL ) |
1196 | 0 | { |
1197 | 0 | libcerror_error_set( |
1198 | 0 | error, |
1199 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1200 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1201 | 0 | "%s: invalid UTF-8 string.", |
1202 | 0 | function ); |
1203 | |
|
1204 | 0 | return( -1 ); |
1205 | 0 | } |
1206 | 540 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1207 | 0 | { |
1208 | 0 | libcerror_error_set( |
1209 | 0 | error, |
1210 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1211 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1212 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1213 | 0 | function ); |
1214 | |
|
1215 | 0 | return( -1 ); |
1216 | 0 | } |
1217 | 540 | if( time_elements == NULL ) |
1218 | 0 | { |
1219 | 0 | libcerror_error_set( |
1220 | 0 | error, |
1221 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1222 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1223 | 0 | "%s: invalid time elements.", |
1224 | 0 | function ); |
1225 | |
|
1226 | 0 | return( -1 ); |
1227 | 0 | } |
1228 | 540 | if( utf8_string_size < 2 ) |
1229 | 0 | { |
1230 | 0 | libcerror_error_set( |
1231 | 0 | error, |
1232 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1233 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1234 | 0 | "%s: UTF-8 string too small.", |
1235 | 0 | function ); |
1236 | |
|
1237 | 0 | return( -1 ); |
1238 | 0 | } |
1239 | 540 | if( ( utf8_string[ 0 ] >= (uint8_t) '0' ) |
1240 | 530 | && ( utf8_string[ 0 ] <= (uint8_t) '9' ) ) |
1241 | 520 | { |
1242 | 520 | if( libfvalue_utf8_string_copy_to_integer( |
1243 | 520 | utf8_string, |
1244 | 520 | utf8_string_size, |
1245 | 520 | &value_64bit, |
1246 | 520 | 16, |
1247 | 520 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1248 | 520 | error ) != 1 ) |
1249 | 10 | { |
1250 | 10 | libcerror_error_set( |
1251 | 10 | error, |
1252 | 10 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1253 | 10 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1254 | 10 | "%s: unable to UTF-8 string to 16-bit value.", |
1255 | 10 | function ); |
1256 | | |
1257 | 10 | return( -1 ); |
1258 | 10 | } |
1259 | 510 | if( ( value_64bit < 1 ) |
1260 | 500 | || ( value_64bit >= 13 ) ) |
1261 | 20 | { |
1262 | 20 | libcerror_error_set( |
1263 | 20 | error, |
1264 | 20 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1265 | 20 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1266 | 20 | "%s: unsupported month value.", |
1267 | 20 | function ); |
1268 | | |
1269 | 20 | return( -1 ); |
1270 | 20 | } |
1271 | 490 | time_elements->tm_mon = (int) ( value_64bit - 1 ); |
1272 | 490 | } |
1273 | 20 | else |
1274 | 20 | { |
1275 | 20 | if( utf8_string_size < 4 ) |
1276 | 20 | { |
1277 | 20 | libcerror_error_set( |
1278 | 20 | error, |
1279 | 20 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1280 | 20 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1281 | 20 | "%s: UTF-8 string too small.", |
1282 | 20 | function ); |
1283 | | |
1284 | 20 | return( -1 ); |
1285 | 20 | } |
1286 | 0 | if( narrow_string_compare( |
1287 | 0 | utf8_string, |
1288 | 0 | "Jan", |
1289 | 0 | 3 ) == 0 ) |
1290 | 0 | { |
1291 | 0 | time_elements->tm_mon = 0; |
1292 | 0 | } |
1293 | 0 | else if( narrow_string_compare( |
1294 | 0 | utf8_string, |
1295 | 0 | "Feb", |
1296 | 0 | 3 ) == 0 ) |
1297 | 0 | { |
1298 | 0 | time_elements->tm_mon = 1; |
1299 | 0 | } |
1300 | 0 | else if( narrow_string_compare( |
1301 | 0 | utf8_string, |
1302 | 0 | "Mar", |
1303 | 0 | 3 ) == 0 ) |
1304 | 0 | { |
1305 | 0 | time_elements->tm_mon = 2; |
1306 | 0 | } |
1307 | 0 | else if( narrow_string_compare( |
1308 | 0 | utf8_string, |
1309 | 0 | "Apr", |
1310 | 0 | 3 ) == 0 ) |
1311 | 0 | { |
1312 | 0 | time_elements->tm_mon = 3; |
1313 | 0 | } |
1314 | 0 | else if( narrow_string_compare( |
1315 | 0 | utf8_string, |
1316 | 0 | "May", |
1317 | 0 | 3 ) == 0 ) |
1318 | 0 | { |
1319 | 0 | time_elements->tm_mon = 4; |
1320 | 0 | } |
1321 | 0 | else if( narrow_string_compare( |
1322 | 0 | utf8_string, |
1323 | 0 | "Jun", |
1324 | 0 | 3 ) == 0 ) |
1325 | 0 | { |
1326 | 0 | time_elements->tm_mon = 5; |
1327 | 0 | } |
1328 | 0 | else if( narrow_string_compare( |
1329 | 0 | utf8_string, |
1330 | 0 | "Jul", |
1331 | 0 | 3 ) == 0 ) |
1332 | 0 | { |
1333 | 0 | time_elements->tm_mon = 6; |
1334 | 0 | } |
1335 | 0 | else if( narrow_string_compare( |
1336 | 0 | utf8_string, |
1337 | 0 | "Aug", |
1338 | 0 | 3 ) == 0 ) |
1339 | 0 | { |
1340 | 0 | time_elements->tm_mon = 7; |
1341 | 0 | } |
1342 | 0 | else if( narrow_string_compare( |
1343 | 0 | utf8_string, |
1344 | 0 | "Sep", |
1345 | 0 | 3 ) == 0 ) |
1346 | 0 | { |
1347 | 0 | time_elements->tm_mon = 8; |
1348 | 0 | } |
1349 | 0 | else if( narrow_string_compare( |
1350 | 0 | utf8_string, |
1351 | 0 | "Oct", |
1352 | 0 | 3 ) == 0 ) |
1353 | 0 | { |
1354 | 0 | time_elements->tm_mon = 9; |
1355 | 0 | } |
1356 | 0 | else if( narrow_string_compare( |
1357 | 0 | utf8_string, |
1358 | 0 | "Nov", |
1359 | 0 | 3 ) == 0 ) |
1360 | 0 | { |
1361 | 0 | time_elements->tm_mon = 10; |
1362 | 0 | } |
1363 | 0 | else if( narrow_string_compare( |
1364 | 0 | utf8_string, |
1365 | 0 | "Dec", |
1366 | 0 | 3 ) == 0 ) |
1367 | 0 | { |
1368 | 0 | time_elements->tm_mon = 11; |
1369 | 0 | } |
1370 | 0 | else |
1371 | 0 | { |
1372 | 0 | libcerror_error_set( |
1373 | 0 | error, |
1374 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1375 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1376 | 0 | "%s: unsupported month value.", |
1377 | 0 | function ); |
1378 | |
|
1379 | 0 | return( -1 ); |
1380 | 0 | } |
1381 | 0 | } |
1382 | 490 | return( 1 ); |
1383 | 540 | } |
1384 | | |
1385 | | /* Copies an UTF-8 encoded string of a year to time elements |
1386 | | * Returns 1 if successful or -1 on error |
1387 | | */ |
1388 | | int libewf_utf8_string_year_copy_to_time_elements( |
1389 | | uint8_t *utf8_string, |
1390 | | size_t utf8_string_size, |
1391 | | struct tm *time_elements, |
1392 | | libcerror_error_t **error ) |
1393 | 648 | { |
1394 | 648 | static char *function = "libewf_utf8_string_year_copy_to_time_elements"; |
1395 | 648 | uint64_t value_64bit = 0; |
1396 | | |
1397 | 648 | if( utf8_string == NULL ) |
1398 | 0 | { |
1399 | 0 | libcerror_error_set( |
1400 | 0 | error, |
1401 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1402 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1403 | 0 | "%s: invalid UTF-8 string.", |
1404 | 0 | function ); |
1405 | |
|
1406 | 0 | return( -1 ); |
1407 | 0 | } |
1408 | 648 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1409 | 0 | { |
1410 | 0 | libcerror_error_set( |
1411 | 0 | error, |
1412 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1413 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1414 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1415 | 0 | function ); |
1416 | |
|
1417 | 0 | return( -1 ); |
1418 | 0 | } |
1419 | 648 | if( time_elements == NULL ) |
1420 | 0 | { |
1421 | 0 | libcerror_error_set( |
1422 | 0 | error, |
1423 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1424 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1425 | 0 | "%s: invalid time elements.", |
1426 | 0 | function ); |
1427 | |
|
1428 | 0 | return( -1 ); |
1429 | 0 | } |
1430 | 648 | if( utf8_string_size < 5 ) |
1431 | 23 | { |
1432 | 23 | libcerror_error_set( |
1433 | 23 | error, |
1434 | 23 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1435 | 23 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1436 | 23 | "%s: UTF-8 string too small.", |
1437 | 23 | function ); |
1438 | | |
1439 | 23 | return( -1 ); |
1440 | 23 | } |
1441 | 625 | if( libfvalue_utf8_string_copy_to_integer( |
1442 | 625 | utf8_string, |
1443 | 625 | utf8_string_size, |
1444 | 625 | &value_64bit, |
1445 | 625 | 32, |
1446 | 625 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1447 | 625 | error ) != 1 ) |
1448 | 29 | { |
1449 | 29 | libcerror_error_set( |
1450 | 29 | error, |
1451 | 29 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1452 | 29 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1453 | 29 | "%s: unable to copy UTF-8 string to 32-bit value.", |
1454 | 29 | function ); |
1455 | | |
1456 | 29 | return( -1 ); |
1457 | 29 | } |
1458 | 596 | if( ( value_64bit < 1900 ) |
1459 | 583 | || ( value_64bit >= 11900 ) ) |
1460 | 44 | { |
1461 | 44 | libcerror_error_set( |
1462 | 44 | error, |
1463 | 44 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1464 | 44 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1465 | 44 | "%s: unsupported year value.", |
1466 | 44 | function ); |
1467 | | |
1468 | 44 | return( -1 ); |
1469 | 44 | } |
1470 | 552 | time_elements->tm_year = (int)( value_64bit - 1900 ); |
1471 | | |
1472 | 552 | return( 1 ); |
1473 | 596 | } |
1474 | | |
1475 | | /* Copies an UTF-8 encoded string of a time value in the format (HH:MM:SS) from time elements |
1476 | | * Returns 1 if successful or -1 on error |
1477 | | */ |
1478 | | int libewf_utf8_string_time_copy_from_time_elements( |
1479 | | uint8_t *utf8_string, |
1480 | | size_t utf8_string_size, |
1481 | | size_t *utf8_string_index, |
1482 | | struct tm *time_elements, |
1483 | | libcerror_error_t **error ) |
1484 | 0 | { |
1485 | 0 | static char *function = "libewf_utf8_string_time_copy_from_time_elements"; |
1486 | 0 | size_t string_index = 0; |
1487 | |
|
1488 | 0 | if( utf8_string == NULL ) |
1489 | 0 | { |
1490 | 0 | libcerror_error_set( |
1491 | 0 | error, |
1492 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1493 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1494 | 0 | "%s: invalid UTF-8 string.", |
1495 | 0 | function ); |
1496 | |
|
1497 | 0 | return( -1 ); |
1498 | 0 | } |
1499 | 0 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1500 | 0 | { |
1501 | 0 | libcerror_error_set( |
1502 | 0 | error, |
1503 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1504 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1505 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1506 | 0 | function ); |
1507 | |
|
1508 | 0 | return( -1 ); |
1509 | 0 | } |
1510 | 0 | if( utf8_string_index == NULL ) |
1511 | 0 | { |
1512 | 0 | libcerror_error_set( |
1513 | 0 | error, |
1514 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1515 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1516 | 0 | "%s: invalid UTF-8 string index.", |
1517 | 0 | function ); |
1518 | |
|
1519 | 0 | return( -1 ); |
1520 | 0 | } |
1521 | 0 | if( *utf8_string_index >= utf8_string_size ) |
1522 | 0 | { |
1523 | 0 | libcerror_error_set( |
1524 | 0 | error, |
1525 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1526 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1527 | 0 | "%s: invalid UTF-8 string index value out of bounds.", |
1528 | 0 | function ); |
1529 | |
|
1530 | 0 | return( -1 ); |
1531 | 0 | } |
1532 | 0 | if( ( *utf8_string_index + 8 ) >= utf8_string_size ) |
1533 | 0 | { |
1534 | 0 | libcerror_error_set( |
1535 | 0 | error, |
1536 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1537 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1538 | 0 | "%s: UTF-8 string too small.", |
1539 | 0 | function ); |
1540 | |
|
1541 | 0 | return( -1 ); |
1542 | 0 | } |
1543 | 0 | if( time_elements == NULL ) |
1544 | 0 | { |
1545 | 0 | libcerror_error_set( |
1546 | 0 | error, |
1547 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1548 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1549 | 0 | "%s: invalid time elements.", |
1550 | 0 | function ); |
1551 | |
|
1552 | 0 | return( -1 ); |
1553 | 0 | } |
1554 | 0 | if( ( time_elements->tm_hour < 0 ) |
1555 | 0 | || ( time_elements->tm_hour > 23 ) ) |
1556 | 0 | { |
1557 | 0 | libcerror_error_set( |
1558 | 0 | error, |
1559 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1560 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
1561 | 0 | "%s: unsupported hours.", |
1562 | 0 | function ); |
1563 | |
|
1564 | 0 | return( -1 ); |
1565 | 0 | } |
1566 | 0 | if( ( time_elements->tm_min < 0 ) |
1567 | 0 | || ( time_elements->tm_min > 59 ) ) |
1568 | 0 | { |
1569 | 0 | libcerror_error_set( |
1570 | 0 | error, |
1571 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1572 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
1573 | 0 | "%s: unsupported minutes.", |
1574 | 0 | function ); |
1575 | |
|
1576 | 0 | return( -1 ); |
1577 | 0 | } |
1578 | | /* Note a value of 60 is used for a leap-second |
1579 | | */ |
1580 | 0 | if( ( time_elements->tm_sec < 0 ) |
1581 | 0 | || ( time_elements->tm_sec > 60 ) ) |
1582 | 0 | { |
1583 | 0 | libcerror_error_set( |
1584 | 0 | error, |
1585 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1586 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
1587 | 0 | "%s: unsupported seconds.", |
1588 | 0 | function ); |
1589 | |
|
1590 | 0 | return( -1 ); |
1591 | 0 | } |
1592 | 0 | string_index = *utf8_string_index; |
1593 | |
|
1594 | 0 | if( time_elements->tm_hour < 10 ) |
1595 | 0 | { |
1596 | 0 | utf8_string[ string_index++ ] = (uint8_t) '0'; |
1597 | 0 | } |
1598 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
1599 | 0 | utf8_string, |
1600 | 0 | utf8_string_size, |
1601 | 0 | &string_index, |
1602 | 0 | (uint64_t) time_elements->tm_hour, |
1603 | 0 | 8, |
1604 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1605 | 0 | error ) != 1 ) |
1606 | 0 | { |
1607 | 0 | libcerror_error_set( |
1608 | 0 | error, |
1609 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1610 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
1611 | 0 | "%s: unable to copy hours to UTF-8 string.", |
1612 | 0 | function ); |
1613 | |
|
1614 | 0 | return( -1 ); |
1615 | 0 | } |
1616 | 0 | utf8_string[ string_index - 1 ] = (uint8_t) ':'; |
1617 | |
|
1618 | 0 | if( time_elements->tm_min < 10 ) |
1619 | 0 | { |
1620 | 0 | utf8_string[ string_index++ ] = (uint8_t) '0'; |
1621 | 0 | } |
1622 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
1623 | 0 | utf8_string, |
1624 | 0 | utf8_string_size, |
1625 | 0 | &string_index, |
1626 | 0 | (uint64_t) time_elements->tm_min, |
1627 | 0 | 8, |
1628 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1629 | 0 | error ) != 1 ) |
1630 | 0 | { |
1631 | 0 | libcerror_error_set( |
1632 | 0 | error, |
1633 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1634 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
1635 | 0 | "%s: unable to copy minutes to UTF-8 string.", |
1636 | 0 | function ); |
1637 | |
|
1638 | 0 | return( -1 ); |
1639 | 0 | } |
1640 | 0 | utf8_string[ string_index - 1 ] = (uint8_t) ':'; |
1641 | |
|
1642 | 0 | if( time_elements->tm_sec < 10 ) |
1643 | 0 | { |
1644 | 0 | utf8_string[ string_index++ ] = (uint8_t) '0'; |
1645 | 0 | } |
1646 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
1647 | 0 | utf8_string, |
1648 | 0 | utf8_string_size, |
1649 | 0 | &string_index, |
1650 | 0 | (uint64_t) time_elements->tm_sec, |
1651 | 0 | 8, |
1652 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1653 | 0 | error ) != 1 ) |
1654 | 0 | { |
1655 | 0 | libcerror_error_set( |
1656 | 0 | error, |
1657 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1658 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
1659 | 0 | "%s: unable to copy seconds to UTF-8 string.", |
1660 | 0 | function ); |
1661 | |
|
1662 | 0 | return( -1 ); |
1663 | 0 | } |
1664 | 0 | *utf8_string_index = string_index - 1; |
1665 | |
|
1666 | 0 | return( 1 ); |
1667 | 0 | } |
1668 | | |
1669 | | /* Copies an UTF-8 encoded string of hours to time elements |
1670 | | * Returns 1 if successful or -1 on error |
1671 | | */ |
1672 | | int libewf_utf8_string_hours_copy_to_time_elements( |
1673 | | uint8_t *utf8_string, |
1674 | | size_t utf8_string_size, |
1675 | | struct tm *time_elements, |
1676 | | libcerror_error_t **error ) |
1677 | 443 | { |
1678 | 443 | static char *function = "libewf_utf8_string_hours_copy_to_time_elements"; |
1679 | 443 | uint64_t value_64bit = 0; |
1680 | | |
1681 | 443 | if( utf8_string == NULL ) |
1682 | 0 | { |
1683 | 0 | libcerror_error_set( |
1684 | 0 | error, |
1685 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1686 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1687 | 0 | "%s: invalid UTF-8 string.", |
1688 | 0 | function ); |
1689 | |
|
1690 | 0 | return( -1 ); |
1691 | 0 | } |
1692 | 443 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1693 | 0 | { |
1694 | 0 | libcerror_error_set( |
1695 | 0 | error, |
1696 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1697 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1698 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1699 | 0 | function ); |
1700 | |
|
1701 | 0 | return( -1 ); |
1702 | 0 | } |
1703 | 443 | if( time_elements == NULL ) |
1704 | 0 | { |
1705 | 0 | libcerror_error_set( |
1706 | 0 | error, |
1707 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1708 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1709 | 0 | "%s: invalid time elements.", |
1710 | 0 | function ); |
1711 | |
|
1712 | 0 | return( -1 ); |
1713 | 0 | } |
1714 | 443 | if( utf8_string_size < 2 ) |
1715 | 0 | { |
1716 | 0 | libcerror_error_set( |
1717 | 0 | error, |
1718 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1719 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1720 | 0 | "%s: UTF-8 string too small.", |
1721 | 0 | function ); |
1722 | |
|
1723 | 0 | return( -1 ); |
1724 | 0 | } |
1725 | 443 | if( libfvalue_utf8_string_copy_to_integer( |
1726 | 443 | utf8_string, |
1727 | 443 | utf8_string_size, |
1728 | 443 | &value_64bit, |
1729 | 443 | 8, |
1730 | 443 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1731 | 443 | error ) != 1 ) |
1732 | 10 | { |
1733 | 10 | libcerror_error_set( |
1734 | 10 | error, |
1735 | 10 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1736 | 10 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1737 | 10 | "%s: unable to UTF-8 string to 8-bit value.", |
1738 | 10 | function ); |
1739 | | |
1740 | 10 | return( -1 ); |
1741 | 10 | } |
1742 | 433 | if( value_64bit >= 24 ) |
1743 | 10 | { |
1744 | 10 | libcerror_error_set( |
1745 | 10 | error, |
1746 | 10 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1747 | 10 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1748 | 10 | "%s: unsupported hours value.", |
1749 | 10 | function ); |
1750 | | |
1751 | 10 | return( -1 ); |
1752 | 10 | } |
1753 | 423 | time_elements->tm_hour = (int) value_64bit; |
1754 | | |
1755 | 423 | return( 1 ); |
1756 | 433 | } |
1757 | | |
1758 | | /* Copies an UTF-8 encoded string of minutes to time elements |
1759 | | * Returns 1 if successful or -1 on error |
1760 | | */ |
1761 | | int libewf_utf8_string_minutes_copy_to_time_elements( |
1762 | | uint8_t *utf8_string, |
1763 | | size_t utf8_string_size, |
1764 | | struct tm *time_elements, |
1765 | | libcerror_error_t **error ) |
1766 | 412 | { |
1767 | 412 | static char *function = "libewf_utf8_string_minutes_copy_to_time_elements"; |
1768 | 412 | uint64_t value_64bit = 0; |
1769 | | |
1770 | 412 | if( utf8_string == NULL ) |
1771 | 0 | { |
1772 | 0 | libcerror_error_set( |
1773 | 0 | error, |
1774 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1775 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1776 | 0 | "%s: invalid UTF-8 string.", |
1777 | 0 | function ); |
1778 | |
|
1779 | 0 | return( -1 ); |
1780 | 0 | } |
1781 | 412 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1782 | 0 | { |
1783 | 0 | libcerror_error_set( |
1784 | 0 | error, |
1785 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1786 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1787 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1788 | 0 | function ); |
1789 | |
|
1790 | 0 | return( -1 ); |
1791 | 0 | } |
1792 | 412 | if( time_elements == NULL ) |
1793 | 0 | { |
1794 | 0 | libcerror_error_set( |
1795 | 0 | error, |
1796 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1797 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1798 | 0 | "%s: invalid time elements.", |
1799 | 0 | function ); |
1800 | |
|
1801 | 0 | return( -1 ); |
1802 | 0 | } |
1803 | 412 | if( utf8_string_size < 2 ) |
1804 | 0 | { |
1805 | 0 | libcerror_error_set( |
1806 | 0 | error, |
1807 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1808 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1809 | 0 | "%s: UTF-8 string too small.", |
1810 | 0 | function ); |
1811 | |
|
1812 | 0 | return( -1 ); |
1813 | 0 | } |
1814 | 412 | if( libfvalue_utf8_string_copy_to_integer( |
1815 | 412 | utf8_string, |
1816 | 412 | utf8_string_size, |
1817 | 412 | &value_64bit, |
1818 | 412 | 8, |
1819 | 412 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1820 | 412 | error ) != 1 ) |
1821 | 10 | { |
1822 | 10 | libcerror_error_set( |
1823 | 10 | error, |
1824 | 10 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1825 | 10 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1826 | 10 | "%s: unable to UTF-8 string to 8-bit value.", |
1827 | 10 | function ); |
1828 | | |
1829 | 10 | return( -1 ); |
1830 | 10 | } |
1831 | 402 | if( value_64bit >= 60 ) |
1832 | 12 | { |
1833 | 12 | libcerror_error_set( |
1834 | 12 | error, |
1835 | 12 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1836 | 12 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1837 | 12 | "%s: unsupported minutes value.", |
1838 | 12 | function ); |
1839 | | |
1840 | 12 | return( -1 ); |
1841 | 12 | } |
1842 | 390 | time_elements->tm_min = (int) value_64bit; |
1843 | | |
1844 | 390 | return( 1 ); |
1845 | 402 | } |
1846 | | |
1847 | | /* Copies an UTF-8 encoded string of seconds to time elements |
1848 | | * Returns 1 if successful or -1 on error |
1849 | | */ |
1850 | | int libewf_utf8_string_seconds_copy_to_time_elements( |
1851 | | uint8_t *utf8_string, |
1852 | | size_t utf8_string_size, |
1853 | | struct tm *time_elements, |
1854 | | libcerror_error_t **error ) |
1855 | 371 | { |
1856 | 371 | static char *function = "libewf_utf8_string_seconds_copy_to_time_elements"; |
1857 | 371 | uint64_t value_64bit = 0; |
1858 | | |
1859 | 371 | if( utf8_string == NULL ) |
1860 | 0 | { |
1861 | 0 | libcerror_error_set( |
1862 | 0 | error, |
1863 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1864 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1865 | 0 | "%s: invalid UTF-8 string.", |
1866 | 0 | function ); |
1867 | |
|
1868 | 0 | return( -1 ); |
1869 | 0 | } |
1870 | 371 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
1871 | 0 | { |
1872 | 0 | libcerror_error_set( |
1873 | 0 | error, |
1874 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1875 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1876 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
1877 | 0 | function ); |
1878 | |
|
1879 | 0 | return( -1 ); |
1880 | 0 | } |
1881 | 371 | if( time_elements == NULL ) |
1882 | 0 | { |
1883 | 0 | libcerror_error_set( |
1884 | 0 | error, |
1885 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1886 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1887 | 0 | "%s: invalid time elements.", |
1888 | 0 | function ); |
1889 | |
|
1890 | 0 | return( -1 ); |
1891 | 0 | } |
1892 | 371 | if( utf8_string_size < 2 ) |
1893 | 0 | { |
1894 | 0 | libcerror_error_set( |
1895 | 0 | error, |
1896 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1897 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
1898 | 0 | "%s: UTF-8 string too small.", |
1899 | 0 | function ); |
1900 | |
|
1901 | 0 | return( -1 ); |
1902 | 0 | } |
1903 | 371 | if( libfvalue_utf8_string_copy_to_integer( |
1904 | 371 | utf8_string, |
1905 | 371 | utf8_string_size, |
1906 | 371 | &value_64bit, |
1907 | 371 | 8, |
1908 | 371 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
1909 | 371 | error ) != 1 ) |
1910 | 9 | { |
1911 | 9 | libcerror_error_set( |
1912 | 9 | error, |
1913 | 9 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1914 | 9 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1915 | 9 | "%s: unable to UTF-8 string to 8-bit value.", |
1916 | 9 | function ); |
1917 | | |
1918 | 9 | return( -1 ); |
1919 | 9 | } |
1920 | 362 | if( value_64bit >= 60 ) |
1921 | 7 | { |
1922 | 7 | libcerror_error_set( |
1923 | 7 | error, |
1924 | 7 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1925 | 7 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
1926 | 7 | "%s: unsupported seconds value.", |
1927 | 7 | function ); |
1928 | | |
1929 | 7 | return( -1 ); |
1930 | 7 | } |
1931 | 355 | time_elements->tm_sec = (int) value_64bit; |
1932 | | |
1933 | 355 | return( 1 ); |
1934 | 362 | } |
1935 | | |
1936 | | /* Copies an UTF-16 encoded string of a day of week from time elements |
1937 | | * Returns 1 if successful or -1 on error |
1938 | | */ |
1939 | | int libewf_utf16_string_day_of_week_copy_from_time_elements( |
1940 | | uint16_t *utf16_string, |
1941 | | size_t utf16_string_size, |
1942 | | size_t *utf16_string_index, |
1943 | | struct tm *time_elements, |
1944 | | libcerror_error_t **error ) |
1945 | 0 | { |
1946 | 0 | const char *day_of_week = NULL; |
1947 | 0 | static char *function = "libewf_utf16_string_day_of_week_copy_from_time_elements"; |
1948 | 0 | size_t string_index = 0; |
1949 | |
|
1950 | 0 | if( utf16_string == NULL ) |
1951 | 0 | { |
1952 | 0 | libcerror_error_set( |
1953 | 0 | error, |
1954 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1955 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1956 | 0 | "%s: invalid UTF-16 string.", |
1957 | 0 | function ); |
1958 | |
|
1959 | 0 | return( -1 ); |
1960 | 0 | } |
1961 | 0 | if( utf16_string_size > (size_t) SSIZE_MAX ) |
1962 | 0 | { |
1963 | 0 | libcerror_error_set( |
1964 | 0 | error, |
1965 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1966 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1967 | 0 | "%s: invalid UTF-16 string size value exceeds maximum.", |
1968 | 0 | function ); |
1969 | |
|
1970 | 0 | return( -1 ); |
1971 | 0 | } |
1972 | 0 | if( utf16_string_index == NULL ) |
1973 | 0 | { |
1974 | 0 | libcerror_error_set( |
1975 | 0 | error, |
1976 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1977 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1978 | 0 | "%s: invalid UTF-16 string index.", |
1979 | 0 | function ); |
1980 | |
|
1981 | 0 | return( -1 ); |
1982 | 0 | } |
1983 | 0 | if( *utf16_string_index >= utf16_string_size ) |
1984 | 0 | { |
1985 | 0 | libcerror_error_set( |
1986 | 0 | error, |
1987 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1988 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
1989 | 0 | "%s: invalid UTF-16 string index value out of bounds.", |
1990 | 0 | function ); |
1991 | |
|
1992 | 0 | return( -1 ); |
1993 | 0 | } |
1994 | 0 | if( ( *utf16_string_index + 3 ) >= utf16_string_size ) |
1995 | 0 | { |
1996 | 0 | libcerror_error_set( |
1997 | 0 | error, |
1998 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1999 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2000 | 0 | "%s: UTF-16 string too small.", |
2001 | 0 | function ); |
2002 | |
|
2003 | 0 | return( -1 ); |
2004 | 0 | } |
2005 | 0 | if( time_elements == NULL ) |
2006 | 0 | { |
2007 | 0 | libcerror_error_set( |
2008 | 0 | error, |
2009 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2010 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2011 | 0 | "%s: invalid time elements.", |
2012 | 0 | function ); |
2013 | |
|
2014 | 0 | return( -1 ); |
2015 | 0 | } |
2016 | 0 | if( ( time_elements->tm_wday < 0 ) |
2017 | 0 | || ( time_elements->tm_wday > 6 ) ) |
2018 | 0 | { |
2019 | 0 | libcerror_error_set( |
2020 | 0 | error, |
2021 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2022 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2023 | 0 | "%s: unsupported day of week.", |
2024 | 0 | function ); |
2025 | |
|
2026 | 0 | return( -1 ); |
2027 | 0 | } |
2028 | 0 | string_index = *utf16_string_index; |
2029 | |
|
2030 | 0 | switch( time_elements->tm_wday ) |
2031 | 0 | { |
2032 | 0 | case 0: |
2033 | 0 | day_of_week = "Sun"; |
2034 | 0 | break; |
2035 | 0 | case 1: |
2036 | 0 | day_of_week = "Mon"; |
2037 | 0 | break; |
2038 | 0 | case 2: |
2039 | 0 | day_of_week = "Tue"; |
2040 | 0 | break; |
2041 | 0 | case 3: |
2042 | 0 | day_of_week = "Wed"; |
2043 | 0 | break; |
2044 | 0 | case 4: |
2045 | 0 | day_of_week = "Thu"; |
2046 | 0 | break; |
2047 | 0 | case 5: |
2048 | 0 | day_of_week = "Fri"; |
2049 | 0 | break; |
2050 | 0 | case 6: |
2051 | 0 | day_of_week = "Sat"; |
2052 | 0 | break; |
2053 | 0 | } |
2054 | 0 | utf16_string[ string_index++ ] = (uint16_t) day_of_week[ 0 ]; |
2055 | 0 | utf16_string[ string_index++ ] = (uint16_t) day_of_week[ 1 ]; |
2056 | 0 | utf16_string[ string_index++ ] = (uint16_t) day_of_week[ 2 ]; |
2057 | |
|
2058 | 0 | *utf16_string_index = string_index; |
2059 | |
|
2060 | 0 | return( 1 ); |
2061 | 0 | } |
2062 | | |
2063 | | /* Copies an UTF-16 encoded string of a month from time elements |
2064 | | * Returns 1 if successful or -1 on error |
2065 | | */ |
2066 | | int libewf_utf16_string_month_copy_from_time_elements( |
2067 | | uint16_t *utf16_string, |
2068 | | size_t utf16_string_size, |
2069 | | size_t *utf16_string_index, |
2070 | | struct tm *time_elements, |
2071 | | libcerror_error_t **error ) |
2072 | 0 | { |
2073 | 0 | const char *month = NULL; |
2074 | 0 | static char *function = "libewf_utf16_string_month_copy_from_time_elements"; |
2075 | 0 | size_t string_index = 0; |
2076 | |
|
2077 | 0 | if( utf16_string == NULL ) |
2078 | 0 | { |
2079 | 0 | libcerror_error_set( |
2080 | 0 | error, |
2081 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2082 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2083 | 0 | "%s: invalid UTF-16 string.", |
2084 | 0 | function ); |
2085 | |
|
2086 | 0 | return( -1 ); |
2087 | 0 | } |
2088 | 0 | if( utf16_string_size > (size_t) SSIZE_MAX ) |
2089 | 0 | { |
2090 | 0 | libcerror_error_set( |
2091 | 0 | error, |
2092 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2093 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2094 | 0 | "%s: invalid UTF-16 string size value exceeds maximum.", |
2095 | 0 | function ); |
2096 | |
|
2097 | 0 | return( -1 ); |
2098 | 0 | } |
2099 | 0 | if( utf16_string_index == NULL ) |
2100 | 0 | { |
2101 | 0 | libcerror_error_set( |
2102 | 0 | error, |
2103 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2104 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2105 | 0 | "%s: invalid UTF-16 string index.", |
2106 | 0 | function ); |
2107 | |
|
2108 | 0 | return( -1 ); |
2109 | 0 | } |
2110 | 0 | if( *utf16_string_index >= utf16_string_size ) |
2111 | 0 | { |
2112 | 0 | libcerror_error_set( |
2113 | 0 | error, |
2114 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2115 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
2116 | 0 | "%s: invalid UTF-16 string index value out of bounds.", |
2117 | 0 | function ); |
2118 | |
|
2119 | 0 | return( -1 ); |
2120 | 0 | } |
2121 | 0 | if( ( *utf16_string_index + 3 ) >= utf16_string_size ) |
2122 | 0 | { |
2123 | 0 | libcerror_error_set( |
2124 | 0 | error, |
2125 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2126 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2127 | 0 | "%s: UTF-16 string too small.", |
2128 | 0 | function ); |
2129 | |
|
2130 | 0 | return( -1 ); |
2131 | 0 | } |
2132 | 0 | if( time_elements == NULL ) |
2133 | 0 | { |
2134 | 0 | libcerror_error_set( |
2135 | 0 | error, |
2136 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2137 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2138 | 0 | "%s: invalid time elements.", |
2139 | 0 | function ); |
2140 | |
|
2141 | 0 | return( -1 ); |
2142 | 0 | } |
2143 | 0 | if( ( time_elements->tm_mon < 0 ) |
2144 | 0 | || ( time_elements->tm_mon > 11 ) ) |
2145 | 0 | { |
2146 | 0 | libcerror_error_set( |
2147 | 0 | error, |
2148 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2149 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2150 | 0 | "%s: unsupported month.", |
2151 | 0 | function ); |
2152 | |
|
2153 | 0 | return( -1 ); |
2154 | 0 | } |
2155 | 0 | string_index = *utf16_string_index; |
2156 | |
|
2157 | 0 | switch( time_elements->tm_mon ) |
2158 | 0 | { |
2159 | 0 | case 0: |
2160 | 0 | month = "Jan"; |
2161 | 0 | break; |
2162 | 0 | case 1: |
2163 | 0 | month = "Feb"; |
2164 | 0 | break; |
2165 | 0 | case 2: |
2166 | 0 | month = "Mar"; |
2167 | 0 | break; |
2168 | 0 | case 3: |
2169 | 0 | month = "Apr"; |
2170 | 0 | break; |
2171 | 0 | case 4: |
2172 | 0 | month = "May"; |
2173 | 0 | break; |
2174 | 0 | case 5: |
2175 | 0 | month = "Jun"; |
2176 | 0 | break; |
2177 | 0 | case 6: |
2178 | 0 | month = "Jul"; |
2179 | 0 | break; |
2180 | 0 | case 7: |
2181 | 0 | month = "Aug"; |
2182 | 0 | break; |
2183 | 0 | case 8: |
2184 | 0 | month = "Sep"; |
2185 | 0 | break; |
2186 | 0 | case 9: |
2187 | 0 | month = "Oct"; |
2188 | 0 | break; |
2189 | 0 | case 10: |
2190 | 0 | month = "Nov"; |
2191 | 0 | break; |
2192 | 0 | case 11: |
2193 | 0 | month = "Dec"; |
2194 | 0 | break; |
2195 | 0 | } |
2196 | 0 | utf16_string[ string_index++ ] = (uint16_t) month[ 0 ]; |
2197 | 0 | utf16_string[ string_index++ ] = (uint16_t) month[ 1 ]; |
2198 | 0 | utf16_string[ string_index++ ] = (uint16_t) month[ 2 ]; |
2199 | |
|
2200 | 0 | *utf16_string_index = string_index; |
2201 | |
|
2202 | 0 | return( 1 ); |
2203 | 0 | } |
2204 | | |
2205 | | /* Copies an UTF-16 encoded string of a time value in the format (HH:MM:SS) from time elements |
2206 | | * Returns 1 if successful or -1 on error |
2207 | | */ |
2208 | | int libewf_utf16_string_time_copy_from_time_elements( |
2209 | | uint16_t *utf16_string, |
2210 | | size_t utf16_string_size, |
2211 | | size_t *utf16_string_index, |
2212 | | struct tm *time_elements, |
2213 | | libcerror_error_t **error ) |
2214 | 0 | { |
2215 | 0 | static char *function = "libewf_utf16_string_time_copy_from_time_elements"; |
2216 | 0 | size_t string_index = 0; |
2217 | |
|
2218 | 0 | if( utf16_string == NULL ) |
2219 | 0 | { |
2220 | 0 | libcerror_error_set( |
2221 | 0 | error, |
2222 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2223 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2224 | 0 | "%s: invalid UTF-16 string.", |
2225 | 0 | function ); |
2226 | |
|
2227 | 0 | return( -1 ); |
2228 | 0 | } |
2229 | 0 | if( utf16_string_size > (size_t) SSIZE_MAX ) |
2230 | 0 | { |
2231 | 0 | libcerror_error_set( |
2232 | 0 | error, |
2233 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2234 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2235 | 0 | "%s: invalid UTF-16 string size value exceeds maximum.", |
2236 | 0 | function ); |
2237 | |
|
2238 | 0 | return( -1 ); |
2239 | 0 | } |
2240 | 0 | if( utf16_string_index == NULL ) |
2241 | 0 | { |
2242 | 0 | libcerror_error_set( |
2243 | 0 | error, |
2244 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2245 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2246 | 0 | "%s: invalid UTF-16 string index.", |
2247 | 0 | function ); |
2248 | |
|
2249 | 0 | return( -1 ); |
2250 | 0 | } |
2251 | 0 | if( *utf16_string_index >= utf16_string_size ) |
2252 | 0 | { |
2253 | 0 | libcerror_error_set( |
2254 | 0 | error, |
2255 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2256 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
2257 | 0 | "%s: invalid UTF-16 string index value out of bounds.", |
2258 | 0 | function ); |
2259 | |
|
2260 | 0 | return( -1 ); |
2261 | 0 | } |
2262 | 0 | if( ( *utf16_string_index + 8 ) >= utf16_string_size ) |
2263 | 0 | { |
2264 | 0 | libcerror_error_set( |
2265 | 0 | error, |
2266 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2267 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2268 | 0 | "%s: UTF-16 string too small.", |
2269 | 0 | function ); |
2270 | |
|
2271 | 0 | return( -1 ); |
2272 | 0 | } |
2273 | 0 | if( time_elements == NULL ) |
2274 | 0 | { |
2275 | 0 | libcerror_error_set( |
2276 | 0 | error, |
2277 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2278 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2279 | 0 | "%s: invalid time elements.", |
2280 | 0 | function ); |
2281 | |
|
2282 | 0 | return( -1 ); |
2283 | 0 | } |
2284 | 0 | if( ( time_elements->tm_hour < 0 ) |
2285 | 0 | || ( time_elements->tm_hour > 23 ) ) |
2286 | 0 | { |
2287 | 0 | libcerror_error_set( |
2288 | 0 | error, |
2289 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2290 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2291 | 0 | "%s: unsupported hours.", |
2292 | 0 | function ); |
2293 | |
|
2294 | 0 | return( -1 ); |
2295 | 0 | } |
2296 | 0 | if( ( time_elements->tm_min < 0 ) |
2297 | 0 | || ( time_elements->tm_min > 59 ) ) |
2298 | 0 | { |
2299 | 0 | libcerror_error_set( |
2300 | 0 | error, |
2301 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2302 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2303 | 0 | "%s: unsupported minutes.", |
2304 | 0 | function ); |
2305 | |
|
2306 | 0 | return( -1 ); |
2307 | 0 | } |
2308 | | /* Note a value of 60 is used for a leap-second |
2309 | | */ |
2310 | 0 | if( ( time_elements->tm_sec < 0 ) |
2311 | 0 | || ( time_elements->tm_sec > 60 ) ) |
2312 | 0 | { |
2313 | 0 | libcerror_error_set( |
2314 | 0 | error, |
2315 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2316 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2317 | 0 | "%s: unsupported seconds.", |
2318 | 0 | function ); |
2319 | |
|
2320 | 0 | return( -1 ); |
2321 | 0 | } |
2322 | 0 | string_index = *utf16_string_index; |
2323 | |
|
2324 | 0 | if( time_elements->tm_hour < 10 ) |
2325 | 0 | { |
2326 | 0 | utf16_string[ string_index++ ] = (uint16_t) '0'; |
2327 | 0 | } |
2328 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
2329 | 0 | utf16_string, |
2330 | 0 | utf16_string_size, |
2331 | 0 | &string_index, |
2332 | 0 | (uint64_t) time_elements->tm_hour, |
2333 | 0 | 8, |
2334 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2335 | 0 | error ) != 1 ) |
2336 | 0 | { |
2337 | 0 | libcerror_error_set( |
2338 | 0 | error, |
2339 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2340 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2341 | 0 | "%s: unable to copy hours to UTF-16 string.", |
2342 | 0 | function ); |
2343 | |
|
2344 | 0 | return( -1 ); |
2345 | 0 | } |
2346 | 0 | utf16_string[ string_index - 1 ] = (uint16_t) ':'; |
2347 | |
|
2348 | 0 | if( time_elements->tm_min < 10 ) |
2349 | 0 | { |
2350 | 0 | utf16_string[ string_index++ ] = (uint16_t) '0'; |
2351 | 0 | } |
2352 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
2353 | 0 | utf16_string, |
2354 | 0 | utf16_string_size, |
2355 | 0 | &string_index, |
2356 | 0 | (uint64_t) time_elements->tm_min, |
2357 | 0 | 8, |
2358 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2359 | 0 | error ) != 1 ) |
2360 | 0 | { |
2361 | 0 | libcerror_error_set( |
2362 | 0 | error, |
2363 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2364 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2365 | 0 | "%s: unable to copy minutes to UTF-16 string.", |
2366 | 0 | function ); |
2367 | |
|
2368 | 0 | return( -1 ); |
2369 | 0 | } |
2370 | 0 | utf16_string[ string_index - 1 ] = (uint16_t) ':'; |
2371 | |
|
2372 | 0 | if( time_elements->tm_sec < 10 ) |
2373 | 0 | { |
2374 | 0 | utf16_string[ string_index++ ] = (uint16_t) '0'; |
2375 | 0 | } |
2376 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
2377 | 0 | utf16_string, |
2378 | 0 | utf16_string_size, |
2379 | 0 | &string_index, |
2380 | 0 | (uint64_t) time_elements->tm_sec, |
2381 | 0 | 8, |
2382 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2383 | 0 | error ) != 1 ) |
2384 | 0 | { |
2385 | 0 | libcerror_error_set( |
2386 | 0 | error, |
2387 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2388 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2389 | 0 | "%s: unable to copy seconds to UTF-16 string.", |
2390 | 0 | function ); |
2391 | |
|
2392 | 0 | return( -1 ); |
2393 | 0 | } |
2394 | 0 | *utf16_string_index = string_index - 1; |
2395 | |
|
2396 | 0 | return( 1 ); |
2397 | 0 | } |
2398 | | |
2399 | | /* Copies a date time values string to a string in a specific formatted UTF-8 encoded date and time string |
2400 | | * The string must be at least 32 characters of size this includes the end of string character |
2401 | | * Returns 1 if successful or -1 on error |
2402 | | */ |
2403 | | int libewf_date_time_values_copy_to_utf8_string( |
2404 | | const uint8_t *date_time_values_string, |
2405 | | size_t date_time_values_string_size, |
2406 | | int date_format, |
2407 | | uint8_t *utf8_string, |
2408 | | size_t utf8_string_size, |
2409 | | libcerror_error_t **error ) |
2410 | 0 | { |
2411 | 0 | struct tm time_elements; |
2412 | |
|
2413 | 0 | static char *function = "libewf_date_time_values_copy_to_utf8_string"; |
2414 | 0 | size_t date_time_values_string_index = 0; |
2415 | 0 | size_t utf8_string_index = 0; |
2416 | 0 | time_t timestamp = 0; |
2417 | |
|
2418 | 0 | if( date_time_values_string == NULL ) |
2419 | 0 | { |
2420 | 0 | libcerror_error_set( |
2421 | 0 | error, |
2422 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2423 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2424 | 0 | "%s: invalid date time values string.", |
2425 | 0 | function ); |
2426 | |
|
2427 | 0 | return( -1 ); |
2428 | 0 | } |
2429 | 0 | if( date_time_values_string_size > (size_t) SSIZE_MAX ) |
2430 | 0 | { |
2431 | 0 | libcerror_error_set( |
2432 | 0 | error, |
2433 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2434 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2435 | 0 | "%s: invalid date time values string size.", |
2436 | 0 | function ); |
2437 | |
|
2438 | 0 | return( -1 ); |
2439 | 0 | } |
2440 | 0 | if( ( date_format != LIBEWF_DATE_FORMAT_CTIME ) |
2441 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_DAYMONTH ) |
2442 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_MONTHDAY ) |
2443 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_ISO8601 ) ) |
2444 | 0 | { |
2445 | 0 | libcerror_error_set( |
2446 | 0 | error, |
2447 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2448 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2449 | 0 | "%s: unsupported date format.", |
2450 | 0 | function ); |
2451 | |
|
2452 | 0 | return( -1 ); |
2453 | 0 | } |
2454 | 0 | if( utf8_string == NULL ) |
2455 | 0 | { |
2456 | 0 | libcerror_error_set( |
2457 | 0 | error, |
2458 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2459 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2460 | 0 | "%s: invalid UTF-8 string.", |
2461 | 0 | function ); |
2462 | |
|
2463 | 0 | return( -1 ); |
2464 | 0 | } |
2465 | 0 | if( utf8_string_size > (size_t) SSIZE_MAX ) |
2466 | 0 | { |
2467 | 0 | libcerror_error_set( |
2468 | 0 | error, |
2469 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2470 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2471 | 0 | "%s: invalid UTF-8 string size value exceeds maximum.", |
2472 | 0 | function ); |
2473 | |
|
2474 | 0 | return( -1 ); |
2475 | 0 | } |
2476 | 0 | if( utf8_string_size < 20 ) |
2477 | 0 | { |
2478 | 0 | libcerror_error_set( |
2479 | 0 | error, |
2480 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2481 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2482 | 0 | "%s: UTF-8 string too small.", |
2483 | 0 | function ); |
2484 | |
|
2485 | 0 | return( -1 ); |
2486 | 0 | } |
2487 | 0 | if( libewf_date_time_values_copy_to_timestamp( |
2488 | 0 | date_time_values_string, |
2489 | 0 | date_time_values_string_size, |
2490 | 0 | ×tamp, |
2491 | 0 | error ) != 1 ) |
2492 | 0 | { |
2493 | 0 | libcerror_error_set( |
2494 | 0 | error, |
2495 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2496 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2497 | 0 | "%s: unable to create timestamp.", |
2498 | 0 | function ); |
2499 | |
|
2500 | 0 | return( -1 ); |
2501 | 0 | } |
2502 | 0 | if( libewf_date_time_localtime( |
2503 | 0 | ×tamp, |
2504 | 0 | &time_elements, |
2505 | 0 | error ) != 1 ) |
2506 | 0 | { |
2507 | 0 | libcerror_error_set( |
2508 | 0 | error, |
2509 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2510 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
2511 | 0 | "%s: unable to create time elements.", |
2512 | 0 | function ); |
2513 | |
|
2514 | 0 | return( -1 ); |
2515 | 0 | } |
2516 | 0 | if( ( time_elements.tm_year + 1900 ) > 10000 ) |
2517 | 0 | { |
2518 | 0 | libcerror_error_set( |
2519 | 0 | error, |
2520 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2521 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
2522 | 0 | "%s: unsupported year value.", |
2523 | 0 | function ); |
2524 | |
|
2525 | 0 | return( -1 ); |
2526 | 0 | } |
2527 | 0 | if( date_format == LIBEWF_DATE_FORMAT_CTIME ) |
2528 | 0 | { |
2529 | 0 | if( utf8_string_size < 25 ) |
2530 | 0 | { |
2531 | 0 | libcerror_error_set( |
2532 | 0 | error, |
2533 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2534 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2535 | 0 | "%s: UTF-8 string too small.", |
2536 | 0 | function ); |
2537 | |
|
2538 | 0 | return( -1 ); |
2539 | 0 | } |
2540 | 0 | if( libewf_utf8_string_day_of_week_copy_from_time_elements( |
2541 | 0 | utf8_string, |
2542 | 0 | utf8_string_size, |
2543 | 0 | &utf8_string_index, |
2544 | 0 | &time_elements, |
2545 | 0 | error ) != 1 ) |
2546 | 0 | { |
2547 | 0 | libcerror_error_set( |
2548 | 0 | error, |
2549 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2550 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2551 | 0 | "%s: unable to copy day of week to UTF-8 string.", |
2552 | 0 | function ); |
2553 | |
|
2554 | 0 | return( -1 ); |
2555 | 0 | } |
2556 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) ' '; |
2557 | |
|
2558 | 0 | if( libewf_utf8_string_month_copy_from_time_elements( |
2559 | 0 | utf8_string, |
2560 | 0 | utf8_string_size, |
2561 | 0 | &utf8_string_index, |
2562 | 0 | &time_elements, |
2563 | 0 | error ) != 1 ) |
2564 | 0 | { |
2565 | 0 | libcerror_error_set( |
2566 | 0 | error, |
2567 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2568 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2569 | 0 | "%s: unable to copy month to UTF-8 string.", |
2570 | 0 | function ); |
2571 | |
|
2572 | 0 | return( -1 ); |
2573 | 0 | } |
2574 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) ' '; |
2575 | |
|
2576 | 0 | if( time_elements.tm_mday < 10 ) |
2577 | 0 | { |
2578 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) ' '; |
2579 | 0 | } |
2580 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2581 | 0 | utf8_string, |
2582 | 0 | utf8_string_size, |
2583 | 0 | &utf8_string_index, |
2584 | 0 | (uint64_t) time_elements.tm_mday, |
2585 | 0 | 8, |
2586 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2587 | 0 | error ) != 1 ) |
2588 | 0 | { |
2589 | 0 | libcerror_error_set( |
2590 | 0 | error, |
2591 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2592 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2593 | 0 | "%s: unable to copy day of month to UTF-8 string.", |
2594 | 0 | function ); |
2595 | |
|
2596 | 0 | return( -1 ); |
2597 | 0 | } |
2598 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) ' '; |
2599 | |
|
2600 | 0 | if( libewf_utf8_string_time_copy_from_time_elements( |
2601 | 0 | utf8_string, |
2602 | 0 | utf8_string_size, |
2603 | 0 | &utf8_string_index, |
2604 | 0 | &time_elements, |
2605 | 0 | error ) != 1 ) |
2606 | 0 | { |
2607 | 0 | libcerror_error_set( |
2608 | 0 | error, |
2609 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2610 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2611 | 0 | "%s: unable to copy time to UTF-8 string.", |
2612 | 0 | function ); |
2613 | |
|
2614 | 0 | return( -1 ); |
2615 | 0 | } |
2616 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) ' '; |
2617 | |
|
2618 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2619 | 0 | utf8_string, |
2620 | 0 | utf8_string_size, |
2621 | 0 | &utf8_string_index, |
2622 | 0 | (uint64_t) time_elements.tm_year + 1900, |
2623 | 0 | 16, |
2624 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2625 | 0 | error ) != 1 ) |
2626 | 0 | { |
2627 | 0 | libcerror_error_set( |
2628 | 0 | error, |
2629 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2630 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2631 | 0 | "%s: unable to copy year to UTF-8 string.", |
2632 | 0 | function ); |
2633 | |
|
2634 | 0 | return( -1 ); |
2635 | 0 | } |
2636 | 0 | utf8_string_index--; |
2637 | 0 | } |
2638 | 0 | else if( ( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
2639 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) |
2640 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) ) |
2641 | 0 | { |
2642 | 0 | if( ( time_elements.tm_mon < 0 ) |
2643 | 0 | || ( time_elements.tm_mon > 11 ) ) |
2644 | 0 | { |
2645 | 0 | libcerror_error_set( |
2646 | 0 | error, |
2647 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2648 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2649 | 0 | "%s: unsupported month.", |
2650 | 0 | function ); |
2651 | |
|
2652 | 0 | return( -1 ); |
2653 | 0 | } |
2654 | 0 | if( ( time_elements.tm_mday < 1 ) |
2655 | 0 | || ( time_elements.tm_mday > 31 ) ) |
2656 | 0 | { |
2657 | 0 | libcerror_error_set( |
2658 | 0 | error, |
2659 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2660 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2661 | 0 | "%s: unsupported day of month.", |
2662 | 0 | function ); |
2663 | |
|
2664 | 0 | return( -1 ); |
2665 | 0 | } |
2666 | 0 | if( ( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
2667 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) ) |
2668 | 0 | { |
2669 | 0 | if( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
2670 | 0 | { |
2671 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
2672 | 0 | { |
2673 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2674 | 0 | } |
2675 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2676 | 0 | utf8_string, |
2677 | 0 | utf8_string_size, |
2678 | 0 | &utf8_string_index, |
2679 | 0 | (uint64_t) time_elements.tm_mon + 1, |
2680 | 0 | 8, |
2681 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2682 | 0 | error ) != 1 ) |
2683 | 0 | { |
2684 | 0 | libcerror_error_set( |
2685 | 0 | error, |
2686 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2687 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2688 | 0 | "%s: unable to copy month to UTF-8 string.", |
2689 | 0 | function ); |
2690 | |
|
2691 | 0 | return( -1 ); |
2692 | 0 | } |
2693 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) '/'; |
2694 | |
|
2695 | 0 | if( time_elements.tm_mday < 10 ) |
2696 | 0 | { |
2697 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2698 | 0 | } |
2699 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2700 | 0 | utf8_string, |
2701 | 0 | utf8_string_size, |
2702 | 0 | &utf8_string_index, |
2703 | 0 | (uint64_t) time_elements.tm_mday, |
2704 | 0 | 8, |
2705 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2706 | 0 | error ) != 1 ) |
2707 | 0 | { |
2708 | 0 | libcerror_error_set( |
2709 | 0 | error, |
2710 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2711 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2712 | 0 | "%s: unable to copy day of month to UTF-8 string.", |
2713 | 0 | function ); |
2714 | |
|
2715 | 0 | return( -1 ); |
2716 | 0 | } |
2717 | 0 | utf8_string_index--; |
2718 | 0 | } |
2719 | 0 | else if( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) |
2720 | 0 | { |
2721 | 0 | if( time_elements.tm_mday < 10 ) |
2722 | 0 | { |
2723 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2724 | 0 | } |
2725 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2726 | 0 | utf8_string, |
2727 | 0 | utf8_string_size, |
2728 | 0 | &utf8_string_index, |
2729 | 0 | (uint64_t) time_elements.tm_mday, |
2730 | 0 | 8, |
2731 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2732 | 0 | error ) != 1 ) |
2733 | 0 | { |
2734 | 0 | libcerror_error_set( |
2735 | 0 | error, |
2736 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2737 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2738 | 0 | "%s: unable to copy day of month to UTF-8 string.", |
2739 | 0 | function ); |
2740 | |
|
2741 | 0 | return( -1 ); |
2742 | 0 | } |
2743 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) '/'; |
2744 | |
|
2745 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
2746 | 0 | { |
2747 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2748 | 0 | } |
2749 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2750 | 0 | utf8_string, |
2751 | 0 | utf8_string_size, |
2752 | 0 | &utf8_string_index, |
2753 | 0 | (uint64_t) time_elements.tm_mon + 1, |
2754 | 0 | 8, |
2755 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2756 | 0 | error ) != 1 ) |
2757 | 0 | { |
2758 | 0 | libcerror_error_set( |
2759 | 0 | error, |
2760 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2761 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2762 | 0 | "%s: unable to copy month to UTF-8 string.", |
2763 | 0 | function ); |
2764 | |
|
2765 | 0 | return( -1 ); |
2766 | 0 | } |
2767 | 0 | utf8_string_index--; |
2768 | 0 | } |
2769 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '/'; |
2770 | |
|
2771 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2772 | 0 | utf8_string, |
2773 | 0 | utf8_string_size, |
2774 | 0 | &utf8_string_index, |
2775 | 0 | (uint64_t) time_elements.tm_year + 1900, |
2776 | 0 | 16, |
2777 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2778 | 0 | error ) != 1 ) |
2779 | 0 | { |
2780 | 0 | libcerror_error_set( |
2781 | 0 | error, |
2782 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2783 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2784 | 0 | "%s: unable to copy year to UTF-8 string.", |
2785 | 0 | function ); |
2786 | |
|
2787 | 0 | return( -1 ); |
2788 | 0 | } |
2789 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) ' '; |
2790 | 0 | } |
2791 | 0 | else if( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) |
2792 | 0 | { |
2793 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2794 | 0 | utf8_string, |
2795 | 0 | utf8_string_size, |
2796 | 0 | &utf8_string_index, |
2797 | 0 | (uint64_t) time_elements.tm_year + 1900, |
2798 | 0 | 16, |
2799 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2800 | 0 | error ) != 1 ) |
2801 | 0 | { |
2802 | 0 | libcerror_error_set( |
2803 | 0 | error, |
2804 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2805 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2806 | 0 | "%s: unable to copy year to UTF-8 string.", |
2807 | 0 | function ); |
2808 | |
|
2809 | 0 | return( -1 ); |
2810 | 0 | } |
2811 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) '-'; |
2812 | |
|
2813 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
2814 | 0 | { |
2815 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2816 | 0 | } |
2817 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2818 | 0 | utf8_string, |
2819 | 0 | utf8_string_size, |
2820 | 0 | &utf8_string_index, |
2821 | 0 | (uint64_t) time_elements.tm_mon + 1, |
2822 | 0 | 8, |
2823 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2824 | 0 | error ) != 1 ) |
2825 | 0 | { |
2826 | 0 | libcerror_error_set( |
2827 | 0 | error, |
2828 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2829 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2830 | 0 | "%s: unable to copy month to UTF-8 string.", |
2831 | 0 | function ); |
2832 | |
|
2833 | 0 | return( -1 ); |
2834 | 0 | } |
2835 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) '-'; |
2836 | |
|
2837 | 0 | if( time_elements.tm_mday < 10 ) |
2838 | 0 | { |
2839 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) '0'; |
2840 | 0 | } |
2841 | 0 | if( libfvalue_utf8_string_with_index_copy_from_integer( |
2842 | 0 | utf8_string, |
2843 | 0 | utf8_string_size, |
2844 | 0 | &utf8_string_index, |
2845 | 0 | (uint64_t) time_elements.tm_mday, |
2846 | 0 | 8, |
2847 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
2848 | 0 | error ) != 1 ) |
2849 | 0 | { |
2850 | 0 | libcerror_error_set( |
2851 | 0 | error, |
2852 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2853 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2854 | 0 | "%s: unable to copy day of month to UTF-8 string.", |
2855 | 0 | function ); |
2856 | |
|
2857 | 0 | return( -1 ); |
2858 | 0 | } |
2859 | 0 | utf8_string[ utf8_string_index - 1 ] = (uint8_t) 'T'; |
2860 | 0 | } |
2861 | 0 | if( libewf_utf8_string_time_copy_from_time_elements( |
2862 | 0 | utf8_string, |
2863 | 0 | utf8_string_size, |
2864 | 0 | &utf8_string_index, |
2865 | 0 | &time_elements, |
2866 | 0 | error ) != 1 ) |
2867 | 0 | { |
2868 | 0 | libcerror_error_set( |
2869 | 0 | error, |
2870 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
2871 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
2872 | 0 | "%s: unable to copy time to UTF-8 string.", |
2873 | 0 | function ); |
2874 | |
|
2875 | 0 | return( -1 ); |
2876 | 0 | } |
2877 | 0 | } |
2878 | 0 | if( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) |
2879 | 0 | { |
2880 | 0 | if( date_time_values_string_size >= 28 ) |
2881 | 0 | { |
2882 | 0 | if( ( utf8_string_index + 7 ) >= utf8_string_size ) |
2883 | 0 | { |
2884 | 0 | libcerror_error_set( |
2885 | 0 | error, |
2886 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2887 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2888 | 0 | "%s: UTF-8 string too small.", |
2889 | 0 | function ); |
2890 | |
|
2891 | 0 | return( -1 ); |
2892 | 0 | } |
2893 | 0 | if( ( date_time_values_string[ 20 ] == (uint8_t ) '+' ) |
2894 | 0 | || ( date_time_values_string[ 20 ] == (uint8_t ) '-' ) ) |
2895 | 0 | { |
2896 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 20 ]; |
2897 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 21 ]; |
2898 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 22 ]; |
2899 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 23 ]; |
2900 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 24 ]; |
2901 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 25 ]; |
2902 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ 26 ]; |
2903 | 0 | } |
2904 | 0 | } |
2905 | 0 | } |
2906 | 0 | else if( date_time_values_string_size > 20 ) |
2907 | 0 | { |
2908 | 0 | if( ( utf8_string_index + ( date_time_values_string_size - 20 ) ) >= utf8_string_size ) |
2909 | 0 | { |
2910 | 0 | libcerror_error_set( |
2911 | 0 | error, |
2912 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2913 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2914 | 0 | "%s: UTF-8 string too small.", |
2915 | 0 | function ); |
2916 | |
|
2917 | 0 | return( -1 ); |
2918 | 0 | } |
2919 | 0 | for( date_time_values_string_index = 19; |
2920 | 0 | date_time_values_string_index < date_time_values_string_size - 1; |
2921 | 0 | date_time_values_string_index++ ) |
2922 | 0 | { |
2923 | 0 | utf8_string[ utf8_string_index++ ] = (uint8_t) date_time_values_string[ date_time_values_string_index ]; |
2924 | 0 | } |
2925 | 0 | } |
2926 | 0 | if( utf8_string_index >= utf8_string_size ) |
2927 | 0 | { |
2928 | 0 | libcerror_error_set( |
2929 | 0 | error, |
2930 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2931 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
2932 | 0 | "%s: UTF-8 string too small.", |
2933 | 0 | function ); |
2934 | |
|
2935 | 0 | return( -1 ); |
2936 | 0 | } |
2937 | 0 | utf8_string[ utf8_string_index ] = 0; |
2938 | |
|
2939 | 0 | return( 1 ); |
2940 | 0 | } |
2941 | | |
2942 | | /* Copies a date time values string to a string in a specific formatted UTF-16 encoded date and time string |
2943 | | * The string must be at least 32 characters of size this includes the end of string character |
2944 | | * Returns 1 if successful or -1 on error |
2945 | | */ |
2946 | | int libewf_date_time_values_copy_to_utf16_string( |
2947 | | const uint8_t *date_time_values_string, |
2948 | | size_t date_time_values_string_size, |
2949 | | int date_format, |
2950 | | uint16_t *utf16_string, |
2951 | | size_t utf16_string_size, |
2952 | | libcerror_error_t **error ) |
2953 | 0 | { |
2954 | 0 | struct tm time_elements; |
2955 | |
|
2956 | 0 | static char *function = "libewf_date_time_values_copy_to_utf16_string"; |
2957 | 0 | size_t date_time_values_string_index = 0; |
2958 | 0 | size_t utf16_string_index = 0; |
2959 | 0 | time_t timestamp = 0; |
2960 | |
|
2961 | 0 | if( date_time_values_string == NULL ) |
2962 | 0 | { |
2963 | 0 | libcerror_error_set( |
2964 | 0 | error, |
2965 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2966 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
2967 | 0 | "%s: invalid date time values string.", |
2968 | 0 | function ); |
2969 | |
|
2970 | 0 | return( -1 ); |
2971 | 0 | } |
2972 | 0 | if( date_time_values_string_size > (size_t) SSIZE_MAX ) |
2973 | 0 | { |
2974 | 0 | libcerror_error_set( |
2975 | 0 | error, |
2976 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2977 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
2978 | 0 | "%s: invalid date time values string size.", |
2979 | 0 | function ); |
2980 | |
|
2981 | 0 | return( -1 ); |
2982 | 0 | } |
2983 | 0 | if( ( date_format != LIBEWF_DATE_FORMAT_CTIME ) |
2984 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_DAYMONTH ) |
2985 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_MONTHDAY ) |
2986 | 0 | && ( date_format != LIBEWF_DATE_FORMAT_ISO8601 ) ) |
2987 | 0 | { |
2988 | 0 | libcerror_error_set( |
2989 | 0 | error, |
2990 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
2991 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
2992 | 0 | "%s: unsupported date format.", |
2993 | 0 | function ); |
2994 | |
|
2995 | 0 | return( -1 ); |
2996 | 0 | } |
2997 | 0 | if( utf16_string == NULL ) |
2998 | 0 | { |
2999 | 0 | libcerror_error_set( |
3000 | 0 | error, |
3001 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3002 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
3003 | 0 | "%s: invalid UTF-16 string.", |
3004 | 0 | function ); |
3005 | |
|
3006 | 0 | return( -1 ); |
3007 | 0 | } |
3008 | 0 | if( utf16_string_size > (size_t) SSIZE_MAX ) |
3009 | 0 | { |
3010 | 0 | libcerror_error_set( |
3011 | 0 | error, |
3012 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3013 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
3014 | 0 | "%s: invalid UTF-16 string size value exceeds maximum.", |
3015 | 0 | function ); |
3016 | |
|
3017 | 0 | return( -1 ); |
3018 | 0 | } |
3019 | 0 | if( utf16_string_size < 20 ) |
3020 | 0 | { |
3021 | 0 | libcerror_error_set( |
3022 | 0 | error, |
3023 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3024 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
3025 | 0 | "%s: UTF-16 string too small.", |
3026 | 0 | function ); |
3027 | |
|
3028 | 0 | return( -1 ); |
3029 | 0 | } |
3030 | 0 | if( libewf_date_time_values_copy_to_timestamp( |
3031 | 0 | date_time_values_string, |
3032 | 0 | date_time_values_string_size, |
3033 | 0 | ×tamp, |
3034 | 0 | error ) != 1 ) |
3035 | 0 | { |
3036 | 0 | libcerror_error_set( |
3037 | 0 | error, |
3038 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3039 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3040 | 0 | "%s: unable to create timestamp.", |
3041 | 0 | function ); |
3042 | |
|
3043 | 0 | return( -1 ); |
3044 | 0 | } |
3045 | 0 | if( libewf_date_time_localtime( |
3046 | 0 | ×tamp, |
3047 | 0 | &time_elements, |
3048 | 0 | error ) != 1 ) |
3049 | 0 | { |
3050 | 0 | libcerror_error_set( |
3051 | 0 | error, |
3052 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3053 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
3054 | 0 | "%s: unable to create time elements.", |
3055 | 0 | function ); |
3056 | |
|
3057 | 0 | return( -1 ); |
3058 | 0 | } |
3059 | 0 | if( ( time_elements.tm_year + 1900 ) > 10000 ) |
3060 | 0 | { |
3061 | 0 | libcerror_error_set( |
3062 | 0 | error, |
3063 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3064 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
3065 | 0 | "%s: unsupported year value.", |
3066 | 0 | function ); |
3067 | |
|
3068 | 0 | return( -1 ); |
3069 | 0 | } |
3070 | 0 | if( date_format == LIBEWF_DATE_FORMAT_CTIME ) |
3071 | 0 | { |
3072 | 0 | if( utf16_string_size < 25 ) |
3073 | 0 | { |
3074 | 0 | libcerror_error_set( |
3075 | 0 | error, |
3076 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3077 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
3078 | 0 | "%s: UTF-16 string too small.", |
3079 | 0 | function ); |
3080 | |
|
3081 | 0 | return( -1 ); |
3082 | 0 | } |
3083 | 0 | if( libewf_utf16_string_day_of_week_copy_from_time_elements( |
3084 | 0 | utf16_string, |
3085 | 0 | utf16_string_size, |
3086 | 0 | &utf16_string_index, |
3087 | 0 | &time_elements, |
3088 | 0 | error ) != 1 ) |
3089 | 0 | { |
3090 | 0 | libcerror_error_set( |
3091 | 0 | error, |
3092 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3093 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3094 | 0 | "%s: unable to copy day of week to UTF-16 string.", |
3095 | 0 | function ); |
3096 | |
|
3097 | 0 | return( -1 ); |
3098 | 0 | } |
3099 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) ' '; |
3100 | |
|
3101 | 0 | if( libewf_utf16_string_month_copy_from_time_elements( |
3102 | 0 | utf16_string, |
3103 | 0 | utf16_string_size, |
3104 | 0 | &utf16_string_index, |
3105 | 0 | &time_elements, |
3106 | 0 | error ) != 1 ) |
3107 | 0 | { |
3108 | 0 | libcerror_error_set( |
3109 | 0 | error, |
3110 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3111 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3112 | 0 | "%s: unable to copy month to UTF-16 string.", |
3113 | 0 | function ); |
3114 | |
|
3115 | 0 | return( -1 ); |
3116 | 0 | } |
3117 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) ' '; |
3118 | |
|
3119 | 0 | if( time_elements.tm_mday < 10 ) |
3120 | 0 | { |
3121 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) ' '; |
3122 | 0 | } |
3123 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3124 | 0 | utf16_string, |
3125 | 0 | utf16_string_size, |
3126 | 0 | &utf16_string_index, |
3127 | 0 | (uint64_t) time_elements.tm_mday, |
3128 | 0 | 8, |
3129 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3130 | 0 | error ) != 1 ) |
3131 | 0 | { |
3132 | 0 | libcerror_error_set( |
3133 | 0 | error, |
3134 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3135 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3136 | 0 | "%s: unable to copy day of month to UTF-16 string.", |
3137 | 0 | function ); |
3138 | |
|
3139 | 0 | return( -1 ); |
3140 | 0 | } |
3141 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) ' '; |
3142 | |
|
3143 | 0 | if( libewf_utf16_string_time_copy_from_time_elements( |
3144 | 0 | utf16_string, |
3145 | 0 | utf16_string_size, |
3146 | 0 | &utf16_string_index, |
3147 | 0 | &time_elements, |
3148 | 0 | error ) != 1 ) |
3149 | 0 | { |
3150 | 0 | libcerror_error_set( |
3151 | 0 | error, |
3152 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3153 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3154 | 0 | "%s: unable to copy time to UTF-16 string.", |
3155 | 0 | function ); |
3156 | |
|
3157 | 0 | return( -1 ); |
3158 | 0 | } |
3159 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) ' '; |
3160 | |
|
3161 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3162 | 0 | utf16_string, |
3163 | 0 | utf16_string_size, |
3164 | 0 | &utf16_string_index, |
3165 | 0 | (uint64_t) time_elements.tm_year + 1900, |
3166 | 0 | 16, |
3167 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3168 | 0 | error ) != 1 ) |
3169 | 0 | { |
3170 | 0 | libcerror_error_set( |
3171 | 0 | error, |
3172 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3173 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3174 | 0 | "%s: unable to copy year to UTF-16 string.", |
3175 | 0 | function ); |
3176 | |
|
3177 | 0 | return( -1 ); |
3178 | 0 | } |
3179 | 0 | utf16_string_index--; |
3180 | 0 | } |
3181 | 0 | else if( ( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
3182 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) |
3183 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) ) |
3184 | 0 | { |
3185 | 0 | if( ( time_elements.tm_mon < 0 ) |
3186 | 0 | || ( time_elements.tm_mon > 11 ) ) |
3187 | 0 | { |
3188 | 0 | libcerror_error_set( |
3189 | 0 | error, |
3190 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3191 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
3192 | 0 | "%s: unsupported month.", |
3193 | 0 | function ); |
3194 | |
|
3195 | 0 | return( -1 ); |
3196 | 0 | } |
3197 | 0 | if( ( time_elements.tm_mday < 1 ) |
3198 | 0 | || ( time_elements.tm_mday > 31 ) ) |
3199 | 0 | { |
3200 | 0 | libcerror_error_set( |
3201 | 0 | error, |
3202 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3203 | 0 | LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE, |
3204 | 0 | "%s: unsupported day of month.", |
3205 | 0 | function ); |
3206 | |
|
3207 | 0 | return( -1 ); |
3208 | 0 | } |
3209 | 0 | if( ( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
3210 | 0 | || ( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) ) |
3211 | 0 | { |
3212 | 0 | if( date_format == LIBEWF_DATE_FORMAT_MONTHDAY ) |
3213 | 0 | { |
3214 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
3215 | 0 | { |
3216 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3217 | 0 | } |
3218 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3219 | 0 | utf16_string, |
3220 | 0 | utf16_string_size, |
3221 | 0 | &utf16_string_index, |
3222 | 0 | (uint64_t) time_elements.tm_mon + 1, |
3223 | 0 | 8, |
3224 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3225 | 0 | error ) != 1 ) |
3226 | 0 | { |
3227 | 0 | libcerror_error_set( |
3228 | 0 | error, |
3229 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3230 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3231 | 0 | "%s: unable to copy month to UTF-16 string.", |
3232 | 0 | function ); |
3233 | |
|
3234 | 0 | return( -1 ); |
3235 | 0 | } |
3236 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) '/'; |
3237 | |
|
3238 | 0 | if( time_elements.tm_mday < 10 ) |
3239 | 0 | { |
3240 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3241 | 0 | } |
3242 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3243 | 0 | utf16_string, |
3244 | 0 | utf16_string_size, |
3245 | 0 | &utf16_string_index, |
3246 | 0 | (uint16_t) time_elements.tm_mday, |
3247 | 0 | 8, |
3248 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3249 | 0 | error ) != 1 ) |
3250 | 0 | { |
3251 | 0 | libcerror_error_set( |
3252 | 0 | error, |
3253 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3254 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3255 | 0 | "%s: unable to copy day of month to UTF-16 string.", |
3256 | 0 | function ); |
3257 | |
|
3258 | 0 | return( -1 ); |
3259 | 0 | } |
3260 | 0 | utf16_string_index--; |
3261 | 0 | } |
3262 | 0 | else if( date_format == LIBEWF_DATE_FORMAT_DAYMONTH ) |
3263 | 0 | { |
3264 | 0 | if( time_elements.tm_mday < 10 ) |
3265 | 0 | { |
3266 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3267 | 0 | } |
3268 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3269 | 0 | utf16_string, |
3270 | 0 | utf16_string_size, |
3271 | 0 | &utf16_string_index, |
3272 | 0 | (uint64_t) time_elements.tm_mday, |
3273 | 0 | 8, |
3274 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3275 | 0 | error ) != 1 ) |
3276 | 0 | { |
3277 | 0 | libcerror_error_set( |
3278 | 0 | error, |
3279 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3280 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3281 | 0 | "%s: unable to copy day of month to UTF-16 string.", |
3282 | 0 | function ); |
3283 | |
|
3284 | 0 | return( -1 ); |
3285 | 0 | } |
3286 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) '/'; |
3287 | |
|
3288 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
3289 | 0 | { |
3290 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3291 | 0 | } |
3292 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3293 | 0 | utf16_string, |
3294 | 0 | utf16_string_size, |
3295 | 0 | &utf16_string_index, |
3296 | 0 | (uint64_t) time_elements.tm_mon + 1, |
3297 | 0 | 8, |
3298 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3299 | 0 | error ) != 1 ) |
3300 | 0 | { |
3301 | 0 | libcerror_error_set( |
3302 | 0 | error, |
3303 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3304 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3305 | 0 | "%s: unable to copy month to UTF-16 string.", |
3306 | 0 | function ); |
3307 | |
|
3308 | 0 | return( -1 ); |
3309 | 0 | } |
3310 | 0 | } |
3311 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) '/'; |
3312 | |
|
3313 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3314 | 0 | utf16_string, |
3315 | 0 | utf16_string_size, |
3316 | 0 | &utf16_string_index, |
3317 | 0 | (uint64_t) time_elements.tm_year + 1900, |
3318 | 0 | 16, |
3319 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3320 | 0 | error ) != 1 ) |
3321 | 0 | { |
3322 | 0 | libcerror_error_set( |
3323 | 0 | error, |
3324 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3325 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3326 | 0 | "%s: unable to copy year to UTF-16 string.", |
3327 | 0 | function ); |
3328 | |
|
3329 | 0 | return( -1 ); |
3330 | 0 | } |
3331 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) ' '; |
3332 | 0 | } |
3333 | 0 | else if( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) |
3334 | 0 | { |
3335 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3336 | 0 | utf16_string, |
3337 | 0 | utf16_string_size, |
3338 | 0 | &utf16_string_index, |
3339 | 0 | (uint64_t) time_elements.tm_year + 1900, |
3340 | 0 | 16, |
3341 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3342 | 0 | error ) != 1 ) |
3343 | 0 | { |
3344 | 0 | libcerror_error_set( |
3345 | 0 | error, |
3346 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3347 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3348 | 0 | "%s: unable to copy year to UTF-16 string.", |
3349 | 0 | function ); |
3350 | |
|
3351 | 0 | return( -1 ); |
3352 | 0 | } |
3353 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) '-'; |
3354 | |
|
3355 | 0 | if( ( time_elements.tm_mon + 1 ) < 10 ) |
3356 | 0 | { |
3357 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3358 | 0 | } |
3359 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3360 | 0 | utf16_string, |
3361 | 0 | utf16_string_size, |
3362 | 0 | &utf16_string_index, |
3363 | 0 | (uint64_t) time_elements.tm_mon + 1, |
3364 | 0 | 8, |
3365 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3366 | 0 | error ) != 1 ) |
3367 | 0 | { |
3368 | 0 | libcerror_error_set( |
3369 | 0 | error, |
3370 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3371 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3372 | 0 | "%s: unable to copy month to UTF-16 string.", |
3373 | 0 | function ); |
3374 | |
|
3375 | 0 | return( -1 ); |
3376 | 0 | } |
3377 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) '-'; |
3378 | |
|
3379 | 0 | if( time_elements.tm_mday < 10 ) |
3380 | 0 | { |
3381 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) '0'; |
3382 | 0 | } |
3383 | 0 | if( libfvalue_utf16_string_with_index_copy_from_integer( |
3384 | 0 | utf16_string, |
3385 | 0 | utf16_string_size, |
3386 | 0 | &utf16_string_index, |
3387 | 0 | (uint64_t) time_elements.tm_mday, |
3388 | 0 | 8, |
3389 | 0 | LIBFVALUE_INTEGER_FORMAT_TYPE_DECIMAL_UNSIGNED, |
3390 | 0 | error ) != 1 ) |
3391 | 0 | { |
3392 | 0 | libcerror_error_set( |
3393 | 0 | error, |
3394 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3395 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3396 | 0 | "%s: unable to copy day of month to UTF-16 string.", |
3397 | 0 | function ); |
3398 | |
|
3399 | 0 | return( -1 ); |
3400 | 0 | } |
3401 | 0 | utf16_string[ utf16_string_index - 1 ] = (uint16_t) 'T'; |
3402 | 0 | } |
3403 | 0 | if( libewf_utf16_string_time_copy_from_time_elements( |
3404 | 0 | utf16_string, |
3405 | 0 | utf16_string_size, |
3406 | 0 | &utf16_string_index, |
3407 | 0 | &time_elements, |
3408 | 0 | error ) != 1 ) |
3409 | 0 | { |
3410 | 0 | libcerror_error_set( |
3411 | 0 | error, |
3412 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
3413 | 0 | LIBCERROR_RUNTIME_ERROR_COPY_FAILED, |
3414 | 0 | "%s: unable to copy time to UTF-16 string.", |
3415 | 0 | function ); |
3416 | |
|
3417 | 0 | return( -1 ); |
3418 | 0 | } |
3419 | 0 | } |
3420 | 0 | if( date_format == LIBEWF_DATE_FORMAT_ISO8601 ) |
3421 | 0 | { |
3422 | 0 | if( date_time_values_string_size >= 28 ) |
3423 | 0 | { |
3424 | 0 | if( ( utf16_string_index + 7 ) >= utf16_string_size ) |
3425 | 0 | { |
3426 | 0 | libcerror_error_set( |
3427 | 0 | error, |
3428 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3429 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
3430 | 0 | "%s: UTF-16 string too small.", |
3431 | 0 | function ); |
3432 | |
|
3433 | 0 | return( -1 ); |
3434 | 0 | } |
3435 | 0 | if( ( date_time_values_string[ 20 ] == (uint16_t ) '+' ) |
3436 | 0 | || ( date_time_values_string[ 20 ] == (uint16_t ) '-' ) ) |
3437 | 0 | { |
3438 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 20 ]; |
3439 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 21 ]; |
3440 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 22 ]; |
3441 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 23 ]; |
3442 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 24 ]; |
3443 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 25 ]; |
3444 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ 26 ]; |
3445 | 0 | } |
3446 | 0 | } |
3447 | 0 | } |
3448 | 0 | else if( date_time_values_string_size > 20 ) |
3449 | 0 | { |
3450 | 0 | if( ( utf16_string_index + ( date_time_values_string_size - 20 ) ) >= utf16_string_size ) |
3451 | 0 | { |
3452 | 0 | libcerror_error_set( |
3453 | 0 | error, |
3454 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3455 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
3456 | 0 | "%s: UTF-16 string too small.", |
3457 | 0 | function ); |
3458 | |
|
3459 | 0 | return( -1 ); |
3460 | 0 | } |
3461 | 0 | for( date_time_values_string_index = 19; |
3462 | 0 | date_time_values_string_index < date_time_values_string_size - 1; |
3463 | 0 | date_time_values_string_index++ ) |
3464 | 0 | { |
3465 | 0 | utf16_string[ utf16_string_index++ ] = (uint16_t) date_time_values_string[ date_time_values_string_index ]; |
3466 | 0 | } |
3467 | 0 | } |
3468 | 0 | if( utf16_string_index >= utf16_string_size ) |
3469 | 0 | { |
3470 | 0 | libcerror_error_set( |
3471 | 0 | error, |
3472 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
3473 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
3474 | 0 | "%s: UTF-16 string too small.", |
3475 | 0 | function ); |
3476 | |
|
3477 | 0 | return( -1 ); |
3478 | 0 | } |
3479 | 0 | utf16_string[ utf16_string_index ] = 0; |
3480 | |
|
3481 | 0 | return( 1 ); |
3482 | 0 | } |
3483 | | |