[Pkg-gnupg-commit] [gnupg2] 61/292: tools: Give mime parser callbacks access to the rfc822 parser.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit 4ac138c84d0f344ca9442f90c96f0e1f76062a4a
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Sep 29 08:11:32 2016 +0200

    tools: Give mime parser callbacks access to the rfc822 parser.
    
    * tools/mime-parser.c (mime_parser_context_s): Add field MSG.
    (parse_message_cb): Set it.
    (mime_parser_rfc822parser): New.
    * tools/mime-parser.h: Declare rfc822parse_t for the new prototype.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 tools/mime-parser.c | 17 +++++++++++++++++
 tools/mime-parser.h |  7 +++++++
 2 files changed, 24 insertions(+)

diff --git a/tools/mime-parser.c b/tools/mime-parser.c
index 7ac3c69..0ca5452 100644
--- a/tools/mime-parser.c
+++ b/tools/mime-parser.c
@@ -64,6 +64,9 @@ struct mime_parser_context_s
   /* The callback to collect a signature.  */
   gpg_error_t (*collect_signature) (void *cookie, const char *data);
 
+  /* The RFC822 parser context is stored here during callbacks.  */
+  rfc822parse_t msg;
+
   /* Helper to convey error codes from user callbacks.  */
   gpg_error_t err;
 
@@ -189,6 +192,9 @@ parse_message_cb (void *opaque, rfc822parse_event_t event, rfc822parse_t msg)
   const char *s;
   int rc = 0;
 
+  /* Make the RFC822 parser context availabale for callbacks.  */
+  ctx->msg = msg;
+
   if (ctx->debug)
     show_message_parser_event (event);
 
@@ -475,6 +481,8 @@ parse_message_cb (void *opaque, rfc822parse_event_t event, rfc822parse_t msg)
         }
     }
 
+  ctx->msg = NULL;
+
   return rc;
 }
 
@@ -599,6 +607,15 @@ mime_parser_set_collect_signature (mime_parser_t ctx,
 }
 
 
+/* Return the RFC888 parser context.  This is only available inside a
+ * callback.  */
+rfc822parse_t
+mime_parser_rfc822parser (mime_parser_t ctx)
+{
+  return ctx->msg;
+}
+
+
 /* Read and parse a message from FP and call the appropriate
  * callbacks.  */
 gpg_error_t
diff --git a/tools/mime-parser.h b/tools/mime-parser.h
index ab0d792..b217a2c 100644
--- a/tools/mime-parser.h
+++ b/tools/mime-parser.h
@@ -48,5 +48,12 @@ void mime_parser_set_collect_signature (mime_parser_t ctx,
 gpg_error_t mime_parser_parse (mime_parser_t ctx, estream_t fp);
 
 
+/* Duplicated declaration of the RFC822 parser context. */
+struct rfc822parse_context;
+typedef struct rfc822parse_context *rfc822parse_t;
+
+rfc822parse_t mime_parser_rfc822parser (mime_parser_t ctx);
+
+
 
 #endif /*GNUPG_MIME_PARSER_H*/

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list