drop mem_alloc and mem_free, use my own hand crafted optmized macros that
[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 #include "lib/mem.h"
18
19 /* A type an a variable to keep track of registered crypto modules. */
20 typedef struct crypt_module *crypt_module_t;
21
22 struct crypt_module {
23   crypt_module_specs_t specs;
24   crypt_module_t next, *prevp;
25 };
26
27 static crypt_module_t modules;
28
29 /* Register a new crypto module. */
30 void crypto_module_register (crypt_module_specs_t specs)
31 {
32   crypt_module_t module_new = p_new(struct crypt_module, 1);
33
34   module_new->specs = specs;
35   module_new->next = modules;
36   if (modules)
37     modules->prevp = &module_new->next;
38   modules = module_new;
39 }
40
41 /* Return the crypto module specs for IDENTIFIER.  This function is
42    usually used via the CRYPT_MOD_CALL[_CHECK] macros. */
43 crypt_module_specs_t crypto_module_lookup (int identifier)
44 {
45   crypt_module_t module = modules;
46
47   while (module && (module->specs->identifier != identifier))
48     module = module->next;
49
50   return module ? module->specs : NULL;
51 }