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 */ 78 EXTERN Agraph_t *Ag_G_global; 79 extern char *AgDataRecName; 80 81 /* set ordering disciplines */ 82 extern Dtdisc_t Ag_subnode_id_disc; 83 extern Dtdisc_t Ag_subnode_seq_disc; 84 extern Dtdisc_t Ag_mainedge_id_disc; 85 extern Dtdisc_t Ag_subedge_id_disc; 86 extern Dtdisc_t Ag_mainedge_seq_disc; 87 extern Dtdisc_t Ag_subedge_seq_disc; 88 extern Dtdisc_t Ag_subgraph_id_disc; 89 extern Agcbdisc_t AgAttrdisc; 90 91 /* internal constructor of graphs and subgraphs */ 92 Agraph_t *agopen1(Agraph_t * g); 93 int agstrclose(Agraph_t * g); 94 95 /* ref string management */ 96 void agmarkhtmlstr(char *s); 97 98 /* object set management */ 99 Agnode_t *agfindnode_by_id(Agraph_t * g, IDTYPE id); 100 Dtcompar_f agdictorder(Agraph_t *, Dict_t *, Dtcompar_f); 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 */ 172