/src/libesedb/libesedb/libesedb_table_definition.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Table 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 <memory.h> |
24 | | #include <types.h> |
25 | | |
26 | | #include "libesedb_catalog_definition.h" |
27 | | #include "libesedb_definitions.h" |
28 | | #include "libesedb_libcdata.h" |
29 | | #include "libesedb_libcerror.h" |
30 | | #include "libesedb_libcnotify.h" |
31 | | #include "libesedb_table_definition.h" |
32 | | |
33 | | /* Creates a table definition |
34 | | * Make sure the value table_definition is referencing, is set to NULL |
35 | | * Returns 1 if successful or -1 on error |
36 | | */ |
37 | | int libesedb_table_definition_initialize( |
38 | | libesedb_table_definition_t **table_definition, |
39 | | libesedb_catalog_definition_t *table_catalog_definition, |
40 | | libcerror_error_t **error ) |
41 | 39.1k | { |
42 | 39.1k | static char *function = "libesedb_table_definition_initialize"; |
43 | | |
44 | 39.1k | if( table_definition == NULL ) |
45 | 0 | { |
46 | 0 | libcerror_error_set( |
47 | 0 | error, |
48 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
49 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
50 | 0 | "%s: invalid table definition.", |
51 | 0 | function ); |
52 | |
|
53 | 0 | return( -1 ); |
54 | 0 | } |
55 | 39.1k | if( *table_definition != NULL ) |
56 | 0 | { |
57 | 0 | libcerror_error_set( |
58 | 0 | error, |
59 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
60 | 0 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
61 | 0 | "%s: invalid table definition value already set.", |
62 | 0 | function ); |
63 | |
|
64 | 0 | return( -1 ); |
65 | 0 | } |
66 | 39.1k | if( table_catalog_definition == NULL ) |
67 | 0 | { |
68 | 0 | libcerror_error_set( |
69 | 0 | error, |
70 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
71 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
72 | 0 | "%s: invalid table catalog definition.", |
73 | 0 | function ); |
74 | |
|
75 | 0 | return( -1 ); |
76 | 0 | } |
77 | 39.1k | if( table_catalog_definition->type != LIBESEDB_CATALOG_DEFINITION_TYPE_TABLE ) |
78 | 0 | { |
79 | 0 | libcerror_error_set( |
80 | 0 | error, |
81 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
82 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
83 | 0 | "%s: unsupported catalog definition type: %" PRIu16 ".", |
84 | 0 | function, |
85 | 0 | table_catalog_definition->type ); |
86 | |
|
87 | 0 | return( -1 ); |
88 | 0 | } |
89 | 39.1k | *table_definition = memory_allocate_structure( |
90 | 39.1k | libesedb_table_definition_t ); |
91 | | |
92 | 39.1k | if( *table_definition == NULL ) |
93 | 0 | { |
94 | 0 | libcerror_error_set( |
95 | 0 | error, |
96 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
97 | 0 | LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
98 | 0 | "%s: unable to create table definition.", |
99 | 0 | function ); |
100 | |
|
101 | 0 | goto on_error; |
102 | 0 | } |
103 | 39.1k | if( memory_set( |
104 | 39.1k | *table_definition, |
105 | 39.1k | 0, |
106 | 39.1k | sizeof( libesedb_table_definition_t ) ) == NULL ) |
107 | 0 | { |
108 | 0 | libcerror_error_set( |
109 | 0 | error, |
110 | 0 | LIBCERROR_ERROR_DOMAIN_MEMORY, |
111 | 0 | LIBCERROR_MEMORY_ERROR_SET_FAILED, |
112 | 0 | "%s: unable to clear table definition.", |
113 | 0 | function ); |
114 | |
|
115 | 0 | memory_free( |
116 | 0 | *table_definition ); |
117 | |
|
118 | 0 | *table_definition = NULL; |
119 | |
|
120 | 0 | return( -1 ); |
121 | 0 | } |
122 | 39.1k | if( libcdata_array_initialize( |
123 | 39.1k | &( ( *table_definition )->column_catalog_definition_array ), |
124 | 39.1k | 0, |
125 | 39.1k | error ) != 1 ) |
126 | 0 | { |
127 | 0 | libcerror_error_set( |
128 | 0 | error, |
129 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
130 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
131 | 0 | "%s: unable to create column catalog definition array.", |
132 | 0 | function ); |
133 | |
|
134 | 0 | goto on_error; |
135 | 0 | } |
136 | 39.1k | if( libcdata_array_initialize( |
137 | 39.1k | &( ( *table_definition )->index_catalog_definition_array ), |
138 | 39.1k | 0, |
139 | 39.1k | error ) != 1 ) |
140 | 0 | { |
141 | 0 | libcerror_error_set( |
142 | 0 | error, |
143 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
144 | 0 | LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED, |
145 | 0 | "%s: unable to create index catalog definition array.", |
146 | 0 | function ); |
147 | |
|
148 | 0 | goto on_error; |
149 | 0 | } |
150 | 39.1k | ( *table_definition )->table_catalog_definition = table_catalog_definition; |
151 | | |
152 | 39.1k | return( 1 ); |
153 | | |
154 | 0 | on_error: |
155 | 0 | if( *table_definition != NULL ) |
156 | 0 | { |
157 | 0 | if( ( *table_definition )->column_catalog_definition_array != NULL ) |
158 | 0 | { |
159 | 0 | libcdata_array_free( |
160 | 0 | &( ( *table_definition )->column_catalog_definition_array ), |
161 | 0 | NULL, |
162 | 0 | NULL ); |
163 | 0 | } |
164 | 0 | memory_free( |
165 | 0 | *table_definition ); |
166 | |
|
167 | 0 | *table_definition = NULL; |
168 | 0 | } |
169 | 0 | return( -1 ); |
170 | 39.1k | } |
171 | | |
172 | | /* Frees a table definition |
173 | | * Returns 1 if successful or -1 on error |
174 | | */ |
175 | | int libesedb_table_definition_free( |
176 | | libesedb_table_definition_t **table_definition, |
177 | | libcerror_error_t **error ) |
178 | 39.1k | { |
179 | 39.1k | static char *function = "libesedb_table_definition_free"; |
180 | 39.1k | int result = 1; |
181 | | |
182 | 39.1k | if( table_definition == NULL ) |
183 | 0 | { |
184 | 0 | libcerror_error_set( |
185 | 0 | error, |
186 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
187 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
188 | 0 | "%s: invalid table definition.", |
189 | 0 | function ); |
190 | |
|
191 | 0 | return( -1 ); |
192 | 0 | } |
193 | 39.1k | if( *table_definition != NULL ) |
194 | 39.1k | { |
195 | 39.1k | if( ( *table_definition )->table_catalog_definition != NULL ) |
196 | 39.1k | { |
197 | 39.1k | if( libesedb_catalog_definition_free( |
198 | 39.1k | &( ( *table_definition )->table_catalog_definition ), |
199 | 39.1k | error ) != 1 ) |
200 | 0 | { |
201 | 0 | libcerror_error_set( |
202 | 0 | error, |
203 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
204 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
205 | 0 | "%s: unable to free table catalog definition.", |
206 | 0 | function ); |
207 | |
|
208 | 0 | result = -1; |
209 | 0 | } |
210 | 39.1k | } |
211 | 39.1k | if( ( *table_definition )->long_value_catalog_definition != NULL ) |
212 | 239 | { |
213 | 239 | if( libesedb_catalog_definition_free( |
214 | 239 | &( ( *table_definition )->long_value_catalog_definition ), |
215 | 239 | error ) != 1 ) |
216 | 0 | { |
217 | 0 | libcerror_error_set( |
218 | 0 | error, |
219 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
220 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
221 | 0 | "%s: unable to free long value catalog definition.", |
222 | 0 | function ); |
223 | |
|
224 | 0 | result = -1; |
225 | 0 | } |
226 | 239 | } |
227 | 39.1k | if( ( *table_definition )->callback_catalog_definition != NULL ) |
228 | 167 | { |
229 | 167 | if( libesedb_catalog_definition_free( |
230 | 167 | &( ( *table_definition )->callback_catalog_definition ), |
231 | 167 | error ) != 1 ) |
232 | 0 | { |
233 | 0 | libcerror_error_set( |
234 | 0 | error, |
235 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
236 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
237 | 0 | "%s: unable to free callback catalog definition.", |
238 | 0 | function ); |
239 | |
|
240 | 0 | result = -1; |
241 | 0 | } |
242 | 167 | } |
243 | 39.1k | if( libcdata_array_free( |
244 | 39.1k | &( ( *table_definition )->column_catalog_definition_array ), |
245 | 39.1k | (int (*)(intptr_t **, libcerror_error_t **)) &libesedb_catalog_definition_free, |
246 | 39.1k | error ) != 1 ) |
247 | 0 | { |
248 | 0 | libcerror_error_set( |
249 | 0 | error, |
250 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
251 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
252 | 0 | "%s: unable to free column catalog definition array.", |
253 | 0 | function ); |
254 | |
|
255 | 0 | result = -1; |
256 | 0 | } |
257 | 39.1k | if( libcdata_array_free( |
258 | 39.1k | &( ( *table_definition )->index_catalog_definition_array ), |
259 | 39.1k | (int (*)(intptr_t **, libcerror_error_t **)) &libesedb_catalog_definition_free, |
260 | 39.1k | error ) != 1 ) |
261 | 0 | { |
262 | 0 | libcerror_error_set( |
263 | 0 | error, |
264 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
265 | 0 | LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
266 | 0 | "%s: unable to free index catalog definition array.", |
267 | 0 | function ); |
268 | |
|
269 | 0 | result = -1; |
270 | 0 | } |
271 | 39.1k | memory_free( |
272 | 39.1k | *table_definition ); |
273 | | |
274 | 39.1k | *table_definition = NULL; |
275 | 39.1k | } |
276 | 39.1k | return( result ); |
277 | 39.1k | } |
278 | | |
279 | | /* Sets a long value catalog definition to the table definition |
280 | | * Returns 1 if successful or -1 on error |
281 | | */ |
282 | | int libesedb_table_definition_set_long_value_catalog_definition( |
283 | | libesedb_table_definition_t *table_definition, |
284 | | libesedb_catalog_definition_t *long_value_catalog_definition, |
285 | | libcerror_error_t **error ) |
286 | 244 | { |
287 | 244 | static char *function = "libesedb_table_definition_set_long_value_catalog_definition"; |
288 | | |
289 | 244 | if( table_definition == NULL ) |
290 | 0 | { |
291 | 0 | libcerror_error_set( |
292 | 0 | error, |
293 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
294 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
295 | 0 | "%s: invalid table definition.", |
296 | 0 | function ); |
297 | |
|
298 | 0 | return( -1 ); |
299 | 0 | } |
300 | 244 | if( table_definition->long_value_catalog_definition != NULL ) |
301 | 5 | { |
302 | 5 | libcerror_error_set( |
303 | 5 | error, |
304 | 5 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
305 | 5 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
306 | 5 | "%s: invalid table definition - long value catalog definition already set.", |
307 | 5 | function ); |
308 | | |
309 | 5 | return( -1 ); |
310 | 5 | } |
311 | 239 | if( long_value_catalog_definition == NULL ) |
312 | 0 | { |
313 | 0 | libcerror_error_set( |
314 | 0 | error, |
315 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
316 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
317 | 0 | "%s: invalid long value catalog definition.", |
318 | 0 | function ); |
319 | |
|
320 | 0 | return( -1 ); |
321 | 0 | } |
322 | 239 | if( long_value_catalog_definition->type != LIBESEDB_CATALOG_DEFINITION_TYPE_LONG_VALUE ) |
323 | 0 | { |
324 | 0 | libcerror_error_set( |
325 | 0 | error, |
326 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
327 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
328 | 0 | "%s: unsupported catalog definition type: %" PRIu16 ".", |
329 | 0 | function, |
330 | 0 | long_value_catalog_definition->type ); |
331 | |
|
332 | 0 | return( -1 ); |
333 | 0 | } |
334 | 239 | table_definition->long_value_catalog_definition = long_value_catalog_definition; |
335 | | |
336 | 239 | return( 1 ); |
337 | 239 | } |
338 | | |
339 | | /* Sets a callback catalog definition to the table definition |
340 | | * Returns 1 if successful or -1 on error |
341 | | */ |
342 | | int libesedb_table_definition_set_callback_catalog_definition( |
343 | | libesedb_table_definition_t *table_definition, |
344 | | libesedb_catalog_definition_t *callback_catalog_definition, |
345 | | libcerror_error_t **error ) |
346 | 173 | { |
347 | 173 | static char *function = "libesedb_table_definition_set_callback_catalog_definition"; |
348 | | |
349 | 173 | if( table_definition == NULL ) |
350 | 0 | { |
351 | 0 | libcerror_error_set( |
352 | 0 | error, |
353 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
354 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
355 | 0 | "%s: invalid table definition.", |
356 | 0 | function ); |
357 | |
|
358 | 0 | return( -1 ); |
359 | 0 | } |
360 | 173 | if( table_definition->callback_catalog_definition != NULL ) |
361 | 6 | { |
362 | 6 | libcerror_error_set( |
363 | 6 | error, |
364 | 6 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
365 | 6 | LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
366 | 6 | "%s: invalid table definition - callback catalog definition already set.", |
367 | 6 | function ); |
368 | | |
369 | 6 | return( -1 ); |
370 | 6 | } |
371 | 167 | if( callback_catalog_definition == NULL ) |
372 | 0 | { |
373 | 0 | libcerror_error_set( |
374 | 0 | error, |
375 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
376 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
377 | 0 | "%s: invalid callback catalog definition.", |
378 | 0 | function ); |
379 | |
|
380 | 0 | return( -1 ); |
381 | 0 | } |
382 | 167 | if( callback_catalog_definition->type != LIBESEDB_CATALOG_DEFINITION_TYPE_CALLBACK ) |
383 | 0 | { |
384 | 0 | libcerror_error_set( |
385 | 0 | error, |
386 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
387 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
388 | 0 | "%s: unsupported catalog definition type: %" PRIu16 ".", |
389 | 0 | function, |
390 | 0 | callback_catalog_definition->type ); |
391 | |
|
392 | 0 | return( -1 ); |
393 | 0 | } |
394 | 167 | table_definition->callback_catalog_definition = callback_catalog_definition; |
395 | | |
396 | 167 | return( 1 ); |
397 | 167 | } |
398 | | |
399 | | /* Retrieves the number of column catalog definitions |
400 | | * Returns 1 if successful or -1 on error |
401 | | */ |
402 | | int libesedb_table_definition_get_number_of_column_catalog_definitions( |
403 | | libesedb_table_definition_t *table_definition, |
404 | | int *number_of_definitions, |
405 | | libcerror_error_t **error ) |
406 | 349 | { |
407 | 349 | static char *function = "libesedb_table_definition_get_number_of_column_catalog_definitions"; |
408 | | |
409 | 349 | if( table_definition == NULL ) |
410 | 0 | { |
411 | 0 | libcerror_error_set( |
412 | 0 | error, |
413 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
414 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
415 | 0 | "%s: invalid table definition.", |
416 | 0 | function ); |
417 | |
|
418 | 0 | return( -1 ); |
419 | 0 | } |
420 | 349 | if( libcdata_array_get_number_of_entries( |
421 | 349 | table_definition->column_catalog_definition_array, |
422 | 349 | number_of_definitions, |
423 | 349 | error ) != 1 ) |
424 | 0 | { |
425 | 0 | libcerror_error_set( |
426 | 0 | error, |
427 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
428 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
429 | 0 | "%s: unable to retrieve number of entries from column catalog definition array.", |
430 | 0 | function ); |
431 | |
|
432 | 0 | return( -1 ); |
433 | 0 | } |
434 | 349 | return( 1 ); |
435 | 349 | } |
436 | | |
437 | | /* Retrieves a specific column catalog definition |
438 | | * Returns 1 if successful or -1 on error |
439 | | */ |
440 | | int libesedb_table_definition_get_column_catalog_definition_by_index( |
441 | | libesedb_table_definition_t *table_definition, |
442 | | int definition_index, |
443 | | libesedb_catalog_definition_t **column_catalog_definition, |
444 | | libcerror_error_t **error ) |
445 | 20.3k | { |
446 | 20.3k | static char *function = "libesedb_table_definition_get_column_catalog_definition_by_index"; |
447 | | |
448 | 20.3k | if( table_definition == NULL ) |
449 | 0 | { |
450 | 0 | libcerror_error_set( |
451 | 0 | error, |
452 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
453 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
454 | 0 | "%s: invalid table definition.", |
455 | 0 | function ); |
456 | |
|
457 | 0 | return( -1 ); |
458 | 0 | } |
459 | 20.3k | if( libcdata_array_get_entry_by_index( |
460 | 20.3k | table_definition->column_catalog_definition_array, |
461 | 20.3k | definition_index, |
462 | 20.3k | (intptr_t **) column_catalog_definition, |
463 | 20.3k | error ) != 1 ) |
464 | 0 | { |
465 | 0 | libcerror_error_set( |
466 | 0 | error, |
467 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
468 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
469 | 0 | "%s: unable to retrieve entry: %d from column catalog definition array.", |
470 | 0 | function, |
471 | 0 | definition_index ); |
472 | |
|
473 | 0 | return( -1 ); |
474 | 0 | } |
475 | 20.3k | return( 1 ); |
476 | 20.3k | } |
477 | | |
478 | | /* Appends a column catalog definition to the table definition |
479 | | * Returns 1 if successful or -1 on error |
480 | | */ |
481 | | int libesedb_table_definition_append_column_catalog_definition( |
482 | | libesedb_table_definition_t *table_definition, |
483 | | libesedb_catalog_definition_t *column_catalog_definition, |
484 | | libcerror_error_t **error ) |
485 | 84.0k | { |
486 | 84.0k | static char *function = "libesedb_table_definition_append_column_catalog_definition"; |
487 | 84.0k | int entry_index = 0; |
488 | | |
489 | 84.0k | if( table_definition == NULL ) |
490 | 0 | { |
491 | 0 | libcerror_error_set( |
492 | 0 | error, |
493 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
494 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
495 | 0 | "%s: invalid table definition.", |
496 | 0 | function ); |
497 | |
|
498 | 0 | return( -1 ); |
499 | 0 | } |
500 | 84.0k | if( column_catalog_definition == NULL ) |
501 | 0 | { |
502 | 0 | libcerror_error_set( |
503 | 0 | error, |
504 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
505 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
506 | 0 | "%s: invalid column catalog definition.", |
507 | 0 | function ); |
508 | |
|
509 | 0 | return( -1 ); |
510 | 0 | } |
511 | 84.0k | if( column_catalog_definition->type != LIBESEDB_CATALOG_DEFINITION_TYPE_COLUMN ) |
512 | 0 | { |
513 | 0 | libcerror_error_set( |
514 | 0 | error, |
515 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
516 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
517 | 0 | "%s: unsupported catalog definition type: %" PRIu16 ".", |
518 | 0 | function, |
519 | 0 | column_catalog_definition->type ); |
520 | |
|
521 | 0 | return( -1 ); |
522 | 0 | } |
523 | 84.0k | if( libcdata_array_append_entry( |
524 | 84.0k | table_definition->column_catalog_definition_array, |
525 | 84.0k | &entry_index, |
526 | 84.0k | (intptr_t *) column_catalog_definition, |
527 | 84.0k | error ) != 1 ) |
528 | 0 | { |
529 | 0 | libcerror_error_set( |
530 | 0 | error, |
531 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
532 | 0 | LIBCERROR_RUNTIME_ERROR_APPEND_FAILED, |
533 | 0 | "%s: unable to append column catalog definition to array.", |
534 | 0 | function ); |
535 | |
|
536 | 0 | return( -1 ); |
537 | 0 | } |
538 | 84.0k | return( 1 ); |
539 | 84.0k | } |
540 | | |
541 | | /* Retrieves the number of index catalog definitions |
542 | | * Returns 1 if successful or -1 on error |
543 | | */ |
544 | | int libesedb_table_definition_get_number_of_index_catalog_definitions( |
545 | | libesedb_table_definition_t *table_definition, |
546 | | int *number_of_definitions, |
547 | | libcerror_error_t **error ) |
548 | 0 | { |
549 | 0 | static char *function = "libesedb_table_definition_get_number_of_index_catalog_definitions"; |
550 | |
|
551 | 0 | if( table_definition == NULL ) |
552 | 0 | { |
553 | 0 | libcerror_error_set( |
554 | 0 | error, |
555 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
556 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
557 | 0 | "%s: invalid table definition.", |
558 | 0 | function ); |
559 | |
|
560 | 0 | return( -1 ); |
561 | 0 | } |
562 | 0 | if( libcdata_array_get_number_of_entries( |
563 | 0 | table_definition->index_catalog_definition_array, |
564 | 0 | number_of_definitions, |
565 | 0 | error ) != 1 ) |
566 | 0 | { |
567 | 0 | libcerror_error_set( |
568 | 0 | error, |
569 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
570 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
571 | 0 | "%s: unable to retrieve number of entries from index catalog definition array.", |
572 | 0 | function ); |
573 | |
|
574 | 0 | return( -1 ); |
575 | 0 | } |
576 | 0 | return( 1 ); |
577 | 0 | } |
578 | | |
579 | | /* Retrieves a specific index catalog definition |
580 | | * Returns 1 if successful or -1 on error |
581 | | */ |
582 | | int libesedb_table_definition_get_index_catalog_definition_by_index( |
583 | | libesedb_table_definition_t *table_definition, |
584 | | int definition_index, |
585 | | libesedb_catalog_definition_t **index_catalog_definition, |
586 | | libcerror_error_t **error ) |
587 | 0 | { |
588 | 0 | static char *function = "libesedb_table_definition_get_index_catalog_definition_by_index"; |
589 | |
|
590 | 0 | if( table_definition == NULL ) |
591 | 0 | { |
592 | 0 | libcerror_error_set( |
593 | 0 | error, |
594 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
595 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
596 | 0 | "%s: invalid table definition.", |
597 | 0 | function ); |
598 | |
|
599 | 0 | return( -1 ); |
600 | 0 | } |
601 | 0 | if( libcdata_array_get_entry_by_index( |
602 | 0 | table_definition->index_catalog_definition_array, |
603 | 0 | definition_index, |
604 | 0 | (intptr_t **) index_catalog_definition, |
605 | 0 | error ) != 1 ) |
606 | 0 | { |
607 | 0 | libcerror_error_set( |
608 | 0 | error, |
609 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
610 | 0 | LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
611 | 0 | "%s: unable to retrieve entry: %d from index catalog definition array.", |
612 | 0 | function, |
613 | 0 | definition_index ); |
614 | |
|
615 | 0 | return( -1 ); |
616 | 0 | } |
617 | 0 | return( 1 ); |
618 | 0 | } |
619 | | |
620 | | /* Appends an index catalog definition to the table definition |
621 | | * Returns 1 if successful or -1 on error |
622 | | */ |
623 | | int libesedb_table_definition_append_index_catalog_definition( |
624 | | libesedb_table_definition_t *table_definition, |
625 | | libesedb_catalog_definition_t *index_catalog_definition, |
626 | | libcerror_error_t **error ) |
627 | 3.10k | { |
628 | 3.10k | static char *function = "libesedb_table_definition_append_index_catalog_definition"; |
629 | 3.10k | int entry_index = 0; |
630 | | |
631 | 3.10k | if( table_definition == NULL ) |
632 | 0 | { |
633 | 0 | libcerror_error_set( |
634 | 0 | error, |
635 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
636 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
637 | 0 | "%s: invalid table definition.", |
638 | 0 | function ); |
639 | |
|
640 | 0 | return( -1 ); |
641 | 0 | } |
642 | 3.10k | if( index_catalog_definition == NULL ) |
643 | 0 | { |
644 | 0 | libcerror_error_set( |
645 | 0 | error, |
646 | 0 | LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
647 | 0 | LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
648 | 0 | "%s: invalid index catalog definition.", |
649 | 0 | function ); |
650 | |
|
651 | 0 | return( -1 ); |
652 | 0 | } |
653 | 3.10k | if( index_catalog_definition->type != LIBESEDB_CATALOG_DEFINITION_TYPE_INDEX ) |
654 | 0 | { |
655 | 0 | libcerror_error_set( |
656 | 0 | error, |
657 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
658 | 0 | LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
659 | 0 | "%s: unsupported catalog definition type: %" PRIu16 ".", |
660 | 0 | function, |
661 | 0 | index_catalog_definition->type ); |
662 | |
|
663 | 0 | return( -1 ); |
664 | 0 | } |
665 | 3.10k | if( libcdata_array_append_entry( |
666 | 3.10k | table_definition->index_catalog_definition_array, |
667 | 3.10k | &entry_index, |
668 | 3.10k | (intptr_t *) index_catalog_definition, |
669 | 3.10k | error ) != 1 ) |
670 | 0 | { |
671 | 0 | libcerror_error_set( |
672 | 0 | error, |
673 | 0 | LIBCERROR_ERROR_DOMAIN_RUNTIME, |
674 | 0 | LIBCERROR_RUNTIME_ERROR_APPEND_FAILED, |
675 | 0 | "%s: unable to append index catalog definition to array.", |
676 | 0 | function ); |
677 | |
|
678 | 0 | return( -1 ); |
679 | 0 | } |
680 | 3.10k | return( 1 ); |
681 | 3.10k | } |
682 | | |