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 C436C429E36 for ; Sun, 16 Dec 2012 14:05:27 -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 bU1uiAhtmCJ1 for ; Sun, 16 Dec 2012 14:05:26 -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 8FC33431FD2 for ; Sun, 16 Dec 2012 14:05:25 -0800 (PST) Received: by mail-la0-f53.google.com with SMTP id w12so4065400lag.26 for ; Sun, 16 Dec 2012 14:05:24 -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=ahWY9uhxaAm4Eh2w8EEyudOafhn1ZOSnmnn/wbUpq9CUytaTntTtXuVJefpFxang1p fzeGai4uA9B51y02xlGdh9HucTKD4tsXvPcOBPDqcnnXUjfuqRq/6nXs5Ut76Opjpk95 nRNJACyz3wmqKTGMh6mZ1sBCbeBj5/M9VNJmw1l4XgUhdTBi1xxjanGIY2f/q3wFoqFx XQLuDQCiOyFsqMOxlSQqsnrLFQ4JVJaxExtabfRjMhu6EDHI666GY8r+pJy2uNQw2eLY eSKtKdd+/hPtjevSD0Cq2MCW+jRCNu1BKjDi1BkL4QQsD+3njjynJjEIEtISQKGjF0Sy UlBA== Received: by 10.112.43.161 with SMTP id x1mr5107336lbl.32.1355695522635; Sun, 16 Dec 2012 14:05:22 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id sj3sm4118235lab.2.2012.12.16.14.05.20 (version=SSLv3 cipher=OTHER); Sun, 16 Dec 2012 14:05:21 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v4 2/5] sprinter: add text0 formatter for null character separated text Date: Mon, 17 Dec 2012 00:05:10 +0200 Message-Id: <67652be343e8eec1934c57aaf0809f7a658866f5.1355695036.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: ALoCoQlprmwhmqDeHISA9aZCfh8eRwLQ0eKUcNS9PosRMUg+wgc2VAxgi8nb/6rMDIoRgiuvY/aK 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 22:05:28 -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