|
Graphviz 2.29.20120208.0545
|
00001 /* $Id$ $Revision$ */ 00002 /* vim:set shiftwidth=4 ts=8: */ 00003 00004 /************************************************************************* 00005 * Copyright (c) 2011 AT&T Intellectual Property 00006 * All rights reserved. This program and the accompanying materials 00007 * are made available under the terms of the Eclipse Public License v1.0 00008 * which accompanies this distribution, and is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * 00011 * Contributors: See CVS logs. Details at http://www.graphviz.org/ 00012 *************************************************************************/ 00013 00014 00015 00016 #ifndef _GRAPH_H 00017 #define _GRAPH_H 1 00018 00019 #if _PACKAGE_ast 00020 #include <ast.h> 00021 #else 00022 #include <sys/types.h> 00023 #include <stdlib.h> 00024 #endif 00025 #include <stdio.h> 00026 #include "cdt.h" 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #define TAIL_ID "tailport" 00033 #define HEAD_ID "headport" 00034 00035 typedef struct Agraph_t Agraph_t; 00036 typedef struct Agnode_t Agnode_t; 00037 typedef struct Agedge_t Agedge_t; 00038 typedef struct Agdict_t Agdict_t; 00039 typedef struct Agsym_t Agsym_t; 00040 typedef struct Agdata_t Agdata_t; 00041 typedef struct Agproto_t Agproto_t; 00042 00043 typedef char *(*gets_f) (char *ubuf, int n, FILE * fp); 00044 00045 #define AGFLAG_DIRECTED (1<<0) 00046 #define AGFLAG_STRICT (1<<1) 00047 #define AGFLAG_METAGRAPH (1<<2) 00048 00049 #define AGRAPH 0 00050 #define AGRAPHSTRICT (AGRAPH | AGFLAG_STRICT) 00051 #define AGDIGRAPH AGFLAG_DIRECTED 00052 #define AGDIGRAPHSTRICT (AGDIGRAPH | AGFLAG_STRICT) 00053 #define AGMETAGRAPH (AGFLAG_DIRECTED | AGFLAG_STRICT | AGFLAG_METAGRAPH) 00054 00055 #define AG_IS_DIRECTED(g) ((g)->kind & AGFLAG_DIRECTED) 00056 #define AG_IS_STRICT(g) ((g)->kind & AGFLAG_STRICT) 00057 #define AG_IS_METAGRAPH(g) ((g)->kind & AGFLAG_METAGRAPH) 00058 #define aginit() aginitlib(sizeof(Agraph_t),sizeof(Agnode_t),sizeof(Agedge_t)) 00059 00060 struct Agraph_t { 00061 int tag:4; 00062 int kind:4; 00063 int handle:24; 00064 char **attr; 00065 char *didset; 00066 char *name; 00067 Agdata_t *univ; 00068 Dict_t *nodes, *inedges, *outedges; 00069 Agraph_t *root; 00070 Agnode_t *meta_node; 00071 Agproto_t *proto; 00072 Agraphinfo_t u; 00073 }; 00074 00075 struct Agnode_t { 00076 int tag:4; 00077 int pad:4; 00078 int handle:24; 00079 char **attr; 00080 char *didset; 00081 char *name; 00082 int id; 00083 Agraph_t *graph; 00084 Agnodeinfo_t u; 00085 }; 00086 00087 struct Agedge_t { 00088 int tag:4; 00089 int printkey:4; 00090 int handle:24; 00091 char **attr; 00092 char *didset; 00093 Agnode_t *head, *tail; 00094 int id; 00095 Agedgeinfo_t u; 00096 }; 00097 00098 struct Agdata_t { /* for main graph */ 00099 Dict_t *node_dict; 00100 Agdict_t *nodeattr; 00101 Agdict_t *edgeattr; 00102 Agdict_t *globattr; 00103 int max_node_id, max_edge_id; 00104 }; 00105 00106 struct Agsym_t { 00107 char *name, *value; 00108 int index; 00109 unsigned char printed; 00110 unsigned char fixed; 00111 }; 00112 00113 struct Agdict_t { 00114 char *name; 00115 Dict_t *dict; 00116 Agsym_t **list; 00117 }; 00118 00119 struct Agproto_t { 00120 Agnode_t *n; 00121 Agedge_t *e; 00122 Agproto_t *prev; 00123 }; 00124 00125 #if _PACKAGE_ast 00126 _BEGIN_EXTERNS_ /* public data */ 00127 #if _BLD_graph && defined(__EXPORT__) 00128 #define extern __EXPORT__ 00129 #endif 00130 #if !_BLD_graph && defined(__IMPORT__) && 0 00131 #define extern __IMPORT__ 00132 #endif 00133 #endif 00134 /*visual studio*/ 00135 #ifdef WIN32_DLL 00136 #ifndef GRAPH_EXPORTS 00137 #define extern __declspec(dllimport) 00138 #else 00139 #define extern __declspec(dllexport) 00140 #endif 00141 00142 #endif 00143 /*end visual studio*/ 00144 extern char *agstrcanon(char *, char *); 00145 extern char *agcanonical(char *); 00146 extern char *agcanon(char *); 00147 extern int aghtmlstr(char *s); 00148 extern char *agget(void *, char *); 00149 extern char *agxget(void *, int); 00150 extern int agset(void *, char *, char *); 00151 extern int agsafeset(void *, char *, char *, char*); 00152 extern int agxset(void *, int, char *); 00153 extern int agindex(void *, char *); 00154 00155 extern int aginitlib(int, int, int); 00156 extern Agraph_t *agopen(char *, int); 00157 extern Agraph_t *agsubg(Agraph_t *, char *); 00158 extern Agraph_t *agfindsubg(Agraph_t *, char *); 00159 extern void agclose(Agraph_t *); 00160 extern Agraph_t *agread(FILE *); 00161 extern Agraph_t *agread_usergets(FILE *, gets_f); 00162 extern void agreadline(int); 00163 extern void agsetfile(char *); 00164 extern Agraph_t *agmemread(char *); 00165 extern void agsetiodisc( 00166 char * (*myfgets) (char *s, int size, FILE *stream), 00167 size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream), 00168 int (*myferror) (FILE *stream) ); 00169 extern int agputs(const char *s, FILE *fp); 00170 extern int agputc(int c, FILE *fp); 00171 extern int agwrite(Agraph_t *, FILE *); 00172 extern int agerrors(void); 00173 extern int agreseterrors(void); 00174 extern Agraph_t *agprotograph(void); 00175 extern Agnode_t *agprotonode(Agraph_t *); 00176 extern Agedge_t *agprotoedge(Agraph_t *); 00177 extern Agraph_t *agusergraph(Agnode_t *); 00178 extern int agnnodes(Agraph_t *); 00179 extern int agnedges(Agraph_t *); 00180 00181 extern void aginsert(Agraph_t *, void *); 00182 extern void agdelete(Agraph_t *, void *); 00183 extern int agcontains(Agraph_t *, void *); 00184 00185 extern Agnode_t *agnode(Agraph_t *, char *); 00186 extern Agnode_t *agfindnode(Agraph_t *, char *); 00187 extern Agnode_t *agfstnode(Agraph_t *); 00188 extern Agnode_t *agnxtnode(Agraph_t *, Agnode_t *); 00189 extern Agnode_t *aglstnode(Agraph_t *); 00190 extern Agnode_t *agprvnode(Agraph_t *, Agnode_t *); 00191 00192 extern Agedge_t *agedge(Agraph_t *, Agnode_t *, Agnode_t *); 00193 extern Agedge_t *agfindedge(Agraph_t *, Agnode_t *, Agnode_t *); 00194 extern Agedge_t *agfstedge(Agraph_t *, Agnode_t *); 00195 extern Agedge_t *agnxtedge(Agraph_t *, Agedge_t *, Agnode_t *); 00196 extern Agedge_t *agfstin(Agraph_t *, Agnode_t *); 00197 extern Agedge_t *agnxtin(Agraph_t *, Agedge_t *); 00198 extern Agedge_t *agfstout(Agraph_t *, Agnode_t *); 00199 extern Agedge_t *agnxtout(Agraph_t *, Agedge_t *); 00200 00201 extern Agsym_t *agattr(void *, char *, char *); 00202 extern Agsym_t *agraphattr(Agraph_t *, char *, char *); 00203 extern Agsym_t *agnodeattr(Agraph_t *, char *, char *); 00204 extern Agsym_t *agedgeattr(Agraph_t *, char *, char *); 00205 extern Agsym_t *agfindattr(void *, char *); 00206 extern Agsym_t *agfstattr(void *); 00207 extern Agsym_t *agnxtattr(void *, Agsym_t *); 00208 extern Agsym_t *aglstattr(void *); 00209 extern Agsym_t *agprvattr(void *, Agsym_t *); 00210 extern int agcopyattr(void *, void *); 00211 00212 typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t; 00213 typedef int (*agusererrf) (char*); 00214 extern agerrlevel_t agerrno; 00215 extern void agseterr(agerrlevel_t); 00216 extern char *aglasterr(void); 00217 extern int agerr(agerrlevel_t level, char *fmt, ...); 00218 extern void agerrorf(const char *fmt, ...); 00219 extern void agwarningf(char *fmt, ...); 00220 extern agusererrf agseterrf(agusererrf); 00221 00222 extern char *agstrdup(char *); 00223 extern char *agstrdup_html(char *s); 00224 extern void agstrfree(char *); 00225 00226 typedef enum { AGNODE = 1, AGEDGE, AGGRAPH } agobjkind_t; 00227 #define agobjkind(p) ((agobjkind_t)(((Agraph_t*)(p))->tag)) 00228 00229 #define agmetanode(g) ((g)->meta_node) 00230 00231 #undef extern 00232 #if _PACKAGE_ast 00233 _END_EXTERNS_ 00234 #endif 00235 #ifdef __cplusplus 00236 } 00237 #endif 00238 #endif /* _GRAPH_H */
1.7.4