File indexing completed on 2025-12-16 10:18:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #pragma once
0023
0024 #include <stddef.h>
0025 #include <stdio.h>
0026
0027 #ifdef __cplusplus
0028 extern "C" {
0029 #endif
0030
0031 #ifdef GVDLL
0032 #ifdef EXPORT_XDOT
0033 #define XDOT_API __declspec(dllexport)
0034 #else
0035 #define XDOT_API __declspec(dllimport)
0036 #endif
0037 #endif
0038
0039 #ifndef XDOT_API
0040 #define XDOT_API
0041 #endif
0042
0043 typedef enum {
0044 xd_none,
0045 xd_linear,
0046 xd_radial
0047 } xdot_grad_type;
0048
0049 typedef struct {
0050 float frac;
0051 char* color;
0052 } xdot_color_stop;
0053
0054 typedef struct {
0055 double x0, y0;
0056 double x1, y1;
0057 int n_stops;
0058 xdot_color_stop* stops;
0059 } xdot_linear_grad;
0060
0061 typedef struct {
0062 double x0, y0, r0;
0063 double x1, y1, r1;
0064 int n_stops;
0065 xdot_color_stop* stops;
0066 } xdot_radial_grad;
0067
0068 typedef struct {
0069 xdot_grad_type type;
0070 union {
0071 char* clr;
0072 xdot_linear_grad ling;
0073 xdot_radial_grad ring;
0074 } u;
0075 } xdot_color;
0076
0077 typedef enum {
0078 xd_left, xd_center, xd_right
0079 } xdot_align;
0080
0081 typedef struct {
0082 double x, y, z;
0083 } xdot_point;
0084
0085 typedef struct {
0086 double x, y, w, h;
0087 } xdot_rect;
0088
0089 typedef struct {
0090 size_t cnt;
0091 xdot_point* pts;
0092 } xdot_polyline;
0093
0094 typedef struct {
0095 double x, y;
0096 xdot_align align;
0097 double width;
0098 char* text;
0099 } xdot_text;
0100
0101 typedef struct {
0102 xdot_rect pos;
0103 char* name;
0104 } xdot_image;
0105
0106 typedef struct {
0107 double size;
0108 char* name;
0109 } xdot_font;
0110
0111 typedef enum {
0112 xd_filled_ellipse, xd_unfilled_ellipse,
0113 xd_filled_polygon, xd_unfilled_polygon,
0114 xd_filled_bezier, xd_unfilled_bezier,
0115 xd_polyline, xd_text,
0116 xd_fill_color, xd_pen_color, xd_font, xd_style, xd_image,
0117 xd_grad_fill_color, xd_grad_pen_color,
0118 xd_fontchar
0119 } xdot_kind;
0120
0121 typedef enum {
0122 xop_ellipse,
0123 xop_polygon,
0124 xop_bezier,
0125 xop_polyline, xop_text,
0126 xop_fill_color, xop_pen_color, xop_font, xop_style, xop_image,
0127 xop_grad_color,
0128 xop_fontchar
0129 } xop_kind;
0130
0131 typedef struct _xdot_op xdot_op;
0132 typedef void (*drawfunc_t)(xdot_op*, int);
0133 typedef void (*freefunc_t)(xdot_op*);
0134
0135 struct _xdot_op {
0136 xdot_kind kind;
0137 union {
0138 xdot_rect ellipse;
0139 xdot_polyline polygon;
0140 xdot_polyline polyline;
0141 xdot_polyline bezier;
0142 xdot_text text;
0143 xdot_image image;
0144 char* color;
0145 xdot_color grad_color;
0146 xdot_font font;
0147 char* style;
0148 unsigned int fontchar;
0149 } u;
0150 drawfunc_t drawfunc;
0151 };
0152
0153 #define XDOT_PARSE_ERROR 1
0154
0155 typedef struct {
0156 size_t cnt;
0157 size_t sz;
0158 xdot_op* ops;
0159 freefunc_t freefunc;
0160 int flags;
0161 } xdot;
0162
0163 typedef struct {
0164 size_t cnt;
0165 size_t n_ellipse;
0166 size_t n_polygon;
0167 size_t n_polygon_pts;
0168 size_t n_polyline;
0169 size_t n_polyline_pts;
0170 size_t n_bezier;
0171 size_t n_bezier_pts;
0172 size_t n_text;
0173 size_t n_font;
0174 size_t n_style;
0175 size_t n_color;
0176 size_t n_image;
0177 size_t n_gradcolor;
0178 size_t n_fontchar;
0179 } xdot_stats;
0180
0181
0182 XDOT_API xdot *parseXDotF(char*, drawfunc_t opfns[], size_t sz);
0183 XDOT_API xdot *parseXDotFOn(char*, drawfunc_t opfns[], size_t sz, xdot*);
0184 XDOT_API xdot* parseXDot (char*);
0185 XDOT_API char* sprintXDot (xdot*);
0186 XDOT_API void fprintXDot (FILE*, xdot*);
0187 XDOT_API void jsonXDot (FILE*, xdot*);
0188 XDOT_API void freeXDot (xdot*);
0189 XDOT_API int statXDot (xdot*, xdot_stats*);
0190 XDOT_API xdot_grad_type colorTypeXDot (char*);
0191 XDOT_API char* parseXDotColor (char* cp, xdot_color* clr);
0192 XDOT_API void freeXDotColor (xdot_color*);
0193
0194 #ifdef __cplusplus
0195 }
0196 #endif