From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 289C3431FBC for ; Fri, 2 Mar 2012 21:20:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 9myX7vb4oA1y for ; Fri, 2 Mar 2012 21:20:32 -0800 (PST) Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU [18.9.25.15]) by olra.theworths.org (Postfix) with ESMTP id 201DA431FBF for ; Fri, 2 Mar 2012 21:20:32 -0800 (PST) X-AuditID: 1209190f-b7f8a6d000000914-03-4f51aa1ff30f Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP id 08.CF.02324.F1AA15F4; Sat, 3 Mar 2012 00:20:31 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q235KV6t017469; Sat, 3 Mar 2012 00:20:31 -0500 Received: from drake.mit.edu (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q235KUhH022247 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 3 Mar 2012 00:20:31 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1S3hOQ-0000h1-7Z; Sat, 03 Mar 2012 00:20:30 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 3/5] show: Convert mbox format to new self-recursive style Date: Sat, 3 Mar 2012 00:20:23 -0500 Message-Id: <1330752025-2542-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1330752025-2542-1-git-send-email-amdragon@mit.edu> References: <1330752025-2542-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixG6nriu/KtDfYGmvtsX1mzOZHRg9nq26 xRzAGMVlk5Kak1mWWqRvl8CVcfDHO/aCDuGK9++fsTQwfuftYuTkkBAwkZjb2skEYYtJXLi3 nq2LkYtDSGAfo8Su+xvZQRJCAusZJU7vkodI3GOSuD/1HiOEM59R4seadkaQKjYBDYlt+5eD 2SIC0hI7785m7WLk4GAWUJP406UCEhYW8JKYPuc8M4jNIqAqMf3wLiaQEl4Be4kDzxghjlCQ OLf6HNheTgEHiZbjx1ghbrCX+NHfyTKBkX8BI8MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXRO9 3MwSvdSU0k2MoJDhlOTfwfjtoNIhRgEORiUe3ssvA/yFWBPLiitzDzFKcjApifKWLw/0F+JL yk+pzEgszogvKs1JLT7EKMHBrCTCu8wTKMebklhZlVqUD5OS5mBREudV03rnJySQnliSmp2a WpBaBJOV4eBQkuCNWgnUKFiUmp5akZaZU4KQZuLgBBnOAzTcA6SGt7ggMbc4Mx0if4pRUUqc VwskIQCSyCjNg+uFxfQrRnGgV4R5A0CqeIDpAK77FdBgJqDBiy/7gQwuSURISTUwTtgsI/rV btsNG9XHt4qCGsJCCw/Pnjw11TeYMSY8I/+dWG7+K7U37zl/+JV3l3/vb/p8cI0ER2Abezv3 E/dFXxpOPfLf73Bzlkd35u8Q06aJ/wNvtKV86N9utio28O4ql9vfjrE8ehKkoTjtYMG9JbL9 4tWby5+JaLU7hS9WVKj1sToQsvCFEktxRqKhFnNRcSIATQ3538QCAAA= 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: Sat, 03 Mar 2012 05:20:34 -0000 Given the lack of recursion, this is pretty easy. --- notmuch-show.c | 40 ++++++++++++++++++---------------------- 1 files changed, 18 insertions(+), 22 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b3a4550..72c141e 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -45,25 +45,15 @@ static const notmuch_show_format_t format_json = { .message_set_end = "]" }; -static void -format_message_mbox (const void *ctx, - notmuch_message_t *message, - unused (int indent)); +static notmuch_status_t +format_part_mbox (const void *ctx, mime_node_t *node, + int indent, const notmuch_show_params_t *params); static const notmuch_show_format_t format_mbox = { - "", NULL, - "", format_message_mbox, - "", NULL, NULL, "", - "", - NULL, - NULL, - NULL, - NULL, - NULL, - "", - "", - "", "", - "" + .message_set_start = "", + .part = format_part_mbox, + .message_set_sep = "", + .message_set_end = "" }; static void @@ -717,11 +707,12 @@ format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent), * * http://qmail.org/qmail-manual-html/man5/mbox.html */ -static void -format_message_mbox (const void *ctx, - notmuch_message_t *message, - unused (int indent)) +static notmuch_status_t +format_part_mbox (const void *ctx, mime_node_t *node, unused (int indent), + unused (const notmuch_show_params_t *params)) { + notmuch_message_t *message = node->envelope_file; + const char *filename; FILE *file; const char *from; @@ -734,12 +725,15 @@ format_message_mbox (const void *ctx, size_t line_size; ssize_t line_len; + if (!message) + INTERNAL_ERROR ("format_part_mbox requires a root part"); + filename = notmuch_message_get_filename (message); file = fopen (filename, "r"); if (file == NULL) { fprintf (stderr, "Failed to open %s: %s\n", filename, strerror (errno)); - return; + return NOTMUCH_STATUS_FILE_ERROR; } from = notmuch_message_get_header (message, "from"); @@ -760,6 +754,8 @@ format_message_mbox (const void *ctx, printf ("\n"); fclose (file); + + return NOTMUCH_STATUS_SUCCESS; } static notmuch_status_t -- 1.7.7.3