sl@0: /* crypto/store/str_meth.c -*- mode:C; c-file-style: "eay" -*- */ sl@0: /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL sl@0: * project 2003. sl@0: */ sl@0: /* ==================================================================== sl@0: * Copyright (c) 2003 The OpenSSL Project. All rights reserved. sl@0: * sl@0: * Redistribution and use in source and binary forms, with or without sl@0: * modification, are permitted provided that the following conditions sl@0: * are met: sl@0: * sl@0: * 1. Redistributions of source code must retain the above copyright sl@0: * notice, this list of conditions and the following disclaimer. sl@0: * sl@0: * 2. Redistributions in binary form must reproduce the above copyright sl@0: * notice, this list of conditions and the following disclaimer in sl@0: * the documentation and/or other materials provided with the sl@0: * distribution. sl@0: * sl@0: * 3. All advertising materials mentioning features or use of this sl@0: * software must display the following acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" sl@0: * sl@0: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to sl@0: * endorse or promote products derived from this software without sl@0: * prior written permission. For written permission, please contact sl@0: * openssl-core@openssl.org. sl@0: * sl@0: * 5. Products derived from this software may not be called "OpenSSL" sl@0: * nor may "OpenSSL" appear in their names without prior written sl@0: * permission of the OpenSSL Project. sl@0: * sl@0: * 6. Redistributions of any form whatsoever must retain the following sl@0: * acknowledgment: sl@0: * "This product includes software developed by the OpenSSL Project sl@0: * for use in the OpenSSL Toolkit (http://www.openssl.org/)" sl@0: * sl@0: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY sl@0: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE sl@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR sl@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR sl@0: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, sl@0: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT sl@0: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; sl@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) sl@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, sl@0: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) sl@0: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED sl@0: * OF THE POSSIBILITY OF SUCH DAMAGE. sl@0: * ==================================================================== sl@0: * sl@0: * This product includes cryptographic software written by Eric Young sl@0: * (eay@cryptsoft.com). This product includes software written by Tim sl@0: * Hudson (tjh@cryptsoft.com). sl@0: * sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include "str_locl.h" sl@0: sl@0: EXPORT_C STORE_METHOD *STORE_create_method(char *name) sl@0: { sl@0: STORE_METHOD *store_method = (STORE_METHOD *)OPENSSL_malloc(sizeof(STORE_METHOD)); sl@0: sl@0: if (store_method) sl@0: { sl@0: memset(store_method, 0, sizeof(*store_method)); sl@0: store_method->name = BUF_strdup(name); sl@0: } sl@0: return store_method; sl@0: } sl@0: sl@0: /* BIG FSCKING WARNING!!!! If you use this on a statically allocated method sl@0: (that is, it hasn't been allocated using STORE_create_method(), you deserve sl@0: anything Murphy can throw at you and more! You have been warned. */ sl@0: EXPORT_C void STORE_destroy_method(STORE_METHOD *store_method) sl@0: { sl@0: if (!store_method) return; sl@0: OPENSSL_free(store_method->name); sl@0: store_method->name = NULL; sl@0: OPENSSL_free(store_method); sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_initialise_function(STORE_METHOD *sm, STORE_INITIALISE_FUNC_PTR init_f) sl@0: { sl@0: sm->init = init_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_cleanup_function(STORE_METHOD *sm, STORE_CLEANUP_FUNC_PTR clean_f) sl@0: { sl@0: sm->clean = clean_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_generate_function(STORE_METHOD *sm, STORE_GENERATE_OBJECT_FUNC_PTR generate_f) sl@0: { sl@0: sm->generate_object = generate_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_get_function(STORE_METHOD *sm, STORE_GET_OBJECT_FUNC_PTR get_f) sl@0: { sl@0: sm->get_object = get_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_store_function(STORE_METHOD *sm, STORE_STORE_OBJECT_FUNC_PTR store_f) sl@0: { sl@0: sm->store_object = store_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_modify_function(STORE_METHOD *sm, STORE_MODIFY_OBJECT_FUNC_PTR modify_f) sl@0: { sl@0: sm->modify_object = modify_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_revoke_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR revoke_f) sl@0: { sl@0: sm->revoke_object = revoke_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_delete_function(STORE_METHOD *sm, STORE_HANDLE_OBJECT_FUNC_PTR delete_f) sl@0: { sl@0: sm->delete_object = delete_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_list_start_function(STORE_METHOD *sm, STORE_START_OBJECT_FUNC_PTR list_start_f) sl@0: { sl@0: sm->list_object_start = list_start_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_list_next_function(STORE_METHOD *sm, STORE_NEXT_OBJECT_FUNC_PTR list_next_f) sl@0: { sl@0: sm->list_object_next = list_next_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_list_end_function(STORE_METHOD *sm, STORE_END_OBJECT_FUNC_PTR list_end_f) sl@0: { sl@0: sm->list_object_end = list_end_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_update_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR update_f) sl@0: { sl@0: sm->update_store = update_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_lock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR lock_f) sl@0: { sl@0: sm->lock_store = lock_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_unlock_store_function(STORE_METHOD *sm, STORE_GENERIC_FUNC_PTR unlock_f) sl@0: { sl@0: sm->unlock_store = unlock_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C int STORE_method_set_ctrl_function(STORE_METHOD *sm, STORE_CTRL_FUNC_PTR ctrl_f) sl@0: { sl@0: sm->ctrl = ctrl_f; sl@0: return 1; sl@0: } sl@0: sl@0: EXPORT_C STORE_INITIALISE_FUNC_PTR STORE_method_get_initialise_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->init; sl@0: } sl@0: sl@0: EXPORT_C STORE_CLEANUP_FUNC_PTR STORE_method_get_cleanup_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->clean; sl@0: } sl@0: sl@0: EXPORT_C STORE_GENERATE_OBJECT_FUNC_PTR STORE_method_get_generate_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->generate_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_GET_OBJECT_FUNC_PTR STORE_method_get_get_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->get_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_STORE_OBJECT_FUNC_PTR STORE_method_get_store_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->store_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_MODIFY_OBJECT_FUNC_PTR STORE_method_get_modify_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->modify_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_revoke_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->revoke_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_HANDLE_OBJECT_FUNC_PTR STORE_method_get_delete_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->delete_object; sl@0: } sl@0: sl@0: EXPORT_C STORE_START_OBJECT_FUNC_PTR STORE_method_get_list_start_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->list_object_start; sl@0: } sl@0: sl@0: EXPORT_C STORE_NEXT_OBJECT_FUNC_PTR STORE_method_get_list_next_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->list_object_next; sl@0: } sl@0: sl@0: EXPORT_C STORE_END_OBJECT_FUNC_PTR STORE_method_get_list_end_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->list_object_end; sl@0: } sl@0: sl@0: EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_update_store_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->update_store; sl@0: } sl@0: sl@0: EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_lock_store_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->lock_store; sl@0: } sl@0: sl@0: EXPORT_C STORE_GENERIC_FUNC_PTR STORE_method_get_unlock_store_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->unlock_store; sl@0: } sl@0: sl@0: EXPORT_C STORE_CTRL_FUNC_PTR STORE_method_get_ctrl_function(STORE_METHOD *sm) sl@0: { sl@0: return sm->ctrl; sl@0: } sl@0: