Coverage Report

Created: 2024-06-12 07:07

/src/libfmapi/libfmapi/libfmapi_one_off_entry_identifier.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * One-off entry identifier 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 "libfmapi_definitions.h"
28
#include "libfmapi_libcerror.h"
29
#include "libfmapi_libcnotify.h"
30
#include "libfmapi_libuna.h"
31
#include "libfmapi_one_off_entry_identifier.h"
32
33
/* Creates an one-off entry identifier
34
 * Make sure the value entry_identifier is referencing, is set to NULL
35
 * Returns 1 if successful or -1 on error
36
 */
37
int libfmapi_one_off_entry_identifier_initialize(
38
     libfmapi_one_off_entry_identifier_t **entry_identifier,
39
     libcerror_error_t **error )
40
572
{
41
572
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
42
572
  static char *function                                                   = "libfmapi_one_off_entry_identifier_initialize";
43
44
572
  if( entry_identifier == 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 entry identifier.",
51
0
     function );
52
53
0
    return( -1 );
54
0
  }
55
572
  if( *entry_identifier != 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 entry identifier value already set.",
62
0
     function );
63
64
0
    return( -1 );
65
0
  }
66
572
  internal_entry_identifier = memory_allocate_structure(
67
572
                               libfmapi_internal_one_off_entry_identifier_t );
68
69
572
  if( internal_entry_identifier == 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 entry identifier.",
76
0
     function );
77
78
0
    goto on_error;
79
0
  }
80
572
  if( memory_set(
81
572
       internal_entry_identifier,
82
572
       0,
83
572
       sizeof( libfmapi_internal_one_off_entry_identifier_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 entry identifier.",
90
0
     function );
91
92
0
    goto on_error;
93
0
  }
94
572
  *entry_identifier = (libfmapi_one_off_entry_identifier_t *) internal_entry_identifier;
95
96
572
  return( 1 );
97
98
0
on_error:
99
0
  if( internal_entry_identifier != NULL )
100
0
  {
101
0
    memory_free(
102
0
     internal_entry_identifier );
103
0
  }
104
0
  return( -1 );
105
572
}
106
107
/* Frees an one-off entry identifier
108
 * Returns 1 if successful or -1 on error
109
 */
110
int libfmapi_one_off_entry_identifier_free(
111
     libfmapi_one_off_entry_identifier_t **entry_identifier,
112
     libcerror_error_t **error )
113
572
{
114
572
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
115
572
  static char *function                                                   = "libfmapi_one_off_entry_identifier_free";
116
117
572
  if( entry_identifier == 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 entry identifier.",
124
0
     function );
125
126
0
    return( -1 );
127
0
  }
128
572
  if( *entry_identifier != NULL )
129
572
  {
130
572
    internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) *entry_identifier;
131
572
    *entry_identifier         = NULL;
132
133
572
    if( internal_entry_identifier->display_name != NULL )
134
143
    {
135
143
      memory_free(
136
143
       internal_entry_identifier->display_name );
137
143
    }
138
572
    if( internal_entry_identifier->address_type != NULL )
139
143
    {
140
143
      memory_free(
141
143
       internal_entry_identifier->address_type );
142
143
    }
143
572
    if( internal_entry_identifier->email_address != NULL )
144
143
    {
145
143
      memory_free(
146
143
       internal_entry_identifier->email_address );
147
143
    }
148
572
    memory_free(
149
572
     internal_entry_identifier );
150
572
  }
151
572
  return( 1 );
152
572
}
153
154
/* Converts a byte stream into an one-off entry identifier
155
 * Returns 1 if successful or -1 on error
156
 */
157
int libfmapi_one_off_entry_identifier_copy_from_byte_stream(
158
     libfmapi_one_off_entry_identifier_t *entry_identifier,
159
     const uint8_t *byte_stream,
160
     size_t byte_stream_size,
161
     int ascii_codepage,
162
     libcerror_error_t **error )
