2 * Copyright notice from original mutt:
3 * Copyright (C) 2004 g10 Code GmbH
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
14 #include "crypt-mod.h"
17 /* A type an a variable to keep track of registered crypto modules. */
18 typedef struct crypt_module *crypt_module_t;
21 crypt_module_specs_t specs;
22 crypt_module_t next, *prevp;
25 static crypt_module_t modules;
27 /* Register a new crypto module. */
28 void crypto_module_register (crypt_module_specs_t specs)
30 crypt_module_t module_new = mem_malloc (sizeof (*module_new));
32 module_new->specs = specs;
33 module_new->next = modules;
35 modules->prevp = &module_new->next;
39 /* Return the crypto module specs for IDENTIFIER. This function is
40 usually used via the CRYPT_MOD_CALL[_CHECK] macros. */
41 crypt_module_specs_t crypto_module_lookup (int identifier)
43 crypt_module_t module = modules;
45 while (module && (module->specs->identifier != identifier))
46 module = module->next;
48 return module ? module->specs : NULL;