Coverage Report

Created: 2024-02-25 07:19

/src/libewf/libfdatetime/libfdatetime_floatingtime.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Floatingtime functions
3
 *
4
 * Copyright (C) 2009-2024, 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 <byte_stream.h>
24
#include <memory.h>
25
#include <types.h>
26
27
#include "libfdatetime_definitions.h"
28
#include "libfdatetime_date_time_values.h"
29
#include "libfdatetime_floatingtime.h"
30
#include "libfdatetime_libcerror.h"
31
#include "libfdatetime_types.h"
32
33
/* Creates a floatingtime
34
 * Make sure the value floatingtime is referencing, is set to NULL
35
 * Returns 1 if successful or -1 on error
36
 */
37
int libfdatetime_floatingtime_initialize(
38
     libfdatetime_floatingtime_t **floatingtime,
39
     libcerror_error_t **error )
40
0
{
41
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
42
0
  static char *function                                       = "libfdatetime_floatingtime_initialize";
43
44
0
  if( floatingtime == NULL )
45
0
  {
46
0
    libcerror_error_set(
47
0
     error,
48
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
49
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
50
0
     "%s: invalid floatingtime.",
51
0
     function );
52
53
0
    return( -1 );
54
0
  }
55
0
  if( *floatingtime != NULL )
56
0
  {
57
0
    libcerror_error_set(
58
0
     error,
59
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
60
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
61
0
     "%s: invalid floatingtime value already set.",
62
0
     function );
63
64
0
    return( -1 );
65
0
  }
66
0
  internal_floatingtime = memory_allocate_structure(
67
0
                           libfdatetime_internal_floatingtime_t );
68
69
0
  if( internal_floatingtime == NULL )
70
0
  {
71
0
    libcerror_error_set(
72
0
     error,
73
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
74
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
75
0
     "%s: unable to create floatingtime.",
76
0
     function );
77
78
0
    goto on_error;
79
0
  }
80
0
  if( memory_set(
81
0
       internal_floatingtime,
82
0
       0,
83
0
       sizeof( libfdatetime_internal_floatingtime_t ) ) == NULL )
84
0
  {
85
0
    libcerror_error_set(
86
0
     error,
87
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
88
0
     LIBCERROR_MEMORY_ERROR_SET_FAILED,
89
0
     "%s: unable to clear floatingtime.",
90
0
     function );
91
92
0
    goto on_error;
93
0
  }
94
0
  *floatingtime = (libfdatetime_floatingtime_t *) internal_floatingtime;
95
96
0
  return( 1 );
97
98
0
on_error:
99
0
  if( internal_floatingtime != NULL )
100
0
  {
101
0
    memory_free(
102
0
     internal_floatingtime );
103
0
  }
104
0
  return( -1 );
105
0
}
106
107
/* Frees a floatingtime
108
 * Returns 1 if successful or -1 on error
109
 */
110
int libfdatetime_floatingtime_free(
111
     libfdatetime_floatingtime_t **floatingtime,
112
     libcerror_error_t **error )
113
0
{
114
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
115
0
  static char *function                                       = "libfdatetime_floatingtime_free";
116
117
0
  if( floatingtime == NULL )
118
0
  {
119
0
    libcerror_error_set(
120
0
     error,
121
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
122
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
123
0
     "%s: invalid floatingtime.",
124
0
     function );
125
126
0
    return( -1 );
127
0
  }
128
0
  if( *floatingtime != NULL )
129
0
  {
130
0
    internal_floatingtime = (libfdatetime_internal_floatingtime_t *) *floatingtime;
131
0
    *floatingtime         = NULL;
132
133
0
    memory_free(
134
0
     internal_floatingtime );
135
0
  }
136
0
  return( 1 );
137
0
}
138
139
/* Converts a byte stream into a floatingtime
140
 * Returns 1 if successful or -1 on error
141
 */
142
int libfdatetime_floatingtime_copy_from_byte_stream(
143
     libfdatetime_floatingtime_t *floatingtime,
144
     const uint8_t *byte_stream,
145
     size_t byte_stream_size,
146
     int byte_order,
147
     libcerror_error_t **error )
148
0
{
149
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
150
0
  static char *function                                       = "libfdatetime_floatingtime_copy_from_byte_stream";
151
152
0
  if( floatingtime == NULL )
153
0
  {
154
0
    libcerror_error_set(
155
0
     error,
156
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
157
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
158
0
     "%s: invalid floatingtime.",
159
0
     function );
160
161
0
    return( -1 );
162
0
  }
163
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
164
165
0
  if( byte_stream == NULL )
166
0
  {
167
0
    libcerror_error_set(
168
0
     error,
169
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
170
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
171
0
     "%s: invalid byte stream.",
172
0
     function );
173
174
0
    return( -1 );
175
0
  }
176
0
  if( byte_stream_size < 8 )
177
0
  {
178
0
    libcerror_error_set(
179
0
     error,
180
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
181
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
182
0
     "%s: byte stream too small.",
183
0
     function );
184
185
0
    return( -1 );
186
0
  }
187
0
  if( byte_stream_size > (size_t) SSIZE_MAX )
188
0
  {
189
0
    libcerror_error_set(
190
0
     error,
191
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
192
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
193
0
     "%s: byte stream size exceeds maximum.",
194
0
     function );
195
196
0
    return( -1 );
197
0
  }
198
0
  if( ( byte_order != LIBFDATETIME_ENDIAN_BIG )
199
0
   && ( byte_order != LIBFDATETIME_ENDIAN_LITTLE ) )
200
0
  {
201
0
    libcerror_error_set(
202
0
     error,
203
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
204
0
     LIBCERROR_ARGUMENT_ERROR_UNSUPPORTED_VALUE,
205
0
     "%s: unsupported byte order.",
206
0
     function );
207
208
0
    return( -1 );
209
0
  }
210
0
  if( byte_order == LIBFDATETIME_ENDIAN_LITTLE )
211
0
  {
212
0
    byte_stream_copy_to_uint64_little_endian(
213
0
     byte_stream,
214
0
     internal_floatingtime->timestamp.integer );
215
0
  }
216
0
  else if( byte_order == LIBFDATETIME_ENDIAN_BIG )
217
0
  {
218
0
    byte_stream_copy_to_uint64_big_endian(
219
0
     byte_stream,
220
0
     internal_floatingtime->timestamp.integer );
221
0
  }
222
0
  return( 1 );
223
0
}
224
225
/* Converts a 64-bit value into a floatingtime
226
 * Returns 1 if successful or -1 on error
227
 */
