1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 912DC6DE14D1
\r
6 for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 10:44:06 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.125 tagged_above=-999 required=5 tests=[AWL=0.115,
\r
12 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id nII8wBD91_0S for <notmuch@notmuchmail.org>;
\r
16 Sun, 16 Aug 2015 10:44:05 -0700 (PDT)
\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])
\r
18 by arlo.cworth.org (Postfix) with ESMTPS id C74E86DE0B26
\r
19 for <notmuch@notmuchmail.org>; Sun, 16 Aug 2015 10:44:04 -0700 (PDT)
\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)
\r
21 (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
22 id 1ZR1x3-0003cg-23; Sun, 16 Aug 2015 17:42:33 +0000
\r
23 Received: (nullmailer pid 26309 invoked by uid 1000); Sun, 16 Aug 2015
\r
25 From: David Bremner <david@tethera.net>
\r
26 To: notmuch@notmuchmail.org
\r
27 Subject: [PATCH 2/8] crypto: make crypto ctx initialization an array
\r
28 Date: Sun, 16 Aug 2015 19:41:10 +0200
\r
29 Message-Id: <1439746876-23654-3-git-send-email-david@tethera.net>
\r
30 X-Mailer: git-send-email 2.5.0
\r
31 In-Reply-To: <1439746876-23654-1-git-send-email-david@tethera.net>
\r
32 References: <54CA467B.30408@gnome.org>
\r
33 <1439746876-23654-1-git-send-email-david@tethera.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.18
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 16 Aug 2015 17:44:06 -0000
\r
48 From: Jani Nikula <jani@nikula.org>
\r
50 Make it trivial to add handlers for new protocols without duplicating
\r
51 code. No functional changes.
\r
53 crypto.c | 13 +++++++------
\r
54 1 file changed, 7 insertions(+), 6 deletions(-)
\r
56 diff --git a/crypto.c b/crypto.c
\r
57 index 1187ad7..f415abd 100644
\r
60 @@ -49,6 +49,7 @@ notmuch_crypto_context_t *
\r
61 notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
\r
63 notmuch_crypto_context_t *cryptoctx = NULL;
\r
67 fprintf (stderr, "Cryptographic protocol is empty.\n");
\r
68 @@ -61,14 +62,14 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
\r
69 * parameter names as defined in this document are
\r
70 * case-insensitive." Thus, we use strcasecmp for the protocol.
\r
72 - if (strcasecmp (protocol, "application/pgp-signature") == 0 ||
\r
73 - strcasecmp (protocol, "application/pgp-encrypted") == 0) {
\r
74 - cryptoctx = create_gpg_context (crypto);
\r
76 - fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");
\r
77 + for (i = 0; i < ARRAY_SIZE (protocols); i++) {
\r
78 + if (strcasecmp (protocol, protocols[i].protocol) == 0)
\r
79 + return protocols[i].get_context (crypto);
\r
83 + fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");
\r