-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnode.h
More file actions
75 lines (67 loc) · 2.96 KB
/
node.h
File metadata and controls
75 lines (67 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* node.h
* This file is part of tdu, a text-mode disk usage visualization utility.
*
* Copyright (C) 2004-2012 Darren Stuart Embry.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307$
*/
#ifndef NODE_H
#define NODE_H
/*****************************************************************************/
#include "tdu.h"
#include <curses.h>
#include <glib.h>
/* Each node's list of children is allocated in blocks of this many. */
#define KIDSATATIME 256
/* Each pathname element has associated with it a node in a tree. */
typedef struct node {
char *name;
long size;
struct node **children; /* reallocated one block at a time */
GHashTable *children_by_name;
long nchildren;
long nchildrenblocks; /* allocated in this many "blocks" */
struct node *parent;
long expanded; /* number of decendents visible -- used for
computing each node's "line number" */
long descendents;
bool is_last_child; /* used for printing tree branches */
int origindex; /* for "unsorting" */
} node_s;
typedef int (*node_sort_fp)(const node_s *, const node_s *);
node_s *new_node (const char *name);
void add_child (node_s *parent, node_s *child);
node_s *find_or_create_child (node_s *node, const char *name);
void add_node (node_s *root, const char *pathname, TDU_SIZE_T size);
TDU_SIZE_T fix_tree_sizes (node_s *node);
long fix_tree_descendents (node_s *node);
void cleanup_tree (node_s *node);
void dump_tree (node_s *node, int level);
long expand_tree (node_s *node, int level);
long expand_tree_ (node_s *node, int level);
long collapse_tree (node_s *node);
void collapse_tree_ (node_s *node);
node_s *find_node_numbered (node_s *node, long nodeline);
long find_node_number_in (node_s *node, node_s *root);
int node_cmp_size (const node_s *a, const node_s *b);
int node_cmp_unsort (const node_s *a, const node_s *b);
int node_cmp_name (const node_s *a, const node_s *b);
int node_cmp_descendents (const node_s *a, const node_s *b);
int node_qsort_cmp (const void *aa, const void *bb);
void tree_sort (node_s *node, node_sort_fp fp, bool reverse, bool isrecursive);
node_s *parse_file (const char *pathname);
/*****************************************************************************/
#endif /* NODE_H */