228
int libfdatetime_floatingtime_copy_from_64bit(
229
     libfdatetime_floatingtime_t *floatingtime,
230
     uint64_t value_64bit,
231
     libcerror_error_t **error )
232
0
{
233
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
234
0
  static char *function                                       = "libfdatetime_floatingtime_copy_from_64bit";
235
236
0
  if( floatingtime == NULL )
237
0
  {
238
0
    libcerror_error_set(
239
0
     error,
240
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
241
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
242
0
     "%s: invalid floatingtime.",
243
0
     function );
244
245
0
    return( -1 );
246
0
  }
247
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
248
249
0
  internal_floatingtime->timestamp.integer = value_64bit;
250
251
0
  return( 1 );
252
0
}
253
254
/* Converts a floatingtime into a 64-bit value
255
 * Returns 1 if successful or -1 on error
256
 */
257
int libfdatetime_floatingtime_copy_to_64bit(
258
     libfdatetime_floatingtime_t *floatingtime,
259
     uint64_t *value_64bit,
260
     libcerror_error_t **error )
261
0
{
262
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
263
0
  static char *function                                       = "libfdatetime_floatingtime_copy_from_64bit";
264
265
0
  if( floatingtime == NULL )
266
0
  {
267
0
    libcerror_error_set(
268
0
     error,
269
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
270
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
271
0
     "%s: invalid floatingtime.",
272
0
     function );
273
274
0
    return( -1 );
275
0
  }
276
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
277
278
0
  if( value_64bit == NULL )
279
0
  {
280
0
    libcerror_error_set(
281
0
     error,
282
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
283
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
284
0
     "%s: invalid 64-bit value.",
285
0
     function );
286
287
0
    return( -1 );
288
0
  }
289
0
  *value_64bit = internal_floatingtime->timestamp.integer;
290
291
0
  return( 1 );
292
0
}
293
294
/* Converts a floatingtime into date time values
295
 * Returns 1 if successful or -1 on error
296
 */
297
int libfdatetime_internal_floatingtime_copy_to_date_time_values(
298
     libfdatetime_internal_floatingtime_t *internal_floatingtime,
299
     libfdatetime_date_time_values_t *date_time_values,
300
     libcerror_error_t **error )
