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 */
73typedef Agobj_t *(*agobjsearchfn_t) (Agraph_t * g, Agobj_t * obj);
74CGHDR_API int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
75 int preorder);
76
77 /* global variables */
78EXTERN Agraph_t *Ag_G_global;
79extern char *AgDataRecName;
80
81 /* set ordering disciplines */
82extern Dtdisc_t Ag_subnode_id_disc;
83extern Dtdisc_t Ag_subnode_seq_disc;
84extern Dtdisc_t Ag_mainedge_id_disc;
85extern Dtdisc_t Ag_subedge_id_disc;
86extern Dtdisc_t Ag_mainedge_seq_disc;
87extern Dtdisc_t Ag_subedge_seq_disc;
88extern Dtdisc_t Ag_subgraph_id_disc;
89extern Agcbdisc_t AgAttrdisc;
90
91 /* internal constructor of graphs and subgraphs */
92Agraph_t *agopen1(Agraph_t * g);
93int agstrclose(Agraph_t * g);
94
95 /* ref string management */
96void agmarkhtmlstr(char *s);
97
98 /* object set management */
99Agnode_t *agfindnode_by_id(Agraph_t * g, IDTYPE id);
100Dtcompar_f agdictorder(Agraph_t *, Dict_t *, Dtcompar_f);
101int agedgecmpf(Dict_t * d, void *arg_e0, void *arg_e1, Dtdisc_t * disc);
102int agnamecmpf(Dict_t * d, void *, void *, Dtdisc_t * disc);
103void agset_node_disc(Agraph_t * g, Dtdisc_t * disc);
104uint64_t agnextseq(Agraph_t * g, int objtype);
105
106/* dict helper functions */
107Dict_t *agdtopen(Agraph_t * g, Dtdisc_t * disc, Dtmethod_t * method);
108void agdtdisc(Agraph_t * g, Dict_t * dict, Dtdisc_t * disc);
109long agdtdelete(Agraph_t * g, Dict_t * dict, void *obj);
110int agdtclose(Agraph_t * g, Dict_t * dict);
111void *agdictobjmem(Dict_t * dict, void * p, size_t size,
112 Dtdisc_t * disc);
113void agdictobjfree(Dict_t * dict, void * p, Dtdisc_t * disc);
114
115 /* name-value pair operations */
116CGHDR_API Agdatadict_t *agdatadict(Agraph_t * g, int cflag);
117CGHDR_API Agattr_t *agattrrec(void *obj);
118
119void agraphattr_init(Agraph_t * g);
120int agraphattr_delete(Agraph_t * g);
121void agnodeattr_init(Agraph_t *g, Agnode_t * n);
122void agnodeattr_delete(Agnode_t * n);
123void agedgeattr_init(Agraph_t *g, Agedge_t * e);
124void agedgeattr_delete(Agedge_t * e);
125
126 /* parsing and lexing graph files */
127int aagparse(void);
128void aglexinit(Agdisc_t * disc, void *ifile);
129int aaglex(void);
130void aglexeof(void);
131void aglexbad(void);
132
133 /* ID management */
134int agmapnametoid(Agraph_t * g, int objtype, char *str,
135 IDTYPE *result, int allocflag);
136int agallocid(Agraph_t * g, int objtype, IDTYPE request);
137void agfreeid(Agraph_t * g, int objtype, IDTYPE id);
138char *agprintid(Agobj_t * obj);
139int aginternalmaplookup(Agraph_t * g, int objtype, char *str,
140 IDTYPE *result);
141void aginternalmapinsert(Agraph_t * g, int objtype, char *str,
142 IDTYPE result);
143char *aginternalmapprint(Agraph_t * g, int objtype, IDTYPE id);
144int aginternalmapdelete(Agraph_t * g, int objtype, IDTYPE id);
145void aginternalmapclose(Agraph_t * g);
146void agregister(Agraph_t * g, int objtype, void *obj);
147
148 /* internal set operations */
149void agedgesetop(Agraph_t * g, Agedge_t * e, int insertion);
150void agdelnodeimage(Agraph_t * g, Agnode_t * node, void *ignored);
151void agdeledgeimage(Agraph_t * g, Agedge_t * edge, void *ignored);
152void *agrebind0(Agraph_t * g, void *obj); /* unsafe */
153CGHDR_API int agrename(Agobj_t * obj, char *newname);
154void agrecclose(Agobj_t * obj);
155
156void agmethod_init(Agraph_t * g, void *obj);
157void agmethod_upd(Agraph_t * g, void *obj, Agsym_t * sym);
158void agmethod_delete(Agraph_t * g, void *obj);
159
160#define CB_INITIALIZE 100
161#define CB_UPDATE 101
162#define CB_DELETION 102
163void agsyspushdisc(Agraph_t * g, Agcbdisc_t * cb, void *state, int stack);
164int agsyspopdisc(Agraph_t * g, Agcbdisc_t * cb, int stack);
165void agrecord_callback(Agraph_t * g, Agobj_t * obj, int kind,
166 Agsym_t * optsym);
167void aginitcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
168void agupdcb(Agraph_t * g, void *obj, Agsym_t * sym, Agcbstack_t * disc);
169void agdelcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
170
171#endif /* ATT_GRAPHPVT_H */
172