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 914D96DE11EC for ; Sun, 20 Aug 2017 06:04:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.045 X-Spam-Level: X-Spam-Status: No, score=0.045 tagged_above=-999 required=5 tests=[AWL=0.065, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-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 wltqfHkhYtjA for ; Sun, 20 Aug 2017 06:04:18 -0700 (PDT) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by arlo.cworth.org (Postfix) with ESMTPS id 5ECC46DE11C7 for ; Sun, 20 Aug 2017 06:04:18 -0700 (PDT) Received: by mail-lf0-f47.google.com with SMTP id d17so57480363lfe.0 for ; Sun, 20 Aug 2017 06:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=RzoBQaJ9E10uduH8oBOkGE7zW9EWNDz7aavCH+6xw6Y=; b=gh7JyDjvEGEql60JoS6U2q8zY1s8Lh3XPBc3VoasyvfeX0cFxu6vo1R7SvdzZDFO/l LkVr3Lias2zEH4wzlBEVUU+SwTpmC7vMa71tyVznZjaii4ztfDv07kEsbOJm/VAsQHv/ +xVaYeSJI0V9NV/eSWGivraIs2XJcCFAYOD1NXm7MAPOzkGaV5lpqz+HSs/5Wl9yxyQM yvdgNJtTWL0M6YVUFCKaGfw312FNol8FynSxbv96uBcTFQm6FoxYokLKCFlI0ulnvb9r 8rteTAeVWwaPR3fDWAiAO/abYGxiVrRyav1McZA2T2gNtYN7Q0A0+vOWLMmXWiIAN74M wezA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=RzoBQaJ9E10uduH8oBOkGE7zW9EWNDz7aavCH+6xw6Y=; b=svgYR0sF3Zg4j0dDVL7G0dV6YrzeObWDAjOwbncmGZ13xO+lX0ooTB0WqmS806y/Be 7+91YetrnV+SacfgtBW9jerdxFiC12ugA4lxwktUH3sRblCtaJWPAEWeqgc2IxwT2jMp 8Wdf2u8VpNjs9AnObzClR+uXRscRIF06Y6LICwljHdpT3Dp/NDoxo4n9XNCu2BWOtbQP pFXY9UvBjOE9pO+XSlO7+4DyCzqSdPJa8U5vNJEs+FOLeApAK+PJZ5SKH10T5z2BSN9Z NVHTFxm4n04CJucdhq36NZJ11jn5VEHvxmku1d2s84LAHy9NqxY14lzAOAcGM4MqqY7b KffA== X-Gm-Message-State: AHYfb5jLLBbgE4u5FtWH4i8msEUSOoJ60h39S+2PojTLmWdCXtry1s68 0iaSYwecjYofyARaWpgHeQ== X-Received: by 10.46.22.20 with SMTP id w20mr6176175ljd.103.1503234256452; Sun, 20 Aug 2017 06:04:16 -0700 (PDT) Received: from localhost (mobile-access-5d6aa6-119.dhcp.inet.fi. [93.106.166.119]) by smtp.gmail.com with ESMTPSA id a63sm462895lfb.94.2017.08.20.06.04.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Aug 2017 06:04:15 -0700 (PDT) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org, notmuch@freelists.org Subject: Re: [PATCH] util: add utility routine to dump the structure of a gmime part In-Reply-To: <20170523004130.15090-1-david@tethera.net> References: <20170523004130.15090-1-david@tethera.net> Date: Sun, 20 Aug 2017 16:04:14 +0300 Message-ID: <87d17ql7ap.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain 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, 20 Aug 2017 13:04:19 -0000 On Mon, 22 May 2017, David Bremner wrote: > For debugging. From the gmime 3.0 test suite. > --- > > I'm not sure this is really in the source tree, but I remember > rumblings from Jani about maybe providing some kind of C equivalent > for the python printmimestructure script. So in case this proves > useful to someone, here it is. I've got an implementation that adds a MIME structure display option to 'notmuch show'. I self-bikeshedded the output format long enough that it doesn't cleanly rebase on top of current git master anymore. Perhaps I'll get it rebased one of these days... BR, Jani. > > util/gmime-extra.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > util/gmime-extra.h | 2 ++ > 2 files changed, 51 insertions(+) > > diff --git a/util/gmime-extra.c b/util/gmime-extra.c > index 81f3fce9..d1c55623 100644 > --- a/util/gmime-extra.c > +++ b/util/gmime-extra.c > @@ -1,5 +1,54 @@ > #include "gmime-extra.h" > > +static void > +print_mime_part_info (const char *path, GMimeObject *object) > +{ > + const GMimeContentType *type; > + gboolean has_md5; > + > + type = g_mime_object_get_content_type (object); > + > + if (GMIME_IS_PART (object)) > + has_md5 = g_mime_object_get_header (object, "Content-Md5") != NULL; > + else > + has_md5 = FALSE; > + > + fprintf (stdout, "%s\t%s/%s%s", path, > + type->type, type->subtype, has_md5 ? "; md5sum=" : "\n"); > + > + if (has_md5) { > + /* validate the Md5 sum */ > + if (g_mime_part_verify_content_md5 ((GMimePart *) object)) > + fprintf (stdout, "GOOD\n"); > + else > + fprintf (stdout, "BAD\n"); > + } > +} > + > +void > +g_mime_object_print_struct (GMimeObject *part) > +{ > + GMimePartIter *iter; > + GMimeObject *parent; > + char *path; > + > + iter = g_mime_part_iter_new (part); > + if (g_mime_part_iter_is_valid (iter)) { > + if ((parent = g_mime_part_iter_get_parent (iter))) > + print_mime_part_info ("TEXT", parent); > + > + do { > + part = g_mime_part_iter_get_current (iter); > + path = g_mime_part_iter_get_path (iter); > + print_mime_part_info (parent ? path : "TEXT", part); > + g_free (path); > + } while (g_mime_part_iter_next (iter)); > + > + } > + > + g_mime_part_iter_free (iter); > +} > + > GMimeStream * > g_mime_stream_stdout_new() > { > diff --git a/util/gmime-extra.h b/util/gmime-extra.h > index eb28cf06..2300dfb0 100644 > --- a/util/gmime-extra.h > +++ b/util/gmime-extra.h > @@ -4,6 +4,8 @@ > > GMimeStream *g_mime_stream_stdout_new(void); > > +void g_mime_object_print_struct(GMimeObject *part); > + > #include > > > -- > 2.11.0