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 E4EA5431FCB for ; Fri, 27 Jul 2012 21:29:27 -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 NvVTVTMNkubP for ; Fri, 27 Jul 2012 21:29:26 -0700 (PDT) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id CC50C431FBD for ; Fri, 27 Jul 2012 21:29:25 -0700 (PDT) X-AuditID: 1209190c-b7f806d000006b87-63-50136aa48809 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id E1.00.27527.4AA63105; Sat, 28 Jul 2012 00:29:24 -0400 (EDT) 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 q6S4TN2h012929; Sat, 28 Jul 2012 00:29:23 -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 q6S4TKVu027355 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sat, 28 Jul 2012 00:29:22 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1SuyeW-0002Ws-G3; Sat, 28 Jul 2012 00:29:20 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 04/13] show: Associate an sprinter with each format Date: Sat, 28 Jul 2012 00:29:05 -0400 Message-Id: <1343449754-9010-5-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1343449754-9010-1-git-send-email-amdragon@mit.edu> References: <1343449754-9010-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRmVeSWpSXmKPExsUixG6nrrskSzjAYNlFBYu9De2MFqvn8lhc vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlXF3okzB JfGKRQcOMzcwvhLqYuTkkBAwkZh86BQbhC0mceHeeiCbi0NIYB+jxJ2Or+wQzgZGiXdnL0A5 j5gk1iy6zQrSIiQwl1Fi6U4uEJtNQENi2/7ljCC2iIC0xM67s4FqODiYBfIkHq+VAAkLC7hJ NK3fCNbKIqAqsXzlTbByXgF7idd730NdIS/x9H4fmM0p4CCx+eUHZohV9hK7J29gncDIv4CR YRWjbEpulW5uYmZOcWqybnFyYl5eapGuoV5uZoleakrpJkZQsHFK8uxgfHNQ6RCjAAejEg+v 8nWhACHWxLLiytxDjJIcTEqivFHhwgFCfEn5KZUZicUZ8UWlOanFhxglOJiVRHh3CgLleFMS K6tSi/JhUtIcLErivJdTbvoLCaQnlqRmp6YWpBbBZGU4OJQkeLdnAjUKFqWmp1akZeaUIKSZ ODhBhvMADV8DUsNbXJCYW5yZDpE/xagoJc47CSQhAJLIKM2D64Ulg1eM4kCvCPNeA6niASYS uO5XQIOZgAZbRAuBDC5JREhJNTBKh3m6r2J/6qq/c9HaPTart8yW7TELsAzOfZh58d6kkydd 9vzNCrfoqy1s38Wx61PTNdUnk5xUd9wvWnx+0en3MesFiu/dfmmbphe2x0F96cPUZ+ucg64K 1vHW3nD4+1sr7VTTLxmTxUvbVXSP//VfdVdrdWz5Iactc2cF2C1RcXL+892tTDhTiaU4I9FQ i7moOBEAUivb2uECAAA= 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: Sat, 28 Jul 2012 04:29:28 -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