1 /*
2  * The cache functions
3  *
4  * Copyright (C) 2010-2017, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This software 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 software 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 software.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _LIBFCACHE_INTERNAL_CACHE_H )
23 #define _LIBFCACHE_INTERNAL_CACHE_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #include "libfcache_cache_value.h"
29 #include "libfcache_date_time.h"
30 #include "libfcache_extern.h"
31 #include "libfcache_libcdata.h"
32 #include "libfcache_libcerror.h"
33 #include "libfcache_types.h"
34 
35 #if defined( __cplusplus )
36 extern "C" {
37 #endif
38 
39 typedef struct libfcache_internal_cache libfcache_internal_cache_t;
40 
41 struct libfcache_internal_cache
42 {
43 	/* The cache entries (array)
44 	 */
45 	libcdata_array_t *entries;
46 
47 	/* The number of cache values
48 	 */
49 	int number_of_cache_values;
50 };
51 
52 LIBFCACHE_EXTERN \
53 int libfcache_cache_initialize(
54      libfcache_cache_t **cache,
55      int maximum_cache_entries,
56      libcerror_error_t **error );
57 
58 LIBFCACHE_EXTERN \
59 int libfcache_cache_free(
60      libfcache_cache_t **cache,
61      libcerror_error_t **error );
62 
63 LIBFCACHE_EXTERN \
64 int libfcache_cache_empty(
65      libfcache_cache_t *cache,
66      libcerror_error_t **error );
67 
68 LIBFCACHE_EXTERN \
69 int libfcache_cache_clone(
70      libfcache_cache_t **destination_cache,
71      libfcache_cache_t *source_cache,
72      libcerror_error_t **error );
73 
74 LIBFCACHE_EXTERN \
75 int libfcache_cache_resize(
76      libfcache_cache_t *cache,
77      int maximum_cache_entries,
78      libcerror_error_t **error );
79 
80 LIBFCACHE_EXTERN \
81 int libfcache_cache_get_number_of_entries(
82      libfcache_cache_t *cache,
83      int *number_of_entries,
84      libcerror_error_t **error );
85 
86 LIBFCACHE_EXTERN \
87 int libfcache_cache_get_number_of_cache_values(
88      libfcache_cache_t *cache,
89      int *number_of_values,
90      libcerror_error_t **error );
91 
92 /* Cache value functions
93  */
94 LIBFCACHE_EXTERN \
95 int libfcache_cache_get_value_by_index(
96      libfcache_cache_t *cache,
97      int cache_entry_index,
98      libfcache_cache_value_t **cache_value,
99      libcerror_error_t **error );
100 
101 LIBFCACHE_EXTERN \
102 int libfcache_cache_set_value_by_index(
103      libfcache_cache_t *cache,
104      int cache_entry_index,
105      int file_index,
106      off64_t offset,
107      time_t timestamp,
108      intptr_t *value,
109      int (*free_value)(
110             intptr_t **value,
111             libcerror_error_t **error ),
112      uint8_t flags,
113      libcerror_error_t **error );
114 
115 #if defined( __cplusplus )
116 }
117 #endif
118 
119 #endif /* !defined( _LIBFCACHE_INTERNAL_CACHE_H ) */
120 
121