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 7D651431FB6 for ; Sun, 16 Dec 2012 13:02:53 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" 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 oXmgE6FzWfTq for ; Sun, 16 Dec 2012 13:02:53 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D7305431FAE for ; Sun, 16 Dec 2012 13:02:52 -0800 (PST) Received: by mail-lb0-f181.google.com with SMTP id ge1so4052259lbb.26 for ; Sun, 16 Dec 2012 13:02:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=yB+hA6dX1WwjVFKH/ANzufa8mVAszdN9OyGxjSv9O74=; b=ilJTteV8uzHoWtpoCUOBaVdk9xM3m8JKn4TA3mD7vmOnNYOGBbbDHxHyN6O2Zcj4C8 XQfC58hX/ckE2jIH+yFOIuCqh/2KrslXxsE221B1N9TD/AFk1TFN2BBPKTm7zn3QnQc6 NoVlE+eVYjxy2730zgxYgnvc01sBqWO4AO/M8vQdCpNtWyfgMZN3u7mBmhMMa9XfqUOU w1odtTu1ghfkyxRAesOfvKaRHziZ/a4qQ6nRd4EGSqcGIk2/EOkeWBnel1UCUsJqx/Pa 736sBwfeVv4N9//jX2ZOaYpM0Mq5ue5ldhlfIy1PedNA9ddbkqRUfHHWrIcjlUfnxkJA HkNA== Received: by 10.152.108.172 with SMTP id hl12mr8769618lab.32.1355691771471; Sun, 16 Dec 2012 13:02:51 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id gr12sm4074841lab.3.2012.12.16.13.02.49 (version=SSLv3 cipher=OTHER); Sun, 16 Dec 2012 13:02:50 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v3 2/5] sprinter: add text0 formatter for null character separated text Date: Sun, 16 Dec 2012 23:02:38 +0200 Message-Id: <5549df295eceb2aa388c0a4c3218dfb43fa13820.1355691124.git.jani@nikula.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlnhRufUKhDMuibpv4dbMYW5ManNu05dliorW3SWjq/4eMC61mWmBfpXnre2VOYmQ3m4stP 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: Sun, 16 Dec 2012 21:02:53 -0000 Same as the text formatter, but with each field separated by a null character rather than a newline character. --- sprinter-text.c | 22 ++++++++++++++++++++++ sprinter.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/sprinter-text.c b/sprinter-text.c index 10343be..7779488 100644 --- a/sprinter-text.c +++ b/sprinter-text.c @@ -68,6 +68,14 @@ text_separator (struct sprinter *sp) } static void +text0_separator (struct sprinter *sp) +{ + struct sprinter_text *sptxt = (struct sprinter_text *) sp; + + fputc ('\0', sptxt->stream); +} + +static void text_set_prefix (struct sprinter *sp, const char *prefix) { struct sprinter_text *sptxt = (struct sprinter_text *) sp; @@ -133,3 +141,17 @@ sprinter_text_create (const void *ctx, FILE *stream) res->stream = stream; return &res->vtable; } + +struct sprinter * +sprinter_text0_create (const void *ctx, FILE *stream) +{ + struct sprinter *sp; + + sp = sprinter_text_create (ctx, stream); + if (! sp) + return NULL; + + sp->separator = text0_separator; + + return sp; +} diff --git a/sprinter.h b/sprinter.h index f43a844..f859672 100644 --- a/sprinter.h +++ b/sprinter.h @@ -67,6 +67,12 @@ typedef struct sprinter { struct sprinter * sprinter_text_create (const void *ctx, FILE *stream); +/* Create a new unstructured printer that emits the text format for + * "notmuch search", with each field separated by a null character + * instead of the newline character. */ +struct sprinter * +sprinter_text0_create (const void *ctx, FILE *stream); + /* Create a new structure printer that emits JSON. */ struct sprinter * sprinter_json_create (const void *ctx, FILE *stream); -- 1.7.10.4