1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/store/str_meth.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,250 @@
1.4 +/* crypto/store/str_meth.c -*- mode:C; c-file-style: "eay" -*- */
1.5 +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
1.6 + * project 2003.
1.7 + */
1.8 +/* ====================================================================
1.9 + * Copyright (c) 2003 The OpenSSL Project. All rights reserved.
1.10 + *
1.11 + * Redistribution and use in source and binary forms, with or without
1.12 + * modification, are permitted provided that the following conditions
1.13 + * are met:
1.14 + *
1.15 + * 1. Redistributions of source code must retain the above copyright
1.16 + * notice, this list of conditions and the following disclaimer.
1.17 + *
1.18 + * 2. Redistributions in binary form must reproduce the above copyright
1.19 + * notice, this list of conditions and the following disclaimer in
1.20 + * the documentation and/or other materials provided with the
1.21 + * distribution.
1.22 + *
1.23 + * 3. All advertising materials mentioning features or use of this
1.24 + * software must display the following acknowledgment:
1.25 + * "This product includes software developed by the OpenSSL Project
1.26 + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
1.27 + *
1.28 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.29 + * endorse or promote products derived from this software without
1.30 + * prior written permission. For written permission, please contact
1.31 + * openssl-core@openssl.org.
1.32 + *
1.33 + * 5. Products derived from this software may not be called "OpenSSL"
1.34 + * nor may "OpenSSL" appear in their names without prior written
1.35 + * permission of the OpenSSL Project.
1.36 + *
1.37 + * 6. Redistributions of any form whatsoever must retain the following
1.38 + * acknowledgment:
1.39 + * "This product includes software developed by the OpenSSL Project
1.40 + * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
1.41 + *
1.42 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.43 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.44 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.45 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.46 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.47 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.48 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.49 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.50 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.51 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.52 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.53 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.54 + * ====================================================================
1.55 + *
1.56 + * This product includes cryptographic software written by Eric Young
1.57 + * (eay@cryptsoft.com). This product includes software written by Tim
1.58 + * Hudson (tjh@cryptsoft.com).
1.59 + *
1.60 + */
1.61 +
1.62 +#include <string.h>
1.63 +#include <openssl/buffer.h>
1.64 +#include "str_locl.h"
1.65 +
1.66 +EXPORT_C STORE_METHOD *STORE_create_method(char *name)
1.67 + {
1.68 + STORE_METHOD *store_method = (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD));
1.69 +
1.70 + if (store_method)
1.71 + {
1.72 + memset(store_method, 0, sizeof(*store_method));
1.73 + store_method->name = BUF_strdup(name);
1.74 +}
1.75 + return store_method;
1.76 + }
1.77 +
1.78 +/* BIG FSCKING WARNING!!!! If you use this on a statically allocated method
1.79 + (that is, it hasn't been allocated using STORE_create_method(), you deserve
1.80 + anything Murphy can throw at you and more! You have been warned. */
1.81 +EXPORT_C void STORE_destroy_method(STORE_METHOD *store_method)
1.82 + {
1.83 + if (!store_method) return;
1.84 + OPENSSL_free(store_method->name);
1.85 + store_method->name = NULL;
1.86 + OPENSSL_free(store_method);
1.87 + }
1.88 +
1.89 +EXPORT_C int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f)
1.90 + {
1.91 + sm->init = init_f;
1.92 + return 1;
1.93 + }
1.94 +
1.95 +EXPORT_C int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f)
1.96 + {
1.97 + sm->clean = clean_f;
1.98 + return 1;
1.99 + }
1.100 +
1.101 +EXPORT_C int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f)
1.102 + {
1.103 + sm->generate_object = generate_f;
1.104 + return 1;
1.105 + }
1.106 +
1.107 +EXPORT_C int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f)
1.108 + {
1.109 + sm->get_object = get_f;
1.110 + return 1;
1.111 + }
1.112 +
1.113 +EXPORT_C int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f)
1.114 + {
1.115 + sm->store_object = store_f;
1.116 + return 1;
1.117 + }
1.118 +
1.119 +EXPORT_C int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f)
1.120 + {
1.121 + sm->modify_object = modify_f;
1.122 + return 1;
1.123 + }
1.124 +
1.125 +EXPORT_C int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f)
1.126 + {
1.127 + sm->revoke_object = revoke_f;
1.128 + return 1;
1.129 + }
1.130 +
1.131 +EXPORT_C int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f)
1.132 + {
1.133 + sm->delete_object = delete_f;
1.134 + return 1;
1.135 + }
1.136 +
1.137 +EXPORT_C int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f)
1.138 + {
1.139 + sm->list_object_start = list_start_f;
1.140 + return 1;
1.141 + }
1.142 +
1.143 +EXPORT_C int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f)
1.144 + {
1.145 + sm->list_object_next = list_next_f;
1.146 + return 1;
1.147 + }
1.148 +
1.149 +EXPORT_C int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f)
1.150 + {
1.151 + sm->list_object_end = list_end_f;
1.152 + return 1;
1.153 + }
1.154 +
1.155 +EXPORT_C int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f)
1.156 + {
1.157 + sm->update_store = update_f;
1.158 + return 1;
1.159 + }
1.160 +
1.161 +EXPORT_C int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f)
1.162 + {
1.163 + sm->lock_store = lock_f;
1.164 + return 1;
1.165 + }
1.166 +
1.167 +EXPORT_C int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f)
1.168 + {
1.169 + sm->unlock_store = unlock_f;
1.170 + return 1;
1.171 + }
1.172 +
1.173 +EXPORT_C int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f)
1.174 + {
1.175 + sm->ctrl = ctrl_f;
1.176 + return 1;
1.177 + }
1.178 +
1.179 +EXPORT_C STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm)
1.180 + {
1.181 + return sm->init;
1.182 + }
1.183 +
1.184 +EXPORT_C STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm)
1.185 + {
1.186 + return sm->clean;
1.187 + }
1.188 +
1.189 +EXPORT_C STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm)
1.190 + {
1.191 + return sm->generate_object;
1.192 + }
1.193 +
1.194 +EXPORT_C STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm)
1.195 + {
1.196 + return sm->get_object;
1.197 + }
1.198 +
1.199 +EXPORT_C STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm)
1.200 + {
1.201 + return sm->store_object;
1.202 + }
1.203 +
1.204 +EXPORT_C STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm)
1.205 + {
1.206 + return sm->modify_object;
1.207 + }
1.208 +
1.209 +EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm)
1.210 + {
1.211 + return sm->revoke_object;
1.212 + }
1.213 +
1.214 +EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm)
1.215 + {
1.216 + return sm->delete_object;
1.217 + }
1.218 +
1.219 +EXPORT_C STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm)
1.220 + {
1.221 + return sm->list_object_start;
1.222 + }
1.223 +
1.224 +EXPORT_C STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm)
1.225 + {
1.226 + return sm->list_object_next;
1.227 + }
1.228 +
1.229 +EXPORT_C STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm)
1.230 + {
1.231 + return sm->list_object_end;
1.232 + }
1.233 +
1.234 +EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm)
1.235 + {
1.236 + return sm->update_store;
1.237 + }
1.238 +
1.239 +EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm)
1.240 + {
1.241 + return sm->lock_store;
1.242 + }
1.243 +
1.244 +EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm)
1.245 + {
1.246 + return sm->unlock_store;
1.247 + }
1.248 +
1.249 +EXPORT_C STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm)
1.250 + {
1.251 + return sm->ctrl;
1.252 + }
1.253 +