From 7d1570b786867f60e34d9433f224d85ea2601de2 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 25 Jul 2012 22:34:44 +2000 Subject: [PATCH] [PATCH 04/13] show: Associate an sprinter with each format --- 92/ac938014bc8189bbafcc5756af1f73cc4204d8 | 161 ++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 92/ac938014bc8189bbafcc5756af1f73cc4204d8 diff --git a/92/ac938014bc8189bbafcc5756af1f73cc4204d8 b/92/ac938014bc8189bbafcc5756af1f73cc4204d8 new file mode 100644 index 000000000..725f28ac1 --- /dev/null +++ b/92/ac938014bc8189bbafcc5756af1f73cc4204d8 @@ -0,0 +1,161 @@ +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 703C3431FD7 + for ; Tue, 24 Jul 2012 19:35:06 -0700 (PDT) +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 grFAm2dARKrt for ; + Tue, 24 Jul 2012 19:35:05 -0700 (PDT) +Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU + [18.7.68.34]) + by olra.theworths.org (Postfix) with ESMTP id 83B10431FAE + for ; Tue, 24 Jul 2012 19:35:05 -0700 (PDT) +X-AuditID: 12074422-b7f1f6d00000090b-01-500f5b5986a8 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP + id 7C.71.02315.95B5F005; Tue, 24 Jul 2012 22:35:05 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6P2Z4Wj011170; + Tue, 24 Jul 2012 22:35:04 -0400 +Received: from drake.dyndns.org + (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 q6P2Z2MJ025121 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 24 Jul 2012 22:35:04 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1StrRG-0004Zn-Au; Tue, 24 Jul 2012 22:35:02 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 04/13] show: Associate an sprinter with each format +Date: Tue, 24 Jul 2012 22:34:44 -0400 +Message-Id: <1343183693-17134-5-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1343183693-17134-1-git-send-email-amdragon@mit.edu> +References: <1343183693-17134-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrBsZzR9gcOUZp8XehnZGi+s3ZzI7 + MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBl3J8oUXBKvWHTgMHMD4yuhLkZODgkBE4nH + tyYzQdhiEhfurWfrYuTiEBLYxyix4NECVghnA6PE7GczmSGcR0wSHWevskM4c4HKPi1gBOln + E9CQ2LZ/OZgtIiAtsfPubFYQm1nATGLuz4lsILawgLPE3vY/YDaLgKrE1YbjzCA2r4CDxJV5 + V5gh7pCXeHq/D6yGU8BR4vyShWAzhYBqehZfY5/AyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJe + XmqRrqlebmaJXmpK6SZGUCixuyjtYPx5UOkQowAHoxIP788nfAFCrIllxZW5hxglOZiURHkr + gvkDhPiS8lMqMxKLM+KLSnNSiw8xSnAwK4nwFoUB5XhTEiurUovyYVLSHCxK4rzXUm76Cwmk + J5akZqemFqQWwWRlODiUJHhbo4AaBYtS01Mr0jJzShDSTBycIMN5gIazgtTwFhck5hZnpkPk + TzEqSonzaoMkBEASGaV5cL2wWH/FKA70ijBvM0gVDzBNwHW/AhrMBDT4eRgfyOCSRISUVANj + zInwRdEXXqSJ7GOZLWIbW7Dxzec9D9nOVbFc2ZRna/SB0WvGlcRV037bbw+/Uii/oVvHY0ou + +0fBNzMqurgrTtnaVD6VFZhotKFv/0rp/PNfs//ZfzqzMMXued5Hr4sVn5/XX+/r3holaP3B + eNJ0kcyZdrMfxqw3fCHRc8HqBaOSSfvMcO8DSizFGYmGWsxFxYkALSZ+DNACAAA= +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, 25 Jul 2012 02:35:06 -0000 + +This associates an sprinter constructor with each show format and uses +this to construct the appropriate sprinter. Currently nothing is done +with this sprinter, but the following patches will weave it through +the layers of notmuch show. +--- + notmuch-client.h | 2 ++ + notmuch-show.c | 9 +++++++++ + 2 files changed, 11 insertions(+) + +diff --git a/notmuch-client.h b/notmuch-client.h +index f930798..e4172a2 100644 +--- a/notmuch-client.h ++++ b/notmuch-client.h +@@ -66,9 +66,11 @@ typedef GMimeCipherContext notmuch_crypto_context_t; + #define STRINGIFY_(s) #s + + typedef struct mime_node mime_node_t; ++typedef struct sprinter sprinter_t; + struct notmuch_show_params; + + typedef struct notmuch_show_format { ++ sprinter_t *(*new_sprinter) (const void *ctx, FILE *stream); + const char *message_set_start; + notmuch_status_t (*part) (const void *ctx, + struct mime_node *node, int indent, +diff --git a/notmuch-show.c b/notmuch-show.c +index d3419e4..d04943f 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -20,12 +20,14 @@ + + #include "notmuch-client.h" + #include "gmime-filter-reply.h" ++#include "sprinter.h" + + static notmuch_status_t + format_part_text (const void *ctx, mime_node_t *node, + int indent, const notmuch_show_params_t *params); + + static const notmuch_show_format_t format_text = { ++ .new_sprinter = sprinter_text_create, + .part = format_part_text, + }; + +@@ -34,6 +36,7 @@ format_part_json_entry (const void *ctx, mime_node_t *node, + int indent, const notmuch_show_params_t *params); + + static const notmuch_show_format_t format_json = { ++ .new_sprinter = sprinter_json_create, + .message_set_start = "[", + .part = format_part_json_entry, + .message_set_sep = ", ", +@@ -46,6 +49,7 @@ 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 = { ++ .new_sprinter = sprinter_text_create, + .part = format_part_mbox, + }; + +@@ -55,6 +59,7 @@ format_part_raw (unused (const void *ctx), mime_node_t *node, + unused (const notmuch_show_params_t *params)); + + static const notmuch_show_format_t format_raw = { ++ .new_sprinter = sprinter_text_create, + .part = format_part_raw, + }; + +@@ -1003,6 +1008,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + char *query_string; + int opt_index, ret; + const notmuch_show_format_t *format = &format_text; ++ sprinter_t *sprinter; + notmuch_show_params_t params = { + .part = -1, + .omit_excluded = TRUE, +@@ -1130,6 +1136,9 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) + return 1; + } + ++ /* Create structure printer. */ ++ sprinter = format->new_sprinter(ctx, stdout); ++ + /* If a single message is requested we do not use search_excludes. */ + if (params.part >= 0) + ret = do_show_single (ctx, query, format, ¶ms); +-- +1.7.10 + -- 2.26.2