Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 | */ |
| 27 | struct 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 Lezcano | cb86e1d | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 36 | int nrchild; |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 37 | unsigned char depth; |
| 38 | }; |
| 39 | |
| 40 | typedef int (*tree_cb_t)(struct tree *t, void *data); |
| 41 | |
| 42 | typedef int (*tree_filter_t)(const char *name); |
| 43 | |
Daniel Lezcano | 25fc4a3 | 2011-08-25 15:46:13 +0200 | [diff] [blame] | 44 | extern struct tree *tree_load(const char *path, tree_filter_t filter, bool follow); |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 45 | |
Daniel Lezcano | 357dd8a | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 46 | extern struct tree *tree_find(struct tree *tree, const char *name); |
| 47 | |
Daniel Lezcano | c193b60 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 48 | extern int tree_for_each(struct tree *tree, tree_cb_t cb, void *data); |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 49 | |
Daniel Lezcano | 6d42e81 | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 50 | extern int tree_for_each_reverse(struct tree *tree, tree_cb_t cb, void *data); |
| 51 | |
Daniel Lezcano | afe6225 | 2011-06-08 23:30:00 +0200 | [diff] [blame] | 52 | extern int tree_for_each_parent(struct tree *tree, tree_cb_t cb, void *data); |
Daniel Lezcano | fabe20a | 2011-06-08 23:30:01 +0200 | [diff] [blame] | 53 | |
| 54 | extern int tree_finds(struct tree *tree, const char *name, struct tree ***ptr); |