exit str_cmp enters m_strcmp
[apps/madmutt.git] / crypt-mod.c
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 2004 g10 Code GmbH
4  *
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.
8  */
9
10 #if HAVE_CONFIG_H
11 # include "config.h"
12 #endif
13
14 #include <lib-lib/mem.h>
15
16 #include "crypt-mod.h"
17
18 /* A type an a variable to keep track of registered crypto modules. */
19 typedef struct crypt_module *crypt_module_t;
20
21 struct crypt_module {
22   crypt_module_specs_t specs;
23   crypt_module_t next, *prevp;
24 };
25
26 static crypt_module_t modules;
27
28 /* Register a new crypto module. */
29 void crypto_module_register (crypt_module_specs_t specs)
30 {
31   crypt_module_t module_new = p_new(struct crypt_module, 1);
32
33   module_new->specs = specs;
34   module_new->next = modules;
35   if (modules)
36     modules->prevp = &module_new->next;
37   modules = module_new;
38 }
39
40 /* Return the crypto module specs for IDENTIFIER.  This function is
41    usually used via the CRYPT_MOD_CALL[_CHECK] macros. */
42 crypt_module_specs_t crypto_module_lookup (int identifier)
43 {
44   crypt_module_t module = modules;
45
46   while (module && (module->specs->identifier != identifier))
47     module = module->next;
48
49   return module ? module->specs : NULL;
50 }