Debian Codegraph @

lib/cgraph/cghdr.h

raw
1 /**
2 * @file
3 * @brief cgraph.h additions
4 * @ingroup core
5 */
6 /*************************************************************************
7 * Copyright (c) 2011 AT&T Intellectual Property
8 * All rights reserved. This program and the accompanying materials
9 * are made available under the terms of the Eclipse Public License v1.0
10 * which accompanies this distribution, and is available at
11 * https://www.eclipse.org/legal/epl-v10.html
12 *
13 * Contributors: Details at https://graphviz.org
14 *************************************************************************/
15
16 #pragma once
17
18 #include "config.h"
19
20 #ifdef GVDLL
21 #ifdef EXPORT_CGHDR
22 #define CGHDR_API __declspec(dllexport)
23 #else
24 #define CGHDR_API __declspec(dllimport)
25 #endif
26 #endif
27
28 #ifndef CGHDR_API
29 #define CGHDR_API /* nothing */
30 #endif
31
32 #include <cgraph.h>
33
34 #include <ctype.h>
35 #include <sys/types.h>
36 #include <stdarg.h>
37 #include <stdbool.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <assert.h>
41 #include <stdint.h>
42 #include <stdio.h>
43
44 #define SUCCESS 0
45 #define FAILURE -1
46 #define LOCALNAMEPREFIX '%'
47
48 #define AGDISC(g,d) ((g)->clos->disc.d)
49 #define AGCLOS(g,d) ((g)->clos->state.d)
50
51 /* functional definitions */
52 typedef Agobj_t *(*agobjsearchfn_t) (Agraph_t * g, Agobj_t * obj);
53 CGHDR_API int agapply(Agraph_t * g, Agobj_t * obj, agobjfn_t fn, void *arg,
54 int preorder);
55
56 /* global variables */
57 extern const char AgDataRecName[];
58
59 /* set ordering disciplines */
60 extern Dtdisc_t Ag_subnode_seq_disc;
61 extern Dtdisc_t Ag_mainedge_id_disc;
62 extern Dtdisc_t Ag_subedge_id_disc;
63 extern Dtdisc_t Ag_mainedge_seq_disc;
64 extern Dtdisc_t Ag_subedge_seq_disc;
65 extern Dtdisc_t Ag_subgraph_id_disc;
66 extern Dtdisc_t Ag_subgraph_seq_disc;
67
68 /* internal constructor of graphs and subgraphs */
69 Agraph_t *agopen1(Agraph_t * g);
70 int agstrclose(Agraph_t * g);
71
72 /// Mask of `Agtag_s.seq` width
73 enum { SEQ_MASK = (1 << (sizeof(unsigned) * 8 - 4)) - 1 };
74
75 /* object set management */
76 Agnode_t *agfindnode_by_id(Agraph_t * g, IDTYPE id);
77 uint64_t agnextseq(Agraph_t * g, int objtype);
78
79 /* dict helper functions */
80 Dict_t *agdtopen(Dtdisc_t *disc, Dtmethod_t *method);
81 void agdtdisc(Agraph_t * g, Dict_t * dict, Dtdisc_t * disc);
82 int agdtdelete(Agraph_t * g, Dict_t * dict, void *obj);
83 int agdtclose(Agraph_t * g, Dict_t * dict);
84
85 /** @addtogroup cgraph_attr
86 * @{
87 */
88 /* name-value pair operations */
89 CGHDR_API Agdatadict_t *agdatadict(Agraph_t *g, bool cflag);
90 CGHDR_API Agattr_t *agattrrec(void *obj);
91
92 void agraphattr_init(Agraph_t * g);
93 int agraphattr_delete(Agraph_t * g);
94 void agnodeattr_init(Agraph_t *g, Agnode_t * n);
95 void agnodeattr_delete(Agnode_t * n);
96 void agedgeattr_init(Agraph_t *g, Agedge_t * e);
97 void agedgeattr_delete(Agedge_t * e);
98 /// @}
99
100 /* parsing and lexing graph files
101 *
102 * aagscan_t is opaque, because it is generated
103 * by flex based on scan.l.
104 * See https://westes.github.io/flex/manual/About-yyscan_005ft.html
105 */
106 typedef void *aagscan_t;
107 typedef struct aagextra_s aagextra_t;
108
109 int aaglex_init_extra(aagextra_t* user_defined, aagscan_t* scanner);
110 int aaglex_destroy(aagscan_t);
111 aagextra_t *aagget_extra(aagscan_t yyscanner);
112 void aagset_in(FILE *, aagscan_t);
113
114 int aagparse(aagscan_t scanner);
115 void aglexeof(aagscan_t yyscanner);
116 void aglexbad(aagscan_t yyscanner);
117
118 /* ID management */
119 int agmapnametoid(Agraph_t *g, int objtype, char *str, IDTYPE *result,
120 bool createflag);
121 void agfreeid(Agraph_t * g, int objtype, IDTYPE id);
122 char *agprintid(Agobj_t * obj);
123 bool aginternalmaplookup(Agraph_t *g, int objtype, char *str, IDTYPE *result);
124 void aginternalmapinsert(Agraph_t * g, int objtype, char *str,
125 IDTYPE result);
126 char *aginternalmapprint(Agraph_t * g, int objtype, IDTYPE id);
127 int aginternalmapdelete(Agraph_t * g, int objtype, IDTYPE id);
128 void aginternalmapclose(Agraph_t * g);
129 void agregister(Agraph_t * g, int objtype, void *obj);
130
131 /* internal set operations */
132 void agedgesetop(Agraph_t * g, Agedge_t * e, int insertion);
133 void agdelnodeimage(Agraph_t *g, Agobj_t *node, void *ignored);
134 void agdeledgeimage(Agraph_t *g, Agobj_t *edge, void *ignored);
135 /// rename an object
136 ///
137 /// @param obj Target to rename
138 /// @param newname Name to assign
139 /// @return 0 on success
140 CGHDR_API int agrename(Agobj_t * obj, char *newname);
141 void agrecclose(Agobj_t * obj);
142
143 /// @addtogroup cgraph_callback
144 /// @{
145 void agmethod_init(Agraph_t * g, void *obj);
146 void agmethod_upd(Agraph_t * g, void *obj, Agsym_t * sym);
147 void agmethod_delete(Agraph_t * g, void *obj);
148
149 void aginitcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
150 void agupdcb(Agraph_t * g, void *obj, Agsym_t * sym, Agcbstack_t * disc);
151 void agdelcb(Agraph_t * g, void *obj, Agcbstack_t * disc);
152 /// @}
153
154 /// @defgroup cgmem memory
155 /// @{
156 void aginternalmapclearlocalnames(Agraph_t *g);
157 /// @}