[RFC PATCH 04/13] Replace remaining places where fopen occurs
authorEthan Glasser-Camp <glasse@cs.rpi.edu>
Wed, 15 Feb 2012 22:01:57 +0000 (17:01 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:44:34 +0000 (09:44 -0800)
c8/30eb4c1f29fe50e3578c2d6bb0ec34956f8e25 [new file with mode: 0644]

diff --git a/c8/30eb4c1f29fe50e3578c2d6bb0ec34956f8e25 b/c8/30eb4c1f29fe50e3578c2d6bb0ec34956f8e25
new file mode 100644 (file)
index 0000000..02459df
--- /dev/null
@@ -0,0 +1,216 @@
+Return-Path: <glasse@cs.rpi.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 9365D429E4B\r
+       for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:07:19 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.54\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.54 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_BL_SPAMCOP_NET=1.246, RCVD_IN_DNSWL_MED=-2.3,\r
+       RCVD_IN_SORBS_WEB=0.614] 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 NWHKeYUZ6Q6p for <notmuch@notmuchmail.org>;\r
+       Wed, 15 Feb 2012 14:07:18 -0800 (PST)\r
+Received: from cliffclavin.cs.rpi.edu (cliffclavin.cs.rpi.edu\r
+ [128.113.126.25])     (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)       by olra.theworths.org (Postfix) with ESMTPS\r
+ id BFDFC429E43        for <notmuch@notmuchmail.org>; Wed, 15 Feb 2012 14:07:18 -0800\r
+ (PST)\r
+X-Hash:\r
+ S|c9a46fb05653beb036aa8a2f5cd53e86bc2366ab|0f4b2c36d102b5f2ffc0459f38eddc6a\r
+X-Countries: Cameroon, United States\r
+X-SMTP-From: accepted <glasse@cs.rpi.edu> [195.24.209.20] [195.24.209.20]\r
+       (localhost) {Cameroon}\r
+DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=cs.rpi.edu; h=from\r
+       :to:cc:subject:date:message-id:in-reply-to:references; s=\r
+       default; i=glasse@cs.rpi.edu; t=1329343636; x=1329948436; l=4548;\r
+       bh=C6KSzMhe4sgXd3I7P9T/rblWgTo=; b=It70KlpQEXVTE65up8/mCga\r
+       uG39FCTr/Ehq2SgYXaHagpP0lp9fkwbj39u35CsE7b9GsSJySRmQqygFmQpwBAp0\r
+       u1LAM8+PrCYit9qBZAPRPDQ8xAEQGR7Lxejr4N01+jYACwCu9+ctl1x/hwbPrici\r
+       QIr9XCBabtU6fwuZBfOc=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=cs.rpi.edu; h=from:to:cc\r
+       :subject:date:message-id:in-reply-to:references; q=dns; s=\r
+       default; b=eJ97MEUSmYXSNvCUxoJs5sFIn66dAE+Oz/4Mxuax+q1nev3bO7XPw\r
+       O5FuzMNP050gBok+teM/oo5eQ2SjERFOivwTRqwQ2Fw62bo9pgJUlrdsLVD6MyFn\r
+       lTLn15utPUongCsvo6FnVjDKxQfmRDTcZXCQtKgaR+VaPFnJWs3Bjs=\r
+X-Spam-Info: -2.7; ALL_TRUSTED,AWL,BAYES_00\r
+X-Spam-Scanned-By: cliffclavin.cs.rpi.edu using SpamAssassin 3.2.5 (hard limit\r
+       15)\r
+Authentication-Results: cliffclavin.cs.rpi.edu;\r
+       DKIM=neutral (none) header.from=glasse@cs.rpi.edu;\r
+       SPF=neutral (mfrom;\r
+       Mechanism '?all' matched) smtp.mail=glasse@cs.rpi.edu\r
+X-Auth-Passed: cliffclavin.cs.rpi.edu:q1FM6Acr008772 Auth:glasse\r
+X-Virus-Scanned-By: cliffclavin.cs.rpi.edu\r
+Received: from localhost ([195.24.209.20]) (authenticated bits=0)\r
+       by cliffclavin.cs.rpi.edu (8.14.3/8.14.3) with ESMTP id q1FM6Acr008772\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);\r
+       Wed, 15 Feb 2012 17:06:56 -0500 (EST)\r
+       (envelope-from glasse@cs.rpi.edu)\r
+From: Ethan Glasser-Camp <glasse@cs.rpi.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC PATCH 04/13] Replace remaining places where fopen occurs\r
+Date: Wed, 15 Feb 2012 17:01:57 -0500\r
+Message-Id: <1329343326-16410-5-git-send-email-glasse@cs.rpi.edu>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+References: <1329343326-16410-1-git-send-email-glasse@cs.rpi.edu>\r
+X-Scanned-By: MIMEDefang 2.67 on 128.113.126.25\r
+Cc: Ethan Glasser-Camp <ethan@betacantrips.com>\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: Wed, 15 Feb 2012 22:07:19 -0000\r
+\r
+From: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+\r
+Because mail might no longer be on disk, other uses of fopen(2) need\r
+to be replaced with calls to notmuch_mailstore_open. This isn't all of\r
+them, but these are the ones that involve touching the API in a lot of\r
+different places.\r
+\r
+This commit updates mime_node_open, show_message_body, and a couple\r
+random calls in the commands notmuch show, notmuch reply,\r
+\r
+Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>\r
+---\r
+ mime-node.c      |    3 ++-\r
+ notmuch-client.h |    2 ++\r
+ notmuch-reply.c  |    2 +-\r
+ notmuch-show.c   |    9 +++++----\r
+ show-message.c   |    3 ++-\r
+ 5 files changed, 12 insertions(+), 7 deletions(-)\r
+\r
+diff --git a/mime-node.c b/mime-node.c\r
+index d6b4506..856fc3b 100644\r
+--- a/mime-node.c\r
++++ b/mime-node.c\r
+@@ -61,6 +61,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
++              notmuch_mailstore_t *mailstore,\r
+ #ifdef GMIME_ATLEAST_26\r
+               GMimeCryptoContext *cryptoctx,\r
+ #else\r
+@@ -89,7 +90,7 @@ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+     }\r
+     talloc_set_destructor (mctx, _mime_node_context_free);\r
+ \r
+-    mctx->file = fopen (filename, "r");\r
++    mctx->file = notmuch_mailstore_open (mailstore, filename);\r
+     if (! mctx->file) {\r
+       fprintf (stderr, "Error opening %s: %s\n", filename, strerror (errno));\r
+       status = NOTMUCH_STATUS_FILE_ERROR;\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index c1c30a2..405aad7 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -188,6 +188,7 @@ query_string_from_args (void *ctx, int argc, char *argv[]);\r
+ \r
+ notmuch_status_t\r
+ show_message_body (notmuch_message_t *message,\r
++                 notmuch_mailstore_t *mailstore,\r
+                  const notmuch_show_format_t *format,\r
+                  notmuch_show_params_t *params);\r
+ \r
+@@ -372,6 +373,7 @@ typedef struct mime_node {\r
+  */\r
+ notmuch_status_t\r
+ mime_node_open (const void *ctx, notmuch_message_t *message,\r
++              notmuch_mailstore_t *mailstore,\r
+ #ifdef GMIME_ATLEAST_26\r
+               GMimeCryptoContext *cryptoctx,\r
+ #else\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index cb1dd6e..523e2d0 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -587,7 +587,7 @@ notmuch_reply_format_default(void *ctx,\r
+               notmuch_message_get_header (mailstore, message, "date"),\r
+               notmuch_message_get_header (mailstore, message, "from"));\r
+ \r
+-      show_message_body (message, format, params);\r
++      show_message_body (message, mailstore, format, params);\r
+ \r
+       notmuch_message_destroy (message);\r
+     }\r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 81d4cf0..0d2a246 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -285,7 +285,7 @@ format_message_mbox (const void *ctx,\r
+     ssize_t line_len;\r
+ \r
+     filename = notmuch_message_get_filename (message);\r
+-    file = fopen (filename, "r");\r
++    file = notmuch_mailstore_open (mailstore, filename);\r
+     if (file == NULL) {\r
+       fprintf (stderr, "Failed to open %s: %s\n",\r
+                filename, strerror (errno));\r
+@@ -830,7 +830,8 @@ show_message (void *ctx,\r
+       void *local = talloc_new (ctx);\r
+       mime_node_t *root, *part;\r
+ \r
+-      if (mime_node_open (local, message, params->cryptoctx, params->decrypt,\r
++      if (mime_node_open (local, message, mailstore,\r
++                          params->cryptoctx, params->decrypt,\r
+                           &root) == NOTMUCH_STATUS_SUCCESS &&\r
+           (part = mime_node_seek_dfs (root, (params->part < 0 ?\r
+                                              0 : params->part))))\r
+@@ -853,7 +854,7 @@ show_message (void *ctx,\r
+     }\r
+ \r
+     if (format->part_content)\r
+-      show_message_body (message, format, params);\r
++      show_message_body (message, mailstore, format, params);\r
+ \r
+     if (params->part <= 0) {\r
+       fputs (format->body_end, stdout);\r
+@@ -955,7 +956,7 @@ do_show_single (void *ctx,\r
+           return 1;\r
+       }\r
+ \r
+-      file = fopen (filename, "r");\r
++      file = notmuch_mailstore_open (mailstore, filename);\r
+       if (file == NULL) {\r
+           fprintf (stderr, "Error: Cannot open file %s: %s\n", filename, strerror (errno));\r
+           return 1;\r
+diff --git a/show-message.c b/show-message.c\r
+index 83ecf81..aed9d3e 100644\r
+--- a/show-message.c\r
++++ b/show-message.c\r
+@@ -80,6 +80,7 @@ show_message_part (mime_node_t *node,\r
+ \r
+ notmuch_status_t\r
+ show_message_body (notmuch_message_t *message,\r
++                 notmuch_mailstore_t *mailstore,\r
+                  const notmuch_show_format_t *format,\r
+                  notmuch_show_params_t *params)\r
+ {\r
+@@ -87,7 +88,7 @@ show_message_body (notmuch_message_t *message,\r
+     show_message_state_t state;\r
+     mime_node_t *root, *part;\r
+ \r
+-    ret = mime_node_open (NULL, message, params->cryptoctx, params->decrypt,\r
++    ret = mime_node_open (NULL, message, mailstore, params->cryptoctx, params->decrypt,\r
+                         &root);\r
+     if (ret)\r
+       return ret;\r
+-- \r
+1.7.5.4\r
+\r