Update version number and copyright year.
[exim.git] / src / src / tree.c
index 791ac79b87f6bf831e2ba4f993408cdc39405d71..86ead896c2e77f73e9e8b9e5e640c4e8a965d22a 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/tree.c,v 1.2 2005/01/04 10:00:42 ph10 Exp $ */
+/* $Cambridge: exim/src/src/tree.c,v 1.5 2007/01/08 10:50:18 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2007 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions for maintaining binary balanced trees and some associated
@@ -342,4 +342,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 */