wolffd@0
|
1 /* $Id: graph.h,v 1.20 2009/06/03 01:10:53 ellson Exp $ $Revision: 1.20 $ */
|
wolffd@0
|
2 /* vim:set shiftwidth=4 ts=8: */
|
wolffd@0
|
3
|
wolffd@0
|
4 /**********************************************************
|
wolffd@0
|
5 * This software is part of the graphviz package *
|
wolffd@0
|
6 * http://www.graphviz.org/ *
|
wolffd@0
|
7 * *
|
wolffd@0
|
8 * Copyright (c) 1994-2004 AT&T Corp. *
|
wolffd@0
|
9 * and is licensed under the *
|
wolffd@0
|
10 * Common Public License, Version 1.0 *
|
wolffd@0
|
11 * by AT&T Corp. *
|
wolffd@0
|
12 * *
|
wolffd@0
|
13 * Information and Software Systems Research *
|
wolffd@0
|
14 * AT&T Research, Florham Park NJ *
|
wolffd@0
|
15 **********************************************************/
|
wolffd@0
|
16
|
wolffd@0
|
17
|
wolffd@0
|
18
|
wolffd@0
|
19 #ifndef _GRAPH_H
|
wolffd@0
|
20 #define _GRAPH_H 1
|
wolffd@0
|
21
|
wolffd@0
|
22 #if _PACKAGE_ast
|
wolffd@0
|
23 #include <ast.h>
|
wolffd@0
|
24 #else
|
wolffd@0
|
25 #include <sys/types.h>
|
wolffd@0
|
26 #include <stdlib.h>
|
wolffd@0
|
27 #endif
|
wolffd@0
|
28 #include <stdio.h>
|
wolffd@0
|
29 #include "cdt.h"
|
wolffd@0
|
30
|
wolffd@0
|
31 #ifdef __cplusplus
|
wolffd@0
|
32 extern "C" {
|
wolffd@0
|
33 #endif
|
wolffd@0
|
34
|
wolffd@0
|
35 #define TAIL_ID "tailport"
|
wolffd@0
|
36 #define HEAD_ID "headport"
|
wolffd@0
|
37
|
wolffd@0
|
38 typedef struct Agraph_t Agraph_t;
|
wolffd@0
|
39 typedef struct Agnode_t Agnode_t;
|
wolffd@0
|
40 typedef struct Agedge_t Agedge_t;
|
wolffd@0
|
41 typedef struct Agdict_t Agdict_t;
|
wolffd@0
|
42 typedef struct Agsym_t Agsym_t;
|
wolffd@0
|
43 typedef struct Agdata_t Agdata_t;
|
wolffd@0
|
44 typedef struct Agproto_t Agproto_t;
|
wolffd@0
|
45
|
wolffd@0
|
46 typedef char *(*gets_f) (char *ubuf, int n, FILE * fp);
|
wolffd@0
|
47
|
wolffd@0
|
48 #define AGFLAG_DIRECTED (1<<0)
|
wolffd@0
|
49 #define AGFLAG_STRICT (1<<1)
|
wolffd@0
|
50 #define AGFLAG_METAGRAPH (1<<2)
|
wolffd@0
|
51
|
wolffd@0
|
52 #define AGRAPH 0
|
wolffd@0
|
53 #define AGRAPHSTRICT (AGRAPH | AGFLAG_STRICT)
|
wolffd@0
|
54 #define AGDIGRAPH AGFLAG_DIRECTED
|
wolffd@0
|
55 #define AGDIGRAPHSTRICT (AGDIGRAPH | AGFLAG_STRICT)
|
wolffd@0
|
56 #define AGMETAGRAPH (AGFLAG_DIRECTED | AGFLAG_STRICT | AGFLAG_METAGRAPH)
|
wolffd@0
|
57
|
wolffd@0
|
58 #define AG_IS_DIRECTED(g) ((g)->kind & AGFLAG_DIRECTED)
|
wolffd@0
|
59 #define AG_IS_STRICT(g) ((g)->kind & AGFLAG_STRICT)
|
wolffd@0
|
60 #define AG_IS_METAGRAPH(g) ((g)->kind & AGFLAG_METAGRAPH)
|
wolffd@0
|
61 #define aginit() aginitlib(sizeof(Agraph_t),sizeof(Agnode_t),sizeof(Agedge_t))
|
wolffd@0
|
62
|
wolffd@0
|
63 struct Agraph_t {
|
wolffd@0
|
64 int tag:4;
|
wolffd@0
|
65 int kind:4;
|
wolffd@0
|
66 int handle:24;
|
wolffd@0
|
67 char **attr;
|
wolffd@0
|
68 char *didset;
|
wolffd@0
|
69 char *name;
|
wolffd@0
|
70 Agdata_t *univ;
|
wolffd@0
|
71 Dict_t *nodes, *inedges, *outedges;
|
wolffd@0
|
72 Agraph_t *root;
|
wolffd@0
|
73 Agnode_t *meta_node;
|
wolffd@0
|
74 Agproto_t *proto;
|
wolffd@0
|
75 Agraphinfo_t u;
|
wolffd@0
|
76 };
|
wolffd@0
|
77
|
wolffd@0
|
78 struct Agnode_t {
|
wolffd@0
|
79 int tag:4;
|
wolffd@0
|
80 int pad:4;
|
wolffd@0
|
81 int handle:24;
|
wolffd@0
|
82 char **attr;
|
wolffd@0
|
83 char *didset;
|
wolffd@0
|
84 char *name;
|
wolffd@0
|
85 int id;
|
wolffd@0
|
86 Agraph_t *graph;
|
wolffd@0
|
87 Agnodeinfo_t u;
|
wolffd@0
|
88 };
|
wolffd@0
|
89
|
wolffd@0
|
90 struct Agedge_t {
|
wolffd@0
|
91 int tag:4;
|
wolffd@0
|
92 int printkey:4;
|
wolffd@0
|
93 int handle:24;
|
wolffd@0
|
94 char **attr;
|
wolffd@0
|
95 char *didset;
|
wolffd@0
|
96 Agnode_t *head, *tail;
|
wolffd@0
|
97 int id;
|
wolffd@0
|
98 Agedgeinfo_t u;
|
wolffd@0
|
99 };
|
wolffd@0
|
100
|
wolffd@0
|
101 struct Agdata_t { /* for main graph */
|
wolffd@0
|
102 Dict_t *node_dict;
|
wolffd@0
|
103 Agdict_t *nodeattr;
|
wolffd@0
|
104 Agdict_t *edgeattr;
|
wolffd@0
|
105 Agdict_t *globattr;
|
wolffd@0
|
106 int max_node_id, max_edge_id;
|
wolffd@0
|
107 };
|
wolffd@0
|
108
|
wolffd@0
|
109 struct Agsym_t {
|
wolffd@0
|
110 char *name, *value;
|
wolffd@0
|
111 int index;
|
wolffd@0
|
112 unsigned char printed;
|
wolffd@0
|
113 unsigned char fixed;
|
wolffd@0
|
114 };
|
wolffd@0
|
115
|
wolffd@0
|
116 struct Agdict_t {
|
wolffd@0
|
117 char *name;
|
wolffd@0
|
118 Dict_t *dict;
|
wolffd@0
|
119 Agsym_t **list;
|
wolffd@0
|
120 };
|
wolffd@0
|
121
|
wolffd@0
|
122 struct Agproto_t {
|
wolffd@0
|
123 Agnode_t *n;
|
wolffd@0
|
124 Agedge_t *e;
|
wolffd@0
|
125 Agproto_t *prev;
|
wolffd@0
|
126 };
|
wolffd@0
|
127
|
wolffd@0
|
128 #if _PACKAGE_ast
|
wolffd@0
|
129 _BEGIN_EXTERNS_ /* public data */
|
wolffd@0
|
130 #if _BLD_graph && defined(__EXPORT__)
|
wolffd@0
|
131 #define extern __EXPORT__
|
wolffd@0
|
132 #endif
|
wolffd@0
|
133 #if !_BLD_graph && defined(__IMPORT__) && 0
|
wolffd@0
|
134 #define extern __IMPORT__
|
wolffd@0
|
135 #endif
|
wolffd@0
|
136 #endif
|
wolffd@0
|
137
|
wolffd@0
|
138 /*visual studio*/
|
wolffd@0
|
139 #ifdef WIN32_DLL
|
wolffd@0
|
140 #ifndef GRAPH_EXPORTS
|
wolffd@0
|
141 #define extern __declspec(dllimport)
|
wolffd@0
|
142 #endif
|
wolffd@0
|
143 #endif
|
wolffd@0
|
144 /*end visual studio*/
|
wolffd@0
|
145 extern char *agstrcanon(char *, char *);
|
wolffd@0
|
146 extern char *agcanonical(char *);
|
wolffd@0
|
147 extern char *agcanon(char *);
|
wolffd@0
|
148 extern int aghtmlstr(char *s);
|
wolffd@0
|
149 extern char *agget(void *, char *);
|
wolffd@0
|
150 extern char *agxget(void *, int);
|
wolffd@0
|
151 extern int agset(void *, char *, char *);
|
wolffd@0
|
152 extern int agsafeset(void *, char *, char *, char*);
|
wolffd@0
|
153 extern int agxset(void *, int, char *);
|
wolffd@0
|
154 extern int agindex(void *, char *);
|
wolffd@0
|
155
|
wolffd@0
|
156 extern void aginitlib(int, int, int);
|
wolffd@0
|
157 extern Agraph_t *agopen(char *, int);
|
wolffd@0
|
158 extern Agraph_t *agsubg(Agraph_t *, char *);
|
wolffd@0
|
159 extern Agraph_t *agfindsubg(Agraph_t *, char *);
|
wolffd@0
|
160 extern void agclose(Agraph_t *);
|
wolffd@0
|
161 extern Agraph_t *agread(FILE *);
|
wolffd@0
|
162 extern Agraph_t *agread_usergets(FILE *, gets_f);
|
wolffd@0
|
163 extern void agreadline(int);
|
wolffd@0
|
164 extern void agsetfile(char *);
|
wolffd@0
|
165 extern Agraph_t *agmemread(char *);
|
wolffd@0
|
166 extern void agsetiodisc(
|
wolffd@0
|
167 char * (*myfgets) (char *s, int size, FILE *stream),
|
wolffd@0
|
168 size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream),
|
wolffd@0
|
169 int (*myferror) (FILE *stream) );
|
wolffd@0
|
170 extern int agputs(const char *s, FILE *fp);
|
wolffd@0
|
171 extern int agputc(int c, FILE *fp);
|
wolffd@0
|
172 extern int agwrite(Agraph_t *, FILE *);
|
wolffd@0
|
173 extern int agerrors(void);
|
wolffd@0
|
174 extern Agraph_t *agprotograph(void);
|
wolffd@0
|
175 extern Agnode_t *agprotonode(Agraph_t *);
|
wolffd@0
|
176 extern Agedge_t *agprotoedge(Agraph_t *);
|
wolffd@0
|
177 extern Agraph_t *agusergraph(Agnode_t *);
|
wolffd@0
|
178 extern int agnnodes(Agraph_t *);
|
wolffd@0
|
179 extern int agnedges(Agraph_t *);
|
wolffd@0
|
180
|
wolffd@0
|
181 extern void aginsert(Agraph_t *, void *);
|
wolffd@0
|
182 extern void agdelete(Agraph_t *, void *);
|
wolffd@0
|
183 extern int agcontains(Agraph_t *, void *);
|
wolffd@0
|
184
|
wolffd@0
|
185 extern Agnode_t *agnode(Agraph_t *, char *);
|
wolffd@0
|
186 extern Agnode_t *agfindnode(Agraph_t *, char *);
|
wolffd@0
|
187 extern Agnode_t *agfstnode(Agraph_t *);
|
wolffd@0
|
188 extern Agnode_t *agnxtnode(Agraph_t *, Agnode_t *);
|
wolffd@0
|
189 extern Agnode_t *aglstnode(Agraph_t *);
|
wolffd@0
|
190 extern Agnode_t *agprvnode(Agraph_t *, Agnode_t *);
|
wolffd@0
|
191
|
wolffd@0
|
192 extern Agedge_t *agedge(Agraph_t *, Agnode_t *, Agnode_t *);
|
wolffd@0
|
193 extern Agedge_t *agfindedge(Agraph_t *, Agnode_t *, Agnode_t *);
|
wolffd@0
|
194 extern Agedge_t *agfstedge(Agraph_t *, Agnode_t *);
|
wolffd@0
|
195 extern Agedge_t *agnxtedge(Agraph_t *, Agedge_t *, Agnode_t *);
|
wolffd@0
|
196 extern Agedge_t *agfstin(Agraph_t *, Agnode_t *);
|
wolffd@0
|
197 extern Agedge_t *agnxtin(Agraph_t *, Agedge_t *);
|
wolffd@0
|
198 extern Agedge_t *agfstout(Agraph_t *, Agnode_t *);
|
wolffd@0
|
199 extern Agedge_t *agnxtout(Agraph_t *, Agedge_t *);
|
wolffd@0
|
200
|
wolffd@0
|
201 extern Agsym_t *agattr(void *, char *, char *);
|
wolffd@0
|
202 extern Agsym_t *agraphattr(Agraph_t *, char *, char *);
|
wolffd@0
|
203 extern Agsym_t *agnodeattr(Agraph_t *, char *, char *);
|
wolffd@0
|
204 extern Agsym_t *agedgeattr(Agraph_t *, char *, char *);
|
wolffd@0
|
205 extern Agsym_t *agfindattr(void *, char *);
|
wolffd@0
|
206 extern Agsym_t *agfstattr(void *);
|
wolffd@0
|
207 extern Agsym_t *agnxtattr(void *, Agsym_t *);
|
wolffd@0
|
208 extern Agsym_t *aglstattr(void *);
|
wolffd@0
|
209 extern Agsym_t *agprvattr(void *, Agsym_t *);
|
wolffd@0
|
210 extern int agcopyattr(void *, void *);
|
wolffd@0
|
211
|
wolffd@0
|
212 typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t;
|
wolffd@0
|
213 extern agerrlevel_t agerrno;
|
wolffd@0
|
214 extern void agseterr(agerrlevel_t);
|
wolffd@0
|
215 extern char *aglasterr(void);
|
wolffd@0
|
216 extern int agerr(agerrlevel_t level, char *fmt, ...);
|
wolffd@0
|
217 extern void agerrorf(const char *fmt, ...);
|
wolffd@0
|
218 extern void agwarningf(char *fmt, ...);
|
wolffd@0
|
219
|
wolffd@0
|
220 extern char *agstrdup(char *);
|
wolffd@0
|
221 extern char *agstrdup_html(char *s);
|
wolffd@0
|
222 extern void agstrfree(char *);
|
wolffd@0
|
223
|
wolffd@0
|
224 typedef enum { AGNODE = 1, AGEDGE, AGGRAPH } agobjkind_t;
|
wolffd@0
|
225 #define agobjkind(p) ((agobjkind_t)(((Agraph_t*)(p))->tag))
|
wolffd@0
|
226
|
wolffd@0
|
227 #define agmetanode(g) ((g)->meta_node)
|
wolffd@0
|
228
|
wolffd@0
|
229 #undef extern
|
wolffd@0
|
230 #if _PACKAGE_ast
|
wolffd@0
|
231 _END_EXTERNS_
|
wolffd@0
|
232 #endif
|
wolffd@0
|
233 #ifdef __cplusplus
|
wolffd@0
|
234 }
|
wolffd@0
|
235 #endif
|
wolffd@0
|
236 #endif /* _GRAPH_H */
|