301
0
{
302
0
  static char *function    = "libfdatetime_internal_floatingtime_copy_to_date_time_values";
303
0
  double floatingtimestamp = 0;
304
0
  uint32_t days_in_century = 0;
305
0
  uint16_t days_in_year    = 0;
306
0
  uint8_t days_in_month    = 0;
307
308
0
  if( internal_floatingtime == NULL )
309
0
  {
310
0
    libcerror_error_set(
311
0
     error,
312
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
313
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
314
0
     "%s: invalid floatingtime.",
315
0
     function );
316
317
0
    return( -1 );
318
0
  }
319
0
  if( date_time_values == NULL )
320
0
  {
321
0
    libcerror_error_set(
322
0
     error,
323
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
324
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
325
0
     "%s: invalid date time values.",
326
0
     function );
327
328
0
    return( -1 );
329
0
  }
330
0
  floatingtimestamp = internal_floatingtime->timestamp.floating_point;
331
332
0
  if( ( floatingtimestamp <= -3650000.0 )
333
0
   || ( floatingtimestamp >= 3650000.0 ) )
334
0
  {
335
0
    libcerror_error_set(
336
0
     error,
337
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
338
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
339
0
     "%s: invalid floatingtime - value out of bounds.",
340
0
     function );
341
342
0
    return( -1 );
343
0
  }
344
  /* Determine the number of years starting at '30 Dec 1899 00:00:00'
345
   * correct the value to days within the year
346
   */
347
0
  date_time_values->year  = 1899;
348
0
  date_time_values->month = 12;
349
0
  date_time_values->day   = 30;
350
351
0
  if( floatingtimestamp >= 2.0 )
352
0
  {
353
0
    date_time_values->year  = 1900;
354
0
    date_time_values->month = 1;
355
0
    date_time_values->day   = 1;
356
357
0
    floatingtimestamp -= 2.0;
358
0
  }
359
0
  while( floatingtimestamp > 0.0 )
360
0
  {
361
0
    if( ( date_time_values->year % 400 ) == 0 )
362
0
    {
363
0
      days_in_century = 36525;
364
0
    }
365
0
    else
366
0
    {
367
0
      days_in_century = 36524;
368
0
    }
369
0
    if( floatingtimestamp <= days_in_century )
370
0
    {
371
0
      break;
372
0
    }
373
0
    floatingtimestamp -= days_in_century;
374
375
0
    date_time_values->year += 100;
376
0
  }
377
0
  while( floatingtimestamp > 0.0 )
378
0
  {
379
    /* Check for a leap year
380
     * The year is ( ( dividable by 4 ) and ( not dividable by 100 ) ) or ( dividable by 400 )
381
     */
382
0
    if( ( ( ( date_time_values->year % 4 ) == 0 )
383
0
      &&  ( ( date_time_values->year % 100 ) != 0 ) )
384
0
     || ( ( date_time_values->year % 400 ) == 0 ) )
385
0
    {
386
0
      days_in_year = 366;
387
0
    }
388
0
    else
389
0
    {
390
0
      days_in_year = 365;
391
0
    }
392
0
    if( floatingtimestamp <= days_in_year )
393
0
    {
394
0
      break;
395
0
    }
396
0
    floatingtimestamp -= days_in_year;
397
398
0
    date_time_values->year += 1;
399
0
  }
400
0
  if( date_time_values->year > 9999 )
401
0
  {
402
0
    libcerror_error_set(
403
0
     error,
404
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
405
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
406
0
     "%s: invalid floatingtime - year value out of bounds.",
407
0
     function );
408
409
0
    return( -1 );
410
0
  }
411
  /* Determine the month correct the value to days within the month
412
   */
413
0
  while( floatingtimestamp > 0.0 )
414
0
  {
415
    /* February (2)
416
     */
417
0
    if( date_time_values->month == 2 )
418
0
    {
419
0
      if( ( ( ( date_time_values->year % 4 ) == 0 )
420
0
        &&  ( ( date_time_values->year % 100 ) != 0 ) )
421
0
       || ( ( date_time_values->year % 400 ) == 0 ) )
422
0
      {
423
0
        days_in_month = 29;
424
0
      }
425
0
      else
426
0
      {
427
0
        days_in_month = 28;
428
0
      }
429
0
    }
430
    /* April (4), June (6), September (9), November (11)
431
     */
432
0
    else if( ( date_time_values->month == 4 )
433
0
          || ( date_time_values->month == 6 )
434
0
          || ( date_time_values->month == 9 )
435
0
          || ( date_time_values->month == 11 ) )
436
0
    {
437
0
      days_in_month = 30;
438
0
    }
439
    /* January (1), March (3), May (5), July (7), August (8), October (10), December (12)
440
     */
441
0
    else if( ( date_time_values->month == 1 )
442
0
          || ( date_time_values->month == 3 )
443
0
          || ( date_time_values->month == 5 )
444
0
          || ( date_time_values->month == 7 )
445
0
          || ( date_time_values->month == 8 )
446
0
          || ( date_time_values->month == 10 )
447
0
          || ( date_time_values->month == 12 ) )
448
0
    {
449
0
      days_in_month = 31;
450
0
    }
451
    /* This should never happen, but just in case
452
     */
453
0
    else
454
0
    {
455
0
      libcerror_error_set(
456
0
       error,
457
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
458
0
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
459
0
       "%s: unsupported month: %d.",
460
0
       function,
461
0
       date_time_values->month );
462
463
0
      return( -1 );
464
0
    }
465
0
    if( floatingtimestamp <= days_in_month )
466
0
    {
467
0
      break;
468
0
    }
469
0
    floatingtimestamp -= days_in_month;
470
471
0
    date_time_values->month += 1;
472
0
  }
473
  /* Determine the day
474
   */
475
0
  date_time_values->day += (uint8_t) floatingtimestamp;
476
0
  floatingtimestamp     -= (int) floatingtimestamp;
477
478
  /* There are 24 hours in a day correct the value to hours
479
   */
480
0
  floatingtimestamp      *= 24.0;
481
0
  date_time_values->hours = (uint8_t) floatingtimestamp;
482
0
  floatingtimestamp      -= date_time_values->hours;
483
484
  /* There are 60 minutes in an hour correct the value to minutes
485
   */
486
0
  floatingtimestamp        *= 60.0;
487
0
  date_time_values->minutes = (uint8_t) floatingtimestamp;
488
0
  floatingtimestamp        -= date_time_values->minutes;
489
490
  /* There are 60 seconds in a minute correct the value to seconds
491
   */
492
0
  floatingtimestamp        *= 60.0;
493
0
  date_time_values->seconds = (uint8_t) floatingtimestamp;
494
0
  floatingtimestamp        -= date_time_values->seconds;
495
496
  /* There are 1000 milli seconds in a seconds correct the value to milli seconds
497
   */
498
0
  floatingtimestamp              *= 1000.0;
499
0
  date_time_values->milli_seconds = (uint8_t) floatingtimestamp;
500
0
  floatingtimestamp              -= date_time_values->milli_seconds;
501
502
  /* There are 1000 micro seconds in a seconds correct the value to micro seconds
503
   */
504
0
  floatingtimestamp              *= 1000.0;
505
0
  date_time_values->micro_seconds = (uint8_t) floatingtimestamp;
506
0
  floatingtimestamp              -= date_time_values->micro_seconds;
507
508
  /* There are 1000 nano seconds in a seconds correct the value to nano seconds
509
   */
510
0
  floatingtimestamp             *= 1000.0;
511
0
  date_time_values->nano_seconds = (uint8_t) floatingtimestamp;
512
513
0
  return( 1 );
514
0
}
515
516
/* Deterimes the size of the string for the floatingtime
517
 * The string size includes the end of string character
518
 * Returns 1 if successful or -1 on error
519
 */
