From 0526c99164d3531b5ec763ffc672407eb24b2296 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 29 Mar 2017 10:02:40 +0200 Subject: gpg: Change parse_packet to take a context. * g10/packet.h (struct parse_packet_ctx_s): New. (parse_packet_ctx_t): New type. (init_parse_packet): New macro. * g10/parse-packet.c (parse_packet, dbg_parse_packet): Change to take a parse context. Change all callers to provide a context instead of directly supplying the input stream. (search_packet, dbg_search_packet): Ditto. (copy_all_packets, dbg_copy_all_packets): Init an use a parse context. (copy_some_packets, dbg_copy_some_packets): Ditto. (skip_some_packets, dbg_skip_some_packets): Ditto. -- We will need this change to handle ring packets inside the parser. Signed-off-by: Werner Koch --- g10/mainproc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'g10/mainproc.c') diff --git a/g10/mainproc.c b/g10/mainproc.c index 4c5dce1e0..30d9b1812 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1330,6 +1330,7 @@ static int do_proc_packets (ctrl_t ctrl, CTX c, iobuf_t a) { PACKET *pkt; + struct parse_packet_ctx_s parsectx; int rc = 0; int any_data = 0; int newpkt; @@ -1341,7 +1342,8 @@ do_proc_packets (ctrl_t ctrl, CTX c, iobuf_t a) pkt = xmalloc( sizeof *pkt ); c->iobuf = a; init_packet(pkt); - while ((rc=parse_packet(a, pkt)) != -1) + init_parse_packet (&parsectx, a); + while ((rc=parse_packet (&parsectx, pkt)) != -1) { any_data = 1; if (rc) -- cgit v1.2.3