diff options
author | Werner Koch <wk@gnupg.org> | 1998-01-02 21:40:10 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1998-01-02 21:40:10 +0100 |
commit | b7bdef0834f9d04f96f69a5323e0ac3e5e1b7bc2 (patch) | |
tree | cb6bae66627f4ea4d0a6b29631223ed2fe78ee8e /g10/kbnode.c | |
parent | Sylvester Version (diff) | |
download | gnupg2-b7bdef0834f9d04f96f69a5323e0ac3e5e1b7bc2.tar.xz gnupg2-b7bdef0834f9d04f96f69a5323e0ac3e5e1b7bc2.zip |
added more stuff
Diffstat (limited to 'g10/kbnode.c')
-rw-r--r-- | g10/kbnode.c | 55 |
1 files changed, 38 insertions, 17 deletions
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; } @@ -58,6 +59,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! */ void @@ -116,26 +127,35 @@ 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; } } + |