Rizin
unix-like reverse engineering framework and cli tools
rz_graph.h
Go to the documentation of this file.
1 #ifndef RZ_GRAPH_H
2 #define RZ_GRAPH_H
3 
4 #include <rz_list.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 typedef struct rz_graph_node_t {
11  unsigned int idx;
12  void *data;
18 
19 typedef struct rz_graph_edge_t {
22  int nth;
24 
25 typedef struct rz_graph_t {
26  unsigned int n_nodes;
27  unsigned int n_edges;
29  RzList *nodes; /* RzGraphNode */
31 
32 typedef struct rz_graph_visitor_t {
34  void (*finish_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis);
35  void (*tree_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis);
36  void (*back_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis);
37  void (*fcross_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis);
38  void *data;
41 typedef void (*RzGraphEdgeCallback)(const RzGraphEdge *e, RzGraphVisitor *vis);
42 
43 // Contrructs a new RzGraph, returns heap-allocated graph.
45 // Destroys the graph and all nodes.
47 // Gets the data of a node by index.
48 RZ_API RzGraphNode *rz_graph_get_node(const RzGraph *g, unsigned int idx);
49 RZ_API RzListIter *rz_graph_node_iter(const RzGraph *g, unsigned int idx);
53 // XXX 'n' is destroyed after calling this function.
61 RZ_API const RzList *rz_graph_innodes(const RzGraph *g, const RzGraphNode *n);
64 RZ_API bool rz_graph_adjacent(const RzGraph *g, const RzGraphNode *from, const RzGraphNode *to);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif // RZ_GRAPH_H
#define e(frag)
#define RZ_API
struct @667 g
int n
Definition: mipsasm.c:19
int idx
Definition: setup.py:197
RZ_API RzGraph * rz_graph_new(void)
Definition: graph.c:108
RZ_API void rz_graph_del_node(RzGraph *g, RzGraphNode *n)
Definition: graph.c:177
void(* RzGraphEdgeCallback)(const RzGraphEdge *e, RzGraphVisitor *vis)
Definition: rz_graph.h:41
struct rz_graph_node_t RzGraphNode
RZ_API const RzList * rz_graph_all_neighbours(const RzGraph *g, const RzGraphNode *n)
Definition: graph.c:261
RZ_API void rz_graph_dfs(RzGraph *g, RzGraphVisitor *vis)
Definition: graph.c:299
RZ_API void rz_graph_del_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to)
Definition: graph.c:232
RZ_API RzGraphNode * rz_graph_nth_neighbour(const RzGraph *g, const RzGraphNode *n, int nth)
Definition: graph.c:251
RZ_API RzGraphNode * rz_graph_add_nodef(RzGraph *g, void *data, RzListFree user_free)
Definition: graph.c:167
RZ_API bool rz_graph_adjacent(const RzGraph *g, const RzGraphNode *from, const RzGraphNode *to)
Definition: graph.c:270
RZ_API const RzList * rz_graph_get_nodes(const RzGraph *g)
Definition: graph.c:265
RZ_API void rz_graph_dfs_node(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis)
Definition: graph.c:277
RZ_API RzGraphNode * rz_graph_node_split_forward(RzGraph *g, RzGraphNode *split_me, void *data)
Definition: graph.c:214
RZ_API const RzList * rz_graph_get_neighbours(const RzGraph *g, const RzGraphNode *n)
Definition: graph.c:245
RZ_API void rz_graph_reset(RzGraph *g)
Definition: graph.c:141
RZ_API void rz_graph_dfs_node_reverse(RzGraph *g, RzGraphNode *n, RzGraphVisitor *vis)
Definition: graph.c:288
RZ_API RzListIter * rz_graph_node_iter(const RzGraph *g, unsigned int idx)
Definition: graph.c:137
RZ_API const RzList * rz_graph_innodes(const RzGraph *g, const RzGraphNode *n)
Definition: graph.c:256
RZ_API void rz_graph_add_edge(RzGraph *g, RzGraphNode *from, RzGraphNode *to)
Definition: graph.c:199
RZ_API void rz_graph_add_edge_at(RzGraph *g, RzGraphNode *from, RzGraphNode *to, int nth)
Definition: graph.c:203
RZ_API void rz_graph_free(RzGraph *g)
Definition: graph.c:124
RZ_API RzGraphNode * rz_graph_add_node(RzGraph *g, void *data)
Definition: graph.c:153
RZ_API RzGraphNode * rz_graph_get_node(const RzGraph *g, unsigned int idx)
Definition: graph.c:129
struct rz_graph_edge_t RzGraphEdge
void(* RzGraphNodeCallback)(RzGraphNode *n, RzGraphVisitor *vis)
Definition: rz_graph.h:40
struct rz_graph_t RzGraph
struct rz_graph_visitor_t RzGraphVisitor
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
RzGraphNode * to
Definition: rz_graph.h:21
RzGraphNode * from
Definition: rz_graph.h:20
void * data
Definition: rz_graph.h:12
unsigned int idx
Definition: rz_graph.h:11
RzList * out_nodes
Definition: rz_graph.h:13
RzList * all_neighbours
Definition: rz_graph.h:15
RzList * in_nodes
Definition: rz_graph.h:14
RzListFree free
Definition: rz_graph.h:16
RzList * nodes
Definition: rz_graph.h:29
int last_index
Definition: rz_graph.h:28
unsigned int n_nodes
Definition: rz_graph.h:26
unsigned int n_edges
Definition: rz_graph.h:27
void(* finish_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis)
Definition: rz_graph.h:34
void(* discover_node)(RzGraphNode *n, struct rz_graph_visitor_t *vis)
Definition: rz_graph.h:33
void(* back_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis)
Definition: rz_graph.h:36
void(* tree_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis)
Definition: rz_graph.h:35
void(* fcross_edge)(const RzGraphEdge *e, struct rz_graph_visitor_t *vis)
Definition: rz_graph.h:37