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