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 951E9429E29 for ; Tue, 6 Mar 2012 10:48:56 -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 uOy6m6sqRnGl for ; Tue, 6 Mar 2012 10:48:55 -0800 (PST) Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU [18.9.25.14]) by olra.theworths.org (Postfix) with ESMTP id 4DAC0431FD4 for ; Tue, 6 Mar 2012 10:48:52 -0800 (PST) X-AuditID: 1209190e-b7f7c6d0000008c3-54-4f565c13afc6 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP id 06.70.02243.31C565F4; Tue, 6 Mar 2012 13:48:51 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q26ImpUK023814; Tue, 6 Mar 2012 13:48:51 -0500 Received: from drake.mit.edu (firewall.royalsociety.org [193.63.75.2]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q26Immga016465 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 6 Mar 2012 13:48:50 -0500 (EST) Received: from amthrax by drake.mit.edu with local (Exim 4.77) (envelope-from ) id 1S4zRI-0003pS-A7; Tue, 06 Mar 2012 18:48:48 +0000 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 5/8] show: Convert mbox format to new self-recursive style Date: Tue, 6 Mar 2012 18:48:41 +0000 Message-Id: <1331059724-14653-6-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1331059724-14653-1-git-send-email-amdragon@mit.edu> References: <1330752025-2542-1-git-send-email-amdragon@mit.edu> <1331059724-14653-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixG6noiscE+Zv8G27pcWefV4W12/OZHZg 8rh7msvj2apbzAFMUVw2Kak5mWWpRfp2CVwZB3+8Yy/oEK54//4ZSwPjd94uRk4OCQETidae /2wQtpjEhXvrgWwuDiGBfYwSf+/NYYZw1jNKzNg/gQnCOcgkMfXtdhaQFiGB+YwSvy6Jgths AhoS2/YvZwSxRQSkJXbenc3axcjBwSzgJNHW5gUSFhbwlWhrfQBWwiKgKrH/3j2wMbwCDhLb Ds6CukJB4tzqc+wgNqeAo8Sep5sYIVaVSVy6eYFlAiP/AkaGVYyyKblVurmJmTnFqcm6xcmJ eXmpRbrGermZJXqpKaWbGEFBxCnJt4Px60GlQ4wCHIxKPLwX9cP8hVgTy4orcw8xSnIwKYny 5kQBhfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwfnsf6i/Em5JYWZValA+TkuZgURLnVdN65yck kJ5YkpqdmlqQWgSTleHgUJLgzYgGGipYlJqeWpGWmVOCkGbi4AQZzgM03Aikhre4IDG3ODMd In+KUVFKnNcPJCEAksgozYPrhUX5K0ZxoFeEeR1BqniACQKu+xXQYCagwW3KwSCDSxIRUlIN jPVX/qbp1yhu0BfpmnrhQEvP71VWLf/+f5BgyXLf6/lV13jv58wJj2ec19F+zrub6/M326rM AyLMm4y2C8z79aAhoMt3bZX9r9n+vRWhjIdYT1XVG1VNbOEsdv7hUVW4ck/b517XlidmRsuf 6/OxR8hLpLJkNVjG//9ooeuUFsF96uW9MJlXSizFGYmGWsxFxYkAKEq4os0CAAA= 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: Tue, 06 Mar 2012 18:48:57 -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