From: Jani Nikula Date: Thu, 6 Dec 2012 22:29:57 +0000 (+0200) Subject: [PATCH 1/2] sprinter: add text0 formatter for null character separated text X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4280745ce2bc2902b87caae19663df1f8a2424d6;p=notmuch-archives.git [PATCH 1/2] sprinter: add text0 formatter for null character separated text --- diff --git a/d7/81be28dd558f54be0644de225db8bc6d5683bf b/d7/81be28dd558f54be0644de225db8bc6d5683bf new file mode 100644 index 000000000..1f24087a1 --- /dev/null +++ b/d7/81be28dd558f54be0644de225db8bc6d5683bf @@ -0,0 +1,127 @@ +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 601A3431FB6 + for ; Thu, 6 Dec 2012 14:30:05 -0800 (PST) +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 yQxdTGsctFB8 for ; + Thu, 6 Dec 2012 14:30:05 -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 A9FCF431FAE + for ; Thu, 6 Dec 2012 14:30:04 -0800 (PST) +Received: by mail-la0-f53.google.com with SMTP id w12so5835867lag.26 + for ; Thu, 06 Dec 2012 14:30:03 -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:x-gm-message-state; + bh=ivJzNGYJ+2ho34b0H5sBN4Tn7tXpK1wyuttWWWDbJ3k=; + b=CImAD2A5NSKaCtZRXWf3Qte4ZfckUqiPjWh6/obZ6pFsT5klCyEr/A1g+k1U+CuSnv + 74C0aywwunK7WiqMcFpCztYnj/03Plqrs6HSTFpgl/RfyN83gFVqjsrHKTUmNVvT444N + n0t5QNJt/eqhEsm7z49UUXG5nKuBXzeLX5cRkVokSi4NP2u7vqzTPvoRGe3Ndj715f0d + ZcNo/X+ZGf5E7V2K8TzGn6ZxSpWI9ZE3JCTN5sEE08Pm2ii3eE/HwAxml6YOZ9uCaKU3 + oYljtgjJEzx3Yg9+vhkMGBRzHCQohptpGyZ05cAAikqvsudgN8vnRptl451rYtPZBW5i + PTHA== +Received: by 10.152.105.68 with SMTP id gk4mr3375775lab.48.1354833001821; + Thu, 06 Dec 2012 14:30:01 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id pw17sm3924175lab.5.2012.12.06.14.29.59 + (version=SSLv3 cipher=OTHER); Thu, 06 Dec 2012 14:30:00 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH 1/2] sprinter: add text0 formatter for null character + separated text +Date: Fri, 7 Dec 2012 00:29:57 +0200 +Message-Id: + <30f03a18ed10c221c13b6672f90654963c76452d.1354832980.git.jani@nikula.org> +X-Mailer: git-send-email 1.7.10.4 +X-Gm-Message-State: + ALoCoQmQpnigYXJ2Vi5ev3kCONReBwMqdJUl0XWI6qCzRXnFh7JE6hNOJ8aLKP7Dos4Cco6Ia3af +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: Thu, 06 Dec 2012 22:30:05 -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 912a526..74e7fec 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 +