diff options
Diffstat (limited to 'src/lib/libcrypto/store/str_meth.c')
-rw-r--r-- | src/lib/libcrypto/store/str_meth.c | 243 |
1 files changed, 145 insertions, 98 deletions
diff --git a/src/lib/libcrypto/store/str_meth.c b/src/lib/libcrypto/store/str_meth.c index 0401aaa129..9457087757 100644 --- a/src/lib/libcrypto/store/str_meth.c +++ b/src/lib/libcrypto/store/str_meth.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -60,189 +60,236 @@ | |||
60 | #include <openssl/buffer.h> | 60 | #include <openssl/buffer.h> |
61 | #include "str_locl.h" | 61 | #include "str_locl.h" |
62 | 62 | ||
63 | STORE_METHOD *STORE_create_method(char *name) | 63 | STORE_METHOD * |
64 | { | 64 | STORE_create_method(char *name) |
65 | { | ||
65 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); | 66 | STORE_METHOD *store_method = calloc(1, sizeof(STORE_METHOD)); |
66 | 67 | ||
67 | if (store_method) | 68 | if (store_method) |
68 | store_method->name = BUF_strdup(name); | 69 | store_method->name = BUF_strdup(name); |
69 | 70 | ||
70 | return store_method; | 71 | return store_method; |
71 | } | 72 | } |
72 | 73 | ||
73 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method | 74 | /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method |
74 | (that is, it hasn't been allocated using STORE_create_method(), you deserve | 75 | (that is, it hasn't been allocated using STORE_create_method(), you deserve |
75 | anything Murphy can throw at you and more! You have been warned. */ | 76 | anything Murphy can throw at you and more! You have been warned. */ |
76 | void STORE_destroy_method(STORE_METHOD *store_method) | 77 | void |
77 | { | 78 | STORE_destroy_method(STORE_METHOD *store_method) |
78 | if (!store_method) return; | 79 | { |
80 | if (!store_method) | ||
81 | return; | ||
79 | free(store_method->name); | 82 | free(store_method->name); |
80 | store_method->name = NULL; | 83 | store_method->name = NULL; |
81 | free(store_method); | 84 | free(store_method); |
82 | } | 85 | } |
83 | 86 | ||
84 | int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f) | 87 | int |
85 | { | 88 | STORE_method_set_initialise_function(STORE_METHOD *sm, |
89 | STORE_INITIALISE_FUNC_PTR init_f) | ||
90 | { | ||
86 | sm->init = init_f; | 91 | sm->init = init_f; |
87 | return 1; | 92 | return 1; |
88 | } | 93 | } |
89 | 94 | ||
90 | int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f) | 95 | int |
91 | { | 96 | STORE_method_set_cleanup_function(STORE_METHOD *sm, |
97 | STORE_CLEANUP_FUNC_PTR clean_f) | ||
98 | { | ||
92 | sm->clean = clean_f; | 99 | sm->clean = clean_f; |
93 | return 1; | 100 | return 1; |
94 | } | 101 | } |
95 | 102 | ||
96 | int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | 103 | int |
97 | { | 104 | STORE_method_set_generate_function(STORE_METHOD *sm, |
105 | STORE_GENERATE_OBJECT_FUNC_PTR generate_f) | ||
106 | { | ||
98 | sm->generate_object = generate_f; | 107 | sm->generate_object = generate_f; |
99 | return 1; | 108 | return 1; |
100 | } | 109 | } |
101 | 110 | ||
102 | int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f) | 111 | int |
103 | { | 112 | STORE_method_set_get_function(STORE_METHOD *sm, |
113 | STORE_GET_OBJECT_FUNC_PTR get_f) | ||
114 | { | ||
104 | sm->get_object = get_f; | 115 | sm->get_object = get_f; |
105 | return 1; | 116 | return 1; |
106 | } | 117 | } |
107 | 118 | ||
108 | int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f) | 119 | int |
109 | { | 120 | STORE_method_set_store_function(STORE_METHOD *sm, |
121 | STORE_STORE_OBJECT_FUNC_PTR store_f) | ||
122 | { | ||
110 | sm->store_object = store_f; | 123 | sm->store_object = store_f; |
111 | return 1; | 124 | return 1; |
112 | } | 125 | } |
113 | 126 | ||
114 | int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | 127 | int |
115 | { | 128 | STORE_method_set_modify_function(STORE_METHOD *sm, |
129 | STORE_MODIFY_OBJECT_FUNC_PTR modify_f) | ||
130 | { | ||
116 | sm->modify_object = modify_f; | 131 | sm->modify_object = modify_f; |
117 | return 1; | 132 | return 1; |
118 | } | 133 | } |
119 | 134 | ||
120 | int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | 135 | int |
121 | { | 136 | STORE_method_set_revoke_function(STORE_METHOD *sm, |
137 | STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) | ||
138 | { | ||
122 | sm->revoke_object = revoke_f; | 139 | sm->revoke_object = revoke_f; |
123 | return 1; | 140 | return 1; |
124 | } | 141 | } |
125 | 142 | ||
126 | int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | 143 | int |
127 | { | 144 | STORE_method_set_delete_function(STORE_METHOD *sm, |
145 | STORE_HANDLE_OBJECT_FUNC_PTR delete_f) | ||
146 | { | ||
128 | sm->delete_object = delete_f; | 147 | sm->delete_object = delete_f; |
129 | return 1; | 148 | return 1; |
130 | } | 149 | } |
131 | 150 | ||
132 | int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f) | 151 | int |
133 | { | 152 | STORE_method_set_list_start_function(STORE_METHOD *sm, |
153 | STORE_START_OBJECT_FUNC_PTR list_start_f) | ||
154 | { | ||
134 | sm->list_object_start = list_start_f; | 155 | sm->list_object_start = list_start_f; |
135 | return 1; | 156 | return 1; |
136 | } | 157 | } |
137 | 158 | ||
138 | int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | 159 | int |
139 | { | 160 | STORE_method_set_list_next_function(STORE_METHOD *sm, |
161 | STORE_NEXT_OBJECT_FUNC_PTR list_next_f) | ||
162 | { | ||
140 | sm->list_object_next = list_next_f; | 163 | sm->list_object_next = list_next_f; |
141 | return 1; | 164 | return 1; |
142 | } | 165 | } |
143 | 166 | ||
144 | int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f) | 167 | int |
145 | { | 168 | STORE_method_set_list_end_function(STORE_METHOD *sm, |
169 | STORE_END_OBJECT_FUNC_PTR list_end_f) | ||
170 | { | ||
146 | sm->list_object_end = list_end_f; | 171 | sm->list_object_end = list_end_f; |
147 | return 1; | 172 | return 1; |
148 | } | 173 | } |
149 | 174 | ||
150 | int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f) | 175 | int |
151 | { | 176 | STORE_method_set_update_store_function(STORE_METHOD *sm, |
177 | STORE_GENERIC_FUNC_PTR update_f) | ||
178 | { | ||
152 | sm->update_store = update_f; | 179 | sm->update_store = update_f; |
153 | return 1; | 180 | return 1; |
154 | } | 181 | } |
155 | 182 | ||
156 | int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f) | 183 | int |
157 | { | 184 | STORE_method_set_lock_store_function(STORE_METHOD *sm, |
185 | STORE_GENERIC_FUNC_PTR lock_f) | ||
186 | { | ||
158 | sm->lock_store = lock_f; | 187 | sm->lock_store = lock_f; |
159 | return 1; | 188 | return 1; |
160 | } | 189 | } |
161 | 190 | ||
162 | int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f) | 191 | int |
163 | { | 192 | STORE_method_set_unlock_store_function(STORE_METHOD *sm, |
193 | STORE_GENERIC_FUNC_PTR unlock_f) | ||
194 | { | ||
164 | sm->unlock_store = unlock_f; | 195 | sm->unlock_store = unlock_f; |
165 | return 1; | 196 | return 1; |
166 | } | 197 | } |
167 | 198 | ||
168 | int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) | 199 | int |
169 | { | 200 | STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) |
201 | { | ||
170 | sm->ctrl = ctrl_f; | 202 | sm->ctrl = ctrl_f; |
171 | return 1; | 203 | return 1; |
172 | } | 204 | } |
173 | 205 | ||
174 | STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm) | 206 | STORE_INITIALISE_FUNC_PTR |
175 | { | 207 | STORE_method_get_initialise_function(STORE_METHOD *sm) |
208 | { | ||
176 | return sm->init; | 209 | return sm->init; |
177 | } | 210 | } |
178 | 211 | ||
179 | STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm) | 212 | STORE_CLEANUP_FUNC_PTR |
180 | { | 213 | STORE_method_get_cleanup_function(STORE_METHOD *sm) |
214 | { | ||
181 | return sm->clean; | 215 | return sm->clean; |
182 | } | 216 | } |
183 | 217 | ||
184 | STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm) | 218 | STORE_GENERATE_OBJECT_FUNC_PTR |
185 | { | 219 | STORE_method_get_generate_function(STORE_METHOD *sm) |
220 | { | ||
186 | return sm->generate_object; | 221 | return sm->generate_object; |
187 | } | 222 | } |
188 | 223 | ||
189 | STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm) | 224 | STORE_GET_OBJECT_FUNC_PTR |
190 | { | 225 | STORE_method_get_get_function(STORE_METHOD *sm) |
226 | { | ||
191 | return sm->get_object; | 227 | return sm->get_object; |
192 | } | 228 | } |
193 | 229 | ||
194 | STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm) | 230 | STORE_STORE_OBJECT_FUNC_PTR |
195 | { | 231 | STORE_method_get_store_function(STORE_METHOD *sm) |
232 | { | ||
196 | return sm->store_object; | 233 | return sm->store_object; |
197 | } | 234 | } |
198 | 235 | ||
199 | STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm) | 236 | STORE_MODIFY_OBJECT_FUNC_PTR |
200 | { | 237 | STORE_method_get_modify_function(STORE_METHOD *sm) |
238 | { | ||
201 | return sm->modify_object; | 239 | return sm->modify_object; |
202 | } | 240 | } |
203 | 241 | ||
204 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm) | 242 | STORE_HANDLE_OBJECT_FUNC_PTR |
205 | { | 243 | STORE_method_get_revoke_function(STORE_METHOD *sm) |
244 | { | ||
206 | return sm->revoke_object; | 245 | return sm->revoke_object; |
207 | } | 246 | } |
208 | 247 | ||
209 | STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm) | 248 | STORE_HANDLE_OBJECT_FUNC_PTR |
210 | { | 249 | STORE_method_get_delete_function(STORE_METHOD *sm) |
250 | { | ||
211 | return sm->delete_object; | 251 | return sm->delete_object; |
212 | } | 252 | } |
213 | 253 | ||
214 | STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm) | 254 | STORE_START_OBJECT_FUNC_PTR |
215 | { | 255 | STORE_method_get_list_start_function(STORE_METHOD *sm) |
256 | { | ||
216 | return sm->list_object_start; | 257 | return sm->list_object_start; |
217 | } | 258 | } |
218 | 259 | ||
219 | STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm) | 260 | STORE_NEXT_OBJECT_FUNC_PTR |
220 | { | 261 | STORE_method_get_list_next_function(STORE_METHOD *sm) |
262 | { | ||
221 | return sm->list_object_next; | 263 | return sm->list_object_next; |
222 | } | 264 | } |
223 | 265 | ||
224 | STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm) | 266 | STORE_END_OBJECT_FUNC_PTR |
225 | { | 267 | STORE_method_get_list_end_function(STORE_METHOD *sm) |
268 | { | ||
226 | return sm->list_object_end; | 269 | return sm->list_object_end; |
227 | } | 270 | } |
228 | 271 | ||
229 | STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm) | 272 | STORE_GENERIC_FUNC_PTR |
230 | { | 273 | STORE_method_get_update_store_function(STORE_METHOD *sm) |
274 | { | ||
231 | return sm->update_store; | 275 | return sm->update_store; |
232 | } | 276 | } |
233 | 277 | ||
234 | STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm) | 278 | STORE_GENERIC_FUNC_PTR |
235 | { | 279 | STORE_method_get_lock_store_function(STORE_METHOD *sm) |
280 | { | ||
236 | return sm->lock_store; | 281 | return sm->lock_store; |
237 | } | 282 | } |
238 | 283 | ||
239 | STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm) | 284 | STORE_GENERIC_FUNC_PTR |
240 | { | 285 | STORE_method_get_unlock_store_function(STORE_METHOD *sm) |
286 | { | ||
241 | return sm->unlock_store; | 287 | return sm->unlock_store; |
242 | } | 288 | } |
243 | 289 | ||
244 | STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm) | 290 | STORE_CTRL_FUNC_PTR |
245 | { | 291 | STORE_method_get_ctrl_function(STORE_METHOD *sm) |
292 | { | ||
246 | return sm->ctrl; | 293 | return sm->ctrl; |
247 | } | 294 | } |
248 | 295 | ||