From dd4eb80174c6f4d2f53b7f65d38ee9007106e72e Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 4 Mar 2012 00:20:22 +1900 Subject: [PATCH] [PATCH 2/5] show: Move format_message_mbox with the other new-style formats --- 13/8e193d02fabd71187e6c95e2fe2d23ee545d6b | 199 ++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 13/8e193d02fabd71187e6c95e2fe2d23ee545d6b diff --git a/13/8e193d02fabd71187e6c95e2fe2d23ee545d6b b/13/8e193d02fabd71187e6c95e2fe2d23ee545d6b new file mode 100644 index 000000000..671ecc6a1 --- /dev/null +++ b/13/8e193d02fabd71187e6c95e2fe2d23ee545d6b @@ -0,0 +1,199 @@ +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 79460431FC7 + for ; Fri, 2 Mar 2012 21:20:33 -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 Cr1raQch2hDa for ; + Fri, 2 Mar 2012 21:20:32 -0800 (PST) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id 099AD431FBC + for ; Fri, 2 Mar 2012 21:20:31 -0800 (PST) +X-AuditID: 12074425-b7f4a6d0000008e0-62-4f51aa1fa178 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 0C.09.02272.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 q235KUKS017467; + Sat, 3 Mar 2012 00:20:30 -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 q235KTYJ022244 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 3 Mar 2012 00:20:30 -0500 (EST) +Received: from amthrax by drake.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1S3hOP-0000gy-DF; Sat, 03 Mar 2012 00:20:29 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 2/5] show: Move format_message_mbox with the other new-style + formats +Date: Sat, 3 Mar 2012 00:20:22 -0500 +Message-Id: <1330752025-2542-3-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/KtDf4M93RYvrN2cyOzB6PFt1 + izmAMYrLJiU1J7MstUjfLoEr49Gsj4wF5yUqJq49ydrA+Eioi5GTQ0LARGLnmj+MELaYxIV7 + 69lAbCGBfYwSu6fUdzFyAdnrGSUOnz3MDOHcY5LoXnKPHcKZzyhx/MAbVpAWNgENiW37l4ON + EhGQlth5dzZQnIODWUBN4k+XCogpLBAi0fQLbAGLgKrEnud3WEBsXgF7iZMXeqCOUJA4t/oc + O4jNKeAg0XL8GCvEQfYSP/o7WSYw8i9gZFjFKJuSW6Wbm5iZU5yarFucnJiXl1qka6GXm1mi + l5pSuokRHDIuqjsYJxxSOsQowMGoxMNb+TzAX4g1say4MvcQoyQHk5Iob/nyQH8hvqT8lMqM + xOKM+KLSnNTiQ4wSHMxKIrzLPIFyvCmJlVWpRfkwKWkOFiVxXk2td35CAumJJanZqakFqUUw + WRkODiUJ3qiVQI2CRanpqRVpmTklCGkmDk6Q4TxAw1tBaniLCxJzizPTIfKnGBWlxHlzQRIC + IImM0jy4XlhMv2IUB3pFmDcApIoHmA7gul8BDWYCGrz4sh/I4JJEhJRUA+NcwVK92x/WPlYU + YYpcmrLyU9L7HJNDrgYSAu92zqj696KUVaSUfYfa53Lx0uvK3trHFybdq1trtV+isbeYt8p9 + tXHno3vHnH1iF3z4uUJD5b1+isSXjtj3rNa7Mu5LneFaKc3xbt/DQl99yWyJ12q1Xbxdb17u + ajG3dpCo3NzMsOid+reFe5RYijMSDbWYi4oTAbDtVRHEAgAA +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:33 -0000 + +Just code motion. +--- + notmuch-show.c | 100 ++++++++++++++++++++++++++++---------------------------- + 1 files changed, 50 insertions(+), 50 deletions(-) + +diff --git a/notmuch-show.c b/notmuch-show.c +index 648f468..b3a4550 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -219,56 +219,6 @@ _is_from_line (const char *line) + return 0; + } + +-/* Print a message in "mboxrd" format as documented, for example, +- * here: +- * +- * http://qmail.org/qmail-manual-html/man5/mbox.html +- */ +-static void +-format_message_mbox (const void *ctx, +- notmuch_message_t *message, +- unused (int indent)) +-{ +- const char *filename; +- FILE *file; +- const char *from; +- +- time_t date; +- struct tm date_gmtime; +- char date_asctime[26]; +- +- char *line = NULL; +- size_t line_size; +- ssize_t line_len; +- +- 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; +- } +- +- from = notmuch_message_get_header (message, "from"); +- from = _extract_email_address (ctx, from); +- +- date = notmuch_message_get_date (message); +- gmtime_r (&date, &date_gmtime); +- asctime_r (&date_gmtime, date_asctime); +- +- printf ("From %s %s", from, date_asctime); +- +- while ((line_len = getline (&line, &line_size, file)) != -1 ) { +- if (_is_from_line (line)) +- putchar ('>'); +- printf ("%s", line); +- } +- +- printf ("\n"); +- +- fclose (file); +-} +- + static void + format_headers_message_part_text (GMimeMessage *message) + { +@@ -762,6 +712,56 @@ format_part_json_entry (const void *ctx, mime_node_t *node, unused (int indent), + return NOTMUCH_STATUS_SUCCESS; + } + ++/* Print a message in "mboxrd" format as documented, for example, ++ * here: ++ * ++ * http://qmail.org/qmail-manual-html/man5/mbox.html ++ */ ++static void ++format_message_mbox (const void *ctx, ++ notmuch_message_t *message, ++ unused (int indent)) ++{ ++ const char *filename; ++ FILE *file; ++ const char *from; ++ ++ time_t date; ++ struct tm date_gmtime; ++ char date_asctime[26]; ++ ++ char *line = NULL; ++ size_t line_size; ++ ssize_t line_len; ++ ++ 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; ++ } ++ ++ from = notmuch_message_get_header (message, "from"); ++ from = _extract_email_address (ctx, from); ++ ++ date = notmuch_message_get_date (message); ++ gmtime_r (&date, &date_gmtime); ++ asctime_r (&date_gmtime, date_asctime); ++ ++ printf ("From %s %s", from, date_asctime); ++ ++ while ((line_len = getline (&line, &line_size, file)) != -1 ) { ++ if (_is_from_line (line)) ++ putchar ('>'); ++ printf ("%s", line); ++ } ++ ++ printf ("\n"); ++ ++ fclose (file); ++} ++ + static notmuch_status_t + show_message (void *ctx, + const notmuch_show_format_t *format, +-- +1.7.7.3 + -- 2.26.2