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 037AD431FB6 for ; Sun, 9 Dec 2012 06:56:08 -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 IU2R33PpEXn7 for ; Sun, 9 Dec 2012 06:56:07 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 59C2B431FAE for ; Sun, 9 Dec 2012 06:56:07 -0800 (PST) Received: by mail-la0-f53.google.com with SMTP id w12so1484159lag.26 for ; Sun, 09 Dec 2012 06:56:05 -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=oIyKI9+q1AfWdENA+zsqDHraydwElEClbKo9xqgXFaQ=; b=QOpRz2qt4oWkMzost+x3YCR+ylKOAoCNwoelZyj6WCNcbSJcNdCE0rmjFKxF0oC0HP POChpbr1l5M/gPbkn4kr8EZF72bhFkMAhEqQ9J+v3j7BbkOhVtUmNMV4NZEbLsH3JyOb e3pI0I1zbVvs+gMGQueY99l/IgqfWwOzUjd01uu9sU+Jt0JRJpzR0y+JBxbT56T3tQFd eN0AsCXLAqhLhCM2jZRsxuvuFWJZ2Y0c9qegQq2/cQ67PiqUCCoAZ4bjwlBa5Q/5Mk9n h4pfo1v5zjjcIothJtmjVbhd95R5QaTpR7/B+l0StnGsSgHP7uP9g5FHW8Yj1TLW1MMS 1opQ== Received: by 10.112.31.194 with SMTP id c2mr4745686lbi.44.1355064965775; Sun, 09 Dec 2012 06:56:05 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id pz9sm6651897lab.11.2012.12.09.06.56.04 (version=SSLv3 cipher=OTHER); Sun, 09 Dec 2012 06:56:04 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v2 1/4] sprinter: add text0 formatter for null character separated text Date: Sun, 9 Dec 2012 16:55:56 +0200 Message-Id: <33103d6a747093548d890816bd55314043396cbd.1355064714.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: ALoCoQnu46/RuFFHCVAo8Y4aahYKhhIBz7RyPnyDlqhOW0aYzhLMUAih4n260AC1lZAxh5Cx8/6P 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, 09 Dec 2012 14:56:08 -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 59776a9..f36b999 100644 --- a/sprinter.h +++ b/sprinter.h @@ -66,6 +66,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