/src/libesedb/libesedb/libesedb_catalog_definition.c
Line | Count | Source |
1 | | /* |
2 | | * Catalog definition functions |
3 | | * |
4 | | * Copyright (C) 2009-2026, Joachim Metz <joachim.metz@gmail.com> |
5 | | * |
6 | | * Refer to AUTHORS for acknowledgements. |
7 | | * |
8 | | * This program is free software: you can redistribute it and/or modify |
9 | | * it under the terms of the GNU Lesser General Public License as published by |
10 | | * the Free Software Foundation, either version 3 of the License, or |
11 | | * (at your option) any later version. |
12 | | * |
13 | | * This program is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | * GNU General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
20 | | */ |
21 | | |
22 | | #include <common.h> |
23 | | #include <byte_stream.h> |
24 | | #include <memory.h> |
25 | | #include <narrow_string.h> |
26 | | #include <system_string.h> |
27 | | #include <types.h> |
28 | | #include <wide_string.h> |
29 | | |
30 | | #include "libesedb_catalog_definition.h" |
31 | | #include "libesedb_codepage.h" |
32 | | #include "libesedb_column_type.h" |
33 | | #include "libesedb_debug.h" |
34 | | #include "libesedb_definitions.h" |
35 | | #include "libesedb_lcid.h" |
36 | | #include "libesedb_libcerror.h" |
37 | | #include "libesedb_libcnotify.h" |
38 | | #include "libesedb_libuna.h" |
39 | | #include "libesedb_unused.h" |
40 | | |
41 | | #include "esedb_page_values.h" |
42 | | |
43 | | #if !defined( LIBESEDB_ATTRIBUTE_FALLTHROUGH ) |
44 | | #if defined( __GNUC__ ) && __GNUC__ >= 7 |
45 | | #define LIBESEDB_ATTRIBUTE_FALLTHROUGH __attribute__ ((fallthrough)) |
46 | | #else |
47 | | #define LIBESEDB_ATTRIBUTE_FALLTHROUGH |
48 | | #endif |
49 | | #endif |
50 | | |
51 | | /* Creates a catalog definition |
52 | | * Make sure the value catalog_definition is referencing, is set to NULL |
53 | | * Returns 1 if successful or -1 on error |
54 | | */ |
55 | | int libesedb_catalog_definition_initialize( |
56 | | libesedb_catalog_definition_t **catalog_definition, |
57 | | libcerror_error_t **error ) |
58 | 156k | { |
59 | 156k | static char *function = "libesedb_catalog_definition_initialize"; |
60 | | |
61 | 156k | if( catalog_definition == NULL ) |
62 | 0 | { |
63 | 0 | libcerror_error_set( |
64 | 0 | error, |
65 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
66 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
67 | 0 | "%s: invalid catalog definition.", |
68 | 0 | function ); |
69 | |
|
70 | 0 | return( -1 ); |
71 | 0 | } |
72 | 156k | if( *catalog_definition != NULL ) |
73 | 0 | { |
74 | 0 | libcerror_error_set( |
75 | 0 | error, |
76 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
77 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
78 | 0 | "%s: invalid catalog definition value already set.", |
79 | 0 | function ); |
80 | |
|
81 | 0 | return( -1 ); |
82 | 0 | } |
83 | 156k | *catalog_definition = memory_allocate_structure( |
84 | 156k | libesedb_catalog_definition_t ); |
85 | | |
86 | 156k | if( *catalog_definition == NULL ) |
87 | 0 | { |
88 | 0 | libcerror_error_set( |
89 | 0 | error, |
90 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
91 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
92 | 0 | "%s: unable to create catalog definition.", |
93 | 0 | function ); |
94 | |
|
95 | 0 | goto on_error; |
96 | 0 | } |
97 | 156k | if( memory_set( |
98 | 156k | *catalog_definition, |
99 | 156k | 0, |
100 | 156k | sizeof( libesedb_catalog_definition_t ) ) == NULL ) |
101 | 0 | { |
102 | 0 | libcerror_error_set( |
103 | 0 | error, |
104 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
105 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
106 | 0 | "%s: unable to clear catalog definition.", |
107 | 0 | function ); |
108 | |
|
109 | 0 | goto on_error; |
110 | 0 | } |
111 | 156k | return( 1 ); |
112 | | |
113 | 0 | on_error: |
114 | 0 | if( *catalog_definition != NULL ) |
115 | 0 | { |
116 | 0 | memory_free( |
117 | 0 | *catalog_definition ); |
118 | |
|
119 | 0 | *catalog_definition = NULL; |
120 | 0 | } |
121 | 0 | return( -1 ); |
122 | 156k | } |
123 | | |
124 | | /* Frees a catalog definition |
125 | | * Returns 1 if successful or -1 on error |
126 | | */ |
127 | | int libesedb_catalog_definition_free( |
128 | | libesedb_catalog_definition_t **catalog_definition, |
129 | | libcerror_error_t **error ) |
130 | 156k | { |
131 | 156k | static char *function = "libesedb_catalog_definition_free"; |
132 | | |
133 | 156k | if( catalog_definition == NULL ) |
134 | 0 | { |
135 | 0 | libcerror_error_set( |
136 | 0 | error, |
137 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
138 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
139 | 0 | "%s: invalid catalog definition.", |
140 | 0 | function ); |
141 | |
|
142 | 0 | return( -1 ); |
143 | 0 | } |
144 | 156k | if( *catalog_definition != NULL ) |
145 | 156k | { |
146 | 156k | if( ( *catalog_definition )->name != NULL ) |
147 | 123k | { |
148 | 123k | memory_free( |
149 | 123k | ( *catalog_definition )->name ); |
150 | 123k | } |
151 | | #if defined( HAVE_DEBUG_OUTPUT ) |
152 | | if( ( *catalog_definition )->name_string != NULL ) |
153 | | { |
154 | | memory_free( |
155 | | ( *catalog_definition )->name_string ); |
156 | | } |
157 | | #endif |
158 | 156k | if( ( *catalog_definition )->template_name != NULL ) |
159 | 14.0k | { |
160 | 14.0k | memory_free( |
161 | 14.0k | ( *catalog_definition )->template_name ); |
162 | 14.0k | } |
163 | 156k | if( ( *catalog_definition )->default_value != NULL ) |
164 | 8.70k | { |
165 | 8.70k | memory_free( |
166 | 8.70k | ( *catalog_definition )->default_value ); |
167 | 8.70k | } |
168 | 156k | memory_free( |
169 | 156k | *catalog_definition ); |
170 | | |
171 | 156k | *catalog_definition = NULL; |
172 | 156k | } |
173 | 156k | return( 1 ); |
174 | 156k | } |
175 | | |
176 | | /* Reads the catalog definition |
177 | | * Returns 1 if successful or -1 on error |
178 | | */ |
179 | | int libesedb_catalog_definition_read_data( |
180 | | libesedb_catalog_definition_t *catalog_definition, |
181 | | const uint8_t *data, |
182 | | size_t data_size, |
183 | | int ascii_codepage LIBESEDB_ATTRIBUTE_UNUSED, |
184 | | libcerror_error_t **error ) |
185 | 156k | { |
186 | 156k | const uint8_t *fixed_size_data_type_value_data = NULL; |
187 | 156k | const uint8_t *variable_size_data_type_value_data = NULL; |
188 | 156k | static char *function = "libesedb_catalog_definition_read_data"; |
189 | 156k | size_t remaining_data_size = 0; |
190 | 156k | size_t variable_size_data_type_value_data_offset = 0; |
191 | 156k | uint16_t data_type_number = 0; |
192 | 156k | uint16_t data_type_size = 0; |
193 | 156k | uint16_t previous_variable_size_data_type_size = 0; |
194 | 156k | uint16_t variable_size_data_type_size = 0; |
195 | 156k | uint16_t variable_size_data_types_offset = 0; |
196 | 156k | uint8_t last_fixed_size_data_type = 0; |
197 | 156k | uint8_t last_variable_size_data_type = 0; |
198 | 156k | uint8_t number_of_variable_size_data_types = 0; |
199 | 156k | uint8_t variable_size_data_type_iterator = 0; |
200 | | |
201 | | #if defined( HAVE_DEBUG_OUTPUT ) |
202 | | system_character_t *value_string = 0; |
203 | | size_t value_string_size = 0; |
204 | | uint32_t value_32bit = 0; |
205 | | uint16_t calculated_variable_size_data_types_offset = 0; |
206 | | uint16_t record_offset = 0; |
207 | | uint16_t value_16bit = 0; |
208 | | int result = 0; |
209 | | #endif |
210 | | |
211 | 156k | LIBESEDB_UNREFERENCED_PARAMETER( ascii_codepage ) |
212 | | |
213 | 156k | if( catalog_definition == NULL ) |
214 | 0 | { |
215 | 0 | libcerror_error_set( |
216 | 0 | error, |
217 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
218 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
219 | 0 | "%s: invalid catalog definition.", |
220 | 0 | function ); |
221 | |
|
222 | 0 | return( -1 ); |
223 | 0 | } |
224 | 156k | if( data == NULL ) |
225 | 0 | { |
226 | 0 | libcerror_error_set( |
227 | 0 | error, |
228 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
229 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
230 | 0 | "%s: invalid data.", |
231 | 0 | function ); |
232 | |
|
233 | 0 | return( -1 ); |
234 | 0 | } |
235 | 156k | if( data_size > (size_t) SSIZE_MAX ) |
236 | 10 | { |
237 | 10 | libcerror_error_set( |
238 | 10 | error, |
239 | 10 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
240 | 10 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
241 | 10 | "%s: invalid data size value exceeds maximum.", |
242 | 10 | function ); |
243 | | |
244 | 10 | return( -1 ); |
245 | 10 | } |
246 | 156k | if( data_size < sizeof( esedb_data_definition_header_t ) ) |
247 | 16 | { |
248 | 16 | libcerror_error_set( |
249 | 16 | error, |
250 | 16 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
251 | 16 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
252 | 16 | "%s: data too small.", |
253 | 16 | function ); |
254 | | |
255 | 16 | return( -1 ); |
256 | 16 | } |
257 | | #if defined( HAVE_DEBUG_OUTPUT ) |
258 | | if( libcnotify_verbose != 0 ) |
259 | | { |
260 | | libcnotify_printf( |
261 | | "%s: data definition:\n", |
262 | | function ); |
263 | | libcnotify_print_data( |
264 | | data, |
265 | | data_size, |
266 | | 0 ); |
267 | | } |
268 | | #endif |
269 | 156k | last_fixed_size_data_type = ( (esedb_data_definition_header_t *) data )->last_fixed_size_data_type; |
270 | 156k | last_variable_size_data_type = ( (esedb_data_definition_header_t *) data )->last_variable_size_data_type; |
271 | | |
272 | 156k | byte_stream_copy_to_uint16_little_endian( |
273 | 156k | ( (esedb_data_definition_header_t *) data )->variable_size_data_types_offset, |
274 | 156k | variable_size_data_types_offset ); |
275 | | |
276 | | #if defined( HAVE_DEBUG_OUTPUT ) |
277 | | if( libcnotify_verbose != 0 ) |
278 | | { |
279 | | libcnotify_printf( |
280 | | "%s: last fixed size data type\t\t\t: %" PRIu8 "\n", |
281 | | function, |
282 | | last_fixed_size_data_type ); |
283 | | |
284 | | libcnotify_printf( |
285 | | "%s: last variable size data type\t\t\t: %" PRIu8 "\n", |
286 | | function, |
287 | | last_variable_size_data_type ); |
288 | | |
289 | | libcnotify_printf( |
290 | | "%s: variable size data types offset\t\t\t: %" PRIu16 "\n", |
291 | | function, |
292 | | variable_size_data_types_offset ); |
293 | | } |
294 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
295 | | |
296 | | /* As far as the documentation states |
297 | | * the column data FIELD structure is 16 bytes of size |
298 | | */ |
299 | 156k | if( last_fixed_size_data_type < 5 ) |
300 | 56 | { |
301 | 56 | libcerror_error_set( |
302 | 56 | error, |
303 | 56 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
304 | 56 | LIBCERROR_ARGUMENT_ERROR_VALUE_TOO_SMALL, |
305 | 56 | "%s: last fixed size data type too small.", |
306 | 56 | function ); |
307 | | |
308 | 56 | return( -1 ); |
309 | 56 | } |
310 | 156k | if( last_fixed_size_data_type > 13 ) |
311 | 34 | { |
312 | 34 | libcerror_error_set( |
313 | 34 | error, |
314 | 34 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
315 | 34 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
316 | 34 | "%s: unsupported last fixed size data type: %" PRIu8 ".", |
317 | 34 | function, |
318 | 34 | last_fixed_size_data_type ); |
319 | | |
320 | 34 | return( -1 ); |
321 | 34 | } |
322 | 156k | if( last_variable_size_data_type > 127 ) |
323 | 145k | { |
324 | 145k | number_of_variable_size_data_types = last_variable_size_data_type - 127; |
325 | 145k | } |
326 | | #if defined( HAVE_DEBUG_OUTPUT ) |
327 | | calculated_variable_size_data_types_offset += sizeof( esedb_data_definition_header_t ); |
328 | | |
329 | | /* Use a fall through to determine the size of the fixed size data types |
330 | | */ |
331 | | switch( last_fixed_size_data_type ) |
332 | | { |
333 | | case 13: |
334 | | calculated_variable_size_data_types_offset += 4; |
335 | | |
336 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
337 | | case 12: |
338 | | calculated_variable_size_data_types_offset += 4; |
339 | | |
340 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
341 | | case 11: |
342 | | calculated_variable_size_data_types_offset += 2; |
343 | | |
344 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
345 | | case 10: |
346 | | calculated_variable_size_data_types_offset += 4; |
347 | | |
348 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
349 | | case 9: |
350 | | calculated_variable_size_data_types_offset += 2; |
351 | | |
352 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
353 | | case 8: |
354 | | if( last_variable_size_data_type > 127 ) |
355 | | { |
356 | | calculated_variable_size_data_types_offset += 1 * number_of_variable_size_data_types; |
357 | | } |
358 | | |
359 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
360 | | case 7: |
361 | | calculated_variable_size_data_types_offset += 4; |
362 | | |
363 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
364 | | case 6: |
365 | | calculated_variable_size_data_types_offset += 4; |
366 | | |
367 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
368 | | case 5: |
369 | | calculated_variable_size_data_types_offset += 4; |
370 | | |
371 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
372 | | case 4: |
373 | | calculated_variable_size_data_types_offset += 4; |
374 | | |
375 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
376 | | case 3: |
377 | | calculated_variable_size_data_types_offset += 4; |
378 | | |
379 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
380 | | case 2: |
381 | | calculated_variable_size_data_types_offset += 2; |
382 | | |
383 | | LIBESEDB_ATTRIBUTE_FALLTHROUGH; |
384 | | case 1: |
385 | | calculated_variable_size_data_types_offset += 4; |
386 | | break; |
387 | | } |
388 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
389 | | |
390 | 156k | if( ( variable_size_data_types_offset < sizeof( esedb_data_definition_header_t ) ) |
391 | 156k | || ( variable_size_data_types_offset > data_size ) ) |
392 | 80 | { |
393 | 80 | libcerror_error_set( |
394 | 80 | error, |
395 | 80 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
396 | 80 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
397 | 80 | "%s: variable size data types offset value out of bounds.", |
398 | 80 | function ); |
399 | | |
400 | 80 | return( -1 ); |
401 | 80 | } |
402 | 156k | fixed_size_data_type_value_data = &( data[ sizeof( esedb_data_definition_header_t ) ] ); |
403 | | |
404 | 156k | byte_stream_copy_to_uint32_little_endian( |
405 | 156k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->father_data_page_object_identifier, |
406 | 156k | catalog_definition->father_data_page_object_identifier ); |
407 | | |
408 | 156k | byte_stream_copy_to_uint16_little_endian( |
409 | 156k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->type, |
410 | 156k | catalog_definition->type ); |
411 | | |
412 | 156k | byte_stream_copy_to_uint32_little_endian( |
413 | 156k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->identifier, |
414 | 156k | catalog_definition->identifier ); |
415 | | |
416 | 156k | if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
417 | 109k | { |
418 | 109k | byte_stream_copy_to_uint32_little_endian( |
419 | 109k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->column_type, |
420 | 109k | catalog_definition->column_type ); |
421 | 109k | } |
422 | 46.9k | else |
423 | 46.9k | { |
424 | 46.9k | byte_stream_copy_to_uint32_little_endian( |
425 | 46.9k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->father_data_page_number, |
426 | 46.9k | catalog_definition->father_data_page_number ); |
427 | 46.9k | } |
428 | 156k | byte_stream_copy_to_uint32_little_endian( |
429 | 156k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->space_usage, |
430 | 156k | catalog_definition->size ); |
431 | | |
432 | 156k | if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
433 | 109k | { |
434 | 109k | byte_stream_copy_to_uint32_little_endian( |
435 | 109k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->codepage, |
436 | 109k | catalog_definition->codepage ); |
437 | 109k | } |
438 | 156k | if( last_fixed_size_data_type >= 10 ) |
439 | 26.9k | { |
440 | 26.9k | byte_stream_copy_to_uint32_little_endian( |
441 | 26.9k | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->lc_map_flags, |
442 | 26.9k | catalog_definition->lcmap_flags ); |
443 | 26.9k | } |
444 | | #if defined( HAVE_DEBUG_OUTPUT ) |
445 | | if( libcnotify_verbose != 0 ) |
446 | | { |
447 | | data_type_number = 1; |
448 | | |
449 | | libcnotify_printf( |
450 | | "%s: (%03" PRIu16 ") father data page (FDP) object identifier\t: %" PRIu32 "\n", |
451 | | function, |
452 | | data_type_number++, |
453 | | catalog_definition->father_data_page_object_identifier ); |
454 | | |
455 | | libcnotify_printf( |
456 | | "%s: (%03" PRIu16 ") type\t\t\t\t\t: 0x%04" PRIx16 " ", |
457 | | function, |
458 | | data_type_number++, |
459 | | catalog_definition->type ); |
460 | | libesedb_debug_print_page_value_definition_type( |
461 | | catalog_definition->type ); |
462 | | libcnotify_printf( |
463 | | "\n" ); |
464 | | |
465 | | libcnotify_printf( |
466 | | "%s: (%03" PRIu16 ") identifier\t\t\t\t\t: %" PRIu32 "\n", |
467 | | function, |
468 | | data_type_number++, |
469 | | catalog_definition->identifier ); |
470 | | |
471 | | if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
472 | | { |
473 | | libcnotify_printf( |
474 | | "%s: (%03" PRIu16 ") column type\t\t\t\t: %" PRIu32 " (%s) %s\n", |
475 | | function, |
476 | | data_type_number++, |
477 | | catalog_definition->column_type, |
478 | | libesedb_column_type_get_identifier( |
479 | | catalog_definition->column_type ), |
480 | | libesedb_column_type_get_description( |
481 | | catalog_definition->column_type ) ); |
482 | | } |
483 | | else |
484 | | { |
485 | | libcnotify_printf( |
486 | | "%s: (%03" PRIu16 ") father data page (FDP) number\t\t: %" PRIu32 "\n", |
487 | | function, |
488 | | data_type_number++, |
489 | | catalog_definition->father_data_page_number ); |
490 | | } |
491 | | libcnotify_printf( |
492 | | "%s: (%03" PRIu16 ") space usage\t\t\t\t: %" PRIu32 "\n", |
493 | | function, |
494 | | data_type_number++, |
495 | | catalog_definition->size ); |
496 | | |
497 | | byte_stream_copy_to_uint32_little_endian( |
498 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->flags, |
499 | | value_32bit ); |
500 | | |
501 | | if( last_fixed_size_data_type >= 6 ) |
502 | | { |
503 | | if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
504 | | { |
505 | | libcnotify_printf( |
506 | | "%s: (%03" PRIu16 ") flags\t\t\t\t\t: 0x%08" PRIx32 "\n", |
507 | | function, |
508 | | data_type_number++, |
509 | | value_32bit ); |
510 | | libesedb_debug_print_column_group_of_bits( |
511 | | value_32bit ); |
512 | | libcnotify_printf( |
513 | | "\n" ); |
514 | | } |
515 | | else if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_INDEX ) |
516 | | { |
517 | | libcnotify_printf( |
518 | | "%s: (%03" PRIu16 ") flags\t\t\t\t\t: 0x%08" PRIx32 "\n", |
519 | | function, |
520 | | data_type_number++, |
521 | | value_32bit ); |
522 | | libesedb_debug_print_index_group_of_bits( |
523 | | value_32bit ); |
524 | | libcnotify_printf( |
525 | | "\n" ); |
526 | | } |
527 | | else |
528 | | { |
529 | | libcnotify_printf( |
530 | | "%s: (%03" PRIu16 ") flags\t\t\t\t\t: 0x%08" PRIx32 "\n", |
531 | | function, |
532 | | data_type_number++, |
533 | | value_32bit ); |
534 | | } |
535 | | } |
536 | | if( last_fixed_size_data_type >= 7 ) |
537 | | { |
538 | | if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
539 | | { |
540 | | libcnotify_printf( |
541 | | "%s: (%03" PRIu16 ") codepage\t\t\t\t\t: %" PRIu32 "", |
542 | | function, |
543 | | data_type_number++, |
544 | | catalog_definition->codepage ); |
545 | | |
546 | | if( catalog_definition->codepage != 0 ) |
547 | | { |
548 | | libcnotify_printf( |
549 | | " (%s) %s", |
550 | | libesedb_codepage_get_identifier( |
551 | | catalog_definition->codepage ), |
552 | | libesedb_codepage_get_description( |
553 | | catalog_definition->codepage ) ); |
554 | | } |
555 | | libcnotify_printf( |
556 | | "\n" ); |
557 | | } |
558 | | else if( catalog_definition->type == LIBESEDB_CATALOG_DEFINITION_TYPE_INDEX ) |
559 | | { |
560 | | byte_stream_copy_to_uint32_little_endian( |
561 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->locale_identifier, |
562 | | value_32bit ); |
563 | | |
564 | | libcnotify_printf( |
565 | | "%s: (%03" PRIu16 ") locale identifier\t\t\t\t: 0x%08" PRIx32 " (%s)\n", |
566 | | function, |
567 | | data_type_number++, |
568 | | value_32bit, |
569 | | libesedb_lcid_language_tag_get_identifier( |
570 | | (uint16_t) value_32bit ), |
571 | | libesedb_lcid_language_tag_get_description( |
572 | | (uint16_t) value_32bit ) ); |
573 | | } |
574 | | else |
575 | | { |
576 | | byte_stream_copy_to_uint32_little_endian( |
577 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->number_of_pages, |
578 | | value_32bit ); |
579 | | |
580 | | libcnotify_printf( |
581 | | "%s: (%03" PRIu16 ") number of pages\t\t\t\t: %" PRIu32 "\n", |
582 | | function, |
583 | | data_type_number++, |
584 | | value_32bit ); |
585 | | } |
586 | | } |
587 | | if( last_fixed_size_data_type >= 8 ) |
588 | | { |
589 | | libcnotify_printf( |
590 | | "%s: (%03" PRIu16 ") root flag\t\t\t\t\t: 0x%02" PRIx8 "\n", |
591 | | function, |
592 | | data_type_number++, |
593 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->root_flag ); |
594 | | } |
595 | | if( last_fixed_size_data_type >= 9 ) |
596 | | { |
597 | | byte_stream_copy_to_uint16_little_endian( |
598 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->record_offset, |
599 | | record_offset ); |
600 | | |
601 | | libcnotify_printf( |
602 | | "%s: (%03" PRIu16 ") record offset\t\t\t\t: %" PRIu16 "\n", |
603 | | function, |
604 | | data_type_number++, |
605 | | record_offset ); |
606 | | } |
607 | | if( last_fixed_size_data_type >= 10 ) |
608 | | { |
609 | | libcnotify_printf( |
610 | | "%s: (%03" PRIu16 ") locale map (LCMAP) flags\t\t\t: 0x%08" PRIx32 "\n", |
611 | | function, |
612 | | data_type_number++, |
613 | | catalog_definition->lcmap_flags ); |
614 | | libesedb_debug_print_lcmap_flags( |
615 | | catalog_definition->lcmap_flags ); |
616 | | } |
617 | | if( last_fixed_size_data_type >= 11 ) |
618 | | { |
619 | | byte_stream_copy_to_uint16_little_endian( |
620 | | ( (esedb_data_definition_t *) fixed_size_data_type_value_data )->key_most, |
621 | | value_16bit ); |
622 | | |
623 | | libcnotify_printf( |
624 | | "%s: (%03" PRIu16 ") key most\t\t\t\t: 0x04%" PRIx16 "\n", |
625 | | function, |
626 | | data_type_number++, |
627 | | value_16bit ); |
628 | | } |
629 | | libcnotify_printf( |
630 | | "\n" ); |
631 | | } |
632 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
633 | | |
634 | | #if defined( HAVE_DEBUG_OUTPUT ) |
635 | | if( libcnotify_verbose != 0 ) |
636 | | { |
637 | | if( variable_size_data_types_offset > calculated_variable_size_data_types_offset ) |
638 | | { |
639 | | libcnotify_printf( |
640 | | "%s: fixed size data types trailing data:\n", |
641 | | function ); |
642 | | libcnotify_print_data( |
643 | | &( data[ calculated_variable_size_data_types_offset ] ), |
644 | | variable_size_data_types_offset - calculated_variable_size_data_types_offset, |
645 | | 0 ); |
646 | | } |
647 | | } |
648 | | #endif /* defined( HAVE_DEBUG_OUTPUT ) */ |
649 | | |
650 | 156k | if( number_of_variable_size_data_types > 0 ) |
651 | 145k | { |
652 | 145k | variable_size_data_type_value_data_offset = variable_size_data_types_offset + ( number_of_variable_size_data_types * 2 ); |
653 | | |
654 | 145k | if( variable_size_data_type_value_data_offset > data_size ) |
655 | 19 | { |
656 | 19 | libcerror_error_set( |
657 | 19 | error, |
658 | 19 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
659 | 19 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
660 | 19 | "%s: variable size data type value data offset exceeds data.", |
661 | 19 | function ); |
662 | | |
663 | 19 | return( -1 ); |
664 | 19 | } |
665 | 145k | variable_size_data_type_value_data = &( data[ variable_size_data_type_value_data_offset ] ); |
666 | 145k | remaining_data_size = data_size - variable_size_data_type_value_data_offset; |
667 | | |
668 | 145k | data_type_number = 128; |
669 | | |
670 | 145k | for( variable_size_data_type_iterator = 0; |
671 | 755k | variable_size_data_type_iterator < number_of_variable_size_data_types; |
672 | 609k | variable_size_data_type_iterator++ ) |
673 | 609k | { |
674 | 609k | if( variable_size_data_types_offset > ( data_size - 2 ) ) |
675 | 0 | { |
676 | 0 | libcerror_error_set( |
677 | 0 | error, |
678 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
679 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
680 | 0 | "%s: variable size data types offset value out of bounds.", |
681 | 0 | function ); |
682 | |
|
683 | 0 | return( -1 ); |
684 | 0 | } |
685 | 609k | byte_stream_copy_to_uint16_little_endian( |
686 | 609k | &( data[ variable_size_data_types_offset ] ), |
687 | 609k | variable_size_data_type_size ); |
688 | | |
689 | 609k | variable_size_data_types_offset += 2; |
690 | | |
691 | | #if defined( HAVE_DEBUG_OUTPUT ) |
692 | | if( libcnotify_verbose != 0 ) |
693 | | { |
694 | | libcnotify_printf( |
695 | | "%s: (%03" PRIu16 ") variable size data type size\t\t: 0x%04" PRIx16 " (%" PRIu16 ")\n", |
696 | | function, |
697 | | data_type_number, |
698 | | variable_size_data_type_size, |
699 | | ( ( variable_size_data_type_size & 0x8000 ) != 0 ) ? 0 : ( variable_size_data_type_size & 0x7fff ) - previous_variable_size_data_type_size ); |
700 | | } |
701 | | #endif |
702 | | /* The MSB signifies that the variable size data type is empty |
703 | | */ |
704 | 609k | if( ( variable_size_data_type_size & 0x8000 ) != 0 ) |
705 | 95.7k | { |
706 | 95.7k | data_type_size = 0; |
707 | 95.7k | } |
708 | 513k | else |
709 | 513k | { |
710 | 513k | data_type_size = variable_size_data_type_size - previous_variable_size_data_type_size; |
711 | | |
712 | 513k | if( ( previous_variable_size_data_type_size > remaining_data_size ) |
713 | 513k | || ( data_type_size > ( remaining_data_size - previous_variable_size_data_type_size ) ) ) |
714 | 92 | { |
715 | 92 | libcerror_error_set( |
716 | 92 | error, |
717 | 92 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
718 | 92 | LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
719 | 92 | "%s: invalid data type size value out of bounds.", |
720 | 92 | function ); |
721 | | |
722 | 92 | return( -1 ); |
723 | 92 | } |
724 | 513k | } |
725 | 609k | switch( data_type_number ) |
726 | 609k | { |
727 | 145k | case 128: |
728 | 145k | if( data_type_size > 0 ) |
729 | 123k | { |
730 | 123k | catalog_definition->name = (uint8_t *) memory_allocate( |
731 | 123k | sizeof( uint8_t ) * data_type_size ); |
732 | | |
733 | 123k | if( catalog_definition->name == NULL ) |
734 | 0 | { |
735 | 0 | libcerror_error_set( |
736 | 0 | error, |
737 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
738 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
739 | 0 | "%s: unable to create name.", |
740 | 0 | function ); |
741 | |
|
742 | 0 | return( -1 ); |
743 | 0 | } |
744 | 123k | catalog_definition->name_size = (size_t) data_type_size; |
745 | | |
746 | 123k | if( memory_copy( |
747 | 123k | catalog_definition->name, |
748 | 123k | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
749 | 123k | catalog_definition->name_size ) == NULL ) |
750 | 0 | { |
751 | 0 | libcerror_error_set( |
752 | 0 | error, |
753 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
754 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
755 | 0 | "%s: unable to set name.", |
756 | 0 | function ); |
757 | |
|
758 | 0 | memory_free( |
759 | 0 | catalog_definition->name ); |
760 | |
|
761 | 0 | catalog_definition->name = NULL; |
762 | 0 | catalog_definition->name_size = 0; |
763 | |
|
764 | 0 | return( -1 ); |
765 | 0 | } |
766 | | #if defined( HAVE_DEBUG_OUTPUT ) |
767 | | if( libcnotify_verbose != 0 ) |
768 | | { |
769 | | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
770 | | result = libuna_utf16_string_size_from_byte_stream( |
771 | | catalog_definition->name, |
772 | | catalog_definition->name_size, |
773 | | ascii_codepage, |
774 | | &value_string_size, |
775 | | error ); |
776 | | #else |
777 | | result = libuna_utf8_string_size_from_byte_stream( |
778 | | catalog_definition->name, |
779 | | catalog_definition->name_size, |
780 | | ascii_codepage, |
781 | | &value_string_size, |
782 | | error ); |
783 | | #endif |
784 | | |
785 | | if( result != 1 ) |
786 | | { |
787 | | libcerror_error_set( |
788 | | error, |
789 | | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
790 | | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
791 | | "%s: unable to determine size of name string.", |
792 | | function ); |
793 | | |
794 | | return( -1 ); |
795 | | } |
796 | | catalog_definition->name_string = system_string_allocate( |
797 | | value_string_size ); |
798 | | |
799 | | if( catalog_definition->name_string == NULL ) |
800 | | { |
801 | | libcerror_error_set( |
802 | | error, |
803 | | LIBCERROR_ERROR_DOMAIN_MEMORY, |
804 | | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
805 | | "%s: unable to create name string.", |
806 | | function ); |
807 | | |
808 | | return( -1 ); |
809 | | } |
810 | | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
811 | | result = libuna_utf16_string_copy_from_byte_stream( |
812 | | (libuna_utf16_character_t *) catalog_definition->name_string, |
813 | | value_string_size, |
814 | | catalog_definition->name, |
815 | | catalog_definition->name_size, |
816 | | ascii_codepage, |
817 | | error ); |
818 | | #else |
819 | | result = libuna_utf8_string_copy_from_byte_stream( |
820 | | (libuna_utf8_character_t *) catalog_definition->name_string, |
821 | | value_string_size, |
822 | | catalog_definition->name, |
823 | | catalog_definition->name_size, |
824 | | ascii_codepage, |
825 | | error ); |
826 | | #endif |
827 | | |
828 | | if( result != 1 ) |
829 | | { |
830 | | libcerror_error_set( |
831 | | error, |
832 | | LIBCERROR_ERROR_DOMAIN_CONVERSION, |
833 | | LIBCERROR_CONVERSION_ERROR_GENERIC, |
834 | | "%s: unable to set name string.", |
835 | | function ); |
836 | | |
837 | | memory_free( |
838 | | catalog_definition->name_string ); |
839 | | |
840 | | catalog_definition->name_string = NULL; |
841 | | |
842 | | return( -1 ); |
843 | | } |
844 | | libcnotify_printf( |
845 | | "%s: (%03" PRIu8 ") name\t\t\t\t\t: %" PRIs_SYSTEM "\n", |
846 | | function, |
847 | | data_type_number, |
848 | | catalog_definition->name_string ); |
849 | | } |
850 | | #endif |
851 | 123k | } |
852 | | #if defined( HAVE_DEBUG_OUTPUT ) |
853 | | else if( libcnotify_verbose != 0 ) |
854 | | { |
855 | | libcnotify_printf( |
856 | | "%s: (%03" PRIu8 ") name\t\t\t\t\t: <NULL>\n", |
857 | | function, |
858 | | data_type_number ); |
859 | | } |
860 | | #endif |
861 | 145k | break; |
862 | | |
863 | | #if defined( HAVE_DEBUG_OUTPUT ) |
864 | | case 129: |
865 | | if( libcnotify_verbose != 0 ) |
866 | | { |
867 | | if( data_type_size > 0 ) |
868 | | { |
869 | | libcnotify_printf( |
870 | | "%s: (%03" PRIu8 ") stats:\n", |
871 | | function, |
872 | | data_type_number ); |
873 | | libcnotify_print_data( |
874 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
875 | | data_type_size, |
876 | | 0 ); |
877 | | } |
878 | | else |
879 | | { |
880 | | libcnotify_printf( |
881 | | "%s: (%03" PRIu8 ") stats\t\t\t\t\t: <NULL>\n", |
882 | | function, |
883 | | data_type_number ); |
884 | | } |
885 | | } |
886 | | break; |
887 | | #endif |
888 | | |
889 | 145k | case 130: |
890 | 30.9k | if( data_type_size > 0 ) |
891 | 14.0k | { |
892 | 14.0k | catalog_definition->template_name = (uint8_t *) memory_allocate( |
893 | 14.0k | sizeof( uint8_t ) * data_type_size ); |
894 | | |
895 | 14.0k | if( catalog_definition->template_name == NULL ) |
896 | 0 | { |
897 | 0 | libcerror_error_set( |
898 | 0 | error, |
899 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
900 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
901 | 0 | "%s: unable to create template name.", |
902 | 0 | function ); |
903 | |
|
904 | 0 | return( -1 ); |
905 | 0 | } |
906 | 14.0k | catalog_definition->template_name_size = (size_t) data_type_size; |
907 | | |
908 | 14.0k | if( memory_copy( |
909 | 14.0k | catalog_definition->template_name, |
910 | 14.0k | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
911 | 14.0k | catalog_definition->template_name_size ) == NULL ) |
912 | 0 | { |
913 | 0 | libcerror_error_set( |
914 | 0 | error, |
915 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
916 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
917 | 0 | "%s: unable to set template name.", |
918 | 0 | function ); |
919 | |
|
920 | 0 | memory_free( |
921 | 0 | catalog_definition->template_name ); |
922 | |
|
923 | 0 | catalog_definition->template_name = NULL; |
924 | 0 | catalog_definition->template_name_size = 0; |
925 | |
|
926 | 0 | return( -1 ); |
927 | 0 | } |
928 | | #if defined( HAVE_DEBUG_OUTPUT ) |
929 | | if( libcnotify_verbose != 0 ) |
930 | | { |
931 | | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
932 | | result = libuna_utf16_string_size_from_byte_stream( |
933 | | catalog_definition->template_name, |
934 | | catalog_definition->template_name_size, |
935 | | ascii_codepage, |
936 | | &value_string_size, |
937 | | error ); |
938 | | #else |
939 | | result = libuna_utf8_string_size_from_byte_stream( |
940 | | catalog_definition->template_name, |
941 | | catalog_definition->template_name_size, |
942 | | ascii_codepage, |
943 | | &value_string_size, |
944 | | error ); |
945 | | #endif |
946 | | |
947 | | if( result != 1 ) |
948 | | { |
949 | | libcerror_error_set( |
950 | | error, |
951 | | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
952 | | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
953 | | "%s: unable to determine size of template name string.", |
954 | | function ); |
955 | | |
956 | | return( -1 ); |
957 | | } |
958 | | value_string = system_string_allocate( |
959 | | value_string_size ); |
960 | | |
961 | | if( value_string == NULL ) |
962 | | { |
963 | | libcerror_error_set( |
964 | | error, |
965 | | LIBCERROR_ERROR_DOMAIN_MEMORY, |
966 | | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
967 | | "%s: unable to create template name string.", |
968 | | function ); |
969 | | |
970 | | return( -1 ); |
971 | | } |
972 | | #if defined( HAVE_WIDE_SYSTEM_CHARACTER ) |
973 | | result = libuna_utf16_string_copy_from_byte_stream( |
974 | | (libuna_utf16_character_t *) value_string, |
975 | | value_string_size, |
976 | | catalog_definition->template_name, |
977 | | catalog_definition->template_name_size, |
978 | | ascii_codepage, |
979 | | error ); |
980 | | #else |
981 | | result = libuna_utf8_string_copy_from_byte_stream( |
982 | | (libuna_utf8_character_t *) value_string, |
983 | | value_string_size, |
984 | | catalog_definition->template_name, |
985 | | catalog_definition->template_name_size, |
986 | | ascii_codepage, |
987 | | error ); |
988 | | #endif |
989 | | |
990 | | if( result != 1 ) |
991 | | { |
992 | | libcerror_error_set( |
993 | | error, |
994 | | LIBCERROR_ERROR_DOMAIN_CONVERSION, |
995 | | LIBCERROR_CONVERSION_ERROR_GENERIC, |
996 | | "%s: unable to set template name string.", |
997 | | function ); |
998 | | |
999 | | memory_free( |
1000 | | value_string ); |
1001 | | |
1002 | | return( -1 ); |
1003 | | } |
1004 | | libcnotify_printf( |
1005 | | "%s: (%03" PRIu8 ") template name\t\t\t\t: %" PRIs_SYSTEM "\n", |
1006 | | function, |
1007 | | data_type_number, |
1008 | | value_string ); |
1009 | | |
1010 | | memory_free( |
1011 | | value_string ); |
1012 | | } |
1013 | | #endif |
1014 | 14.0k | } |
1015 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1016 | | else if( libcnotify_verbose != 0 ) |
1017 | | { |
1018 | | libcnotify_printf( |
1019 | | "%s: (%03" PRIu8 ") template name\t\t\t\t: <NULL>\n", |
1020 | | function, |
1021 | | data_type_number ); |
1022 | | } |
1023 | | #endif |
1024 | 30.9k | break; |
1025 | | |
1026 | 30.9k | case 131: |
1027 | 26.9k | if( data_type_size > 0 ) |
1028 | 8.70k | { |
1029 | 8.70k | catalog_definition->default_value = (uint8_t *) memory_allocate( |
1030 | 8.70k | sizeof( uint8_t ) * data_type_size ); |
1031 | | |
1032 | 8.70k | if( catalog_definition->default_value == NULL ) |
1033 | 0 | { |
1034 | 0 | libcerror_error_set( |
1035 | 0 | error, |
1036 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
1037 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
1038 | 0 | "%s: unable to create default value.", |
1039 | 0 | function ); |
1040 | |
|
1041 | 0 | return( -1 ); |
1042 | 0 | } |
1043 | 8.70k | catalog_definition->default_value_size = (size_t) data_type_size; |
1044 | | |
1045 | 8.70k | if( memory_copy( |
1046 | 8.70k | catalog_definition->default_value, |
1047 | 8.70k | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1048 | 8.70k | catalog_definition->default_value_size ) == NULL ) |
1049 | 0 | { |
1050 | 0 | libcerror_error_set( |
1051 | 0 | error, |
1052 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
1053 | 0 | LIBCERROR_MEMORY_ERROR_COPY_FAILED, |
1054 | 0 | "%s: unable to set default value.", |
1055 | 0 | function ); |
1056 | |
|
1057 | 0 | memory_free( |
1058 | 0 | catalog_definition->default_value ); |
1059 | |
|
1060 | 0 | catalog_definition->default_value = NULL; |
1061 | 0 | catalog_definition->default_value_size = 0; |
1062 | |
|
1063 | 0 | return( -1 ); |
1064 | 0 | } |
1065 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1066 | | if( libcnotify_verbose != 0 ) |
1067 | | { |
1068 | | libcnotify_printf( |
1069 | | "%s: (%03" PRIu8 ") default value:\n", |
1070 | | function, |
1071 | | data_type_number ); |
1072 | | libcnotify_print_data( |
1073 | | catalog_definition->default_value, |
1074 | | catalog_definition->default_value_size, |
1075 | | 0 ); |
1076 | | } |
1077 | | #endif |
1078 | 8.70k | } |
1079 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1080 | | else if( libcnotify_verbose != 0 ) |
1081 | | { |
1082 | | libcnotify_printf( |
1083 | | "%s: (%03" PRIu8 ") default value\t\t\t\t: <NULL>\n", |
1084 | | function, |
1085 | | data_type_number ); |
1086 | | } |
1087 | | #endif |
1088 | 26.9k | break; |
1089 | | |
1090 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1091 | | case 132: |
1092 | | if( libcnotify_verbose != 0 ) |
1093 | | { |
1094 | | if( data_type_size > 0 ) |
1095 | | { |
1096 | | libcnotify_printf( |
1097 | | "%s: (%03" PRIu8 ") KeyFldIDs:\n", |
1098 | | function, |
1099 | | data_type_number ); |
1100 | | libcnotify_print_data( |
1101 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1102 | | data_type_size, |
1103 | | 0 ); |
1104 | | } |
1105 | | else |
1106 | | { |
1107 | | libcnotify_printf( |
1108 | | "%s: (%03" PRIu8 ") KeyFldIDs\t\t\t\t: <NULL>\n", |
1109 | | function, |
1110 | | data_type_number ); |
1111 | | } |
1112 | | } |
1113 | | break; |
1114 | | |
1115 | | case 133: |
1116 | | if( libcnotify_verbose != 0 ) |
1117 | | { |
1118 | | if( data_type_size > 0 ) |
1119 | | { |
1120 | | libcnotify_printf( |
1121 | | "%s: (%03" PRIu8 ") VarSegMac:\n", |
1122 | | function, |
1123 | | data_type_number ); |
1124 | | libcnotify_print_data( |
1125 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1126 | | data_type_size, |
1127 | | 0 ); |
1128 | | } |
1129 | | else |
1130 | | { |
1131 | | libcnotify_printf( |
1132 | | "%s: (%03" PRIu8 ") VarSegMac\t\t\t\t\t: <NULL>\n", |
1133 | | function, |
1134 | | data_type_number ); |
1135 | | } |
1136 | | } |
1137 | | break; |
1138 | | |
1139 | | case 134: |
1140 | | if( libcnotify_verbose != 0 ) |
1141 | | { |
1142 | | if( data_type_size > 0 ) |
1143 | | { |
1144 | | libcnotify_printf( |
1145 | | "%s: (%03" PRIu8 ") ConditionalColumns:\n", |
1146 | | function, |
1147 | | data_type_number ); |
1148 | | libcnotify_print_data( |
1149 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1150 | | data_type_size, |
1151 | | 0 ); |
1152 | | } |
1153 | | else |
1154 | | { |
1155 | | libcnotify_printf( |
1156 | | "%s: (%03" PRIu8 ") ConditionalColumns\t\t\t\t: <NULL>\n", |
1157 | | function, |
1158 | | data_type_number ); |
1159 | | } |
1160 | | } |
1161 | | break; |
1162 | | |
1163 | | case 135: |
1164 | | if( libcnotify_verbose != 0 ) |
1165 | | { |
1166 | | if( data_type_size > 0 ) |
1167 | | { |
1168 | | libcnotify_printf( |
1169 | | "%s: (%03" PRIu8 ") TupleLimits:\n", |
1170 | | function, |
1171 | | data_type_number ); |
1172 | | libcnotify_print_data( |
1173 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1174 | | data_type_size, |
1175 | | 0 ); |
1176 | | } |
1177 | | else |
1178 | | { |
1179 | | libcnotify_printf( |
1180 | | "%s: (%03" PRIu8 ") TupleLimits\t\t\t\t: <NULL>\n", |
1181 | | function, |
1182 | | data_type_number ); |
1183 | | } |
1184 | | } |
1185 | | break; |
1186 | | |
1187 | | case 136: |
1188 | | if( libcnotify_verbose != 0 ) |
1189 | | { |
1190 | | if( data_type_size > 0 ) |
1191 | | { |
1192 | | libcnotify_printf( |
1193 | | "%s: (%03" PRIu8 ") Version:\n", |
1194 | | function, |
1195 | | data_type_number ); |
1196 | | libcnotify_print_data( |
1197 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1198 | | data_type_size, |
1199 | | 0 ); |
1200 | | } |
1201 | | else |
1202 | | { |
1203 | | libcnotify_printf( |
1204 | | "%s: (%03" PRIu8 ") Version\t\t\t\t: <NULL>\n", |
1205 | | function, |
1206 | | data_type_number ); |
1207 | | } |
1208 | | } |
1209 | | break; |
1210 | | #endif |
1211 | | |
1212 | 405k | default: |
1213 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1214 | | if( libcnotify_verbose != 0 ) |
1215 | | { |
1216 | | if( data_type_size > 0 ) |
1217 | | { |
1218 | | libcnotify_printf( |
1219 | | "%s: (%03" PRIu16 ") variable size data type:\n", |
1220 | | function, |
1221 | | data_type_number ); |
1222 | | libcnotify_print_data( |
1223 | | &( variable_size_data_type_value_data[ previous_variable_size_data_type_size ] ), |
1224 | | data_type_size, |
1225 | | 0 ); |
1226 | | } |
1227 | | else |
1228 | | { |
1229 | | libcnotify_printf( |
1230 | | "%s: (%03" PRIu16 ") variable size data type\t\t: <NULL>\n", |
1231 | | function, |
1232 | | data_type_number ); |
1233 | | } |
1234 | | } |
1235 | | #endif |
1236 | 405k | break; |
1237 | 609k | } |
1238 | 609k | if( data_type_size > 0 ) |
1239 | 158k | { |
1240 | 158k | previous_variable_size_data_type_size = variable_size_data_type_size; |
1241 | 158k | } |
1242 | 609k | data_type_number++; |
1243 | 609k | } |
1244 | 145k | } |
1245 | | #if defined( HAVE_DEBUG_OUTPUT ) |
1246 | | if( libcnotify_verbose != 0 ) |
1247 | | { |
1248 | | libcnotify_printf( |
1249 | | "\n" ); |
1250 | | } |
1251 | | #endif |
1252 | 156k | return( 1 ); |
1253 | 156k | } |
1254 | | |
1255 | | /* Retrieves the catalog definition identifier |
1256 | | * Returns 1 if successful or -1 on error |
1257 | | */ |
1258 | | int libesedb_catalog_definition_get_identifier( |
1259 | | libesedb_catalog_definition_t *catalog_definition, |
1260 | | uint32_t *identifier, |
1261 | | libcerror_error_t **error ) |
1262 | 0 | { |
1263 | 0 | static char *function = "libesedb_catalog_definition_get_identifier"; |
1264 | |
|
1265 | 0 | if( catalog_definition == NULL ) |
1266 | 0 | { |
1267 | 0 | libcerror_error_set( |
1268 | 0 | error, |
1269 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1270 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1271 | 0 | "%s: invalid catalog definition.", |
1272 | 0 | function ); |
1273 | |
|
1274 | 0 | return( -1 ); |
1275 | 0 | } |
1276 | 0 | if( identifier == NULL ) |
1277 | 0 | { |
1278 | 0 | libcerror_error_set( |
1279 | 0 | error, |
1280 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1281 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1282 | 0 | "%s: invalid identifier.", |
1283 | 0 | function ); |
1284 | |
|
1285 | 0 | return( -1 ); |
1286 | 0 | } |
1287 | 0 | *identifier = catalog_definition->identifier; |
1288 | |
|
1289 | 0 | return( 1 ); |
1290 | 0 | } |
1291 | | |
1292 | | /* Retrieves the catalog definition column type |
1293 | | * Returns 1 if successful or -1 on error |
1294 | | */ |
1295 | | int libesedb_catalog_definition_get_column_type( |
1296 | | libesedb_catalog_definition_t *catalog_definition, |
1297 | | uint32_t *column_type, |
1298 | | libcerror_error_t **error ) |
1299 | 0 | { |
1300 | 0 | static char *function = "libesedb_catalog_definition_get_column_type"; |
1301 | |
|
1302 | 0 | if( catalog_definition == NULL ) |
1303 | 0 | { |
1304 | 0 | libcerror_error_set( |
1305 | 0 | error, |
1306 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1307 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1308 | 0 | "%s: invalid catalog definition.", |
1309 | 0 | function ); |
1310 | |
|
1311 | 0 | return( -1 ); |
1312 | 0 | } |
1313 | 0 | if( column_type == NULL ) |
1314 | 0 | { |
1315 | 0 | libcerror_error_set( |
1316 | 0 | error, |
1317 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1318 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1319 | 0 | "%s: invalid column type.", |
1320 | 0 | function ); |
1321 | |
|
1322 | 0 | return( -1 ); |
1323 | 0 | } |
1324 | 0 | *column_type = catalog_definition->column_type; |
1325 | |
|
1326 | 0 | return( 1 ); |
1327 | 0 | } |
1328 | | |
1329 | | /* Retrieves the size of the UTF-8 encoded string string of the catalog definition name |
1330 | | * The returned size includes the end of string character |
1331 | | * Returns 1 if successful or -1 on error |
1332 | | */ |
1333 | | int libesedb_catalog_definition_get_utf8_name_size( |
1334 | | libesedb_catalog_definition_t *catalog_definition, |
1335 | | size_t *utf8_string_size, |
1336 | | int ascii_codepage, |
1337 | | libcerror_error_t **error ) |
1338 | 0 | { |
1339 | 0 | static char *function = "libesedb_catalog_definition_get_utf8_name_size"; |
1340 | |
|
1341 | 0 | if( catalog_definition == NULL ) |
1342 | 0 | { |
1343 | 0 | libcerror_error_set( |
1344 | 0 | error, |
1345 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1346 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1347 | 0 | "%s: invalid catalog definition.", |
1348 | 0 | function ); |
1349 | |
|
1350 | 0 | return( -1 ); |
1351 | 0 | } |
1352 | 0 | if( libuna_utf8_string_size_from_byte_stream( |
1353 | 0 | catalog_definition->name, |
1354 | 0 | catalog_definition->name_size, |
1355 | 0 | ascii_codepage, |
1356 | 0 | utf8_string_size, |
1357 | 0 | error ) != 1 ) |
1358 | 0 | { |
1359 | 0 | libcerror_error_set( |
1360 | 0 | error, |
1361 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1362 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1363 | 0 | "%s: unable to retrieve UTF-8 string size.", |
1364 | 0 | function ); |
1365 | |
|
1366 | 0 | return( -1 ); |
1367 | 0 | } |
1368 | 0 | return( 1 ); |
1369 | 0 | } |
1370 | | |
1371 | | /* Retrieves the UTF-8 encoded string of the catalog definition name |
1372 | | * The size should include the end of string character |
1373 | | * Returns 1 if successful or -1 on error |
1374 | | */ |
1375 | | int libesedb_catalog_definition_get_utf8_name( |
1376 | | libesedb_catalog_definition_t *catalog_definition, |
1377 | | uint8_t *utf8_string, |
1378 | | size_t utf8_string_size, |
1379 | | int ascii_codepage, |
1380 | | libcerror_error_t **error ) |
1381 | 0 | { |
1382 | 0 | static char *function = "libesedb_catalog_definition_get_utf8_name"; |
1383 | |
|
1384 | 0 | if( catalog_definition == NULL ) |
1385 | 0 | { |
1386 | 0 | libcerror_error_set( |
1387 | 0 | error, |
1388 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1389 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1390 | 0 | "%s: invalid catalog definition.", |
1391 | 0 | function ); |
1392 | |
|
1393 | 0 | return( -1 ); |
1394 | 0 | } |
1395 | 0 | if( libuna_utf8_string_copy_from_byte_stream( |
1396 | 0 | utf8_string, |
1397 | 0 | utf8_string_size, |
1398 | 0 | catalog_definition->name, |
1399 | 0 | catalog_definition->name_size, |
1400 | 0 | ascii_codepage, |
1401 | 0 | error ) != 1 ) |
1402 | 0 | { |
1403 | 0 | libcerror_error_set( |
1404 | 0 | error, |
1405 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1406 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1407 | 0 | "%s: unable to set UTF-8 string.", |
1408 | 0 | function ); |
1409 | |
|
1410 | 0 | return( -1 ); |
1411 | 0 | } |
1412 | 0 | return( 1 ); |
1413 | 0 | } |
1414 | | |
1415 | | /* Retrieves the size of the UTF-16 encoded string of the catalog definition name |
1416 | | * The returned size includes the end of string character |
1417 | | * Returns 1 if successful or -1 on error |
1418 | | */ |
1419 | | int libesedb_catalog_definition_get_utf16_name_size( |
1420 | | libesedb_catalog_definition_t *catalog_definition, |
1421 | | size_t *utf16_string_size, |
1422 | | int ascii_codepage, |
1423 | | libcerror_error_t **error ) |
1424 | 0 | { |
1425 | 0 | static char *function = "libesedb_catalog_definition_get_utf16_name_size"; |
1426 | |
|
1427 | 0 | if( catalog_definition == NULL ) |
1428 | 0 | { |
1429 | 0 | libcerror_error_set( |
1430 | 0 | error, |
1431 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1432 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1433 | 0 | "%s: invalid catalog definition.", |
1434 | 0 | function ); |
1435 | |
|
1436 | 0 | return( -1 ); |
1437 | 0 | } |
1438 | 0 | if( libuna_utf16_string_size_from_byte_stream( |
1439 | 0 | catalog_definition->name, |
1440 | 0 | catalog_definition->name_size, |
1441 | 0 | ascii_codepage, |
1442 | 0 | utf16_string_size, |
1443 | 0 | error ) != 1 ) |
1444 | 0 | { |
1445 | 0 | libcerror_error_set( |
1446 | 0 | error, |
1447 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1448 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1449 | 0 | "%s: unable to retrieve UTF-16 string size.", |
1450 | 0 | function ); |
1451 | |
|
1452 | 0 | return( -1 ); |
1453 | 0 | } |
1454 | 0 | return( 1 ); |
1455 | 0 | } |
1456 | | |
1457 | | /* Retrieves the UTF-16 encoded string of the catalog definition name |
1458 | | * The size should include the end of string character |
1459 | | * Returns 1 if successful or -1 on error |
1460 | | */ |
1461 | | int libesedb_catalog_definition_get_utf16_name( |
1462 | | libesedb_catalog_definition_t *catalog_definition, |
1463 | | uint16_t *utf16_string, |
1464 | | size_t utf16_string_size, |
1465 | | int ascii_codepage, |
1466 | | libcerror_error_t **error ) |
1467 | 0 | { |
1468 | 0 | static char *function = "libesedb_catalog_definition_get_utf16_name"; |
1469 | |
|
1470 | 0 | if( catalog_definition == NULL ) |
1471 | 0 | { |
1472 | 0 | libcerror_error_set( |
1473 | 0 | error, |
1474 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1475 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1476 | 0 | "%s: invalid catalog definition.", |
1477 | 0 | function ); |
1478 | |
|
1479 | 0 | return( -1 ); |
1480 | 0 | } |
1481 | 0 | if( libuna_utf16_string_copy_from_byte_stream( |
1482 | 0 | utf16_string, |
1483 | 0 | utf16_string_size, |
1484 | 0 | catalog_definition->name, |
1485 | 0 | catalog_definition->name_size, |
1486 | 0 | ascii_codepage, |
1487 | 0 | error ) != 1 ) |
1488 | 0 | { |
1489 | 0 | libcerror_error_set( |
1490 | 0 | error, |
1491 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1492 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1493 | 0 | "%s: unable to set UTF-16 string.", |
1494 | 0 | function ); |
1495 | |
|
1496 | 0 | return( -1 ); |
1497 | 0 | } |
1498 | 0 | return( 1 ); |
1499 | 0 | } |
1500 | | |
1501 | | /* Retrieves the size of the UTF-8 encoded string string of the catalog definition template name |
1502 | | * The returned size includes the end of string character |
1503 | | * Returns 1 if successful or -1 on error |
1504 | | */ |
1505 | | int libesedb_catalog_definition_get_utf8_template_name_size( |
1506 | | libesedb_catalog_definition_t *catalog_definition, |
1507 | | size_t *utf8_string_size, |
1508 | | int ascii_codepage, |
1509 | | libcerror_error_t **error ) |
1510 | 0 | { |
1511 | 0 | static char *function = "libesedb_catalog_definition_get_utf8_template_name_size"; |
1512 | |
|
1513 | 0 | if( catalog_definition == NULL ) |
1514 | 0 | { |
1515 | 0 | libcerror_error_set( |
1516 | 0 | error, |
1517 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1518 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1519 | 0 | "%s: invalid catalog definition.", |
1520 | 0 | function ); |
1521 | |
|
1522 | 0 | return( -1 ); |
1523 | 0 | } |
1524 | 0 | if( catalog_definition->template_name == NULL ) |
1525 | 0 | { |
1526 | 0 | if( utf8_string_size == NULL ) |
1527 | 0 | { |
1528 | 0 | libcerror_error_set( |
1529 | 0 | error, |
1530 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1531 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1532 | 0 | "%s: invalid UTF-8 string size.", |
1533 | 0 | function ); |
1534 | |
|
1535 | 0 | return( -1 ); |
1536 | 0 | } |
1537 | 0 | *utf8_string_size = 0; |
1538 | 0 | } |
1539 | 0 | else |
1540 | 0 | { |
1541 | 0 | if( libuna_utf8_string_size_from_byte_stream( |
1542 | 0 | catalog_definition->template_name, |
1543 | 0 | catalog_definition->template_name_size, |
1544 | 0 | ascii_codepage, |
1545 | 0 | utf8_string_size, |
1546 | 0 | error ) != 1 ) |
1547 | 0 | { |
1548 | 0 | libcerror_error_set( |
1549 | 0 | error, |
1550 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1551 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1552 | 0 | "%s: unable to retrieve UTF-8 string size.", |
1553 | 0 | function ); |
1554 | |
|
1555 | 0 | return( -1 ); |
1556 | 0 | } |
1557 | 0 | } |
1558 | 0 | return( 1 ); |
1559 | 0 | } |
1560 | | |
1561 | | /* Retrieves the UTF-8 encoded string of the catalog definition template name |
1562 | | * The size should include the end of string character |
1563 | | * Returns 1 if successful or -1 on error |
1564 | | */ |
1565 | | int libesedb_catalog_definition_get_utf8_template_name( |
1566 | | libesedb_catalog_definition_t *catalog_definition, |
1567 | | uint8_t *utf8_string, |
1568 | | size_t utf8_string_size, |
1569 | | int ascii_codepage, |
1570 | | libcerror_error_t **error ) |
1571 | 0 | { |
1572 | 0 | static char *function = "libesedb_catalog_definition_get_utf8_template_name"; |
1573 | |
|
1574 | 0 | if( catalog_definition == NULL ) |
1575 | 0 | { |
1576 | 0 | libcerror_error_set( |
1577 | 0 | error, |
1578 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1579 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1580 | 0 | "%s: invalid catalog definition.", |
1581 | 0 | function ); |
1582 | |
|
1583 | 0 | return( -1 ); |
1584 | 0 | } |
1585 | 0 | if( catalog_definition->template_name != NULL ) |
1586 | 0 | { |
1587 | 0 | if( libuna_utf8_string_copy_from_byte_stream( |
1588 | 0 | utf8_string, |
1589 | 0 | utf8_string_size, |
1590 | 0 | catalog_definition->template_name, |
1591 | 0 | catalog_definition->template_name_size, |
1592 | 0 | ascii_codepage, |
1593 | 0 | error ) != 1 ) |
1594 | 0 | { |
1595 | 0 | libcerror_error_set( |
1596 | 0 | error, |
1597 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1598 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1599 | 0 | "%s: unable to set UTF-8 string.", |
1600 | 0 | function ); |
1601 | |
|
1602 | 0 | return( -1 ); |
1603 | 0 | } |
1604 | 0 | } |
1605 | 0 | return( 1 ); |
1606 | 0 | } |
1607 | | |
1608 | | /* Retrieves the size of the UTF-16 encoded string of the catalog definition template name |
1609 | | * The returned size includes the end of string character |
1610 | | * Returns 1 if successful or -1 on error |
1611 | | */ |
1612 | | int libesedb_catalog_definition_get_utf16_template_name_size( |
1613 | | libesedb_catalog_definition_t *catalog_definition, |
1614 | | size_t *utf16_string_size, |
1615 | | int ascii_codepage, |
1616 | | libcerror_error_t **error ) |
1617 | 0 | { |
1618 | 0 | static char *function = "libesedb_catalog_definition_get_utf16_template_name_size"; |
1619 | |
|
1620 | 0 | if( catalog_definition == NULL ) |
1621 | 0 | { |
1622 | 0 | libcerror_error_set( |
1623 | 0 | error, |
1624 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1625 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1626 | 0 | "%s: invalid catalog definition.", |
1627 | 0 | function ); |
1628 | |
|
1629 | 0 | return( -1 ); |
1630 | 0 | } |
1631 | 0 | if( catalog_definition->template_name == NULL ) |
1632 | 0 | { |
1633 | 0 | if( utf16_string_size == NULL ) |
1634 | 0 | { |
1635 | 0 | libcerror_error_set( |
1636 | 0 | error, |
1637 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1638 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1639 | 0 | "%s: invalid UTF-16 string size.", |
1640 | 0 | function ); |
1641 | |
|
1642 | 0 | return( -1 ); |
1643 | 0 | } |
1644 | 0 | *utf16_string_size = 0; |
1645 | 0 | } |
1646 | 0 | else |
1647 | 0 | { |
1648 | 0 | if( libuna_utf16_string_size_from_byte_stream( |
1649 | 0 | catalog_definition->template_name, |
1650 | 0 | catalog_definition->template_name_size, |
1651 | 0 | ascii_codepage, |
1652 | 0 | utf16_string_size, |
1653 | 0 | error ) != 1 ) |
1654 | 0 | { |
1655 | 0 | libcerror_error_set( |
1656 | 0 | error, |
1657 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1658 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
1659 | 0 | "%s: unable to retrieve UTF-16 string size.", |
1660 | 0 | function ); |
1661 | |
|
1662 | 0 | return( -1 ); |
1663 | 0 | } |
1664 | 0 | } |
1665 | 0 | return( 1 ); |
1666 | 0 | } |
1667 | | |
1668 | | /* Retrieves the UTF-16 encoded string of the catalog definition template name |
1669 | | * The size should include the end of string character |
1670 | | * Returns 1 if successful or -1 on error |
1671 | | */ |
1672 | | int libesedb_catalog_definition_get_utf16_template_name( |
1673 | | libesedb_catalog_definition_t *catalog_definition, |
1674 | | uint16_t *utf16_string, |
1675 | | size_t utf16_string_size, |
1676 | | int ascii_codepage, |
1677 | | libcerror_error_t **error ) |
1678 | 0 | { |
1679 | 0 | static char *function = "libesedb_catalog_definition_get_utf16_template_name"; |
1680 | |
|
1681 | 0 | if( catalog_definition == NULL ) |
1682 | 0 | { |
1683 | 0 | libcerror_error_set( |
1684 | 0 | error, |
1685 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1686 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1687 | 0 | "%s: invalid catalog definition.", |
1688 | 0 | function ); |
1689 | |
|
1690 | 0 | return( -1 ); |
1691 | 0 | } |
1692 | 0 | if( catalog_definition->template_name != NULL ) |
1693 | 0 | { |
1694 | 0 | if( libuna_utf16_string_copy_from_byte_stream( |
1695 | 0 | utf16_string, |
1696 | 0 | utf16_string_size, |
1697 | 0 | catalog_definition->template_name, |
1698 | 0 | catalog_definition->template_name_size, |
1699 | 0 | ascii_codepage, |
1700 | 0 | error ) != 1 ) |
1701 | 0 | { |
1702 | 0 | libcerror_error_set( |
1703 | 0 | error, |
1704 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1705 | 0 | LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
1706 | 0 | "%s: unable to set UTF-16 string.", |
1707 | 0 | function ); |
1708 | |
|
1709 | 0 | return( -1 ); |
1710 | 0 | } |
1711 | 0 | } |
1712 | 0 | return( 1 ); |
1713 | 0 | } |
1714 | | |
1715 | | /* Compares the name of the table definition with a name |
1716 | | * Returns 1 if equal, 0 if not or -1 on error |
1717 | | */ |
1718 | | int libesedb_catalog_definition_compare_name( |
1719 | | libesedb_catalog_definition_t *catalog_definition, |
1720 | | const uint8_t *name, |
1721 | | size_t name_size, |
1722 | | libcerror_error_t **error ) |
1723 | 0 | { |
1724 | 0 | static char *function = "libesedb_catalog_definition_compare_name"; |
1725 | |
|
1726 | 0 | if( catalog_definition == NULL ) |
1727 | 0 | { |
1728 | 0 | libcerror_error_set( |
1729 | 0 | error, |
1730 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1731 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1732 | 0 | "%s: invalid catalog definition.", |
1733 | 0 | function ); |
1734 | |
|
1735 | 0 | return( -1 ); |
1736 | 0 | } |
1737 | 0 | if( catalog_definition->name == NULL ) |
1738 | 0 | { |
1739 | 0 | libcerror_error_set( |
1740 | 0 | error, |
1741 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1742 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1743 | 0 | "%s: invalid catalog definition - missing name.", |
1744 | 0 | function ); |
1745 | |
|
1746 | 0 | return( -1 ); |
1747 | 0 | } |
1748 | 0 | if( name == NULL ) |
1749 | 0 | { |
1750 | 0 | libcerror_error_set( |
1751 | 0 | error, |
1752 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1753 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1754 | 0 | "%s: invalid name.", |
1755 | 0 | function ); |
1756 | |
|
1757 | 0 | return( -1 ); |
1758 | 0 | } |
1759 | 0 | if( ( name_size == 0 ) |
1760 | 0 | || ( name_size > (size_t) SSIZE_MAX ) ) |
1761 | 0 | { |
1762 | 0 | libcerror_error_set( |
1763 | 0 | error, |
1764 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1765 | 0 | LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
1766 | 0 | "%s: invalid name size value exceeds maximum.", |
1767 | 0 | function ); |
1768 | |
|
1769 | 0 | return( -1 ); |
1770 | 0 | } |
1771 | 0 | if( name_size == catalog_definition->name_size ) |
1772 | 0 | { |
1773 | 0 | if( memory_compare( |
1774 | 0 | catalog_definition->name, |
1775 | 0 | name, |
1776 | 0 | name_size ) == 0 ) |
1777 | 0 | { |
1778 | 0 | return( 1 ); |
1779 | 0 | } |
1780 | 0 | } |
1781 | 0 | return( 0 ); |
1782 | 0 | } |
1783 | | |
1784 | | /* Compares the name of the table definition with an UTF-8 encoded string |
1785 | | * Returns LIBUNA_COMPARE_LESS, LIBUNA_COMPARE_EQUAL, LIBUNA_COMPARE_GREATER if successful or -1 on error |
1786 | | */ |
1787 | | int libesedb_catalog_definition_compare_name_with_utf8_string( |
1788 | | libesedb_catalog_definition_t *catalog_definition, |
1789 | | const uint8_t *utf8_string, |
1790 | | size_t utf8_string_length, |
1791 | | libcerror_error_t **error ) |
1792 | 5.51k | { |
1793 | 5.51k | static char *function = "libesedb_catalog_definition_compare_name_with_utf8_string"; |
1794 | 5.51k | int result = 0; |
1795 | | |
1796 | 5.51k | if( catalog_definition == NULL ) |
1797 | 0 | { |
1798 | 0 | libcerror_error_set( |
1799 | 0 | error, |
1800 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1801 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1802 | 0 | "%s: invalid catalog definition.", |
1803 | 0 | function ); |
1804 | |
|
1805 | 0 | return( -1 ); |
1806 | 0 | } |
1807 | 5.51k | if( catalog_definition->name == NULL ) |
1808 | 15 | { |
1809 | 15 | libcerror_error_set( |
1810 | 15 | error, |
1811 | 15 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1812 | 15 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1813 | 15 | "%s: invalid catalog definition - missing name.", |
1814 | 15 | function ); |
1815 | | |
1816 | 15 | return( -1 ); |
1817 | 15 | } |
1818 | | /* TODO use ascii codepage */ |
1819 | 5.49k | result = libuna_utf8_string_compare_with_byte_stream( |
1820 | 5.49k | utf8_string, |
1821 | 5.49k | utf8_string_length, |
1822 | 5.49k | catalog_definition->name, |
1823 | 5.49k | catalog_definition->name_size, |
1824 | 5.49k | LIBUNA_CODEPAGE_WINDOWS_1252, |
1825 | 5.49k | error ); |
1826 | | |
1827 | 5.49k | if( result == -1 ) |
1828 | 106 | { |
1829 | 106 | libcerror_error_set( |
1830 | 106 | error, |
1831 | 106 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1832 | 106 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1833 | 106 | "%s: unable to compare UTF-8 string with catalog definition name.", |
1834 | 106 | function ); |
1835 | | |
1836 | 106 | return( -1 ); |
1837 | 106 | } |
1838 | 5.39k | return( result ); |
1839 | 5.49k | } |
1840 | | |
1841 | | /* Compares the name of the table definition with an UTF-16 encoded string |
1842 | | * Returns LIBUNA_COMPARE_LESS, LIBUNA_COMPARE_EQUAL, LIBUNA_COMPARE_GREATER if successful or -1 on error |
1843 | | */ |
1844 | | int libesedb_catalog_definition_compare_name_with_utf16_string( |
1845 | | libesedb_catalog_definition_t *catalog_definition, |
1846 | | const uint16_t *utf16_string, |
1847 | | size_t utf16_string_length, |
1848 | | libcerror_error_t **error ) |
1849 | 0 | { |
1850 | 0 | static char *function = "libesedb_catalog_definition_compare_name_with_utf16_string"; |
1851 | 0 | int result = 0; |
1852 | |
|
1853 | 0 | if( catalog_definition == NULL ) |
1854 | 0 | { |
1855 | 0 | libcerror_error_set( |
1856 | 0 | error, |
1857 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
1858 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
1859 | 0 | "%s: invalid catalog definition.", |
1860 | 0 | function ); |
1861 | |
|
1862 | 0 | return( -1 ); |
1863 | 0 | } |
1864 | 0 | if( catalog_definition->name == NULL ) |
1865 | 0 | { |
1866 | 0 | libcerror_error_set( |
1867 | 0 | error, |
1868 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1869 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1870 | 0 | "%s: invalid catalog definition - missing name.", |
1871 | 0 | function ); |
1872 | |
|
1873 | 0 | return( -1 ); |
1874 | 0 | } |
1875 | | /* TODO use ascii codepage */ |
1876 | 0 | result = libuna_utf16_string_compare_with_byte_stream( |
1877 | 0 | utf16_string, |
1878 | 0 | utf16_string_length, |
1879 | 0 | catalog_definition->name, |
1880 | 0 | catalog_definition->name_size, |
1881 | 0 | LIBUNA_CODEPAGE_WINDOWS_1252, |
1882 | 0 | error ); |
1883 | |
|
1884 | 0 | if( result == -1 ) |
1885 | 0 | { |
1886 | 0 | libcerror_error_set( |
1887 | 0 | error, |
1888 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
1889 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
1890 | 0 | "%s: unable to compare UTF-16 string with catalog definition name.", |
1891 | 0 | function ); |
1892 | |
|
1893 | 0 | return( -1 ); |
1894 | 0 | } |
1895 | 0 | return( result ); |
1896 | 0 | } |
1897 | | |