mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
f5b565a5b8
commit
0526c99164
7 changed files with 137 additions and 77 deletions
|
@ -378,6 +378,7 @@ int
|
|||
keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
|
||||
{
|
||||
PACKET *pkt;
|
||||
struct parse_packet_ctx_s parsectx;
|
||||
int rc;
|
||||
KBNODE keyblock = NULL, node, lastnode;
|
||||
IOBUF a;
|
||||
|
@ -407,10 +408,11 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
|
|||
|
||||
pkt = xmalloc (sizeof *pkt);
|
||||
init_packet (pkt);
|
||||
init_parse_packet (&parsectx, a);
|
||||
hd->found.n_packets = 0;;
|
||||
lastnode = NULL;
|
||||
save_mode = set_packet_list_mode(0);
|
||||
while ((rc=parse_packet (a, pkt)) != -1) {
|
||||
while ((rc=parse_packet (&parsectx, pkt)) != -1) {
|
||||
hd->found.n_packets++;
|
||||
if (gpg_err_code (rc) == GPG_ERR_UNKNOWN_PACKET) {
|
||||
free_packet (pkt);
|
||||
|
@ -985,6 +987,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||
{
|
||||
int rc;
|
||||
PACKET pkt;
|
||||
struct parse_packet_ctx_s parsectx;
|
||||
int save_mode;
|
||||
off_t offset, main_offset;
|
||||
size_t n;
|
||||
|
@ -1120,12 +1123,13 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
|||
if (DBG_LOOKUP)
|
||||
log_debug ("%s: %ssearching from start of resource.\n",
|
||||
__func__, scanned_from_start ? "" : "not ");
|
||||
init_parse_packet (&parsectx, hd->current.iobuf);
|
||||
while (1)
|
||||
{
|
||||
byte afp[MAX_FINGERPRINT_LEN];
|
||||
size_t an;
|
||||
|
||||
rc = search_packet (hd->current.iobuf, &pkt, &offset, need_uid);
|
||||
rc = search_packet (&parsectx, &pkt, &offset, need_uid);
|
||||
if (ignore_legacy && gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
|
||||
{
|
||||
free_packet (&pkt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue