Graphviz  2.41.20170921.2350
xdot.h
Go to the documentation of this file.
1 /* vim:set shiftwidth=4 ts=8: */
2 
3 /*************************************************************************
4  * Copyright (c) 2011 AT&T Intellectual Property
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors: See CVS logs. Details at http://www.graphviz.org/
11  *************************************************************************/
12 
13 #ifndef XDOT_H
14 #define XDOT_H
15 #include <stdio.h>
16 #ifdef _WIN32
17 #include <windows.h>
18 #endif
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #ifdef _WIN32
25 # ifdef EXPORT_XDOT
26 # define XDOT_API __declspec(dllexport)
27 # else
28 # define XDOT_API __declspec(dllimport)
29 # endif
30 #else
31 # define XDOT_API extern
32 #endif
33 
34 #define INITIAL_XDOT_CAPACITY 512
35 
36 typedef enum {
41 
42 typedef struct {
43  float frac;
44  char* color;
46 
47 typedef struct {
48  double x0, y0;
49  double x1, y1;
50  int n_stops;
53 
54 typedef struct {
55  double x0, y0, r0;
56  double x1, y1, r1;
57  int n_stops;
60 
61 typedef struct {
63  union {
64  char* clr;
67  } u;
68 } xdot_color;
69 
70 typedef enum {
72 } xdot_align;
73 
74 typedef struct {
75  double x, y, z;
76 } xdot_point;
77 
78 typedef struct {
79  double x, y, w, h;
80 } xdot_rect;
81 
82 typedef struct {
83  int cnt;
86 
87 typedef struct {
88  double x, y;
90  double width;
91  char* text;
92 } xdot_text;
93 
94 typedef struct {
96  char* name;
97 } xdot_image;
98 
99 typedef struct {
100  double size;
101  char* name;
102 } xdot_font;
103 
104 typedef enum {
112 } xdot_kind;
113 
114 typedef enum {
122 } xop_kind;
123 
124 typedef struct _xdot_op xdot_op;
125 typedef void (*drawfunc_t)(xdot_op*, int);
126 typedef void (*freefunc_t)(xdot_op*);
127 
128 struct _xdot_op {
130  union {
131  xdot_rect ellipse; /* xd_filled_ellipse, xd_unfilled_ellipse */
132  xdot_polyline polygon; /* xd_filled_polygon, xd_unfilled_polygon */
133  xdot_polyline polyline; /* xd_polyline */
134  xdot_polyline bezier; /* xd_filled_bezier, xd_unfilled_bezier */
135  xdot_text text; /* xd_text */
136  xdot_image image; /* xd_image */
137  char* color; /* xd_fill_color, xd_pen_color */
138  xdot_color grad_color; /* xd_grad_fill_color, xd_grad_pen_color */
139  xdot_font font; /* xd_font */
140  char* style; /* xd_style */
141  unsigned int fontchar; /* xd_fontchar */
142  } u;
144 };
145 
146 #define XDOT_PARSE_ERROR 1
147 
148 typedef struct {
149  int cnt; /* no. of xdot ops */
150  int sz; /* sizeof structure containing xdot_op as first field */
151  xdot_op* ops;
153  int flags;
154 } xdot;
155 
156 typedef struct {
157  int cnt; /* no. of xdot ops */
163  int n_bezier;
165  int n_text;
166  int n_font;
167  int n_style;
168  int n_color;
169  int n_image;
172 } xdot_stats;
173 
174 /* ops are indexed by xop_kind */
175 XDOT_API xdot* parseXDotF (char*, drawfunc_t opfns[], int sz);
176 XDOT_API xdot* parseXDotFOn (char*, drawfunc_t opfns[], int sz, xdot*);
177 XDOT_API xdot* parseXDot (char*);
178 XDOT_API char* sprintXDot (xdot*);
179 XDOT_API void fprintXDot (FILE*, xdot*);
180 XDOT_API void jsonXDot (FILE*, xdot*);
181 XDOT_API void freeXDot (xdot*);
184 XDOT_API char* parseXDotColor (char* cp, xdot_color* clr);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 #endif
xdot_linear_grad ling
Definition: xdot.h:65
int n_bezier
Definition: xdot.h:163
int n_color
Definition: xdot.h:168
xdot_color grad_color
Definition: xdot.h:138
int n_gradcolor
Definition: xdot.h:170
Definition: xdot.h:38
double y0
Definition: xdot.h:48
union _xdot_op::@54 u
int n_bezier_pts
Definition: xdot.h:164
int statXDot(xdot *x, xdot_stats *sp)
Definition: xdot.c:963
int flags
Definition: xdot.h:153
int n_fontchar
Definition: xdot.h:171
int cnt
Definition: xdot.h:157
Definition: xdot.h:78
double size
Definition: xdot.h:100
char * text
Definition: xdot.h:91
Definition: xdot.h:109
xdot_color_stop * stops
Definition: xdot.h:58
int sz
Definition: xdot.h:150
int n_stops
Definition: xdot.h:50
xdot_polyline bezier
Definition: xdot.h:134
XDOT_API xdot_grad_type colorTypeXDot(char *)
Definition: xdot.h:71
Definition: xdot.h:39
xdot_color_stop * stops
Definition: xdot.h:51
Definition: xdot.h:99
char * name
Definition: xdot.h:101
freefunc_t freefunc
Definition: xdot.h:152
char * color
Definition: xdot.h:44
Definition: xdot.h:108
void(* freefunc_t)(xdot_op *)
Definition: xdot.h:126
Definition: xdot.h:71
Definition: xdot.h:71
int n_font
Definition: xdot.h:166
Definition: xdot.h:128
xdot_grad_type type
Definition: xdot.h:62
xdot_rect ellipse
Definition: xdot.h:131
char * clr
Definition: xdot.h:64
char * sprintXDot(xdot *x)
Definition: xdot.c:881
xdot * parseXDot(char *s)
Definition: xdot.c:496
double y1
Definition: xdot.h:49
xdot_kind kind
Definition: xdot.h:129
Definition: xdot.h:87
Definition: xdot.h:119
double z
Definition: xdot.h:75
int n_ellipse
Definition: xdot.h:158
char * parseXDotColor(char *cp, xdot_color *clr)
Definition: xdot.c:1130
Definition: xdot.h:148
char * style
Definition: xdot.h:140
int
Definition: grammar.c:1264
xdot_image image
Definition: xdot.h:136
Definition: xdot.h:109
char * color
Definition: xdot.h:137
void fprintXDot(FILE *fp, xdot *x)
Definition: xdot.c:894
#define XDOT_API
Definition: xdot.h:31
int n_polygon_pts
Definition: xdot.h:160
int n_style
Definition: xdot.h:167
unsigned int fontchar
Definition: xdot.h:141
int n_stops
Definition: xdot.h:57
xdot_rect pos
Definition: xdot.h:95
double y
Definition: xdot.h:79
double y0
Definition: xdot.h:55
double width
Definition: xdot.h:90
int n_image
Definition: xdot.h:169
int n_polygon
Definition: xdot.h:159
xdot * parseXDotF(char *s, drawfunc_t fns[], int sz)
Definition: xdot.c:491
int cnt
Definition: xdot.h:83
xdot_radial_grad ring
Definition: xdot.h:66
int cnt
Definition: xdot.h:149
xdot_op * ops
Definition: xdot.h:151
xdot_kind
Definition: xdot.h:104
xdot_grad_type
Definition: xdot.h:36
float frac
Definition: xdot.h:43
char * name
Definition: xdot.h:96
void jsonXDot(FILE *fp, xdot *x)
Definition: xdot.c:899
Definition: xdot.h:118
xdot_align
Definition: xdot.h:70
void(* drawfunc_t)(xdot_op *, int)
Definition: xdot.h:125
xdot_point * pts
Definition: xdot.h:84
xop_kind
Definition: xdot.h:114
void freeXDot(xdot *x)
Definition: xdot.c:945
xdot_polyline polygon
Definition: xdot.h:132
xdot_text text
Definition: xdot.h:135
double y
Definition: xdot.h:88
xdot_align align
Definition: xdot.h:89
double y1
Definition: xdot.h:56
Definition: xdot.h:37
int n_polyline_pts
Definition: xdot.h:162
int n_text
Definition: xdot.h:165
drawfunc_t drawfunc
Definition: xdot.h:143
xdot_polyline polyline
Definition: xdot.h:133
int n_polyline
Definition: xdot.h:161
void freeXDotColor(xdot_color *cp)
Definition: xdot.c:1158
xdot * parseXDotFOn(char *s, drawfunc_t fns[], int sz, xdot *x)
Definition: xdot.c:433
Definition: xdot.h:109
xdot_font font
Definition: xdot.h:139