X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Ftree.c;h=72c084a6eeb69e8b74cb4d7e25c78cf193baaaf9;hb=560e71cc545182bb51a7d038ac40eebac8e045aa;hp=12592c1009501e269b3e64e6aa94206ef268d9ed;hpb=059ec3d9952740285fb1ebf47961b8aca2eb1b4a;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/tree.c b/src/src/tree.c index 12592c100..72c084a6e 100644 --- a/src/src/tree.c +++ b/src/src/tree.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/tree.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2004 */ +/* Copyright (c) University of Cambridge 1995 - 2015 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions for maintaining binary balanced trees and some associated @@ -330,7 +328,7 @@ Returns: pointer to node, or NULL if not found */ tree_node * -tree_search(tree_node *p, uschar *name) +tree_search(tree_node *p, const uschar *name) { while (p != NULL) { @@ -342,4 +340,26 @@ return NULL; } + +/************************************************* +* Walk tree recursively and execute function * +*************************************************/ + +/* +Arguments: + p root of the tree + f function to execute for each name-value-pair + ctx context data for f +*/ + +void +tree_walk(tree_node *p, void (*f)(uschar*, uschar*, void*), void *ctx) +{ +if (p == NULL) return; +f(p->name, p->data.ptr, ctx); +if (p->left != NULL) tree_walk(p->left, f, ctx); +if (p->right != NULL) tree_walk(p->right, f, ctx); +} + + /* End of tree.c */