blob: 5c1c697aa31d831ac9b63959cc60fd3a8b80d6ab [file] [log] [blame]
Daniel Lezcanoc193b602011-06-08 23:30:00 +02001/*******************************************************************************
2 * Copyright (C) 2010, Linaro Limited.
3 *
4 * This file is part of PowerDebug.
5 *
6 * All rights reserved. This program and the accompanying materials
7 * are made available under the terms of the Eclipse Public License v1.0
8 * which accompanies this distribution, and is available at
9 * http://www.eclipse.org/legal/epl-v10.html
10 *
11 * Author:
12 * Daniel Lezcano <daniel.lezcano@linaro.org>
13 *
14 *******************************************************************************/
15
16/*
17 * Structure describing a node of the clock tree
18 *
19 * tail : points to the last element in the list
20 * next : points to the next element in the list
21 * child : points to the child node
22 * parent : points to the parent node
23 * depth : the recursive level of the node
24 * path : absolute pathname of the directory
25 * name : basename of the directory
26 */
27struct tree {
28 struct tree *tail;
29 struct tree *next;
30 struct tree *prev;
31 struct tree *child;
32 struct tree *parent;
33 char *path;
34 char *name;
35 void *private;
Daniel Lezcanocb86e1d2011-06-08 23:30:01 +020036 int nrchild;
Daniel Lezcanoc193b602011-06-08 23:30:00 +020037 unsigned char depth;
38};
39
40typedef int (*tree_cb_t)(struct tree *t, void *data);
41
42typedef int (*tree_filter_t)(const char *name);
43
Daniel Lezcano25fc4a32011-08-25 15:46:13 +020044extern struct tree *tree_load(const char *path, tree_filter_t filter, bool follow);
Daniel Lezcanoc193b602011-06-08 23:30:00 +020045
Daniel Lezcano357dd8a2011-06-08 23:30:00 +020046extern struct tree *tree_find(struct tree *tree, const char *name);
47
Daniel Lezcanoc193b602011-06-08 23:30:00 +020048extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data);
Daniel Lezcanoafe62252011-06-08 23:30:00 +020049
Daniel Lezcano6d42e812011-06-08 23:30:01 +020050extern int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data);
51
Daniel Lezcanoafe62252011-06-08 23:30:00 +020052extern int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data);
Daniel Lezcanofabe20a2011-06-08 23:30:01 +020053
54extern int tree_finds(struct tree *tree, const char *name, struct tree ***ptr);