520
int libfdatetime_floatingtime_get_string_size(
521
     libfdatetime_floatingtime_t *floatingtime,
522
     size_t *string_size,
523
     uint32_t string_format_flags,
524
     libcerror_error_t **error )
525
0
{
526
0
  libfdatetime_date_time_values_t date_time_values;
527
528
0
  static char *function = "libfdatetime_floatingtime_get_string_size";
529
0
  int result            = 0;
530
531
0
  if( floatingtime == NULL )
532
0
  {
533
0
    libcerror_error_set(
534
0
     error,
535
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
536
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
537
0
     "%s: invalid floatingtime.",
538
0
     function );
539
540
0
    return( -1 );
541
0
  }
542
0
  if( string_size == NULL )
543
0
  {
544
0
    libcerror_error_set(
545
0
     error,
546
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
547
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
548
0
     "%s: invalid string size.",
549
0
     function );
550
551
0
    return( -1 );
552
0
  }
553
0
  result = libfdatetime_internal_floatingtime_copy_to_date_time_values(
554
0
            (libfdatetime_internal_floatingtime_t *) floatingtime,
555
0
            &date_time_values,
556
0
            error );
557
558
0
  if( result != 1 )
559
0
  {
560
#if defined( HAVE_DEBUG_OUTPUT )
561
    libcerror_error_set(
562
     error,
563
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
564
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
565
     "%s: unable to set date time values.",
566
     function );
567
568
/* TODO debug print error */
569
570
#endif /* defined( HAVE_DEBUG_OUTPUT ) */
571
572
0
    if( ( error != NULL )
573
0
     && ( *error != NULL ) )
574
0
    {
575
0
      libcerror_error_free(
576
0
       error );
577
0
    }
578
0
  }
579
0
  else
580
0
  {
581
0
    result = libfdatetime_date_time_values_get_string_size(
582
0
              &date_time_values,
583
0
              string_size,
584
0
              string_format_flags,
585
0
              error );
586
587
0
    if( result == -1 )
588
0
    {
589
0
      libcerror_error_set(
590
0
       error,
591
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
592
0
       LIBCERROR_RUNTIME_ERROR_GET_FAILED,
593
0
       "%s: unable to get string size.",
594
0
       function );
595
596
0
      return( -1 );
597
0
    }
598
0
  }
599
0
  if( result != 1 )
600
0
  {
601
    /* Make sure the string can hold the hexadecimal representation of the floatingtime
602
     */
603
0
    *string_size = 21;
604
0
  }
605
0
  return( 1 );
606
0
}
607
608
/* Converts the floatingtime into an UTF-8 string in hexadecimal representation
609
 * The string size should include the end of string character
610
 * Returns 1 if successful or -1 on error
611
 */
612
int libfdatetime_internal_floatingtime_copy_to_utf8_string_in_hexadecimal(
613
     libfdatetime_internal_floatingtime_t *internal_floatingtime,
614
     uint8_t *utf8_string,
615
     size_t utf8_string_size,
616
     size_t *utf8_string_index,
617
     libcerror_error_t **error )
618
0
{
619
0
  static char *function = "libfdatetime_internal_floatingtime_copy_to_utf8_string_in_hexadecimal";
620
0
  size_t string_index   = 0;
621
0
  uint8_t byte_value    = 0;
622
0
  int8_t byte_shift     = 0;
623
624
0
  if( internal_floatingtime == NULL )
625
0
  {
626
0
    libcerror_error_set(
627
0
     error,
628
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
629
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
630
0
     "%s: invalid floatingtime.",
631
0
     function );
632
633
0
    return( -1 );
634
0
  }
635
0
  if( utf8_string == NULL )
636
0
  {
637
0
    libcerror_error_set(
638
0
     error,
639
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
640
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
641
0
     "%s: invalid UTF-8 string.",
642
0
     function );
643
644
0
    return( -1 );
645
0
  }
646
0
  if( utf8_string_size > (size_t) SSIZE_MAX )
647
0
  {
648
0
    libcerror_error_set(
649
0
     error,
650
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
651
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
652
0
     "%s: invalid UTF-8 string size value exceeds maximum.",
653
0
     function );
654
655
0
    return( -1 );
656
0
  }
657
0
  if( utf8_string_index == NULL )
658
0
  {
659
0
    libcerror_error_set(
660
0
     error,
661
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
662
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
663
0
     "%s: invalid UTF-8 string index.",
664
0
     function );
665
666
0
    return( -1 );
667
0
  }
668
0
  if( ( utf8_string_size < 21 )
669
0
   || ( *utf8_string_index > ( utf8_string_size - 21 ) ) )
670
0
  {
671
0
    libcerror_error_set(
672
0
     error,
673
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
674
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
675
0
     "%s: UTF-8 string is too small.",
676
0
     function );
677
678
0
    return( -1 );
679
0
  }
680
0
  string_index = *utf8_string_index;
681
682
0
  utf8_string[ string_index++ ] = (uint8_t) '(';
683
0
  utf8_string[ string_index++ ] = (uint8_t) '0';
684
0
  utf8_string[ string_index++ ] = (uint8_t) 'x';
685
686
0
  byte_shift = 60;
687
688
0
  do
689
0
  {
690
0
    byte_value = ( internal_floatingtime->timestamp.integer >> byte_shift ) & 0x0f;
691
692
0
    if( byte_value <= 9 )
693
0
    {
694
0
      utf8_string[ string_index++ ] = (uint8_t) '0' + byte_value;
695
0
    }
696
0
    else
697
0
    {
698
0
      utf8_string[ string_index++ ] = (uint8_t) 'a' + byte_value - 10;
699
0
    }
700
0
    byte_shift -= 4;
701
0
  }
702
0
  while( byte_shift >= 0 );
703
704
0
  utf8_string[ string_index++ ] = (uint8_t) ')';
705
706
0
  utf8_string[ string_index++ ] = 0;
707
708
0
  *utf8_string_index = string_index;
709
710
0
  return( 1 );
711
0
}
712
713
/* Converts the floatingtime into an UTF-8 string
714
 * The string size should include the end of string character
715
 * Returns 1 if successful or -1 on error
716
 */
