1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-09 17:53:03 +01:00

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.
This commit is contained in:
Werner Koch 2014-06-12 14:41:40 +02:00
parent 6eeb31abee
commit d8314e31c5

View File

@ -403,11 +403,18 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos,
int hdrlen; int hdrlen;
int new_ctb = 0, partial = 0; int new_ctb = 0, partial = 0;
int with_uid = (onlykeypkts == 2); int with_uid = (onlykeypkts == 2);
off_t pos;
*skip = 0; *skip = 0;
assert (!pkt->pkt.generic); assert (!pkt->pkt.generic);
if (retpos || list_mode)
{
pos = iobuf_tell (inp);
if (retpos) if (retpos)
*retpos = iobuf_tell (inp); *retpos = pos;
}
else
pos = 0; /* (silence compiler warning) */
if ((ctb = iobuf_get (inp)) == -1) if ((ctb = iobuf_get (inp)) == -1)
{ {
@ -559,6 +566,12 @@ parse (IOBUF inp, PACKET * pkt, int onlykeypkts, off_t * retpos,
#endif #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; pkt->pkttype = pkttype;
rc = G10ERR_UNKNOWN_PACKET; /* default error */ rc = G10ERR_UNKNOWN_PACKET; /* default error */
switch (pkttype) switch (pkttype)