mutt stable branch with some hacks
at jcs 58 lines 1.8 kB view raw
1/* 2 * Copyright (C) 2004 g10 Code GmbH 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19#if HAVE_CONFIG_H 20# include "config.h" 21#endif 22 23#include "crypt-mod.h" 24 25/* A type an a variable to keep track of registered crypto modules. */ 26typedef struct crypt_module *crypt_module_t; 27 28struct crypt_module 29{ 30 crypt_module_specs_t specs; 31 crypt_module_t next, *prevp; 32}; 33 34static crypt_module_t modules; 35 36/* Register a new crypto module. */ 37void crypto_module_register (crypt_module_specs_t specs) 38{ 39 crypt_module_t module_new = safe_malloc (sizeof (*module_new)); 40 41 module_new->specs = specs; 42 module_new->next = modules; 43 if (modules) 44 modules->prevp = &module_new->next; 45 modules = module_new; 46} 47 48/* Return the crypto module specs for IDENTIFIER. This function is 49 usually used via the CRYPT_MOD_CALL[_CHECK] macros. */ 50crypt_module_specs_t crypto_module_lookup (int identifier) 51{ 52 crypt_module_t module = modules; 53 54 while (module && (module->specs->identifier != identifier)) 55 module = module->next; 56 57 return module ? module->specs : NULL; 58}