717
int libfdatetime_floatingtime_copy_to_utf8_string(
718
     libfdatetime_floatingtime_t *floatingtime,
719
     uint8_t *utf8_string,
720
     size_t utf8_string_size,
721
     uint32_t string_format_flags,
722
     libcerror_error_t **error )
723
0
{
724
0
  static char *function    = "libfdatetime_floatingtime_copy_to_utf8_string";
725
0
  size_t utf8_string_index = 0;
726
727
0
  if( libfdatetime_floatingtime_copy_to_utf8_string_with_index(
728
0
       floatingtime,
729
0
       utf8_string,
730
0
       utf8_string_size,
731
0
       &utf8_string_index,
732
0
       string_format_flags,
733
0
       error ) != 1 )
734
0
  {
735
0
    libcerror_error_set(
736
0
     error,
737
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
738
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
739
0
     "%s: unable to copy floatingtime to UTF-8 string.",
740
0
     function );
741
742
0
    return( -1 );
743
0
  }
744
0
  return( 1 );
745
0
}
746
747
/* Converts the floatingtime into an UTF-8 string
748
 * The string size should include the end of string character
749
 * Returns 1 if successful or -1 on error
750
 */
751
int libfdatetime_floatingtime_copy_to_utf8_string_with_index(
752
     libfdatetime_floatingtime_t *floatingtime,
753
     uint8_t *utf8_string,
754
     size_t utf8_string_size,
755
     size_t *utf8_string_index,
756
     uint32_t string_format_flags,
757
     libcerror_error_t **error )
758
0
{
759
0
  libfdatetime_date_time_values_t date_time_values;
760
761
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
762
0
  static char *function                                       = "libfdatetime_floatingtime_copy_to_utf8_string_with_index";
763
0
  int result                                                  = 0;
764
765
0
  if( floatingtime == NULL )
766
0
  {
767
0
    libcerror_error_set(
768
0
     error,
769
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
770
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
771
0
     "%s: invalid floatingtime.",
772
0
     function );
773
774
0
    return( -1 );
775
0
  }
776
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
777
778
0
  result = libfdatetime_internal_floatingtime_copy_to_date_time_values(
779
0
            internal_floatingtime,
780
0
            &date_time_values,
781
0
            error );
782
783
0
  if( result != 1 )
784
0
  {
785
#if defined( HAVE_DEBUG_OUTPUT )
786
    libcerror_error_set(
787
     error,
788
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
789
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
790
     "%s: unable to set date time values.",
791
     function );
792
793
/* TODO debug print error */
794
795
#endif /* defined( HAVE_DEBUG_OUTPUT ) */
796
797
0
    if( ( error != NULL )
798
0
     && ( *error != NULL ) )
799
0
    {
800
0
      libcerror_error_free(
801
0
       error );
802
0
    }
803
0
  }
804
0
  else
805
0
  {
806
0
    result = libfdatetime_date_time_values_copy_to_utf8_string_with_index(
807
0
              &date_time_values,
808
0
              utf8_string,
809
0
              utf8_string_size,
810
0
              utf8_string_index,
811
0
              string_format_flags,
812
0
              error );
813
814
0
    if( result == -1 )
815
0
    {
816
0
      libcerror_error_set(
817
0
       error,
818
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
819
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
820
0
       "%s: unable to copy date time values to UTF-8 string.",
821
0
       function );
822
823
0
      return( -1 );
824
0
    }
825
0
  }
826
0
  if( result != 1 )
827
0
  {
828
0
    result = libfdatetime_internal_floatingtime_copy_to_utf8_string_in_hexadecimal(
829
0
              internal_floatingtime,
830
0
              utf8_string,
831
0
              utf8_string_size,
832
0
              utf8_string_index,
833
0
              error );
834
835
0
    if( result == -1 )
836
0
    {
837
0
      libcerror_error_set(
838
0
       error,
839
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
840
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
841
0
       "%s: unable to floatingtime to hexadecimal UTF-8 string.",
842
0
       function );
843
844
0
      return( -1 );
845
0
    }
846
0
  }
847
0
  return( 1 );
848
0
}
849
850
/* Converts the floatingtime into an UTF-16 string in hexadecimal representation
851
 * The string size should include the end of string character
852
 * Returns 1 if successful or -1 on error
853
 */
854
int libfdatetime_internal_floatingtime_copy_to_utf16_string_in_hexadecimal(
855
     libfdatetime_internal_floatingtime_t *internal_floatingtime,
856
     uint16_t *utf16_string,
857
     size_t utf16_string_size,
858
     size_t *utf16_string_index,
859
     libcerror_error_t **error )
860
0
{
861
0
  static char *function = "libfdatetime_internal_floatingtime_copy_to_utf16_string_in_hexadecimal";
862
0
  size_t string_index   = 0;
863
0
  uint8_t byte_value    = 0;
864
0
  int8_t byte_shift     = 0;
865
866
0
  if( internal_floatingtime == 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 floatingtime.",
873
0
     function );
874
875
0
    return( -1 );
876
0
  }
877
0
  if( utf16_string == NULL )
878
0
  {
879
0
    libcerror_error_set(
880
0
     error,
881
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
882
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
883
0
     "%s: invalid UTF-16 string.",
884
0
     function );
885
886
0
    return( -1 );
887
0
  }
888
0
  if( utf16_string_size > (size_t) SSIZE_MAX )
889
0
  {
890
0
    libcerror_error_set(
891
0
     error,
892
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
893
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
894
0
     "%s: invalid UTF-16 string size value exceeds maximum.",
895
0
     function );
896
897
0
    return( -1 );
898
0
  }
899
0
  if( utf16_string_index == NULL )
900
0
  {
901
0
    libcerror_error_set(
902
0
     error,
903
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
904
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
905
0
     "%s: invalid UTF-16 string index.",
906
0
     function );
907
908
0
    return( -1 );
909
0
  }
910
0
  if( ( utf16_string_size < 21 )
911
0
   || ( *utf16_string_index > ( utf16_string_size - 21 ) ) )
912
0
  {
913
0
    libcerror_error_set(
914
0
     error,
915
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
916
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
917
0
     "%s: UTF-16 string is too small.",
918
0
     function );
919
920
0
    return( -1 );
921
0
  }
922
0
  string_index = *utf16_string_index;
923
924
0
  utf16_string[ string_index++ ] = (uint16_t) '(';
925
0
  utf16_string[ string_index++ ] = (uint16_t) '0';
926
0
  utf16_string[ string_index++ ] = (uint16_t) 'x';
927
928
0
  byte_shift = 60;
929
930
0
  do
931
0
  {
932
0
    byte_value = ( internal_floatingtime->timestamp.integer >> byte_shift ) & 0x0f;
933
934
0
    if( byte_value <= 9 )
935
0
    {
936
0
      utf16_string[ string_index++ ] = (uint16_t) '0' + byte_value;
937
0
    }
938
0
    else
939
0
    {
940
0
      utf16_string[ string_index++ ] = (uint16_t) 'a' + byte_value - 10;
941
0
    }
942
0
    byte_shift -= 4;
943
0
  }
944
0
  while( byte_shift >= 0 );
945
946
0
  utf16_string[ string_index++ ] = (uint16_t) ')';
947
948
0
  utf16_string[ string_index++ ] = 0;
949
950
0
  *utf16_string_index = string_index;
951
952
0
  return( 1 );
953
0
}
954
955
/* Converts the floatingtime into an UTF-16 string
956
 * The string size should include the end of string character
957
 * Returns 1 if successful or -1 on error
958
 */
959
int libfdatetime_floatingtime_copy_to_utf16_string(
960
     libfdatetime_floatingtime_t *floatingtime,
961
     uint16_t *utf16_string,
962
     size_t utf16_string_size,
963
     uint32_t string_format_flags,
964
     libcerror_error_t **error )
965
0
{
966
0
  static char *function     = "libfdatetime_floatingtime_copy_to_utf16_string";
967
0
  size_t utf16_string_index = 0;
968
969
0
  if( libfdatetime_floatingtime_copy_to_utf16_string_with_index(
970
0
       floatingtime,
971
0
       utf16_string,
972
0
       utf16_string_size,
973
0
       &utf16_string_index,
974
0
       string_format_flags,
975
0
       error ) != 1 )
976
0
  {
977
0
    libcerror_error_set(
978
0
     error,
979
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
980
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
981
0
     "%s: unable to copy floatingtime to UTF-16 string.",
982
0
     function );
983
984
0
    return( -1 );
985
0
  }
986
0
  return( 1 );
987
0
}
988
989
/* Converts the floatingtime into an UTF-16 string
990
 * The string size should include the end of string character
991
 * Returns 1 if successful or -1 on error
992
 */
993
int libfdatetime_floatingtime_copy_to_utf16_string_with_index(
994
     libfdatetime_floatingtime_t *floatingtime,
995
     uint16_t *utf16_string,
996
     size_t utf16_string_size,
997
     size_t *utf16_string_index,
998
     uint32_t string_format_flags,
999
     libcerror_error_t **error )
