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