aboutsummaryrefslogtreecommitdiff
blob: 68d5c75309494bf10209ef34af2c27728d5d60ed (plain)
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
/*
 * Copyright 2005-2022 Gentoo Foundation
 * Distributed under the terms of the GNU General Public License v2
 */

#ifndef _DEP_H
#define _DEP_H 1

#include "atom.h"
#include "colors.h"
#include "set.h"
#include "tree.h"
#include "xarray.h"

typedef enum {
	DEP_NULL = 0,
	DEP_NORM = 1,
	DEP_USE = 2,
	DEP_OR = 3,
	DEP_GROUP = 4
} dep_type;

static const char * const _dep_names[] = {
	"NULL",
	"NORM",
	"USE",
	"OR",
	"GROUP"
};

struct _dep_node {
	dep_type          type;
	char             *info;
	char              atom_resolved:1;
	depend_atom      *atom;
	struct _dep_node *parent;
	struct _dep_node *neighbor;
	struct _dep_node *children;
};
typedef struct _dep_node dep_node;

/* prototypes */
#ifdef NDEBUG
# define dep_dump_tree(r)
#else
# define dep_dump_tree(r) dep_print_tree(stdout, r, 0, NULL, NORM, 0)
#endif

dep_node *dep_grow_tree(const char *depend);
void dep_print_tree(FILE *fp, const dep_node *root, size_t space, array_t *m, const char *c, int verbose);
void dep_resolve_tree(dep_node *root, tree_ctx *t);
void dep_burn_tree(dep_node *root);
void dep_prune_use(dep_node *root, set *use);
void dep_flatten_tree(const dep_node *root, array_t *out);

#endif