/src/libpff/libpff/libpff_item_values.c
Line | Count | Source |
1 | | /* |
2 | | * Item values functions |
3 | | * |
4 | | * Copyright (C) 2008-2025, Joachim Metz <joachim.metz@gmail.com> |
5 | | * |
6 | | * Refer to AUTHORS for acknowledgements. |
7 | | * |
8 | | * This program is free software: you can redistribute it and/or modify |
9 | | * it under the terms of the GNU Lesser General Public License as published by |
10 | | * the Free Software Foundation, either version 3 of the License, or |
11 | | * (at your option) any later version. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | * GNU General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include <common.h> |
23 | | #include <memory.h> |
24 | | #include <types.h> |
25 | | |
26 | | #include "libpff_debug.h" |
27 | | #include "libpff_definitions.h" |
28 | | #include "libpff_io_handle.h" |
29 | | #include "libpff_item_values.h" |
30 | | #include "libpff_libbfio.h" |
31 | | #include "libpff_libcdata.h" |
32 | | #include "libpff_libcerror.h" |
33 | | #include "libpff_libcnotify.h" |
34 | | #include "libpff_libfcache.h" |
35 | | #include "libpff_libfdata.h" |
36 | | #include "libpff_libuna.h" |
37 | | #include "libpff_local_descriptor_value.h" |
38 | | #include "libpff_local_descriptors.h" |
39 | | #include "libpff_offsets_index.h" |
40 | | #include "libpff_record_entry.h" |
41 | | #include "libpff_table.h" |
42 | | #include "libpff_types.h" |
43 | | #include "libpff_value_type.h" |
44 | | |
45 | | /* Creates item values |
46 | | * Make sure the value item_values is referencing, is set to NULL |
47 | | * Returns 1 if successful or -1 on error |
48 | | */ |
49 | | int libpff_item_values_initialize( |
50 | | libpff_item_values_t **item_values, |
51 | | uint32_t descriptor_identifier, |
52 | | uint64_t data_identifier, |
53 | | uint64_t local_descriptors_identifier, |
54 | | uint8_t recovered, |
55 | | libcerror_error_t **error ) |
56 | 7.85k | { |
57 | 7.85k | static char *function = "libpff_item_values_initialize"; |
58 | | |
59 | 7.85k | if( item_values == NULL ) |
60 | 0 | { |
61 | 0 | libcerror_error_set( |
62 | 0 | error, |
63 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
64 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
65 | 0 | "%s: invalid item values.", |
66 | 0 | function ); |
67 | |
|
68 | 0 | return( -1 ); |
69 | 0 | } |
70 | 7.85k | if( *item_values != NULL ) |
71 | 0 | { |
72 | 0 | libcerror_error_set( |
73 | 0 | error, |
74 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
75 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
76 | 0 | "%s: invalid iitem values value already set.", |
77 | 0 | function ); |
78 | |
|
79 | 0 | return( -1 ); |
80 | 0 | } |
81 | 7.85k | *item_values = memory_allocate_structure( |
82 | 7.85k | libpff_item_values_t ); |
83 | | |
84 | 7.85k | if( *item_values == NULL ) |
85 | 0 | { |
86 | 0 | libcerror_error_set( |
87 | 0 | error, |
88 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
89 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
90 | 0 | "%s: unable to create item values.", |
91 | 0 | function ); |
92 | |
|
93 | 0 | goto on_error; |
94 | 0 | } |
95 | 7.85k | if( memory_set( |
96 | 7.85k | *item_values, |
97 | 7.85k | 0, |
98 | 7.85k | sizeof( libpff_item_values_t ) ) == NULL ) |
99 | 0 | { |
100 | 0 | libcerror_error_set( |
101 | 0 | error, |
102 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
103 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
104 | 0 | "%s: unable to clear item values.", |
105 | 0 | function ); |
106 | |
|
107 | 0 | goto on_error; |
108 | 0 | } |
109 | 7.85k | ( *item_values )->descriptor_identifier = descriptor_identifier; |
110 | 7.85k | ( *item_values )->data_identifier = data_identifier; |
111 | 7.85k | ( *item_values )->local_descriptors_identifier = local_descriptors_identifier; |
112 | 7.85k | ( *item_values )->recovered = recovered; |
113 | | |
114 | 7.85k | return( 1 ); |
115 | | |
116 | 0 | on_error: |
117 | 0 | if( *item_values != NULL ) |
118 | 0 | { |
119 | 0 | memory_free( |
120 | 0 | *item_values ); |
121 | |
|
122 | 0 | *item_values = NULL; |
123 | 0 | } |
124 | 0 | return( -1 ); |
125 | 7.85k | } |
126 | | |
127 | | /* Frees item values |
128 | | * Returns 1 if successful or -1 on error |
129 | | */ |
130 | | int libpff_item_values_free( |
131 | | libpff_item_values_t **item_values, |
132 | | libcerror_error_t **error ) |
133 | 7.85k | { |
134 | 7.85k | static char *function = "libpff_item_values_free"; |
135 | 7.85k | int result = 1; |
136 | | |
137 | 7.85k | if( item_values == NULL ) |
138 | 0 | { |
139 | 0 | libcerror_error_set( |
140 | 0 | error, |
141 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
142 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
143 | 0 | "%s: invalid item values.", |
144 | 0 | function ); |
145 | |
|
146 | 0 | return( -1 ); |
147 | 0 | } |
148 | 7.85k | if( *item_values != NULL ) |
149 | 7.85k | { |
150 | 7.85k | if( ( *item_values )->table != NULL ) |
151 | 1.07k | { |
152 | 1.07k | if( libpff_table_free( |
153 | 1.07k | &( ( *item_values )->table ), |
154 | 1.07k | error ) != 1 ) |
155 | 0 | { |
156 | 0 | libcerror_error_set( |
157 | 0 | error, |
158 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
159 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
160 | 0 | "%s: unable to free table.", |
161 | 0 | function ); |
162 | |
|
163 | 0 | result = -1; |
164 | 0 | } |
165 | 1.07k | } |
166 | 7.85k | memory_free( |
167 | 7.85k | *item_values ); |
168 | | |
169 | 7.85k | *item_values = NULL; |
170 | 7.85k | } |
171 | 7.85k | return( result ); |
172 | 7.85k | } |
173 | | |
174 | | /* Clone copies the item values |
175 | | * Copies the values and creates sub elements if necessary |
176 | | * Returns 1 if successful or -1 on error |
177 | | */ |
178 | | int libpff_item_values_clone_copy( |
179 | | libpff_item_values_t *destination_item_values, |
180 | | libpff_item_values_t *source_item_values, |
181 | | libcerror_error_t **error ) |
182 | 0 | { |
183 | 0 | static char *function = "libpff_item_values_clone_copy"; |
184 | |
|
185 | 0 | if( destination_item_values == NULL ) |
186 | 0 | { |
187 | 0 | libcerror_error_set( |
188 | 0 | error, |
189 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
190 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
191 | 0 | "%s: invalid destination item values.", |
192 | 0 | function ); |
193 | |
|
194 | 0 | return( -1 ); |
195 | 0 | } |
196 | 0 | if( destination_item_values->table != 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 destination item values - table already set.", |
203 | 0 | function ); |
204 | |
|
205 | 0 | return( -1 ); |
206 | 0 | } |
207 | 0 | if( source_item_values == NULL ) |
208 | 0 | { |
209 | 0 | libcerror_error_set( |
210 | 0 | error, |
211 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
212 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
213 | 0 | "%s: invalid source item values.", |
214 | 0 | function ); |
215 | |
|
216 | 0 | return( -1 ); |
217 | 0 | } |
218 | 0 | if( libpff_table_clone( |
219 | 0 | &( destination_item_values->table ), |
220 | 0 | source_item_values->table, |
221 | 0 | error ) != 1 ) |
222 | 0 | { |
223 | 0 | libcerror_error_set( |
224 | 0 | error, |
225 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
226 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
227 | 0 | "%s: unable to clone table.", |
228 | 0 | function ); |
229 | |
|
230 | 0 | return( -1 ); |
231 | 0 | } |
232 | 0 | return( 1 ); |
233 | 0 | } |
234 | | |
235 | | /* Reads the item values for a specific descriptor |
236 | | * Returns 1 if successful or -1 on error |
237 | | */ |
238 | | int libpff_item_values_read( |
239 | | libpff_item_values_t *item_values, |
240 | | libcdata_list_t *name_to_id_map_list, |
241 | | libpff_io_handle_t *io_handle, |
242 | | libbfio_handle_t *file_io_handle, |
243 | | libpff_offsets_index_t *offsets_index, |
244 | | int debug_item_type, |
245 | | libcerror_error_t **error ) |
246 | 7.77k | { |
247 | 7.77k | static char *function = "libpff_item_values_read"; |
248 | | |
249 | 7.77k | if( item_values == NULL ) |
250 | 0 | { |
251 | 0 | libcerror_error_set( |
252 | 0 | error, |
253 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
254 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
255 | 0 | "%s: invalid item values.", |
256 | 0 | function ); |
257 | |
|
258 | 0 | return( -1 ); |
259 | 0 | } |
260 | 7.77k | if( item_values->table != NULL ) |
261 | 0 | { |
262 | 0 | libcerror_error_set( |
263 | 0 | error, |
264 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
265 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
266 | 0 | "%s: invalid item values - table already set.", |
267 | 0 | function ); |
268 | |
|
269 | 0 | return( -1 ); |
270 | 0 | } |
271 | 7.77k | if( libpff_table_initialize( |
272 | 7.77k | &( item_values->table ), |
273 | 7.77k | item_values->descriptor_identifier, |
274 | 7.77k | item_values->data_identifier, |
275 | 7.77k | item_values->local_descriptors_identifier, |
276 | 7.77k | item_values->recovered, |
277 | 7.77k | error ) != 1 ) |
278 | 0 | { |
279 | 0 | libcerror_error_set( |
280 | 0 | error, |
281 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
282 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
283 | 0 | "%s: unable to create table.", |
284 | 0 | function ); |
285 | |
|
286 | 0 | goto on_error; |
287 | 0 | } |
288 | 7.77k | if( libpff_table_read( |
289 | 7.77k | item_values->table, |
290 | 7.77k | io_handle, |
291 | 7.77k | file_io_handle, |
292 | 7.77k | offsets_index, |
293 | 7.77k | name_to_id_map_list, |
294 | 7.77k | debug_item_type, |
295 | 7.77k | error ) != 1 ) |
296 | 6.70k | { |
297 | 6.70k | libcerror_error_set( |
298 | 6.70k | error, |
299 | 6.70k | LIBCERROR_ERROR_DOMAIN_IO, |
300 | 6.70k | LIBCERROR_IO_ERROR_READ_FAILED, |
301 | 6.70k | "%s: unable to read table.", |
302 | 6.70k | function ); |
303 | | |
304 | 6.70k | goto on_error; |
305 | 6.70k | } |
306 | 1.07k | return( 1 ); |
307 | | |
308 | 6.70k | on_error: |
309 | 6.70k | if( item_values->table != NULL ) |
310 | 6.70k | { |
311 | 6.70k | libpff_table_free( |
312 | 6.70k | &( item_values->table ), |
313 | 6.70k | NULL ); |
314 | 6.70k | } |
315 | 6.70k | return( -1 ); |
316 | 7.77k | } |
317 | | |
318 | | /* Retrieves the local descriptor value for the specific identifier |
319 | | * Returns 1 if successful, 0 if no value was found or -1 on error |
320 | | */ |
321 | | int libpff_item_values_get_local_descriptors_value_by_identifier( |
322 | | libpff_item_values_t *item_values, |
323 | | libbfio_handle_t *file_io_handle, |
324 | | uint32_t descriptor_identifier, |
325 | | libpff_local_descriptor_value_t **local_descriptor_value, |
326 | | libcerror_error_t **error ) |
327 | 0 | { |
328 | 0 | static char *function = "libpff_item_values_get_local_descriptors_value_by_identifier"; |
329 | 0 | int result = 0; |
330 | |
|
331 | 0 | if( item_values == NULL ) |
332 | 0 | { |
333 | 0 | libcerror_error_set( |
334 | 0 | error, |
335 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
336 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
337 | 0 | "%s: invalid item values.", |
338 | 0 | function ); |
339 | |
|
340 | 0 | return( -1 ); |
341 | 0 | } |
342 | 0 | result = libpff_table_get_local_descriptors_value_by_identifier( |
343 | 0 | item_values->table, |
344 | 0 | file_io_handle, |
345 | 0 | (uint64_t) descriptor_identifier, |
346 | 0 | local_descriptor_value, |
347 | 0 | error ); |
348 | |
|
349 | 0 | if( result == -1 ) |
350 | 0 | { |
351 | 0 | libcerror_error_set( |
352 | 0 | error, |
353 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
354 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
355 | 0 | "%s: unable to retrieve local descriptor identifier: %" PRIu32 ".", |
356 | 0 | function, |
357 | 0 | descriptor_identifier ); |
358 | |
|
359 | 0 | return( -1 ); |
360 | 0 | } |
361 | 0 | return( result ); |
362 | 0 | } |
363 | | |
364 | | /* Retrieves the number of item value sets |
365 | | * Returns 1 if successful or -1 on error |
366 | | */ |
367 | | int libpff_item_values_get_number_of_record_sets( |
368 | | libpff_item_values_t *item_values, |
369 | | libcdata_list_t *name_to_id_map_list, |
370 | | libpff_io_handle_t *io_handle, |
371 | | libbfio_handle_t *file_io_handle, |
372 | | libpff_offsets_index_t *offsets_index, |
373 | | int *number_of_record_sets, |
374 | | libcerror_error_t **error ) |
375 | 0 | { |
376 | 0 | static char *function = "libpff_item_values_get_number_of_record_sets"; |
377 | |
|
378 | 0 | if( item_values == NULL ) |
379 | 0 | { |
380 | 0 | libcerror_error_set( |
381 | 0 | error, |
382 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
383 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
384 | 0 | "%s: invalid item values.", |
385 | 0 | function ); |
386 | |
|
387 | 0 | return( -1 ); |
388 | 0 | } |
389 | 0 | if( item_values->table == NULL ) |
390 | 0 | { |
391 | | #if defined( HAVE_DEBUG_OUTPUT ) |
392 | | if( libcnotify_verbose != 0 ) |
393 | | { |
394 | | libcnotify_printf( |
395 | | "%s: reading item values of descriptor: %" PRIu32 "\n", |
396 | | function, |
397 | | item_values->descriptor_identifier ); |
398 | | } |
399 | | #endif |
400 | 0 | if( libpff_item_values_read( |
401 | 0 | item_values, |
402 | 0 | name_to_id_map_list, |
403 | 0 | io_handle, |
404 | 0 | file_io_handle, |
405 | 0 | offsets_index, |
406 | 0 | LIBPFF_DEBUG_ITEM_TYPE_DEFAULT, |
407 | 0 | error ) != 1 ) |
408 | 0 | { |
409 | 0 | libcerror_error_set( |
410 | 0 | error, |
411 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
412 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
413 | 0 | "%s: unable to read item values.", |
414 | 0 | function ); |
415 | |
|
416 | 0 | return( -1 ); |
417 | 0 | } |
418 | 0 | } |
419 | 0 | if( libpff_table_get_number_of_record_sets( |
420 | 0 | item_values->table, |
421 | 0 | number_of_record_sets, |
422 | 0 | error ) != 1 ) |
423 | 0 | { |
424 | 0 | libcerror_error_set( |
425 | 0 | error, |
426 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
427 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
428 | 0 | "%s: unable to retrieve number of record sets.", |
429 | 0 | function ); |
430 | |
|
431 | 0 | return( -1 ); |
432 | 0 | } |
433 | 0 | return( 1 ); |
434 | 0 | } |
435 | | |
436 | | /* Retrieves the record entry matching the entry and value type pair from the item values. |
437 | | * |
438 | | * When the LIBPFF_ENTRY_VALUE_FLAG_MATCH_ANY_VALUE_TYPE flag is set |
439 | | * the value type is ignored and set. The default behavior is a strict |
440 | | * matching of the value type. In this case the value type must be filled |
441 | | * with the corresponding value type |
442 | | * |
443 | | * When the LIBPFF_ENTRY_VALUE_FLAG_IGNORE_NAME_TO_ID_MAP is set |
444 | | * the name to identifier mapping is ignored. The default behavior is |
445 | | * to use the mapped entry value. In this case named properties are not |
446 | | * retrieved. |
447 | | * |
448 | | * Returns 1 if successful, 0 if not available or -1 on error |
449 | | */ |
450 | | int libpff_item_values_get_record_entry_by_type( |
451 | | libpff_item_values_t *item_values, |
452 | | libcdata_list_t *name_to_id_map_list, |
453 | | libpff_io_handle_t *io_handle, |
454 | | libbfio_handle_t *file_io_handle, |
455 | | libpff_offsets_index_t *offsets_index, |
456 | | int record_set_index, |
457 | | uint32_t entry_type, |
458 | | uint32_t value_type, |
459 | | libpff_record_entry_t **record_entry, |
460 | | uint8_t flags, |
461 | | libcerror_error_t **error ) |
462 | 0 | { |
463 | 0 | static char *function = "libpff_item_values_get_record_entry_by_type"; |
464 | 0 | int result = 0; |
465 | |
|
466 | 0 | if( item_values == NULL ) |
467 | 0 | { |
468 | 0 | libcerror_error_set( |
469 | 0 | error, |
470 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
471 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
472 | 0 | "%s: invalid item values.", |
473 | 0 | function ); |
474 | |
|
475 | 0 | return( -1 ); |
476 | 0 | } |
477 | 0 | if( item_values->table == NULL ) |
478 | 0 | { |
479 | | #if defined( HAVE_DEBUG_OUTPUT ) |
480 | | if( libcnotify_verbose != 0 ) |
481 | | { |
482 | | libcnotify_printf( |
483 | | "%s: reading item values of descriptor: %" PRIu32 "\n", |
484 | | function, |
485 | | item_values->descriptor_identifier ); |
486 | | } |
487 | | #endif |
488 | 0 | if( libpff_item_values_read( |
489 | 0 | item_values, |
490 | 0 | name_to_id_map_list, |
491 | 0 | io_handle, |
492 | 0 | file_io_handle, |
493 | 0 | offsets_index, |
494 | 0 | LIBPFF_DEBUG_ITEM_TYPE_DEFAULT, |
495 | 0 | error ) != 1 ) |
496 | 0 | { |
497 | 0 | libcerror_error_set( |
498 | 0 | error, |
499 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
500 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
501 | 0 | "%s: unable to read item values.", |
502 | 0 | function ); |
503 | |
|
504 | 0 | return( -1 ); |
505 | 0 | } |
506 | 0 | } |
507 | 0 | result = libpff_table_get_record_entry_by_type( |
508 | 0 | item_values->table, |
509 | 0 | record_set_index, |
510 | 0 | entry_type, |
511 | 0 | value_type, |
512 | 0 | record_entry, |
513 | 0 | flags, |
514 | 0 | error ); |
515 | |
|
516 | 0 | if( result == -1 ) |
517 | 0 | { |
518 | 0 | libcerror_error_set( |
519 | 0 | error, |
520 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
521 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
522 | 0 | "%s: unable to retrieve record entry.", |
523 | 0 | function ); |
524 | |
|
525 | 0 | return( -1 ); |
526 | 0 | } |
527 | 0 | return( result ); |
528 | 0 | } |
529 | | |
530 | | /* Retrieves the record entry matching the UTF-8 encoded entry name from the item values. |
531 | | * |
532 | | * When the LIBPFF_ENTRY_VALUE_FLAG_MATCH_ANY_VALUE_TYPE flag is set |
533 | | * the value type is ignored and set. The default behavior is a strict |
534 | | * matching of the value type. In this case the value type must be filled |
535 | | * with the corresponding value type |
536 | | * |
537 | | * Returns 1 if successful, 0 if not available or -1 on error |
538 | | */ |
539 | | int libpff_item_values_get_record_entry_by_utf8_name( |
540 | | libpff_item_values_t *item_values, |
541 | | libcdata_list_t *name_to_id_map_list, |
542 | | libpff_io_handle_t *io_handle, |
543 | | libbfio_handle_t *file_io_handle, |
544 | | libpff_offsets_index_t *offsets_index, |
545 | | int record_set_index, |
546 | | const uint8_t *utf8_string, |
547 | | size_t utf8_string_length, |
548 | | uint32_t value_type, |
549 | | libpff_record_entry_t **record_entry, |
550 | | uint8_t flags, |
551 | | libcerror_error_t **error ) |
552 | 0 | { |
553 | 0 | static char *function = "libpff_item_values_get_record_entry_by_utf8_name"; |
554 | 0 | int result = 0; |
555 | |
|
556 | 0 | if( item_values == NULL ) |
557 | 0 | { |
558 | 0 | libcerror_error_set( |
559 | 0 | error, |
560 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
561 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
562 | 0 | "%s: invalid item values.", |
563 | 0 | function ); |
564 | |
|
565 | 0 | return( -1 ); |
566 | 0 | } |
567 | 0 | if( item_values->table == NULL ) |
568 | 0 | { |
569 | | #if defined( HAVE_DEBUG_OUTPUT ) |
570 | | if( libcnotify_verbose != 0 ) |
571 | | { |
572 | | libcnotify_printf( |
573 | | "%s: reading item values of descriptor: %" PRIu32 "\n", |
574 | | function, |
575 | | item_values->descriptor_identifier ); |
576 | | } |
577 | | #endif |
578 | 0 | if( libpff_item_values_read( |
579 | 0 | item_values, |
580 | 0 | name_to_id_map_list, |
581 | 0 | io_handle, |
582 | 0 | file_io_handle, |
583 | 0 | offsets_index, |
584 | 0 | LIBPFF_DEBUG_ITEM_TYPE_DEFAULT, |
585 | 0 | error ) != 1 ) |
586 | 0 | { |
587 | 0 | libcerror_error_set( |
588 | 0 | error, |
589 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
590 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
591 | 0 | "%s: unable to read item values.", |
592 | 0 | function ); |
593 | |
|
594 | 0 | return( -1 ); |
595 | 0 | } |
596 | 0 | } |
597 | 0 | result = libpff_table_get_record_entry_by_utf8_name( |
598 | 0 | item_values->table, |
599 | 0 | record_set_index, |
600 | 0 | utf8_string, |
601 | 0 | utf8_string_length, |
602 | 0 | value_type, |
603 | 0 | record_entry, |
604 | 0 | flags, |
605 | 0 | error ); |
606 | |
|
607 | 0 | if( result == -1 ) |
608 | 0 | { |
609 | 0 | libcerror_error_set( |
610 | 0 | error, |
611 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
612 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
613 | 0 | "%s: unable to retrieve record entry.", |
614 | 0 | function ); |
615 | |
|
616 | 0 | return( -1 ); |
617 | 0 | } |
618 | 0 | return( result ); |
619 | 0 | } |
620 | | |
621 | | /* Retrieves the record entry matching the UTF-16 encoded entry name from the item values. |
622 | | * |
623 | | * When the LIBPFF_ENTRY_VALUE_FLAG_MATCH_ANY_VALUE_TYPE flag is set |
624 | | * the value type is ignored and set. The default behavior is a strict |
625 | | * matching of the value type. In this case the value type must be filled |
626 | | * with the corresponding value type |
627 | | * |
628 | | * Returns 1 if successful, 0 if not available or -1 on error |
629 | | */ |
630 | | int libpff_item_values_get_record_entry_by_utf16_name( |
631 | | libpff_item_values_t *item_values, |
632 | | libcdata_list_t *name_to_id_map_list, |
633 | | libpff_io_handle_t *io_handle, |
634 | | libbfio_handle_t *file_io_handle, |
635 | | libpff_offsets_index_t *offsets_index, |
636 | | int record_set_index, |
637 | | const uint16_t *utf16_string, |
638 | | size_t utf16_string_length, |
639 | | uint32_t value_type, |
640 | | libpff_record_entry_t **record_entry, |
641 | | uint8_t flags, |
642 | | libcerror_error_t **error ) |
643 | 0 | { |
644 | 0 | static char *function = "libpff_item_values_get_record_entry_by_utf16_name"; |
645 | 0 | int result = 0; |
646 | |
|
647 | 0 | if( item_values == NULL ) |
648 | 0 | { |
649 | 0 | libcerror_error_set( |
650 | 0 | error, |
651 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
652 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
653 | 0 | "%s: invalid item values.", |
654 | 0 | function ); |
655 | |
|
656 | 0 | return( -1 ); |
657 | 0 | } |
658 | 0 | if( item_values->table == NULL ) |
659 | 0 | { |
660 | | #if defined( HAVE_DEBUG_OUTPUT ) |
661 | | if( libcnotify_verbose != 0 ) |
662 | | { |
663 | | libcnotify_printf( |
664 | | "%s: reading item values of descriptor: %" PRIu32 "\n", |
665 | | function, |
666 | | item_values->descriptor_identifier ); |
667 | | } |
668 | | #endif |
669 | 0 | if( libpff_item_values_read( |
670 | 0 | item_values, |
671 | 0 | name_to_id_map_list, |
672 | 0 | io_handle, |
673 | 0 | file_io_handle, |
674 | 0 | offsets_index, |
675 | 0 | LIBPFF_DEBUG_ITEM_TYPE_DEFAULT, |
676 | 0 | error ) != 1 ) |
677 | 0 | { |
678 | 0 | libcerror_error_set( |
679 | 0 | error, |
680 | 0 | LIBCERROR_ERROR_DOMAIN_IO, |
681 | 0 | LIBCERROR_IO_ERROR_READ_FAILED, |
682 | 0 | "%s: unable to read item values.", |
683 | 0 | function ); |
684 | |
|
685 | 0 | return( -1 ); |
686 | 0 | } |
687 | 0 | } |
688 | 0 | result = libpff_table_get_record_entry_by_utf16_name( |
689 | 0 | item_values->table, |
690 | 0 | record_set_index, |
691 | 0 | utf16_string, |
692 | 0 | utf16_string_length, |
693 | 0 | value_type, |
694 | 0 | record_entry, |
695 | 0 | flags, |
696 | 0 | error ); |
697 | |
|
698 | 0 | if( result == -1 ) |
699 | 0 | { |
700 | 0 | libcerror_error_set( |
701 | 0 | error, |
702 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
703 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
704 | 0 | "%s: unable to retrieve record entry.", |
705 | 0 | function ); |
706 | |
|
707 | 0 | return( -1 ); |
708 | 0 | } |
709 | 0 | return( result ); |
710 | 0 | } |
711 | | |