aboutsummaryrefslogtreecommitdiff
path: root/tree.h
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2011-06-08 23:30:00 +0200
committerDaniel Lezcano <daniel.lezcano@free.fr>2011-06-08 23:30:00 +0200
commitc193b6018c016260a3ac51d51285a2c02512218f (patch)
treeffd542cdeefd3acce0be78c6325fb2fc8b08b60c /tree.h
parent1c25df9671dfcc987d547f29745d121670149cf5 (diff)
tree structure abstraction for directory hierarchies
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'tree.h')
-rw-r--r--tree.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/tree.h b/tree.h
new file mode 100644
index 0000000..57c70f8
--- /dev/null
+++ b/tree.h
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Linaro Limited.
+ *
+ * This file is part of PowerDebug.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Author:
+ * Daniel Lezcano <daniel.lezcano@linaro.org>
+ *
+ *******************************************************************************/
+
+/*
+ * Structure describing a node of the clock tree
+ *
+ * tail : points to the last element in the list
+ * next : points to the next element in the list
+ * child : points to the child node
+ * parent : points to the parent node
+ * depth : the recursive level of the node
+ * path : absolute pathname of the directory
+ * name : basename of the directory
+ */
+struct tree {
+ struct tree *tail;
+ struct tree *next;
+ struct tree *prev;
+ struct tree *child;
+ struct tree *parent;
+ char *path;
+ char *name;
+ void *private;
+ unsigned char depth;
+};
+
+typedef int (*tree_cb_t)(struct tree *t, void *data);
+
+typedef int (*tree_filter_t)(const char *name);
+
+extern struct tree *tree_load(const char *path, tree_filter_t filter);
+
+extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data);