From b7bdef0834f9d04f96f69a5323e0ac3e5e1b7bc2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 2 Jan 1998 20:40:10 +0000 Subject: added more stuff --- g10/kbnode.c | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'g10/kbnode.c') diff --git a/g10/kbnode.c b/g10/kbnode.c index 844bafe6c..19e0870df 100644 --- a/g10/kbnode.c +++ b/g10/kbnode.c @@ -38,6 +38,7 @@ new_kbnode( PACKET *pkt ) n->pkt = pkt; n->child = NULL; n->flag = 0; + n->private_flag=0; /* kludge to delete a node */ return n; } @@ -57,6 +58,16 @@ release_kbnode( KBNODE n ) } +/**************** + * Delete NODE from ROOT, ROOT must exist! + * Note does only work with walk_kbtree!! + */ +void +delete_kbnode( KBNODE root, KBNODE node ) +{ + node->private_flag |= 1; +} + /**************** * Append NODE to ROOT, ROOT must exist! */ @@ -115,27 +126,36 @@ find_kbparent( KBNODE root, KBNODE node ) */ KBNODE walk_kbtree( KBNODE root, KBNODE *context ) +{ + return walk_kbtree2( root, context, 0 ); +} + +KBNODE +walk_kbtree2( KBNODE root, KBNODE *context, int all ) { KBNODE n; - if( !*context ) { - *context = root; - return root; - } + do { + if( !*context ) { + *context = root; + return root; + } + + n = *context; + if( n->child ) { + n = n->child; + *context = n; + } + else if( n->next ) { + n = n->next; + *context = n; + } + else if( (n = find_kbparent( root, n )) ) { + n = n->next; + *context = n; + } + } while( !all && n && (n->private_flag & 1) ); - n = *context; - if( n->child ) { - n = n->child; - *context = n; - } - else if( n->next ) { - n = n->next; - *context = n; - } - else if( (n = find_kbparent( root, n )) ) { - n = n->next; - *context = n; - } return n; } @@ -147,3 +167,4 @@ clear_kbnode_flags( KBNODE n ) n->flag = 0; } } + -- cgit v1.2.3