Graphviz  2.41.20170921.2350
cghdr.h
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #ifndef ATT_GRAPHPVT_H
15 #define ATT_GRAPHPVT_H 1
16 #define _BLD_cgraph 1
17 
18 #ifndef EXTERN
19 #define EXTERN extern
20 #endif
21 
22 #ifdef _WIN32
23 # ifdef EXPORT_CGHDR
24 # define CGHDR_API __declspec(dllexport)
25 # else
26 # define CGHDR_API __declspec(dllimport)
27 # endif
28 #else
29 # define CGHDR_API extern
30 #endif
31 
32 #include "config.h"
33 
34 #include <cgraph.h>
35 
36 #include <ctype.h>
37 #include <sys/types.h>
38 #include <stdarg.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif /* HAVE_UNISTD_H */
44 #ifdef DEBUG
45 #include <assert.h>
46 #else
47 #define assert(x)
48 #endif
49 #include <stdint.h>
50 
51 #ifndef streq
52 #define streq(s,t) ((*s == *t) && !strcmp((s),(t)))
53 #endif
54 #define NOTUSED(var) (void) var
55 
56 #define NILgraph NIL(Agraph_t*)
57 #define NILnode NIL(Agnode_t*)
58 #define NILedge NIL(Agedge_t*)
59 #define NILsym NIL(Agsym_t*)
60 #define NILstr NIL(char*)
61 
62 #define SUCCESS 0
63 #define FAILURE -1
64 #define LOCALNAMEPREFIX '%'
65 
66 #define AGDISC(g,d) ((g)->clos->disc.d)
67 #define AGCLOS(g,d) ((g)->clos->state.d)
68 #define AGNEW(g,t) ((t*)(agalloc(g,sizeof(t))))
69 
70 #define ISALNUM(c) ((isalnum(c)) || ((c) == '_') || (!isascii(c)))
71 
72  /* functional definitions */
73 typedef Agobj_t *(*agobjsearchfn_t) (Agraph_t * g, Agobj_t * obj);
74 CGHDR_API int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
75  int preorder);
76 
77  /* global variables */
79 extern char *AgDataRecName;
80 
81  /* set ordering disciplines */
89 extern Agcbdisc_t AgAttrdisc;
90 
91  /* internal constructor of graphs and subgraphs */
93 int agstrclose(Agraph_t * g);
94 
95  /* ref string management */
96 void agmarkhtmlstr(char *s);
97 
98  /* object set management */
101 int agedgecmpf(Dict_t * d, void *arg_e0, void *arg_e1, Dtdisc_t * disc);
102 int agnamecmpf(Dict_t * d, void *, void *, Dtdisc_t * disc);
103 void agset_node_disc(Agraph_t * g, Dtdisc_t * disc);
104 uint64_t agnextseq(Agraph_t * g, int objtype);
105 
106 /* dict helper functions */
107 Dict_t *agdtopen(Agraph_t * g, Dtdisc_t * disc, Dtmethod_t * method);
108 void agdtdisc(Agraph_t * g, Dict_t * dict, Dtdisc_t * disc);
109 long agdtdelete(Agraph_t * g, Dict_t * dict, void *obj);
110 int agdtclose(Agraph_t * g, Dict_t * dict);
111 void *agdictobjmem(Dict_t * dict, void * p, size_t size,
112  Dtdisc_t * disc);
113 void agdictobjfree(Dict_t * dict, void * p, Dtdisc_t * disc);
114 
115  /* name-value pair operations */
116 CGHDR_API Agdatadict_t *agdatadict(Agraph_t * g, int cflag);
117 CGHDR_API Agattr_t *agattrrec(void *obj);
118 
119 void agraphattr_init(Agraph_t * g);
120 int agraphattr_delete(Agraph_t * g);
121 void agnodeattr_init(Agraph_t *g, Agnode_t * n);
122 void agnodeattr_delete(Agnode_t * n);
123 void agedgeattr_init(Agraph_t *g, Agedge_t * e);
124 void agedgeattr_delete(Agedge_t * e);
125 
126  /* parsing and lexing graph files */
127 int aagparse(void);
128 void aglexinit(Agdisc_t * disc, void *ifile);
129 int aaglex(void);
130 void aglexeof(void);
131 void aglexbad(void);
132 
133  /* ID management */
134 int agmapnametoid(Agraph_t * g, int objtype, char *str,
135  IDTYPE *result, int allocflag);
136 int agallocid(Agraph_t * g, int objtype, IDTYPE request);
137 void agfreeid(Agraph_t * g, int objtype, IDTYPE id);
138 char *agprintid(Agobj_t * obj);
139 int aginternalmaplookup(Agraph_t * g, int objtype, char *str,
140  IDTYPE *result);
141 void aginternalmapinsert(Agraph_t * g, int objtype, char *str,
142  IDTYPE result);
143 char *aginternalmapprint(Agraph_t * g, int objtype, IDTYPE id);
144 int aginternalmapdelete(Agraph_t * g, int objtype, IDTYPE id);
145 void aginternalmapclose(Agraph_t * g);
146 void agregister(Agraph_t * g, int objtype, void *obj);
147 
148  /* internal set operations */
149 void agedgesetop(Agraph_t * g, Agedge_t * e, int insertion);
150 void agdelnodeimage(Agraph_t * g, Agnode_t * node, void *ignored);
151 void agdeledgeimage(Agraph_t * g, Agedge_t * edge, void *ignored);
152 void *agrebind0(Agraph_t * g, void *obj); /* unsafe */
153 CGHDR_API int agrename(Agobj_t * obj, char *newname);
154 void agrecclose(Agobj_t * obj);
155 
156 void agmethod_init(Agraph_t * g, void *obj);
157 void agmethod_upd(Agraph_t * g, void *obj, Agsym_t * sym);
158 void agmethod_delete(Agraph_t * g, void *obj);
159 
160 #define CB_INITIALIZE 100
161 #define CB_UPDATE 101
162 #define CB_DELETION 102
163 void agsyspushdisc(Agraph_t * g, Agcbdisc_t * cb, void *state, int stack);
164 int agsyspopdisc(Agraph_t * g, Agcbdisc_t * cb, int stack);
165 void agrecord_callback(Agraph_t * g, Agobj_t * obj, int kind,
166  Agsym_t * optsym);
167 void aginitcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
168 void agupdcb(Agraph_t * g, void *obj, Agsym_t * sym, Agcbstack_t * disc);
169 void agdelcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
170 
171 #endif /* ATT_GRAPHPVT_H */
void agnodeattr_init(Agraph_t *g, Agnode_t *n)
Definition: attr.c:390
void aginternalmapinsert(Agraph_t *g, int objtype, char *str, IDTYPE result)
Definition: imap.c:118
int(* Dtcompar_f)(Dt_t *, void *, void *, Dtdisc_t *)
Definition: cdt.h:40
void agdtdisc(Agraph_t *g, Dict_t *dict, Dtdisc_t *disc)
Definition: utils.c:95
void agdelcb(Agraph_t *g, void *obj, Agcbstack_t *disc)
Definition: obj.c:146
void agraphattr_init(Agraph_t *g)
Definition: attr.c:357
void agmarkhtmlstr(char *s)
Definition: refstr.c:188
int agdtclose(Agraph_t *g, Dict_t *dict)
Definition: utils.c:79
Dtdisc_t Ag_mainedge_seq_disc
Definition: edge.c:447
void agrecclose(Agobj_t *obj)
Definition: rec.c:263
Dtdisc_t Ag_subgraph_id_disc
Definition: graph.c:262
int agmapnametoid(Agraph_t *g, int objtype, char *str, IDTYPE *result, int allocflag)
Definition: id.c:96
Dtdisc_t Ag_subedge_id_disc
Definition: edge.c:484
Agraph_t * agopen1(Agraph_t *g)
Definition: graph.c:69
void agregister(Agraph_t *g, int objtype, void *obj)
Definition: id.c:169
Definition: cdt.h:80
void aglexinit(Agdisc_t *disc, void *ifile)
Definition: scan.c:579
Dtdisc_t Ag_subnode_seq_disc
Definition: node.c:326
Dtcompar_f agdictorder(Agraph_t *, Dict_t *, Dtcompar_f)
int agstrclose(Agraph_t *g)
Definition: refstr.c:69
#define CGHDR_API
Definition: cghdr.h:29
int aagparse(void)
Dtdisc_t Ag_subnode_id_disc
Definition: node.c:314
void agsyspushdisc(Agraph_t *g, Agcbdisc_t *cb, void *state, int stack)
int aaglex(void)
uint64_t agnextseq(Agraph_t *g, int objtype)
Definition: graph.c:157
Dtdisc_t Ag_mainedge_id_disc
Definition: edge.c:472
Agdatadict_t * agdatadict(Agraph_t *g, int cflag)
Definition: attr.c:41
void agedgeattr_init(Agraph_t *g, Agedge_t *e)
Definition: attr.c:409
void agrecord_callback(Agraph_t *g, Agobj_t *obj, int kind, Agsym_t *optsym)
Definition: pend.c:193
void aginitcb(Agraph_t *g, void *obj, Agcbstack_t *disc)
Definition: obj.c:84
char * aginternalmapprint(Agraph_t *g, int objtype, IDTYPE id)
Definition: imap.c:155
uint64_t IDTYPE
Definition: cgraph.h:51
int agnamecmpf(Dict_t *d, void *, void *, Dtdisc_t *disc)
void agedgeattr_delete(Agedge_t *e)
Definition: attr.c:418
char * agprintid(Agobj_t *obj)
long agdtdelete(Agraph_t *g, Dict_t *dict, void *obj)
Definition: utils.c:67
void agdelnodeimage(Agraph_t *g, Agnode_t *node, void *ignored)
Definition: node.c:174
void agupdcb(Agraph_t *g, void *obj, Agsym_t *sym, Agcbstack_t *disc)
Definition: obj.c:115
void agdeledgeimage(Agraph_t *g, Agedge_t *edge, void *ignored)
Definition: edge.c:327
int aginternalmaplookup(Agraph_t *g, int objtype, char *str, IDTYPE *result)
Definition: imap.c:95
void aginternalmapclose(Agraph_t *g)
Definition: imap.c:214
EXTERN Agraph_t * Ag_G_global
Definition: cghdr.h:78
void agmethod_delete(Agraph_t *g, void *obj)
Definition: obj.c:138
void agfreeid(Agraph_t *g, int objtype, IDTYPE id)
Definition: id.c:131
int aginternalmapdelete(Agraph_t *g, int objtype, IDTYPE id)
Definition: imap.c:165
Definition: grammar.c:79
Dtdisc_t Ag_subedge_seq_disc
Definition: edge.c:459
void agmethod_init(Agraph_t *g, void *obj)
Definition: obj.c:76
void * agrebind0(Agraph_t *g, void *obj)
void agedgesetop(Agraph_t *g, Agedge_t *e, int insertion)
Agattr_t * agattrrec(void *obj)
Definition: attr.c:231
char * AgDataRecName
Definition: attr.c:169
Dict_t * agdtopen(Agraph_t *g, Dtdisc_t *disc, Dtmethod_t *method)
Definition: utils.c:53
int agallocid(Agraph_t *g, int objtype, IDTYPE request)
Definition: id.c:126
CGHDR_API int agrename(Agobj_t *obj, char *newname)
Definition: obj.c:37
Agcbdisc_t AgAttrdisc
int agedgecmpf(Dict_t *d, void *arg_e0, void *arg_e1, Dtdisc_t *disc)
void aglexbad(void)
Definition: scan.c:2231
void agset_node_disc(Agraph_t *g, Dtdisc_t *disc)
Agnode_t * node(Agraph_t *g, char *name)
Definition: gv.cpp:103
void aglexeof(void)
Definition: scan.c:2229
void * agdictobjmem(Dict_t *dict, void *p, size_t size, Dtdisc_t *disc)
Definition: utils.c:19
void agmethod_upd(Agraph_t *g, void *obj, Agsym_t *sym)
Definition: obj.c:107
Definition: cdt.h:99
agxbuf * str
Definition: htmlparse.c:85
#define EXTERN
Definition: cghdr.h:19
void agnodeattr_delete(Agnode_t *n)
Definition: attr.c:399
Agnode_t * agfindnode_by_id(Agraph_t *g, IDTYPE id)
Definition: node.c:16
int agsyspopdisc(Agraph_t *g, Agcbdisc_t *cb, int stack)
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
Definition: apply.c:61
void agdictobjfree(Dict_t *dict, void *p, Dtdisc_t *disc)
Definition: utils.c:40
void(* agobjfn_t)(Agraph_t *g, Agobj_t *obj, void *arg)
Definition: cgraph.h:210
int agraphattr_delete(Agraph_t *g)
Definition: attr.c:370
Agedge_t * edge(Agraph_t *g, Agnode_t *t, Agnode_t *h)
Definition: gv.cpp:110