1000
0
{
1001
0
  libfdatetime_date_time_values_t date_time_values;
1002
1003
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
1004
0
  static char *function                                       = "libfdatetime_floatingtime_copy_to_utf16_string_with_index";
1005
0
  int result                                                  = 0;
1006
1007
0
  if( floatingtime == NULL )
1008
0
  {
1009
0
    libcerror_error_set(
1010
0
     error,
1011
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1012
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1013
0
     "%s: invalid floatingtime.",
1014
0
     function );
1015
1016
0
    return( -1 );
1017
0
  }
1018
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
1019
1020
0
  result = libfdatetime_internal_floatingtime_copy_to_date_time_values(
1021
0
            internal_floatingtime,
1022
0
            &date_time_values,
1023
0
            error );
1024
1025
0
  if( result != 1 )
1026
0
  {
1027
#if defined( HAVE_DEBUG_OUTPUT )
1028
    libcerror_error_set(
1029
     error,
1030
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1031
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1032
     "%s: unable to set date time values.",
1033
     function );
1034
1035
/* TODO debug print error */
1036
1037
#endif /* defined( HAVE_DEBUG_OUTPUT ) */
1038
1039
0
    if( ( error != NULL )
1040
0
     && ( *error != NULL ) )
1041
0
    {
1042
0
      libcerror_error_free(
1043
0
       error );
1044
0
    }
1045
0
  }
1046
0
  else
1047
0
  {
1048
0
    result = libfdatetime_date_time_values_copy_to_utf16_string_with_index(
1049
0
              &date_time_values,
1050
0
              utf16_string,
1051
0
              utf16_string_size,
1052
0
              utf16_string_index,
1053
0
              string_format_flags,
1054
0
              error );
1055
1056
0
    if( result == -1 )
1057
0
    {
1058
0
      libcerror_error_set(
1059
0
       error,
1060
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1061
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1062
0
       "%s: unable to copy date time values to UTF-16 string.",
1063
0
       function );
1064
1065
0
      return( -1 );
1066
0
    }
1067
0
  }
1068
0
  if( result != 1 )
1069
0
  {
1070
0
    result = libfdatetime_internal_floatingtime_copy_to_utf16_string_in_hexadecimal(
1071
0
              internal_floatingtime,
1072
0
              utf16_string,
1073
0
              utf16_string_size,
1074
0
              utf16_string_index,
1075
0
              error );
1076
1077
0
    if( result == -1 )
1078
0
    {
1079
0
      libcerror_error_set(
1080
0
       error,
1081
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1082
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1083
0
       "%s: unable to floatingtime to hexadecimal UTF-16 string.",
1084
0
       function );
1085
1086
0
      return( -1 );
1087
0
    }
1088
0
  }
1089
0
  return( 1 );
1090
0
}
1091
1092
/* Converts the floatingtime into an UTF-32 string in hexadecimal representation
1093
 * The string size should include the end of string character
1094
 * Returns 1 if successful or -1 on error
1095
 */
1096
int libfdatetime_internal_floatingtime_copy_to_utf32_string_in_hexadecimal(
1097
     libfdatetime_internal_floatingtime_t *internal_floatingtime,
1098
     uint32_t *utf32_string,
1099
     size_t utf32_string_size,
1100
     size_t *utf32_string_index,
1101
     libcerror_error_t **error )
1102
0
{
1103
0
  static char *function = "libfdatetime_internal_floatingtime_copy_to_utf32_string_in_hexadecimal";
1104
0
  size_t string_index   = 0;
1105
0
  uint8_t byte_value    = 0;
1106
0
  int8_t byte_shift     = 0;
1107
1108
0
  if( internal_floatingtime == NULL )
1109
0
  {
1110
0
    libcerror_error_set(
1111
0
     error,
1112
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1113
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1114
0
     "%s: invalid floatingtime.",
1115
0
     function );
1116
1117
0
    return( -1 );
1118
0
  }
1119
0
  if( utf32_string == NULL )
1120
0
  {
1121
0
    libcerror_error_set(
1122
0
     error,
1123
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1124
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1125
0
     "%s: invalid UTF-32 string.",
1126
0
     function );
1127
1128
0
    return( -1 );
1129
0
  }
1130
0
  if( utf32_string_size > (size_t) SSIZE_MAX )
1131
0
  {
1132
0
    libcerror_error_set(
1133
0
     error,
1134
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1135
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM,
1136
0
     "%s: invalid UTF-32 string size value exceeds maximum.",
1137
0
     function );
1138
1139
0
    return( -1 );
1140
0
  }
1141
0
  if( utf32_string_index == NULL )
1142
0
  {
1143
0
    libcerror_error_set(
1144
0
     error,
1145
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1146
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1147
0
     "%s: invalid UTF-32 string index.",
1148
0
     function );
1149
1150
0
    return( -1 );
1151
0
  }
1152
0
  if( ( utf32_string_size < 21 )
1153
0
   || ( *utf32_string_index > ( utf32_string_size - 21 ) ) )
1154
0
  {
1155
0
    libcerror_error_set(
1156
0
     error,
1157
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1158
0
     LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL,
1159
0
     "%s: UTF-32 string is too small.",
1160
0
     function );
1161
1162
0
    return( -1 );
1163
0
  }
1164
0
  string_index = *utf32_string_index;
1165
1166
0
  utf32_string[ string_index++ ] = (uint32_t) '(';
1167
0
  utf32_string[ string_index++ ] = (uint32_t) '0';
1168
0
  utf32_string[ string_index++ ] = (uint32_t) 'x';
1169
1170
0
  byte_shift = 60;
1171
1172
0
  do
1173
0
  {
1174
0
    byte_value = ( internal_floatingtime->timestamp.integer >> byte_shift ) & 0x0f;
1175
1176
0
    if( byte_value <= 9 )
1177
0
    {
1178
0
      utf32_string[ string_index++ ] = (uint32_t) '0' + byte_value;
1179
0
    }
1180
0
    else
1181
0
    {
1182
0
      utf32_string[ string_index++ ] = (uint32_t) 'a' + byte_value - 10;
1183
0
    }
1184
0
    byte_shift -= 4;
1185
0
  }
1186
0
  while( byte_shift >= 0 );
1187
1188
0
  utf32_string[ string_index++ ] = (uint32_t) ')';
1189
1190
0
  utf32_string[ string_index++ ] = 0;
1191
1192
0
  *utf32_string_index = string_index;
1193
1194
0
  return( 1 );
1195
0
}
1196
1197
/* Converts the floatingtime into an UTF-32 string
1198
 * The string size should include the end of string character
1199
 * Returns 1 if successful or -1 on error
1200
 */
