From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 8EB616DE0361 for ; Sun, 21 May 2017 05:48:37 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.001 X-Spam-Level: X-Spam-Status: No, score=-0.001 tagged_above=-999 required=5 tests=[AWL=0.010, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JhzmXCsfmSNk for ; Sun, 21 May 2017 05:48:36 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 3634E6DE00D2 for ; Sun, 21 May 2017 05:48:36 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1dCQGq-0003yH-Ob; Sun, 21 May 2017 08:47:40 -0400 Received: (nullmailer pid 26667 invoked by uid 1000); Sun, 21 May 2017 12:48:34 -0000 From: David Bremner To: notmuch@notmuchmail.org, notmuch@freelists.org Subject: [PATCH 1/5] util: convenience function to create gmime stream for stdout Date: Sun, 21 May 2017 09:48:17 -0300 Message-Id: <20170521124821.23924-2-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170521124821.23924-1-david@tethera.net> References: <20170521124821.23924-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.23 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, 21 May 2017 12:48:37 -0000 It turns out that our use of GMimeStreamPipe has only succeeded because gmime has been ignoring some seek failures; this will no longer be the case in gmime 3.0, so we use a GMimeStreamPipe, which does not assume seekability, wrapped in a buffering stream. --- util/Makefile.local | 2 +- util/gmime-extra.c | 15 +++++++++++++++ util/gmime-extra.h | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 util/gmime-extra.c create mode 100644 util/gmime-extra.h diff --git a/util/Makefile.local b/util/Makefile.local index a6962d49..3027880b 100644 --- a/util/Makefile.local +++ b/util/Makefile.local @@ -5,7 +5,7 @@ extra_cflags += -I$(srcdir)/$(dir) libnotmuch_util_c_srcs := $(dir)/xutil.c $(dir)/error_util.c $(dir)/hex-escape.c \ $(dir)/string-util.c $(dir)/talloc-extra.c $(dir)/zlib-extra.c \ - $(dir)/util.c + $(dir)/util.c $(dir)/gmime-extra.c libnotmuch_util_modules := $(libnotmuch_util_c_srcs:.c=.o) diff --git a/util/gmime-extra.c b/util/gmime-extra.c new file mode 100644 index 00000000..d0366812 --- /dev/null +++ b/util/gmime-extra.c @@ -0,0 +1,15 @@ +#include "gmime-extra.h" + +GMimeStream * +g_mime_stream_stdout_new() +{ + GMimeStream *stream_stdout = NULL; + + stream_stdout = g_mime_stream_pipe_new (STDOUT_FILENO); + if (!stream_stdout) + return NULL; + + g_mime_stream_pipe_set_owner (GMIME_STREAM_PIPE (stream_stdout), FALSE); + + return g_mime_stream_buffer_new (stream_stdout, GMIME_STREAM_BUFFER_BLOCK_WRITE); +} diff --git a/util/gmime-extra.h b/util/gmime-extra.h new file mode 100644 index 00000000..e0432a94 --- /dev/null +++ b/util/gmime-extra.h @@ -0,0 +1,6 @@ +#ifndef _GMIME_EXTRA_H +#define _GMIME_EXTRA_H +#include + +GMimeStream *g_mime_stream_stdout_new(void); +#endif -- 2.11.0