drop even more stupid glue.
authorPierre Habouzit <madcoder@debian.org>
Mon, 2 Apr 2007 22:52:57 +0000 (00:52 +0200)
committerPierre Habouzit <madcoder@debian.org>
Mon, 2 Apr 2007 22:52:57 +0000 (00:52 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
lib-crypt/Makefile.am
lib-crypt/crypt-mod.c [deleted file]
lib-crypt/crypt-mod.h
lib-crypt/cryptglue.c

index eaefdb9..89eda9d 100644 (file)
@@ -1,10 +1,10 @@
 noinst_LIBRARIES = libcrypt.a
 
 libcrypt_a_SOURCES = crypt.h crypt-mod.h \
-                    crypt.c crypt-mod.c \
+                    crypt.c \
                     cryptglue.c \
                     crypt-gpgme.h crypt-gpgme.c
 
-noinst_HEADERS     =  crypt.h crypt-mod.h crypt-gpgme.h
+noinst_HEADERS     =  crypt.h crypt-gpgme.h
 
 -include $(top_builddir)/tools/cflags.mk
diff --git a/lib-crypt/crypt-mod.c b/lib-crypt/crypt-mod.c
deleted file mode 100644 (file)
index d853535..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright notice from original mutt:
- * Copyright (C) 2004 g10 Code GmbH
- *
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-
-#include "crypt-mod.h"
-
-/* A type an a variable to keep track of registered crypto modules. */
-typedef struct crypt_module *crypt_module_t;
-
-struct crypt_module {
-  crypt_module_specs_t specs;
-  crypt_module_t next, *prevp;
-};
-
-static crypt_module_t modules;
-
-/* Register a new crypto module. */
-void crypto_module_register (crypt_module_specs_t specs)
-{
-  crypt_module_t module_new = p_new(struct crypt_module, 1);
-
-  module_new->specs = specs;
-  module_new->next = modules;
-  if (modules)
-    modules->prevp = &module_new->next;
-  modules = module_new;
-}
-
-/* Return the crypto module specs for IDENTIFIER.  This function is
-   usually used via the CRYPT_MOD_CALL[_CHECK] macros. */
-crypt_module_specs_t crypto_module_lookup (int identifier)
-{
-  crypt_module_t module = modules;
-
-  while (module && (module->specs->identifier != identifier))
-    module = module->next;
-
-  return module ? module->specs : NULL;
-}
index 6e6a1c3..fa1833d 100644 (file)
@@ -53,10 +53,7 @@ typedef void (*crypt_func_smime_invoke_import_t) (char *infile,
 typedef void (*crypt_func_init_t) (void);
 
 
-/*
-   A structure to keep all crypto module fucntions together.
- */
-typedef struct crypt_module_functions {
+typedef struct crypt_module_specs {
     /* Common/General functions.  */
     crypt_func_init_t init;
     crypt_func_decrypt_mime_t decrypt_mime;
@@ -84,36 +81,15 @@ typedef struct crypt_module_functions {
     crypt_func_smime_verify_sender_t smime_verify_sender;
     crypt_func_smime_build_smime_entity_t smime_build_smime_entity;
     crypt_func_smime_invoke_import_t smime_invoke_import;
-} crypt_module_functions_t;
-
-
-/*
-   A structure to decribe a crypto module. 
- */
-typedef struct crypt_module_specs {
-  int identifier;               /* Identifying bit.  */
-  crypt_module_functions_t functions;
-}                 *crypt_module_specs_t;
-
-
-
-/* 
-   High Level crypto module interface. 
- */
+} crypt_module_specs_t;
 
-void crypto_module_register (crypt_module_specs_t specs);
-crypt_module_specs_t crypto_module_lookup (int identifier);
+struct crypt_module_specs crypt_mod_SMIME_gpgme;
+struct crypt_module_specs crypt_mod_PGP_gpgme;
 
-/* If the crypto module identifier by IDENTIFIER has been registered,
-   call its function FUNC.  Do nothing else.  This may be used as an
-   expression. */
 #define CRYPT_MOD_CALL_CHECK(identifier, func) \
-  (crypto_module_lookup (APPLICATION_ ## identifier) \
-   && (crypto_module_lookup (APPLICATION_ ## identifier))->functions.func)
+    ((crypt_mod_##identifier##_gpgme).func)
 
-/* Call the function FUNC in the crypto module identified by
-   IDENTIFIER. This may be used as an expression. */
 #define CRYPT_MOD_CALL(identifier, func) \
-  *(crypto_module_lookup (APPLICATION_ ## identifier))->functions.func
+    (*((crypt_mod_##identifier##_gpgme).func))
 
 #endif
index 742c4a0..ea5ba59 100644 (file)
 #include "crypt-mod.h"
 #include "crypt-gpgme.h"
 
-static struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
-    {
-        smime_gpgme_init,
-        smime_gpgme_decrypt_mime,
-        smime_gpgme_application_handler,
-        NULL,                        /* encrypted_handler */
-        smime_gpgme_findkeys,
-        smime_gpgme_sign_message,
-        smime_gpgme_verify_one,
-        smime_gpgme_send_menu,
-
-        NULL,                        /* pgp_encrypt_message */
-        NULL,                        /* pgp_make_key_attachment */
-        NULL,                        /* pgp_check_traditional */
-        NULL,                        /* pgp_traditional_encryptsign */
-        NULL,                        /* pgp_invoke_getkeys */
-        NULL,                        /* pgp_invoke_import */
-        NULL,                        /* pgp_extract_keys_from_attachment_list */
-
-        NULL,                        /* smime_getkeys */
-        smime_gpgme_verify_sender,
-        smime_gpgme_build_smime_entity,
-        NULL,                        /* smime_invoke_import */
-    }
+struct crypt_module_specs crypt_mod_SMIME_gpgme = {
+    smime_gpgme_init,
+    smime_gpgme_decrypt_mime,
+    smime_gpgme_application_handler,
+    NULL,                        /* encrypted_handler */
+    smime_gpgme_findkeys,
+    smime_gpgme_sign_message,
+    smime_gpgme_verify_one,
+    smime_gpgme_send_menu,
+
+    NULL,                        /* pgp_encrypt_message */
+    NULL,                        /* pgp_make_key_attachment */
+    NULL,                        /* pgp_check_traditional */
+    NULL,                        /* pgp_traditional_encryptsign */
+    NULL,                        /* pgp_invoke_getkeys */
+    NULL,                        /* pgp_invoke_import */
+    NULL,                        /* pgp_extract_keys_from_attachment_list */
+
+    NULL,                        /* smime_getkeys */
+    smime_gpgme_verify_sender,
+    smime_gpgme_build_smime_entity,
+    NULL,                        /* smime_invoke_import */
 };
 
-static struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP,
-    {
-        pgp_gpgme_init,
-        pgp_gpgme_decrypt_mime,
-        pgp_gpgme_application_handler,
-        pgp_gpgme_encrypted_handler,
-        pgp_gpgme_findkeys,
-        pgp_gpgme_sign_message,
-        pgp_gpgme_verify_one,
-        pgp_gpgme_send_menu,
-
-        /* PGP specific.  */
-        pgp_gpgme_encrypt_message,
-        NULL,                        /* pgp_make_key_attachment, */
-        pgp_gpgme_check_traditional,
-        NULL,                        /* pgp_traditional_encryptsign  */
-        NULL,                        /* pgp_invoke_getkeys  */
-        pgp_gpgme_invoke_import,     /* pgp_invoke_import  */
-        pgp_gpgme_from_attachment_list,
-                                     /* pgp_extract_keys_from_attachment_list  */
-
-        NULL,                        /* smime_getkeys */
-        NULL,                        /* smime_verify_sender */
-        NULL,                        /* smime_build_smime_entity */
-        NULL,                        /* smime_invoke_import */
-    }
+struct crypt_module_specs crypt_mod_PGP_gpgme = {
+    pgp_gpgme_init,
+    pgp_gpgme_decrypt_mime,
+    pgp_gpgme_application_handler,
+    pgp_gpgme_encrypted_handler,
+    pgp_gpgme_findkeys,
+    pgp_gpgme_sign_message,
+    pgp_gpgme_verify_one,
+    pgp_gpgme_send_menu,
+
+    /* PGP specific.  */
+    pgp_gpgme_encrypt_message,
+    NULL,                        /* pgp_make_key_attachment, */
+    pgp_gpgme_check_traditional,
+    NULL,                        /* pgp_traditional_encryptsign  */
+    NULL,                        /* pgp_invoke_getkeys  */
+    pgp_gpgme_invoke_import,     /* pgp_invoke_import  */
+    pgp_gpgme_from_attachment_list,
+                                 /* pgp_extract_keys_from_attachment_list  */
+
+    NULL,                        /* smime_getkeys */
+    NULL,                        /* smime_verify_sender */
+    NULL,                        /* smime_build_smime_entity */
+    NULL,                        /* smime_invoke_import */
 };
 
 void crypt_init (void)
 {
-    crypto_module_register (&crypt_mod_pgp_gpgme);
-    crypto_module_register (&crypt_mod_smime_gpgme);
-
     (CRYPT_MOD_CALL(PGP, init))();
-    (CRYPT_MOD_CALL (SMIME, init)) ();
+    (CRYPT_MOD_CALL(SMIME, init))();
 }
 
 /* Show a message that a backend will be invoked. */
@@ -101,12 +94,7 @@ void crypt_invoke_message (int type)
 }
 
 
-/* 
-
-    PGP
-
-*/
-
+/* PGP */
 
 /* Decrypt a PGP/MIME message. */
 int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)