1 #ifndef R2_GRAPH_DRAWABLE_H
2 #define R2_GRAPH_DRAWABLE_H
3 
4 #include <r_types.h>
5 #include <r_util/r_graph.h>
6 #include <r_config.h>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 /**
13  * @brief Generic drawable graph node.
14  *
15  * Provides minimal information to draw something without output format specific details.
16  */
17 typedef struct r_anal_graph_node_info_t {
18 	char *title;
19 	char *body;
20 	/**
21 	 * @brief Optional offset for the object corresponding to node.
22 	 *
23 	 * Interactive output modes can use it to provide actions like seeking to
24 	 * this position or modify the object.
25 	 */
26 	ut64 offset;
27 } RGraphNodeInfo;
28 
29 R_API void r_graph_free_node_info(void *ptr);
30 R_API RGraphNodeInfo *r_graph_create_node_info(const char *title, const char *body, ut64 offset);
31 R_API RGraphNode *r_graph_add_node_info(RGraph *graph, const char *title, const char *body, ut64 offset);
32 
33 /**
34  * @brief Convert graph to Graphviz dot format.
35  *
36  * @param graph Graph with RGraphNodeInfo used as node user data
37  * @param node_properties List node styling attributes. Can be set to NULL.
38  * @param edge_properties List edge styling attributes. Can be set to NULL.
39  */
40 R_API char *r_graph_drawable_to_dot(RGraph /*RGraphNodeInfo*/ *graph, const char *node_properties, const char *edge_properties);
41 /**
42  * @brief Convert graph to JSON.
43  *
44  * @param[in] graph Graph to convert
45  * @param[out] pj Json output structure. Can be used to include the resulting JSON value inside bigger JSON.
46  * @param[in] use_offset Set this to true if graph uses \ref RGraphNodeInfo::offset offset field.
47  */
48 R_API void r_graph_drawable_to_json(RGraph /*RGraphNodeInfo*/ *graph, PJ *pj, bool use_offset);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 #endif
54