1 /*
2  * Grain data functions
3  *
4  * Copyright (C) 2009-2021, 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 #if !defined( _LIBVMDK_GRAIN_DATA_H )
23 #define _LIBVMDK_GRAIN_DATA_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "libvmdk_io_handle.h"
29 #include "libvmdk_libcerror.h"
30 #include "libvmdk_libfdata.h"
31 
32 #if defined( __cplusplus )
33 extern "C" {
34 #endif
35 
36 typedef struct libvmdk_grain_data libvmdk_grain_data_t;
37 
38 struct libvmdk_grain_data
39 {
40 	/* The uncompressed data offset
41 	 */
42 	off64_t uncompressed_data_offset;
43 
44 	/* The compressed data size
45 	 */
46 	uint32_t compressed_data_size;
47 
48 	/* The data
49 	 */
50 	uint8_t *data;
51 
52 	/* The data size
53 	 */
54 	size_t data_size;
55 };
56 
57 int libvmdk_grain_data_initialize(
58      libvmdk_grain_data_t **grain_data,
59      size_t data_size,
60      libcerror_error_t **error );
61 
62 int libvmdk_grain_data_free(
63      libvmdk_grain_data_t **grain_data,
64      libcerror_error_t **error );
65 
66 ssize_t libvmdk_grain_data_read_compressed_header(
67          libvmdk_grain_data_t *grain_data,
68          libvmdk_io_handle_t *io_handle,
69          libbfio_pool_t *file_io_pool,
70          int file_io_pool_entry,
71          libcerror_error_t **error );
72 
73 int libvmdk_grain_data_read_element_data(
74      libvmdk_io_handle_t *io_handle,
75      libbfio_pool_t *file_io_pool,
76      libfdata_list_element_t *element,
77      libfdata_cache_t *cache,
78      int file_io_pool_entry,
79      off64_t grain_data_offset,
80      size64_t grain_data_size,
81      uint32_t grain_data_flags,
82      uint8_t read_flags,
83      libcerror_error_t **error );
84 
85 #if defined( __cplusplus )
86 }
87 #endif
88 
89 #endif /* !defined( _LIBVMDK_GRAIN_DATA_H ) */
90 
91