1201
int libfdatetime_floatingtime_copy_to_utf32_string(
1202
     libfdatetime_floatingtime_t *floatingtime,
1203
     uint32_t *utf32_string,
1204
     size_t utf32_string_size,
1205
     uint32_t string_format_flags,
1206
     libcerror_error_t **error )
1207
0
{
1208
0
  static char *function     = "libfdatetime_floatingtime_copy_to_utf32_string";
1209
0
  size_t utf32_string_index = 0;
1210
1211
0
  if( libfdatetime_floatingtime_copy_to_utf32_string_with_index(
1212
0
       floatingtime,
1213
0
       utf32_string,
1214
0
       utf32_string_size,
1215
0
       &utf32_string_index,
1216
0
       string_format_flags,
1217
0
       error ) != 1 )
1218
0
  {
1219
0
    libcerror_error_set(
1220
0
     error,
1221
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1222
0
     LIBCERROR_RUNTIME_ERROR_COPY_FAILED,
1223
0
     "%s: unable to copy floatingtime to UTF-32 string.",
1224
0
     function );
1225
1226
0
    return( -1 );
1227
0
  }
1228
0
  return( 1 );
1229
0
}
1230
1231
/* Converts the floatingtime into an UTF-32 string
1232
 * The string size should include the end of string character
1233
 * Returns 1 if successful or -1 on error
1234
 */
1235
int libfdatetime_floatingtime_copy_to_utf32_string_with_index(
1236
     libfdatetime_floatingtime_t *floatingtime,
1237
     uint32_t *utf32_string,
1238
     size_t utf32_string_size,
1239
     size_t *utf32_string_index,
1240
     uint32_t string_format_flags,
1241
     libcerror_error_t **error )
1242
0
{
1243
0
  libfdatetime_date_time_values_t date_time_values;
1244
1245
0
  libfdatetime_internal_floatingtime_t *internal_floatingtime = NULL;
1246
0
  static char *function                                       = "libfdatetime_floatingtime_copy_to_utf32_string_with_index";
1247
0
  int result                                                  = 0;
1248
1249
0
  if( floatingtime == NULL )
1250
0
  {
1251
0
    libcerror_error_set(
1252
0
     error,
1253
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1254
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1255
0
     "%s: invalid floatingtime.",
1256
0
     function );
1257
1258
0
    return( -1 );
1259
0
  }
1260
0
  internal_floatingtime = (libfdatetime_internal_floatingtime_t *) floatingtime;
1261
1262
0
  result = libfdatetime_internal_floatingtime_copy_to_date_time_values(
1263
0
            internal_floatingtime,
1264
0
            &date_time_values,
1265
0
            error );
1266
1267
0
  if( result != 1 )
1268
0
  {
1269
#if defined( HAVE_DEBUG_OUTPUT )
1270
    libcerror_error_set(
1271
     error,
1272
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1273
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1274
     "%s: unable to set date time values.",
1275
     function );
1276
1277
/* TODO debug print error */
1278
1279
#endif /* defined( HAVE_DEBUG_OUTPUT ) */
1280
1281
0
    if( ( error != NULL )
1282
0
     && ( *error != NULL ) )
1283
0
    {
1284
0
      libcerror_error_free(
1285
0
       error );
1286
0
    }
1287
0
  }
1288
0
  else
1289
0
  {
1290
0
    result = libfdatetime_date_time_values_copy_to_utf32_string_with_index(
1291
0
              &date_time_values,
1292
0
              utf32_string,
1293
0
              utf32_string_size,
1294
0
              utf32_string_index,
1295
0
              string_format_flags,
1296
0
              error );
1297
1298
0
    if( result == -1 )
1299
0
    {
1300
0
      libcerror_error_set(
1301
0
       error,
1302
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1303
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1304
0
       "%s: unable to copy date time values to UTF-32 string.",
1305
0
       function );
1306
1307
0
      return( -1 );
1308
0
    }
1309
0
  }
1310
0
  if( result != 1 )
1311
0
  {
1312
0
    result = libfdatetime_internal_floatingtime_copy_to_utf32_string_in_hexadecimal(
1313
0
              internal_floatingtime,
1314
0
              utf32_string,
1315
0
              utf32_string_size,
1316
0
              utf32_string_index,
1317
0
              error );
1318
1319
0
    if( result == -1 )
1320
0
    {
1321
0
      libcerror_error_set(
1322
0
       error,
1323
0
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
1324
0
       LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1325
0
       "%s: unable to floatingtime to hexadecimal UTF-32 string.",
1326
0
       function );
1327
1328
0
      return( -1 );
1329
0
    }
1330
0
  }
1331
0
  return( 1 );
1332
0
}
1333