diff options
author | Werner Koch <wk@gnupg.org> | 2014-06-12 14:41:40 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-06-12 14:41:40 +0200 |
commit | d8314e31c58ea0827d0e2361dabcdf869ab08fce (patch) | |
tree | 5ee124641d7c77eb5238e95f9e86a434f7804e93 /g10 | |
parent | speedo: Improve building of the w32 installer. (diff) | |
download | gnupg2-d8314e31c58ea0827d0e2361dabcdf869ab08fce.tar.xz gnupg2-d8314e31c58ea0827d0e2361dabcdf869ab08fce.zip |
gpg: Improve the output of --list-packets
* g10/parse-packet.c (parse): Print packet meta info in list mode.
--
In particular having the file offset of the packets is often useful.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/parse-packet.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c index 26ca0381f..28f9016b9 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -403,11 +403,18 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos, int hdrlen; int new_ctb = 0, partial = 0; int with_uid = (onlykeypkts == 2); + off_t pos; *skip = 0; assert (!pkt->pkt.generic); - if (retpos) - *retpos = iobuf_tell (inp); + if (retpos || list_mode) + { + pos = iobuf_tell (inp); + if (retpos) + *retpos = pos; + } + else + pos = 0; /* (silence compiler warning) */ if ((ctb = iobuf_get (inp)) == -1) { @@ -559,6 +566,12 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos, #endif } + if (list_mode) + es_fprintf (listfp, "# off=%lu ctb=%02x tag=%d hlen=%d plen=%lu%s%s\n", + (unsigned long)pos, ctb, pkttype, hdrlen, pktlen, + partial? " partial":"", + new_ctb? " new-ctb":""); + pkt->pkttype = pkttype; rc = G10ERR_UNKNOWN_PACKET; /* default error */ switch (pkttype) |