163
572
{
164
572
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
165
572
  static char *function                                                   = "libfmapi_one_off_entry_identifier_copy_from_byte_stream";
166
572
  size_t byte_stream_offset                                               = 0;
167
572
  size_t string_size                                                      = 0;
168
572
  uint16_t flags                                                          = 0;
169
572
  uint16_t format_version                                                 = 0;
170
572
  uint16_t supported_flags                                                = 0;
171
172
572
  if( entry_identifier == NULL )
173
0
  {
174
0
    libcerror_error_set(
175
0
     error,
176
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
177
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
178
0
     "%s: invalid entry identifier.",
179
0
     function );
180
181
0
    return( -1 );
182
0
  }
183
572
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
184
185
572
  if( internal_entry_identifier->email_address != NULL )
186
0
  {
187
0
    libcerror_error_set(
188
0
     error,
189
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
190
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
191
0
     "%s: invalid entry identifier - email address value already set.",
192
0
     function );
193
194
0
    return( -1 );
195
0
  }
196
572
  if( internal_entry_identifier->address_type != NULL )
197
0
  {
198
0
    libcerror_error_set(
199
0
     error,
200
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
201
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
202
0
     "%s: invalid entry identifier - address type value already set.",
203
0
     function );
204
205
0
    return( -1 );
206
0
  }
207
572
  if( internal_entry_identifier->display_name != NULL )
208
0
  {
209
0
    libcerror_error_set(
210
0
     error,
211
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
212
0
     LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
213
0
     "%s: invalid entry identifier - display value value already set.",
214
0
     function );
215
216
0
    return( -1 );
217
0
  }
218
572
  if( byte_stream == NULL )
219
0
  {
220
0
    libcerror_error_set(
221
0
     error,
222
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
223
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
224
0
     "%s: invalid byte stream.",
225
0
     function );
226
227
0
    return( -1 );
228
0
  }
229
572
  if( ( byte_stream_size < 4 )
230
572
   || ( byte_stream_size > (size_t) SSIZE_MAX ) )
231
2
  {
232
2
    libcerror_error_set(
233
2
     error,
234
2
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
235
2
     LIBCERROR_ARGUMENT_ERROR_VALUE_OUT_OF_BOUNDS,
236
2
     "%s: invalid byte stream size value out of bounds.",
237
2
     function );
238
239
2
    return( -1 );
240
2
  }
241
#if defined( HAVE_DEBUG_OUTPUT )
242
  if( libcnotify_verbose != 0 )
243
  {
244
    libcnotify_printf(
245
     "%s: one-off entry identifier header data:\n",
246
     function );
247
    libcnotify_print_data(
248
     byte_stream,
249
     4,
250
     0 );
251
  }
252
#endif
253
570
  byte_stream_copy_to_uint16_little_endian(
254
570
   &( byte_stream[ 0 ] ),
255
570
   format_version );
256
257
570
  byte_stream_copy_to_uint16_little_endian(
258
570
   &( byte_stream[ 2 ] ),
259
570
   flags );
260
261
#if defined( HAVE_DEBUG_OUTPUT )
262
  if( libcnotify_verbose != 0 )
263
  {
264
    libcnotify_printf(
265
     "%s: format version\t: %" PRIu16 "\n",
266
     function,
267
     format_version );
268
269
    libcnotify_printf(
270
     "%s: flags\t\t: 0x%04" PRIx16 "\n",
271
     function,
272
     flags );
273
  }
274
#endif
275
570
  byte_stream_offset += 4;
276
277
570
  if( format_version != 0 )
278
19
  {
279
19
    libcerror_error_set(
280
19
     error,
281
19
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
282
19
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
283
19
     "%s: unsupported format version: %" PRIu16 ".",
284
19
     function,
285
19
     format_version );
286
287
19
    goto on_error;
288
19
  }
289
551
  supported_flags = LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_NO_RICH_INFO
290
551
                  | LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_0x1000
291
551
                  | LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE;
292
293
551
  if( ( flags & ~( supported_flags ) ) != 0 )
294
13
  {
295
13
    libcerror_error_set(
296
13
     error,
297
13
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
298
13
     LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
299
13
     "%s: unsupported flags: 0x%04" PRIx16 ".",
300
13
     function,
301
13
     flags );
302
303
13
    goto on_error;
304
13
  }
305
538
  internal_entry_identifier->format_version = format_version;
306
538
  internal_entry_identifier->flags          = flags;
307
538
  internal_entry_identifier->ascii_codepage = ascii_codepage;
308
309
538
  string_size = byte_stream_offset;
310
311
538
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
312
257
  {
313
3.05M
    while( string_size < ( byte_stream_size - 3 ) )
314
3.05M
    {
315
3.05M
      if( ( byte_stream[ string_size ] == 0 )
316
3.05M
       && ( byte_stream[ string_size + 1 ] == 0 ) )
317
179
      {
318
179
        break;
319
179
      }
320
3.05M
      string_size += 2;
321
3.05M
    }
322
257
    if( ( string_size >= ( byte_stream_size - 1 ) )
323
257
     || ( byte_stream[ string_size ] != 0 )
324
257
     || ( byte_stream[ string_size + 1 ] != 0 ) )
325
54
    {
326
54
      libcerror_error_set(
327
54
       error,
328
54
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
329
54
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
330
54
       "%s: unsupported display name value in byte stream.",
331
54
       function );
332
333
54
      goto on_error;
334
54
    }
335
203
    string_size += 2;
336
203
  }
337
281
  else
338
281
  {
339
5.74M
    while( string_size < ( byte_stream_size - 1 ) )
340
5.74M
    {
341
5.74M
      if( byte_stream[ string_size ] == 0 )
342
217
      {
343
217
        break;
344
217
      }
345
5.74M
      string_size += 1;
346
5.74M
    }
347
281
    if( ( string_size >= byte_stream_size )
348
281
     || ( byte_stream[ string_size ] != 0 ) )
349
18
    {
350
18
      libcerror_error_set(
351
18
       error,
352
18
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
353
18
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
354
18
       "%s: unsupported display name value in byte stream.",
355
18
       function );
356
357
18
      return( -1 );
358
18
    }
359
263
    string_size += 1;
360
263
  }
361
466
  string_size -= byte_stream_offset;
362
363
466
  if( ( string_size == 0 )
364
466
   || ( string_size > MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
365
0
  {
366
0
    libcerror_error_set(
367
0
     error,
368
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
369
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
370
0
     "%s: invalid display name size value out of bounds.",
371
0
     function );
372
373
0
    goto on_error;
374
0
  }
375
#if defined( HAVE_DEBUG_OUTPUT )
376
  if( libcnotify_verbose != 0 )
377
  {
378
    libcnotify_printf(
379
     "%s: display name data:\n",
380
     function );
381
    libcnotify_print_data(
382
     &( byte_stream[ byte_stream_offset ] ),
383
     string_size,
384
     0 );
385
  }
386
#endif
387
466
  internal_entry_identifier->display_name = (uint8_t *) memory_allocate(
388
466
                                                         sizeof( uint8_t ) * string_size );
389
390
466
  if( internal_entry_identifier->display_name == NULL )
391
0
  {
392
0
    libcerror_error_set(
393
0
     error,
394
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
395
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
396
0
     "%s: unable to create display name.",
397
0
     function );
398
399
0
    goto on_error;
400
0
  }
401
466
  if( memory_copy(
402
466
       internal_entry_identifier->display_name,
403
466
       &( byte_stream[ byte_stream_offset ] ),
404
466
       string_size ) == NULL )
405
0
  {
406
0
    libcerror_error_set(
407
0
     error,
408
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
409
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
410
0
     "%s: unable to copy display name.",
411
0
     function );
412
413
0
    goto on_error;
414
0
  }
415
466
  internal_entry_identifier->display_name_size = string_size;
416
417
466
  byte_stream_offset += string_size;
418
419
466
  string_size = byte_stream_offset;
420
421
466
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
422
203
  {
423
456k
    while( string_size < ( byte_stream_size - 3 ) )
424
456k
    {
425
456k
      if( ( byte_stream[ string_size ] == 0 )
426
456k
       && ( byte_stream[ string_size + 1 ] == 0 ) )
427
93
      {
428
93
        break;
429
93
      }
430
456k
      string_size += 2;
431
456k
    }
432
203
    if( ( string_size >= ( byte_stream_size - 1 ) )
433
203
     || ( byte_stream[ string_size ] != 0 )
434
203
     || ( byte_stream[ string_size + 1 ] != 0 ) )
435
83
    {
436
83
      libcerror_error_set(
437
83
       error,
438
83
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
439
83
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
440
83
       "%s: unsupported address type value in byte stream.",
441
83
       function );
442
443
83
      goto on_error;
444
83
    }
445
120
    string_size += 2;
446
120
  }
447
263
  else
448
263
  {
449
7.62M
    while( string_size < ( byte_stream_size - 1 ) )
450
7.62M
    {
451
7.62M
      if( byte_stream[ string_size ] == 0 )
452
132
      {
453
132
        break;
454
132
      }
455
7.62M
      string_size += 1;
456
7.62M
    }
457
263
    if( ( string_size >= byte_stream_size )
458
263
     || ( byte_stream[ string_size ] != 0 ) )
459
62
    {
460
62
      libcerror_error_set(
461
62
       error,
462
62
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
463
62
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
464
62
       "%s: unsupported address type value in byte stream.",
465
62
       function );
466
467
62
      goto on_error;
468
62
    }
469
201
    string_size += 1;
470
201
  }
471
321
  string_size -= byte_stream_offset;
472
473
321
  if( ( string_size == 0 )
474
321
   || ( string_size > MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
475
0
  {
476
0
    libcerror_error_set(
477
0
     error,
478
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
479
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
480
0
     "%s: invalid address type size value out of bounds.",
481
0
     function );
482
483
0
    goto on_error;
484
0
  }
485
#if defined( HAVE_DEBUG_OUTPUT )
486
  if( libcnotify_verbose != 0 )
487
  {
488
    libcnotify_printf(
489
     "%s: address type data:\n",
490
     function );
491
    libcnotify_print_data(
492
     &( byte_stream[ byte_stream_offset ] ),
493
     string_size,
494
     0 );
495
  }
496
#endif
497
321
  internal_entry_identifier->address_type = (uint8_t *) memory_allocate(
498
321
                                                         sizeof( uint8_t ) * string_size );
499
500
321
  if( internal_entry_identifier->address_type == NULL )
501
0
  {
502
0
    libcerror_error_set(
503
0
     error,
504
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
505
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
506
0
     "%s: unable to create address type.",
507
0
     function );
508
509
0
    goto on_error;
510
0
  }
511
321
  if( memory_copy(
512
321
       internal_entry_identifier->address_type,
513
321
       &( byte_stream[ byte_stream_offset ] ),
514
321
       string_size ) == NULL )
515
0
  {
516
0
    libcerror_error_set(
517
0
     error,
518
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
519
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
520
0
     "%s: unable to copy address type.",
521
0
     function );
522
523
0
    goto on_error;
524
0
  }
525
321
  internal_entry_identifier->address_type_size = string_size;
526
527
321
  byte_stream_offset += string_size;
528
529
321
  string_size = byte_stream_offset;
530
531
321
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
532
120
  {
533
44.3k
    while( string_size < ( byte_stream_size - 3 ) )
534
44.2k
    {
535
44.2k
      if( ( byte_stream[ string_size ] == 0 )
536
44.2k
       && ( byte_stream[ string_size + 1 ] == 0 ) )
537
23
      {
538
23
        break;
539
23
      }
540
44.1k
      string_size += 2;
541
44.1k
    }
542
120
    if( ( string_size >= ( byte_stream_size - 1 ) )
543
120
     || ( byte_stream[ string_size ] != 0 )
544
120
     || ( byte_stream[ string_size + 1 ] != 0 ) )
545
89
    {
546
89
      libcerror_error_set(
547
89
       error,
548
89
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
549
89
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
550
89
       "%s: unsupported email address value in byte stream.",
551
89
       function );
552
553
89
      goto on_error;
554
89
    }
555
31
    string_size += 2;
556
31
  }
557
201
  else
558
201
  {
559
2.55M
    while( string_size < ( byte_stream_size - 1 ) )
560
2.55M
    {
561
2.55M
      if( byte_stream[ string_size ] == 0 )
562
39
      {
563
39
        break;
564
39
      }
565
2.55M
      string_size += 1;
566
2.55M
    }
567
201
    if( ( string_size >= byte_stream_size )
568
201
     || ( byte_stream[ string_size ] != 0 ) )
569
89
    {
570
89
      libcerror_error_set(
571
89
       error,
572
89
       LIBCERROR_ERROR_DOMAIN_RUNTIME,
573
89
       LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE,
574
89
       "%s: unsupported email address value in byte stream.",
575
89
       function );
576
577
89
      goto on_error;
578
89
    }
579
112
    string_size += 1;
580
112
  }
581
143
  string_size -= byte_stream_offset;
582
583
143
  if( ( string_size == 0 )
584
143
   || ( string_size > MEMORY_MAXIMUM_ALLOCATION_SIZE ) )
585
0
  {
586
0
    libcerror_error_set(
587
0
     error,
588
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
589
0
     LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS,
590
0
     "%s: invalid email address size value out of bounds.",
591
0
     function );
592
593
0
    goto on_error;
594
0
  }
595
#if defined( HAVE_DEBUG_OUTPUT )
596
  if( libcnotify_verbose != 0 )
597
  {
598
    libcnotify_printf(
599
     "%s: email address data:\n",
600
     function );
601
    libcnotify_print_data(
602
     &( byte_stream[ byte_stream_offset ] ),
603
     string_size,
604
     0 );
605
  }
606
#endif
607
143
  internal_entry_identifier->email_address = (uint8_t *) memory_allocate(
608
143
                                                          sizeof( uint8_t ) * string_size );
609
610
143
  if( internal_entry_identifier->email_address == NULL )
611
0
  {
612
0
    libcerror_error_set(
613
0
     error,
614
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
615
0
     LIBCERROR_MEMORY_ERROR_INSUFFICIENT,
616
0
     "%s: unable to create email address.",
617
0
     function );
618
619
0
    goto on_error;
620
0
  }
621
143
  if( memory_copy(
622
143
       internal_entry_identifier->email_address,
623
143
       &( byte_stream[ byte_stream_offset ] ),
624
143
       string_size ) == NULL )
625
0
  {
626
0
    libcerror_error_set(
627
0
     error,
628
0
     LIBCERROR_ERROR_DOMAIN_MEMORY,
629
0
     LIBCERROR_MEMORY_ERROR_COPY_FAILED,
630
0
     "%s: unable to copy email address.",
631
0
     function );
632
633
0
    goto on_error;
634
0
  }
635
143
  internal_entry_identifier->email_address_size = string_size;
636
637
143
  byte_stream_offset += string_size;
638
639
#if defined( HAVE_DEBUG_OUTPUT )
640
  if( libcnotify_verbose != 0 )
641
  {
642
    if( byte_stream_offset < byte_stream_size )
643
    {
644
      libcnotify_printf(
645
       "%s: trailing data:\n",
646
       function );
647
      libcnotify_print_data(
648
       &( byte_stream[ byte_stream_offset ] ),
649
       byte_stream_size - byte_stream_offset,
650
       0 );
651
    }
652
  }
653
#endif
654
143
  return( 1 );
655
656
409
on_error:
657
409
  if( internal_entry_identifier->email_address != NULL )
658
0
  {
659
0
    memory_free(
660
0
     internal_entry_identifier->email_address );
661
662
0
    internal_entry_identifier->email_address = NULL;
663
0
  }
664
409
  if( internal_entry_identifier->address_type != NULL )
665
178
  {
666
178
    memory_free(
667
178
     internal_entry_identifier->address_type );
668
669
178
    internal_entry_identifier->address_type = NULL;
670
178
  }
671
409
  if( internal_entry_identifier->display_name != NULL )
672
323
  {
673
323
    memory_free(
674
323
     internal_entry_identifier->display_name );
675
676
323
    internal_entry_identifier->display_name = NULL;
677
323
  }
678
409
  return( -1 );
679
143
}
680
681
/* Retrieves the format version
682
 * Returns 1 if successful or -1 on error
683
 */
684
int libfmapi_one_off_entry_identifier_get_version(
685
     libfmapi_one_off_entry_identifier_t *entry_identifier,
686
     uint16_t *format_version,
687
     libcerror_error_t **error )
688
0
{
689
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
690
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_version";
691
692
0
  if( entry_identifier == NULL )
693
0
  {
694
0
    libcerror_error_set(
695
0
     error,
696
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
697
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
698
0
     "%s: invalid entry identifier.",
699
0
     function );
700
701
0
    return( -1 );
702
0
  }
703
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
704
705
0
  if( format_version == NULL )
706
0
  {
707
0
    libcerror_error_set(
708
0
     error,
709
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
710
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
711
0
     "%s: invalid format version.",
712
0
     function );
713
714
0
    return( -1 );
715
0
  }
716
0
  *format_version = internal_entry_identifier->format_version;
717
718
0
  return( 1 );
719
0
}
720
721
/* Retrieves the flags
722
 * Returns 1 if successful or -1 on error
723
 */
724
int libfmapi_one_off_entry_identifier_get_flags(
725
     libfmapi_one_off_entry_identifier_t *entry_identifier,
726
     uint16_t *flags,
727
     libcerror_error_t **error )
728
0
{
729
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
730
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_flags";
731
732
0
  if( entry_identifier == NULL )
733
0
  {
734
0
    libcerror_error_set(
735
0
     error,
736
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
737
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
738
0
     "%s: invalid entry identifier.",
739
0
     function );
740
741
0
    return( -1 );
742
0
  }
743
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
744
745
0
  if( flags == NULL )
746
0
  {
747
0
    libcerror_error_set(
748
0
     error,
749
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
750
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
751
0
     "%s: invalid flags.",
752
0
     function );
753
754
0
    return( -1 );
755
0
  }
756
0
  *flags = internal_entry_identifier->flags;
757
758
0
  return( 1 );
759
0
}
760
761
/* Retrieves the UTF-8 string size of the one-off entry identifier display name
762
 * The returned size includes the end of string character
763
 * Returns 1 if successful or -1 on error
764
 */
765
int libfmapi_one_off_entry_identifier_get_utf8_display_name_size(
766
     libfmapi_one_off_entry_identifier_t *entry_identifier,
767
     size_t *utf8_string_size,
768
     libcerror_error_t **error )
769
0
{
770
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
771
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_display_name_size";
772
0
  int result                                                              = 0;
773
774
0
  if( entry_identifier == NULL )
775
0
  {
776
0
    libcerror_error_set(
777
0
     error,
778
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
779
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
780
0
     "%s: invalid entry identifier.",
781
0
     function );
782
783
0
    return( -1 );
784
0
  }
785
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
786
787
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
788
0
  {
789
0
    result = libuna_utf8_string_size_from_utf16_stream(
790
0
        internal_entry_identifier->display_name,
791
0
        internal_entry_identifier->display_name_size,
792
0
        LIBUNA_ENDIAN_LITTLE,
793
0
        utf8_string_size,
794
0
        error );
795
0
  }
796
0
  else
797
0
  {
798
0
    result = libuna_utf8_string_size_from_byte_stream(
799
0
        internal_entry_identifier->display_name,
800
0
        internal_entry_identifier->display_name_size,
801
0
        internal_entry_identifier->ascii_codepage,
802
0
        utf8_string_size,
803
0
        error );
804
0
  }
805
0
  if( result != 1 )
806
0
  {
807
0
    libcerror_error_set(
808
0
     error,
809
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
810
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
811
0
     "%s: unable to retrieve UTF-8 string size.",
812
0
     function );
813
814
0
    return( -1 );
815
0
  }
816
0
  return( 1 );
817
0
}
818
819
/* Retrieves the UTF-8 string of the one-off entry identifier display name
820
 * The size should include the end of string character
821
 * Returns 1 if successful or -1 on error
822
 */
823
int libfmapi_one_off_entry_identifier_get_utf8_display_name(
824
     libfmapi_one_off_entry_identifier_t *entry_identifier,
825
     uint8_t *utf8_string,
826
     size_t utf8_string_size,
827
     libcerror_error_t **error )
828
0
{
829
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
830
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_display_name";
831
0
  int result                                                              = 0;
832
833
0
  if( entry_identifier == NULL )
834
0
  {
835
0
    libcerror_error_set(
836
0
     error,
837
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
838
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
839
0
     "%s: invalid entry identifier.",
840
0
     function );
841
842
0
    return( -1 );
843
0
  }
844
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
845
846
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
847
0
  {
848
0
    result = libuna_utf8_string_copy_from_utf16_stream(
849
0
        utf8_string,
850
0
        utf8_string_size,
851
0
        internal_entry_identifier->display_name,
852
0
        internal_entry_identifier->display_name_size,
853
0
        LIBUNA_ENDIAN_LITTLE,
854
0
        error );
855
0
  }
856
0
  else
857
0
  {
858
0
    result = libuna_utf8_string_copy_from_byte_stream(
859
0
        utf8_string,
860
0
        utf8_string_size,
861
0
        internal_entry_identifier->display_name,
862
0
        internal_entry_identifier->display_name_size,
863
0
        internal_entry_identifier->ascii_codepage,
864
0
        error );
865
0
  }
866
0
  if( result != 1 )
867
0
  {
868
0
    libcerror_error_set(
869
0
     error,
870
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
871
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
872
0
     "%s: unable to set UTF-8 string.",
873
0
     function );
874
875
0
    return( -1 );
876
0
  }
877
0
  return( 1 );
878
0
}
879
880
/* Retrieves the UTF-16 string size of the one-off entry identifier display name
881
 * The returned size includes the end of string character
882
 * Returns 1 if successful or -1 on error
883
 */
884
int libfmapi_one_off_entry_identifier_get_utf16_display_name_size(
885
     libfmapi_one_off_entry_identifier_t *entry_identifier,
886
     size_t *utf16_string_size,
887
     libcerror_error_t **error )
888
0
{
889
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
890
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_display_name_size";
891
0
  int result                                                              = 0;
892
893
0
  if( entry_identifier == NULL )
894
0
  {
895
0
    libcerror_error_set(
896
0
     error,
897
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
898
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
899
0
     "%s: invalid entry identifier.",
900
0
     function );
901
902
0
    return( -1 );
903
0
  }
904
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
905
906
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
907
0
  {
908
0
    result = libuna_utf16_string_size_from_utf16_stream(
909
0
        internal_entry_identifier->display_name,
910
0
        internal_entry_identifier->display_name_size,
911
0
        LIBUNA_ENDIAN_LITTLE,
912
0
        utf16_string_size,
913
0
        error );
914
0
  }
915
0
  else
916
0
  {
917
0
    result = libuna_utf16_string_size_from_byte_stream(
918
0
        internal_entry_identifier->display_name,
919
0
        internal_entry_identifier->display_name_size,
920
0
        internal_entry_identifier->ascii_codepage,
921
0
        utf16_string_size,
922
0
        error );
923
0
  }
924
0
  if( result != 1 )
925
0
  {
926
0
    libcerror_error_set(
927
0
     error,
928
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
929
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
930
0
     "%s: unable to retrieve UTF-16 string size.",
931
0
     function );
932
933
0
    return( -1 );
934
0
  }
935
0
  return( 1 );
936
0
}
937
938
/* Retrieves the UTF-16 string of the one-off entry identifier display name
939
 * The size should include the end of string character
940
 * Returns 1 if successful or -1 on error
941
 */
942
int libfmapi_one_off_entry_identifier_get_utf16_display_name(
943
     libfmapi_one_off_entry_identifier_t *entry_identifier,
944
     uint16_t *utf16_string,
945
     size_t utf16_string_size,
946
     libcerror_error_t **error )
947
0
{
948
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
949
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_display_name";
950
0
  int result                                                              = 0;
951
952
0
  if( entry_identifier == NULL )
953
0
  {
954
0
    libcerror_error_set(
955
0
     error,
956
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
957
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
958
0
     "%s: invalid entry identifier.",
959
0
     function );
960
961
0
    return( -1 );
962
0
  }
963
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
964
965
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
966
0
  {
967
0
    result = libuna_utf16_string_copy_from_utf16_stream(
968
0
        utf16_string,
969
0
        utf16_string_size,
970
0
        internal_entry_identifier->display_name,
971
0
        internal_entry_identifier->display_name_size,
972
0
        LIBUNA_ENDIAN_LITTLE,
973
0
        error );
974
0
  }
975
0
  else
976
0
  {
977
0
    result = libuna_utf16_string_copy_from_byte_stream(
978
0
        utf16_string,
979
0
        utf16_string_size,
980
0
        internal_entry_identifier->display_name,
981
0
        internal_entry_identifier->display_name_size,
982
0
        internal_entry_identifier->ascii_codepage,
983
0
        error );
984
0
  }
985
0
  if( result != 1 )
986
0
  {
987
0
    libcerror_error_set(
988
0
     error,
989
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
990
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
991
0
     "%s: unable to set UTF-16 string.",
992
0
     function );
993
994
0
    return( -1 );
995
0
  }
996
0
  return( 1 );
997
0
}
998
999
/* Retrieves the UTF-8 string size of the one-off entry identifier address type
1000
 * The returned size includes the end of string character
1001
 * Returns 1 if successful or -1 on error
1002
 */
1003
int libfmapi_one_off_entry_identifier_get_utf8_address_type_size(
1004
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1005
     size_t *utf8_string_size,
1006
     libcerror_error_t **error )
1007
0
{
1008
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1009
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_address_type_size";
1010
0
  int result                                                              = 0;
1011
1012
0
  if( entry_identifier == NULL )
1013
0
  {
1014
0
    libcerror_error_set(
1015
0
     error,
1016
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1017
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1018
0
     "%s: invalid entry identifier.",
1019
0
     function );
1020
1021
0
    return( -1 );
1022
0
  }
1023
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1024
1025
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1026
0
  {
1027
0
    result = libuna_utf8_string_size_from_utf16_stream(
1028
0
        internal_entry_identifier->address_type,
1029
0
        internal_entry_identifier->address_type_size,
1030
0
        LIBUNA_ENDIAN_LITTLE,
1031
0
        utf8_string_size,
1032
0
        error );
1033
0
  }
1034
0
  else
1035
0
  {
1036
0
    result = libuna_utf8_string_size_from_byte_stream(
1037
0
        internal_entry_identifier->address_type,
1038
0
        internal_entry_identifier->address_type_size,
1039
0
        internal_entry_identifier->ascii_codepage,
1040
0
        utf8_string_size,
1041
0
        error );
1042
0
  }
1043
0
  if( result != 1 )
1044
0
  {
1045
0
    libcerror_error_set(
1046
0
     error,
1047
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1048
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1049
0
     "%s: unable to retrieve UTF-8 string size.",
1050
0
     function );
1051
1052
0
    return( -1 );
1053
0
  }
1054
0
  return( 1 );
1055
0
}
1056
1057
/* Retrieves the UTF-8 string of the one-off entry identifier address type
1058
 * The size should include the end of string character
1059
 * Returns 1 if successful or -1 on error
1060
 */
1061
int libfmapi_one_off_entry_identifier_get_utf8_address_type(
1062
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1063
     uint8_t *utf8_string,
1064
     size_t utf8_string_size,
1065
     libcerror_error_t **error )
1066
0
{
1067
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1068
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_address_type";
1069
0
  int result                                                              = 0;
1070
1071
0
  if( entry_identifier == NULL )
1072
0
  {
1073
0
    libcerror_error_set(
1074
0
     error,
1075
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1076
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1077
0
     "%s: invalid entry identifier.",
1078
0
     function );
1079
1080
0
    return( -1 );
1081
0
  }
1082
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1083
1084
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1085
0
  {
1086
0
    result = libuna_utf8_string_copy_from_utf16_stream(
1087
0
        utf8_string,
1088
0
        utf8_string_size,
1089
0
        internal_entry_identifier->address_type,
1090
0
        internal_entry_identifier->address_type_size,
1091
0
        LIBUNA_ENDIAN_LITTLE,
1092
0
        error );
1093
0
  }
1094
0
  else
1095
0
  {
1096
0
    result = libuna_utf8_string_copy_from_byte_stream(
1097
0
        utf8_string,
1098
0
        utf8_string_size,
1099
0
        internal_entry_identifier->address_type,
1100
0
        internal_entry_identifier->address_type_size,
1101
0
        internal_entry_identifier->ascii_codepage,
1102
0
        error );
1103
0
  }
1104
0
  if( result != 1 )
1105
0
  {
1106
0
    libcerror_error_set(
1107
0
     error,
1108
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1109
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1110
0
     "%s: unable to set UTF-8 string.",
1111
0
     function );
1112
1113
0
    return( -1 );
1114
0
  }
1115
0
  return( 1 );
1116
0
}
1117
1118
/* Retrieves the UTF-16 string size of the one-off entry identifier address type
1119
 * The returned size includes the end of string character
1120
 * Returns 1 if successful or -1 on error
1121
 */
1122
int libfmapi_one_off_entry_identifier_get_utf16_address_type_size(
1123
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1124
     size_t *utf16_string_size,
1125
     libcerror_error_t **error )
1126
0
{
1127
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1128
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_address_type_size";
1129
0
  int result                                                              = 0;
1130
1131
0
  if( entry_identifier == NULL )
1132
0
  {
1133
0
    libcerror_error_set(
1134
0
     error,
1135
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1136
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1137
0
     "%s: invalid entry identifier.",
1138
0
     function );
1139
1140
0
    return( -1 );
1141
0
  }
1142
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1143
1144
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1145
0
  {
1146
0
    result = libuna_utf16_string_size_from_utf16_stream(
1147
0
        internal_entry_identifier->address_type,
1148
0
        internal_entry_identifier->address_type_size,
1149
0
        LIBUNA_ENDIAN_LITTLE,
1150
0
        utf16_string_size,
1151
0
        error );
1152
0
  }
1153
0
  else
1154
0
  {
1155
0
    result = libuna_utf16_string_size_from_byte_stream(
1156
0
        internal_entry_identifier->address_type,
1157
0
        internal_entry_identifier->address_type_size,
1158
0
        internal_entry_identifier->ascii_codepage,
1159
0
        utf16_string_size,
1160
0
        error );
1161
0
  }
1162
0
  if( result != 1 )
1163
0
  {
1164
0
    libcerror_error_set(
1165
0
     error,
1166
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1167
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1168
0
     "%s: unable to retrieve UTF-16 string size.",
1169
0
     function );
1170
1171
0
    return( -1 );
1172
0
  }
1173
0
  return( 1 );
1174
0
}
1175
1176
/* Retrieves the UTF-16 string of the one-off entry identifier address type
1177
 * The size should include the end of string character
1178
 * Returns 1 if successful or -1 on error
1179
 */
1180
int libfmapi_one_off_entry_identifier_get_utf16_address_type(
1181
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1182
     uint16_t *utf16_string,
1183
     size_t utf16_string_size,
1184
     libcerror_error_t **error )
1185
0
{
1186
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1187
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_address_type";
1188
0
  int result                                                              = 0;
1189
1190
0
  if( entry_identifier == NULL )
1191
0
  {
1192
0
    libcerror_error_set(
1193
0
     error,
1194
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1195
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1196
0
     "%s: invalid entry identifier.",
1197
0
     function );
1198
1199
0
    return( -1 );
1200
0
  }
1201
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1202
1203
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1204
0
  {
1205
0
    result = libuna_utf16_string_copy_from_utf16_stream(
1206
0
        utf16_string,
1207
0
        utf16_string_size,
1208
0
        internal_entry_identifier->address_type,
1209
0
        internal_entry_identifier->address_type_size,
1210
0
        LIBUNA_ENDIAN_LITTLE,
1211
0
        error );
1212
0
  }
1213
0
  else
1214
0
  {
1215
0
    result = libuna_utf16_string_copy_from_byte_stream(
1216
0
        utf16_string,
1217
0
        utf16_string_size,
1218
0
        internal_entry_identifier->address_type,
1219
0
        internal_entry_identifier->address_type_size,
1220
0
        internal_entry_identifier->ascii_codepage,
1221
0
        error );
1222
0
  }
1223
0
  if( result != 1 )
1224
0
  {
1225
0
    libcerror_error_set(
1226
0
     error,
1227
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1228
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1229
0
     "%s: unable to set UTF-16 string.",
1230
0
     function );
1231
1232
0
    return( -1 );
1233
0
  }
1234
0
  return( 1 );
1235
0
}
1236
1237
/* Retrieves the UTF-8 string size of the one-off entry identifier email address
1238
 * The returned size includes the end of string character
1239
 * Returns 1 if successful or -1 on error
1240
 */
1241
int libfmapi_one_off_entry_identifier_get_utf8_email_address_size(
1242
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1243
     size_t *utf8_string_size,
1244
     libcerror_error_t **error )
1245
0
{
1246
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1247
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_email_address_size";
1248
0
  int result                                                              = 0;
1249
1250
0
  if( entry_identifier == NULL )
1251
0
  {
1252
0
    libcerror_error_set(
1253
0
     error,
1254
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1255
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1256
0
     "%s: invalid entry identifier.",
1257
0
     function );
1258
1259
0
    return( -1 );
1260
0
  }
1261
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1262
1263
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1264
0
  {
1265
0
    result = libuna_utf8_string_size_from_utf16_stream(
1266
0
        internal_entry_identifier->email_address,
1267
0
        internal_entry_identifier->email_address_size,
1268
0
        LIBUNA_ENDIAN_LITTLE,
1269
0
        utf8_string_size,
1270
0
        error );
1271
0
  }
1272
0
  else
1273
0
  {
1274
0
    result = libuna_utf8_string_size_from_byte_stream(
1275
0
        internal_entry_identifier->email_address,
1276
0
        internal_entry_identifier->email_address_size,
1277
0
        internal_entry_identifier->ascii_codepage,
1278
0
        utf8_string_size,
1279
0
        error );
1280
0
  }
1281
0
  if( result != 1 )
1282
0
  {
1283
0
    libcerror_error_set(
1284
0
     error,
1285
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1286
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1287
0
     "%s: unable to retrieve UTF-8 string size.",
1288
0
     function );
1289
1290
0
    return( -1 );
1291
0
  }
1292
0
  return( 1 );
1293
0
}
1294
1295
/* Retrieves the UTF-8 string of the one-off entry identifier email address
1296
 * The size should include the end of string character
1297
 * Returns 1 if successful or -1 on error
1298
 */
1299
int libfmapi_one_off_entry_identifier_get_utf8_email_address(
1300
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1301
     uint8_t *utf8_string,
1302
     size_t utf8_string_size,
1303
     libcerror_error_t **error )
1304
0
{
1305
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1306
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf8_email_address";
1307
0
  int result                                                              = 0;
1308
1309
0
  if( entry_identifier == NULL )
1310
0
  {
1311
0
    libcerror_error_set(
1312
0
     error,
1313
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1314
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1315
0
     "%s: invalid entry identifier.",
1316
0
     function );
1317
1318
0
    return( -1 );
1319
0
  }
1320
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1321
1322
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1323
0
  {
1324
0
    result = libuna_utf8_string_copy_from_utf16_stream(
1325
0
        utf8_string,
1326
0
        utf8_string_size,
1327
0
        internal_entry_identifier->email_address,
1328
0
        internal_entry_identifier->email_address_size,
1329
0
        LIBUNA_ENDIAN_LITTLE,
1330
0
        error );
1331
0
  }
1332
0
  else
1333
0
  {
1334
0
    result = libuna_utf8_string_copy_from_byte_stream(
1335
0
        utf8_string,
1336
0
        utf8_string_size,
1337
0
        internal_entry_identifier->email_address,
1338
0
        internal_entry_identifier->email_address_size,
1339
0
        internal_entry_identifier->ascii_codepage,
1340
0
        error );
1341
0
  }
1342
0
  if( result != 1 )
1343
0
  {
1344
0
    libcerror_error_set(
1345
0
     error,
1346
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1347
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1348
0
     "%s: unable to set UTF-8 string.",
1349
0
     function );
1350
1351
0
    return( -1 );
1352
0
  }
1353
0
  return( 1 );
1354
0
}
1355
1356
/* Retrieves the UTF-16 string size of the one-off entry identifier email address
1357
 * The returned size includes the end of string character
1358
 * Returns 1 if successful or -1 on error
1359
 */
1360
int libfmapi_one_off_entry_identifier_get_utf16_email_address_size(
1361
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1362
     size_t *utf16_string_size,
1363
     libcerror_error_t **error )
1364
0
{
1365
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1366
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_email_address_size";
1367
0
  int result                                                              = 0;
1368
1369
0
  if( entry_identifier == NULL )
1370
0
  {
1371
0
    libcerror_error_set(
1372
0
     error,
1373
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1374
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1375
0
     "%s: invalid entry identifier.",
1376
0
     function );
1377
1378
0
    return( -1 );
1379
0
  }
1380
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1381
1382
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1383
0
  {
1384
0
    result = libuna_utf16_string_size_from_utf16_stream(
1385
0
        internal_entry_identifier->email_address,
1386
0
        internal_entry_identifier->email_address_size,
1387
0
        LIBUNA_ENDIAN_LITTLE,
1388
0
        utf16_string_size,
1389
0
        error );
1390
0
  }
1391
0
  else
1392
0
  {
1393
0
    result = libuna_utf16_string_size_from_byte_stream(
1394
0
        internal_entry_identifier->email_address,
1395
0
        internal_entry_identifier->email_address_size,
1396
0
        internal_entry_identifier->ascii_codepage,
1397
0
        utf16_string_size,
1398
0
        error );
1399
0
  }
1400
0
  if( result != 1 )
1401
0
  {
1402
0
    libcerror_error_set(
1403
0
     error,
1404
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1405
0
     LIBCERROR_RUNTIME_ERROR_GET_FAILED,
1406
0
     "%s: unable to retrieve UTF-16 string size.",
1407
0
     function );
1408
1409
0
    return( -1 );
1410
0
  }
1411
0
  return( 1 );
1412
0
}
1413
1414
/* Retrieves the UTF-16 string of the one-off entry identifier email address
1415
 * The size should include the end of string character
1416
 * Returns 1 if successful or -1 on error
1417
 */
1418
int libfmapi_one_off_entry_identifier_get_utf16_email_address(
1419
     libfmapi_one_off_entry_identifier_t *entry_identifier,
1420
     uint16_t *utf16_string,
1421
     size_t utf16_string_size,
1422
     libcerror_error_t **error )
1423
0
{
1424
0
  libfmapi_internal_one_off_entry_identifier_t *internal_entry_identifier = NULL;
1425
0
  static char *function                                                   = "libfmapi_one_off_entry_identifier_get_utf16_email_address";
1426
0
  int result                                                              = 0;
1427
1428
0
  if( entry_identifier == NULL )
1429
0
  {
1430
0
    libcerror_error_set(
1431
0
     error,
1432
0
     LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
1433
0
     LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
1434
0
     "%s: invalid entry identifier.",
1435
0
     function );
1436
1437
0
    return( -1 );
1438
0
  }
1439
0
  internal_entry_identifier = (libfmapi_internal_one_off_entry_identifier_t *) entry_identifier;
1440
1441
0
  if( ( internal_entry_identifier->flags & LIBFMAPI_ONE_OFF_ENTRY_IDENTIFIER_FLAG_UNICODE ) != 0 )
1442
0
  {
1443
0
    result = libuna_utf16_string_copy_from_utf16_stream(
1444
0
        utf16_string,
1445
0
        utf16_string_size,
1446
0
        internal_entry_identifier->email_address,
1447
0
        internal_entry_identifier->email_address_size,
1448
0
        LIBUNA_ENDIAN_LITTLE,
1449
0
        error );
1450
0
  }
1451
0
  else
1452
0
  {
1453
0
    result = libuna_utf16_string_copy_from_byte_stream(
1454
0
        utf16_string,
1455
0
        utf16_string_size,
1456
0
        internal_entry_identifier->email_address,
1457
0
        internal_entry_identifier->email_address_size,
1458
0
        internal_entry_identifier->ascii_codepage,
1459
0
        error );
1460
0
  }
1461
0
  if( result != 1 )
1462
0
  {
1463
0
    libcerror_error_set(
1464
0
     error,
1465
0
     LIBCERROR_ERROR_DOMAIN_RUNTIME,
1466
0
     LIBCERROR_RUNTIME_ERROR_SET_FAILED,
1467
0
     "%s: unable to set UTF-16 string.",
1468
0
     function );
1469
1470
0
    return( -1 );
1471
0
  }
1472
0
  return( 1 );
1473
0
}
1474