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 C874F429E3B for ; Thu, 2 Aug 2012 18:15:24 -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 jKC1cLeFwHTg for ; Thu, 2 Aug 2012 18:15:23 -0700 (PDT) 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 091A6429E3C for ; Thu, 2 Aug 2012 18:15:10 -0700 (PDT) X-AuditID: 12074425-b7f9b6d0000008c4-c5-501b261e4ae9 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP id 1A.BD.02244.E162B105; Thu, 2 Aug 2012 21:15:10 -0400 (EDT) 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 q731FA6S019979; Thu, 2 Aug 2012 21:15:10 -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 q731F9YJ002825 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Thu, 2 Aug 2012 21:15:10 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1Sx6To-0003wG-5F; Thu, 02 Aug 2012 21:15:04 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v3 04/13] show: Associate an sprinter with each format Date: Thu, 2 Aug 2012 21:14:50 -0400 Message-Id: <1343956499-14543-5-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu> References: <1343956499-14543-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRmVeSWpSXmKPExsUixG6noiunJh1gsOCMmcXquTwW12/OZLZ4 s3IeqwOzx85Zd9k9Dn9dyOLxbNUt5gDmKC6blNSczLLUIn27BK6MI1PfsBXcEqu4+PsWSwNj s1AXIyeHhICJRNO6h0wQtpjEhXvr2boYuTiEBPYxSkzq/cAO4axnlFj6cBIzhPOQSeLXl7+s EM5cRok3Z/4yg/SzCWhIbNu/nBHEFhGQlth5dzYriM0sECexZcp/sLiwgJtE26kPYHEWAVWJ b0+/g+3mFXCQ+H+4gxXiDnmJp/f72EBsTgFHiddvX4H1CgHVLG/rZp3AyL+AkWEVo2xKbpVu bmJmTnFqsm5xcmJeXmqRroVebmaJXmpK6SZGcHi5qO5gnHBI6RCjAAejEg+vkaR0gBBrYllx Ze4hRkkOJiVRXmYloBBfUn5KZUZicUZ8UWlOavEhRgkOZiUR3qolUgFCvCmJlVWpRfkwKWkO FiVx3hspN/2FBNITS1KzU1MLUotgsjIcHEoSvLKqQEMFi1LTUyvSMnNKENJMHJwgw3mAhtuD 1PAWFyTmFmemQ+RPMSpKifOygyQEQBIZpXlwvbD4f8UoDvSKMO8FFaAqHmDqgOt+BTSYCWiw nRnI1cUliQgpqQbG2S2BtXaGkydeeiEU+dDSe+Pm5Ib8QtczfgEisnNKz267NFO6Lk3Rzqvw DZ/Rm+sxC2/9dfPNZH96/kLT3J7KL9zthccS37xyfmBWHeVtdEJQ49KNoz5LxCZYMSxv2Hv8 SJD+tGMiKg6LwzNCKvX5TnYLXrGVeeUoKThxzdFKbq6M9NCgmFQlluKMREMt5qLiRAA1UrJU 2gIAAA== Cc: tomi.ollila@iki.fi 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: Fri, 03 Aug 2012 01:15:25 -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 | 1 + notmuch-show.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/notmuch-client.h b/notmuch-client.h index f930798..bbc0a11 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -69,6 +69,7 @@ typedef struct mime_node mime_node_t; struct notmuch_show_params; typedef struct notmuch_show_format { + struct sprinter *(*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