blob: a52544b175fbc344958cf8586e22d0774cf57849 (
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
|
#include "config.h"
#include <assert.h>
#include <ccan/aga/aga.h>
#include <ccan/container_of/container_of.h>
#include <ccan/ptrint/ptrint.h>
#include "simple-graph.h"
static ptrint_t *error_first_edge(const struct aga_graph *g,
const struct aga_node *n)
{
return int2ptr(1);
}
static ptrint_t *error_next_edge(const struct aga_graph *g,
const struct aga_node *n,
ptrint_t *edge)
{
assert(edge == int2ptr(1));
return NULL;
}
static int error_edge_info(const struct aga_graph *g, const struct aga_node *n,
ptrint_t *edge, struct aga_edge_info *ei)
{
struct error_graph *eg = container_of(g, struct error_graph, sg.g);
int fromindex = n - eg->sg.nodes;
switch (fromindex) {
case 1:
ei->to = &eg->sg.nodes[2];
break;
case 2:
ei->to = NULL;
break;
case 3:
ei->to = &eg->sg.nodes[4];
break;
default:
return -1;
}
return 0;
}
void error_graph_init(struct error_graph *eg)
{
simple_graph_init(&eg->sg, error_first_edge, error_next_edge,
error_edge_info);
}
|