Re: [PATCH v4 1/7] cli: use typedef to deal with gmime 2.4/2.6 incompatibility
authorAustin Clements <amdragon@MIT.EDU>
Fri, 25 May 2012 14:41:36 +0000 (10:41 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:23 +0000 (09:47 -0800)
68/efa300d75274e2a5d115dcac2b75841aa99917 [new file with mode: 0644]

diff --git a/68/efa300d75274e2a5d115dcac2b75841aa99917 b/68/efa300d75274e2a5d115dcac2b75841aa99917
new file mode 100644 (file)
index 0000000..f014994
--- /dev/null
@@ -0,0 +1,167 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7EBD3431FBC\r
+       for <notmuch@notmuchmail.org>; Fri, 25 May 2012 07:41:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id mtv+RlQ-QbtJ for <notmuch@notmuchmail.org>;\r
+       Fri, 25 May 2012 07:41:39 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
+       [18.7.68.35])\r
+       by olra.theworths.org (Postfix) with ESMTP id CB26D431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 25 May 2012 07:41:39 -0700 (PDT)\r
+X-AuditID: 12074423-b7fcc6d0000008a8-11-4fbf9a237399\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id FE.63.02216.32A9FBF4; Fri, 25 May 2012 10:41:39 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q4PEfcCK008281; \r
+       Fri, 25 May 2012 10:41:38 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4PEfaOF007396\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Fri, 25 May 2012 10:41:37 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1SXvhw-0000dT-Ly; Fri, 25 May 2012 10:41:36 -0400\r
+Date: Fri, 25 May 2012 10:41:36 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: [PATCH v4 1/7] cli: use typedef to deal with gmime 2.4/2.6\r
+       incompatibility\r
+Message-ID: <20120525144136.GB11804@mit.edu>\r
+References: <1337812843-14986-1-git-send-email-jrollins@finestructure.net>\r
+       <1337812843-14986-2-git-send-email-jrollins@finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1337812843-14986-2-git-send-email-jrollins@finestructure.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsUixCmqras8a7+/waeNPBZ79nlZXL85k9mB\r
+       yePuaS6PZ6tuMQcwRXHZpKTmZJalFunbJXBl7Dj3i7VgrVjF20W5DYwvBLsYOTkkBEwkWua9\r
+       YISwxSQu3FvP1sXIxSEksI9RoqlzFSuEs4FRYuvPHSwgVUICJ5kkGmeLQSSWMEr87NnFBpJg\r
+       EVCVOPHrHhOIzSagIbFt/3KwsSICZhI9X/6A2cwCWhJbN34Asjk4hAUiJRZ+1AQJ8wroSJz4\r
+       0wA1v5tRoueBAERcUOLkzCcsMK03/r1kAmllFpCWWP6PAyTMKeAtsfLADbALRAVUJKac3MY2\r
+       gVFoFpLuWUi6ZyF0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRrppebWaKXmlK6iREUzuwu\r
+       yjsY/xxUOsQowMGoxMPLGL3PX4g1say4MvcQoyQHk5Iob8jM/f5CfEn5KZUZicUZ8UWlOanF\r
+       hxglOJiVRHhZ0oByvCmJlVWpRfkwKWkOFiVx3rWau/2FBNITS1KzU1MLUotgsjIcHEoSvGEg\r
+       QwWLUtNTK9Iyc0oQ0kwcnCDDeYCGR4HU8BYXJOYWZ6ZD5E8xKkqJ84aCJARAEhmleXC9sHTz\r
+       ilEc6BVhiHYeYKqC634FNJgJaPCWx3tBBpckIqSkGhidE+KO8F9a+tTHhd0jmtVrIdP7Rc2d\r
+       85ryvAxXSqtt2KuyecsVJyON2p9V2Wu3ubCVLxUXUVubwKNz/GTs3MuGK8vbn685zv2wYN2N\r
+       fa2TspTPaXt0q6vO7WOO9tqkdujkG4NL2w577JTbefT8qzv6hiWWLu+iQib/2R1VtHzLUYE7\r
+       FZwVMrFKLMUZiYZazEXFiQBh2tHKEgMAAA==\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 25 May 2012 14:41:40 -0000\r
+\r
+Quoth Jameson Graef Rollins on May 23 at  3:40 pm:\r
+> gmime 2.4 defines GMimeCipherContext, while 2.6 defines\r
+> GMimeCryptoContext.  We can use a typedef to cover this discrepancy\r
+> and remove a bunch of #ifdefs.\r
+> ---\r
+>  mime-node.c      |    8 --------\r
+>  notmuch-client.h |   10 ++--------\r
+>  2 files changed, 2 insertions(+), 16 deletions(-)\r
+> \r
+> diff --git a/mime-node.c b/mime-node.c\r
+> index a95bdab..06fdb70 100644\r
+> --- a/mime-node.c\r
+> +++ b/mime-node.c\r
+> @@ -33,11 +33,7 @@ typedef struct mime_node_context {\r
+>      GMimeMessage *mime_message;\r
+>  \r
+>      /* Context provided by the caller. */\r
+> -#ifdef GMIME_ATLEAST_26\r
+>      GMimeCryptoContext *cryptoctx;\r
+> -#else\r
+> -    GMimeCipherContext *cryptoctx;\r
+> -#endif\r
+>      notmuch_bool_t decrypt;\r
+>  } mime_node_context_t;\r
+>  \r
+> @@ -61,11 +57,7 @@ _mime_node_context_free (mime_node_context_t *res)\r
+>  \r
+>  notmuch_status_t\r
+>  mime_node_open (const void *ctx, notmuch_message_t *message,\r
+> -#ifdef GMIME_ATLEAST_26\r
+>              GMimeCryptoContext *cryptoctx,\r
+> -#else\r
+> -            GMimeCipherContext *cryptoctx,\r
+> -#endif\r
+>              notmuch_bool_t decrypt, mime_node_t **root_out)\r
+>  {\r
+>      const char *filename = notmuch_message_get_filename (message);\r
+> diff --git a/notmuch-client.h b/notmuch-client.h\r
+> index 19b7f01..337409f 100644\r
+> --- a/notmuch-client.h\r
+> +++ b/notmuch-client.h\r
+> @@ -36,6 +36,8 @@\r
+>   * these to check the version number. */\r
+>  #ifdef GMIME_MAJOR_VERSION\r
+>  #define GMIME_ATLEAST_26\r
+> +#else\r
+> +typedef GMimeCipherContext GMimeCryptoContext;\r
+\r
+I like the typedef idea, but I don't think we should overload\r
+GMimeCryptoContext like this.  If someone is reading through the GMime\r
+2.4 code and sees this, they're going to assume that it's a GMime\r
+structure, go looking for it, find that it's only in 2.6 and be\r
+baffled.  Instead, how about providing a typedef to abstract *both*\r
+cases?  Something like\r
+\r
+#ifdef GMIME_MAJOR_VERSION\r
+#define GMIME_ATLEAST_26\r
+typedef notmuch_crypto_context_t GMimeCipherContext;\r
+#else\r
+typedef notmuch_crypto_context_t GMimeCryptoContext;\r
+#endif\r
+\r
+>  #endif\r
+>  \r
+>  #include "notmuch.h"\r
+> @@ -79,11 +81,7 @@ typedef struct notmuch_show_params {\r
+>      notmuch_bool_t omit_excluded;\r
+>      notmuch_bool_t raw;\r
+>      int part;\r
+> -#ifdef GMIME_ATLEAST_26\r
+>      GMimeCryptoContext* cryptoctx;\r
+> -#else\r
+> -    GMimeCipherContext* cryptoctx;\r
+> -#endif\r
+>      notmuch_bool_t decrypt;\r
+>  } notmuch_show_params_t;\r
+>  \r
+> @@ -355,11 +353,7 @@ struct mime_node {\r
+>   */\r
+>  notmuch_status_t\r
+>  mime_node_open (const void *ctx, notmuch_message_t *message,\r
+> -#ifdef GMIME_ATLEAST_26\r
+>              GMimeCryptoContext *cryptoctx,\r
+> -#else\r
+> -            GMimeCipherContext *cryptoctx,\r
+> -#endif\r
+>              notmuch_bool_t decrypt, mime_node_t **node_out);\r
+>  \r
+>  /* Return a new MIME node for the requested child part of parent.\r