NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
crypt_mod.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include "mutt/lib.h"
31 #include "crypt_mod.h"
32 
39 {
41  STAILQ_ENTRY(CryptModule) entries;
42 };
43 STAILQ_HEAD(CryptModuleList, CryptModule);
44 
45 static struct CryptModuleList CryptModules = STAILQ_HEAD_INITIALIZER(CryptModules);
46 
52 {
53  struct CryptModule *module = mutt_mem_calloc(1, sizeof(struct CryptModule));
54  module->specs = specs;
55  STAILQ_INSERT_HEAD(&CryptModules, module, entries);
56 }
57 
66 {
67  struct CryptModule *module = NULL;
68  STAILQ_FOREACH(module, &CryptModules, entries)
69  {
70  if (module->specs->identifier == identifier)
71  {
72  return module->specs;
73  }
74  }
75  return NULL;
76 }
77 
82 {
83  struct CryptModule *np = NULL, *tmp = NULL;
84  STAILQ_FOREACH_SAFE(np, &CryptModules, entries, tmp)
85  {
86  STAILQ_REMOVE(&CryptModules, np, CryptModule, entries);
87  FREE(&np);
88  }
89 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define STAILQ_REMOVE(head, elm, type, field)
Definition: queue.h:399
A crypto plugin module.
Definition: crypt_mod.c:38
static struct CryptModuleList CryptModules
Definition: crypt_mod.c:45
void crypto_module_register(struct CryptModuleSpecs *specs)
Register a new crypto module.
Definition: crypt_mod.c:51
#define STAILQ_ENTRY(type)
Definition: queue.h:324
STAILQ_HEAD(CryptModuleList, CryptModule)
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:359
Crypto API.
Definition: crypt_mod.h:44
#define STAILQ_INSERT_HEAD(head, elm, field)
Definition: queue.h:380
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
struct CryptModuleSpecs * crypto_module_lookup(int identifier)
Lookup a crypto module by name.
Definition: crypt_mod.c:65
struct CryptModuleSpecs * specs
Crypto module definition.
Definition: crypt_mod.c:40
int identifier
Identifying bit.
Definition: crypt_mod.h:46
#define FREE(x)
Definition: memory.h:40
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
void crypto_module_free(void)
Clean up the crypto modules.
Definition: crypt_mod.c:81
Convenience wrapper for the library headers.
Register crypto modules.