GRAPH = graph
endif
+# tclhandle still needed for gd
+TCLHANDLE_INCLUDES=-I$(top_srcdir)/tclpkg/tclhandle
+TCLHANDLE_LIBS=$(top_builddir)/tclpkg/tclhandle/libtclhandle_C.la
+
pdfdir = $(pkgdatadir)/doc/pdf
htmldir = $(pkgdatadir)/doc/html
-I$(top_srcdir)/lib/common \
-I$(top_srcdir)/lib/$(GRAPH) \
-I$(top_srcdir)/lib/cdt \
- -I$(top_srcdir)/lib/pathplan \
- -I$(top_srcdir)/tclpkg/tclhandle $(GD_INCLUDES) $(TCL_INCLUDES)
+ -I$(top_srcdir)/lib/pathplan $(TCLHANDLE_INCLUDES) $(GD_INCLUDES) $(TCL_INCLUDES)
LIBS = -lc
tcldot-nodecmd.c \
tcldot-edgecmd.c \
tcldot-util.c \
- tcldot-mygets.c \
+ tcldot-id.c \
+ tcldot-io.c \
+ tcldot-mem.c \
no_builtins.c $(GDTCLFT)
libtcldot_la_CPPFLAGS = $(AM_CPPFLAGS) -DDEMAND_LOADING=1
libtcldot_la_LDFLAGS = -no-undefined
-libtcldot_la_LIBADD = $(top_builddir)/tclpkg/tclhandle/libtclhandle_C.la \
+libtcldot_la_LIBADD = $(TCLHANDLE_LIBS) \
$(top_builddir)/tclpkg/tclstubs/libtclstubs_C.la \
$(top_builddir)/lib/cdt/libcdt.la \
$(top_builddir)/lib/$(GRAPH)/lib$(GRAPH).la \
tcldot-nodecmd.c \
tcldot-edgecmd.c \
tcldot-util.c \
- tcldot-mygets.c \
+ tcldot-id.c \
+ tcldot-io.c \
+ tcldot-mem.c \
tcldot_builtins.c $(GDTCLFT)
libtcldot_builtin_la_CPPFLAGS = $(AM_CPPFLAGS) -DDEMAND_LOADING=1
libtcldot_builtin_la_LDFLAGS =
-libtcldot_builtin_la_LIBADD = \
- $(top_builddir)/tclpkg/tclhandle/libtclhandle_C.la \
+libtcldot_builtin_la_LIBADD = $(TCLHANDLE_LIBS) \
$(top_builddir)/plugin/dot_layout/libgvplugin_dot_layout_C.la \
$(top_builddir)/plugin/neato_layout/libgvplugin_neato_layout_C.la \
$(top_builddir)/plugin/core/libgvplugin_core_C.la \
#endif /* TCLOBJ */
)
{
- char c, buf[16], *s, **argv2;
+ char c, buf[32], *s, **argv2;
int i, j, length, argc2;
Agraph_t *g;
- Agedge_t **ep, *e;
+ Agedge_t *e;
Agsym_t *a;
+#ifndef WITH_CGRAPH
+ Agedge_t **ep;
ictx_t *ictx = (ictx_t *)clientData;
+#else
+ gctx_t *gctx = (gctx_t *)clientData;
+ ictx_t *ictx = gctx->ictx;
+#endif
GVC_t *gvc = ictx->gvc;
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], "\" option ?arg arg ...?",
- NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], "\" option ?arg arg ...?", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
if (!(ep = (Agedge_t **) tclhandleXlate(ictx->edgeTblPtr, argv[0]))) {
- Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL);
+ Tcl_AppendResult(interp, "Edge \"", argv[0], "\" not found", NULL);
return TCL_ERROR;
}
e = *ep;
+#else
+ e = cmd2e(gctx,argv[0]);
+ if (!e) {
+ Tcl_AppendResult(interp, "Edge \"", argv[0], "\" not found", NULL);
+ return TCL_ERROR;
+ }
+#endif
g = agraphof(agtail(e));
c = argv[1][0];
if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
#ifndef WITH_CGRAPH
- tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e));
- Tcl_DeleteCommand(interp, argv[0]);
+ deleteEdge(ictx, g, e);
+#else
+ deleteEdge(gctx, g, e);
#endif
- agdelete(g, e);
reset_layout(gvc, g);
return TCL_OK;
return TCL_OK;
} else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(agtail(e)));
+#else
+ sprintf(buf,"node%p",agtail(e));
+#endif
Tcl_AppendElement(interp, buf);
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(aghead(e)));
+#else
+ sprintf(buf,"node%p",aghead(e));
+#endif
Tcl_AppendElement(interp, buf);
return TCL_OK;
Tcl_AppendElement(interp, agxget(e, a));
#endif
} else {
- Tcl_AppendResult(interp, " No attribute named \"",
- argv2[j], "\"", NULL);
+ Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL);
return TCL_ERROR;
}
}
}
return TCL_OK;
- } else if ((c == 'q')
- && (strncmp(argv[1], "queryattributevalues", length) ==
- 0)) {
+ } else if ((c == 'q') && (strncmp(argv[1], "queryattributevalues", length) == 0)) {
for (i = 2; i < argc; i++) {
if (Tcl_SplitList
(interp, argv[i], &argc2,
Tcl_AppendElement(interp, agxget(e, a));
#endif
} else {
- Tcl_AppendResult(interp, " No attribute named \"", argv2[j], "\"", NULL);
+ Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL);
return TCL_ERROR;
}
}
}
return TCL_OK;
- } else if ((c == 's')
- && (strncmp(argv[1], "setattributes", length) == 0)) {
+ } else if ((c == 's') && (strncmp(argv[1], "setattributes", length) == 0)) {
if (argc == 3) {
if (Tcl_SplitList
(interp, argv[2], &argc2,
(CONST84 char ***) &argv2) != TCL_OK)
return TCL_ERROR;
if ((argc2 == 0) || (argc2 % 2)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0],
"\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
NULL);
Tcl_Free((char *) argv2);
Tcl_Free((char *) argv2);
} else {
if ((argc < 4) || (argc % 2)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0],
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0],
"\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
NULL);
return TCL_ERROR;
s = "->";
else
s = "--";
- Tcl_AppendResult(interp,
- agnameof(agtail(e)), s, agnameof(aghead(e)), NULL);
+ Tcl_AppendResult(interp, agnameof(agtail(e)), s, agnameof(aghead(e)), NULL);
return TCL_OK;
} else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
+ Tcl_AppendResult(interp, "Bad option \"", argv[1],
"\": must be one of:",
"\n\tdelete, listattributes, listnodes,",
"\n\tueryattributes, queryattributevalues,",
#include "tcldot.h"
-Agraph_t *cmd2g(gctx_t *gctx, char *cmd) {
- Agraph_t *g = NULL;
-
- if (sscanf(cmd, "graph%p", &g) != 1 || !g) {
- Tcl_AppendResult(gctx->ictx->interp, " \"", cmd, "\" not found", NULL);
- return NULL;
- }
- return g;
-}
-Agnode_t *cmd2n(gctx_t *gctx, char *cmd) {
- Agnode_t *n = NULL;
-
- if (sscanf(cmd, "node%p", &n) != 1 || !n) {
- Tcl_AppendResult(gctx->ictx->interp, " \"", cmd, "\" not found", NULL);
- return NULL;
- }
- return n;
-}
-Agedge_t *cmd2e(gctx_t *gctx, char *cmd) {
- Agedge_t *e = NULL;
-
- if (sscanf(cmd, "edge%p", &e) != 1 || !e) {
- Tcl_AppendResult(gctx->ictx->interp, " \"", cmd, "\" not found", NULL);
- return NULL;
- }
- return e;
-}
-
int graphcmd(ClientData clientData, Tcl_Interp * interp,
#ifndef TCLOBJ
int argc, char *argv[]
Agraph_t *g, *sg;
Agnode_t *n, *tail, *head;
Agedge_t *e;
-// FIXME #ifndef WITH_CGRAPH
- Agraph_t **sgp;
- Agnode_t **np;
-// #endif
#ifndef WITH_CGRAPH
- Agraph_t **gp;
+ Agraph_t **gp, **sgp;
+ Agnode_t **np;
Agedge_t **ep;
ictx_t *ictx = (ictx_t *)clientData;
unsigned long id;
GVJ_t *job = gvc->job;
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"",
- NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", NULL);
return TCL_ERROR;
}
#ifndef WITH_CGRAPH
if (!(gp = (Agraph_t **) tclhandleXlate(ictx->graphTblPtr, argv[0]))) {
- Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL);
+ Tcl_AppendResult(interp, "Graph \"", argv[0], "\" not found", NULL);
return TCL_ERROR;
}
g = *gp;
#else
g = cmd2g(gctx,argv[0]);
- if (!g)
+ if (!g) {
+ Tcl_AppendResult(interp, "Graph \"", argv[0], "\" not found", NULL);
return TCL_ERROR;
+ }
#endif
c = argv[1][0];
if ((c == 'a') && (strncmp(argv[1], "addedge", length) == 0)) {
if ((argc < 4) || (argc % 2)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0],
" addedge tail head ?attributename attributevalue? ?...?\"",
NULL);
return TCL_ERROR;
#ifndef WITH_CGRAPH
if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) {
if (!(tail = agfindnode(g, argv[2]))) {
- Tcl_AppendResult(interp, "Tail node \"", argv[2],
- "\" not found.", NULL);
+ Tcl_AppendResult(interp, "Tail node \"", argv[2], "\" not found.", NULL);
return TCL_ERROR;
}
}
+ else {
+ tail = *np;
+ }
#else
tail = cmd2n(gctx,argv[2]);
if (!tail) {
- return TCL_ERROR;
- }
-#endif
- else {
-#ifndef WITH_CGRAPH
- tail = *np;
-#endif
- if (agroot(g) != agroot(agraphof(tail))) {
- Tcl_AppendResult(interp, "Node ", argv[2],
- " is not in the graph.", NULL);
+ if (!(tail = agfindnode(g, argv[2]))) {
+ Tcl_AppendResult(interp, "Tail node \"", argv[2], "\" not found.", NULL);
return TCL_ERROR;
}
+ }
+#endif
+ if (agroot(g) != agroot(agraphof(tail))) {
+ Tcl_AppendResult(interp, "Tail node ", argv[2], " is not in the graph.", NULL);
+ return TCL_ERROR;
}
#ifndef WITH_CGRAPH
if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[3]))) {
if (!(head = agfindnode(g, argv[3]))) {
- Tcl_AppendResult(interp, "Head node \"", argv[3],
- "\" not found.", NULL);
+ Tcl_AppendResult(interp, "Head node \"", argv[3], "\" not found.", NULL);
return TCL_ERROR;
}
}
+ else {
+ head = *np;
+ }
#else
head = cmd2n(gctx,argv[2]);
if (!head) {
- return TCL_ERROR;
- }
-#endif
- else {
-#ifndef WITH_CGRAPH
- head = *np;
-#endif
- if (agroot(g) != agroot(agraphof(head))) {
- Tcl_AppendResult(interp, "Node ", argv[3],
- " is not in the graph.", NULL);
+ if (!(head = agfindnode(g, argv[3]))) {
+ Tcl_AppendResult(interp, "Head node \"", argv[3], "\" not found.", NULL);
return TCL_ERROR;
}
+ }
+#endif
+ if (agroot(g) != agroot(agraphof(head))) {
+ Tcl_AppendResult(interp, "Head node ", argv[3], " is not in the graph.", NULL);
+ return TCL_ERROR;
}
#ifdef WITH_CGRAPH
e = agedge(g, tail, head, NULL, 1);
+ sprintf(buf,"edge%p",e);
+ Tcl_AppendResult(interp, buf, NULL);
#else
e = agedge(g, tail, head);
#endif
#endif
i = 3;
} else {
- /* else use handle as name */
#ifdef WITH_CGRAPH
- n = agnode(g, Tcl_GetStringResult(interp), 1);
+ n = agnode(g, NULL, 1); /* anon node */
#else
+ /* else use handle as name */
np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, Tcl_GetStringResult(interp), &id);
n = agnode(g, Tcl_GetStringResult(interp));
*np = n;
#endif
i = 2;
}
-#ifdef WITH_CGRAPH
+#ifndef WITH_CGRAPH
np = (Agnode_t **)tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n));
*np = n;
+#else
+ sprintf(buf,"node%p",n);
+ Tcl_AppendResult(interp, buf, NULL);
#endif
setnodeattributes(agroot(g), n, &argv[i], argc - i);
reset_layout(gvc, g);
/* if odd number of args then argv[2] is name */
#ifdef WITH_CGRAPH
sg = agsubg(g, argv[2], 1);
+ sprintf(buf,"graph%p",sg);
+ Tcl_AppendResult(interp, buf, NULL);
#else
sg = agsubg(g, argv[2]);
if (! (sgp = (Agraph_t **) tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg))) || *sgp != sg) {
#endif
i = 3;
} else {
- /* else use handle as name */
#ifdef WITH_CGRAPH
- sg = agsubg(g, Tcl_GetStringResult(interp), 1);
+ sg = agsubg(g, NULL, 1); /* anon subgraph */
#else
+ /* else use handle as name */
sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, Tcl_GetStringResult(interp), &id);
sg = agsubg(g, Tcl_GetStringResult(interp));
*sgp = sg;
#endif
i = 2;
}
-#ifdef WITH_CGRAPH
+#ifndef WITH_CGRAPH
sgp = (Agraph_t **)tclhandleXlateIndex(ictx->graphTblPtr, AGID(sg));
*sgp = sg;
#endif
} else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
reset_layout(gvc, g);
#ifndef WITH_CGRAPH
- deleteNodes(ictx, g);
deleteGraph(ictx, g);
#else
- deleteNodes(g);
- deleteGraph(g);
+ deleteGraph(gctx, g);
#endif
return TCL_OK;
Tcl_AppendResult(interp, "Edge \"", argv[2], " - ", argv[3], "\" not found.", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",e);
+#endif
Tcl_AppendElement(interp, buf);
return TCL_OK;
Tcl_AppendResult(interp, "Node not found.", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(n));
+#else
+ sprintf(buf,"node%p",n);
+#endif
Tcl_AppendResult(interp, buf, NULL);
return TCL_OK;
} else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) {
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",e);
+#endif
Tcl_AppendElement(interp, buf);
}
}
} else if ((c == 'l') && (strncmp(argv[1], "listnodes", length) == 0)) {
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(n));
+#else
+ sprintf(buf,"node%p",n);
+#endif
Tcl_AppendElement(interp, buf);
+
}
return TCL_OK;
} else if ((c == 'l')
&& (strncmp(argv[1], "listnodesrev", length) == 0)) {
for (n = aglstnode(g); n; n = agprvnode(g, n)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(n));
+#else
+ sprintf(buf,"node%p",n);
+#endif
Tcl_AppendElement(interp, buf);
}
return TCL_OK;
&& (strncmp(argv[1], "listsubgraphs", length) == 0)) {
#ifdef WITH_CGRAPH
for (sg = agfstsubg(g); sg; sg = agnxtsubg(sg)) {
- tclhandleString(ictx->graphTblPtr, buf, AGID(sg));
+ sprintf(buf,"graph%p",sg);
Tcl_AppendElement(interp, buf);
}
#else
--- /dev/null
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/*************************************************************************
+ * Copyright (c) 2011 AT&T Intellectual Property
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: See CVS logs. Details at http://www.graphviz.org/
+ *************************************************************************/
+
+
+#include "tcldot.h"
+
+#ifdef WITH_CGRAPH
+
+// Agiddisc functions
+static void *myiddisc_open(Agraph_t *g, Agdisc_t *disc) {
+ ictx_t *ictx = (ictx_t *)disc;
+ gctx_t *gctx;
+
+ gctx = (gctx_t *)malloc(sizeof(gctx_t));
+ gctx->g = g;
+ gctx->ictx = ictx;
+ return (void *)gctx;
+}
+static long myiddisc_map(void *state, int objtype, char *str, unsigned long *id, int createflag) {
+ gctx_t *gctx = (gctx_t *)state;
+ ictx_t *ictx = gctx->ictx;
+ char *s;
+
+ if (str) {
+ if (createflag)
+ s = agstrdup(gctx->g, str);
+ else
+ s = agstrbind(gctx->g, str);
+ *id = (unsigned long) s;
+ } else {
+ *id = ictx->ctr; /* counter maintained in per-interp space, so that
+ ids are unique across all graphs in the interp */
+ ictx->ctr += 2;
+ }
+ return TRUE;
+}
+/* we don't allow users to explicitly set IDs, either */
+static long myiddisc_alloc(void *state, int objtype, unsigned long request_id) {
+ NOTUSED(state);
+ NOTUSED(objtype);
+ NOTUSED(request_id);
+ return FALSE;
+}
+static void myiddisc_free(void *state, int objtype, unsigned long id) {
+ gctx_t *gctx = (gctx_t *)state;
+
+/* FIXME no obj* available
+ ictx_t *ictx = gctx->ictx;
+ char buf[32] = "";
+
+ switch (objtype) {
+ case AGRAPH: sprintf(buf,"graph%lu",id); break;
+ case AGNODE: sprintf(buf,"node%lu",id); break;
+ case AGINEDGE:
+ case AGOUTEDGE: sprintf(buf,"edge%lu",id); break;
+ }
+ Tcl_DeleteCommand(ictx->interp, buf);
+*/
+ if (id % 2 == 0)
+ agstrfree(gctx->g, (char *) id);
+}
+static char *myiddisc_print(void *state, int objtype, unsigned long id) {
+ NOTUSED(state);
+ NOTUSED(objtype);
+ if (id % 2 == 0)
+ return (char *) id;
+ else
+ return "";
+}
+static void myiddisc_close(void *state) {
+ free(state);
+}
+static void myiddisc_register(void *state, int objtype, void *obj) {
+ gctx_t *gctx = (gctx_t *)state;
+ ictx_t *ictx = gctx->ictx;
+ Tcl_Interp *interp = ictx->interp;
+ Tcl_CmdProc *proc = NULL;
+ char buf[32] = "";
+
+ switch (objtype) {
+ case AGRAPH: sprintf(buf,"graph%p",obj); proc=graphcmd; break;
+ case AGNODE: sprintf(buf,"node%p",obj); proc=nodecmd; break;
+ case AGINEDGE:
+ case AGOUTEDGE: sprintf(buf,"edge%p",obj); proc=edgecmd; break;
+ }
+#ifndef TCLOBJ
+ Tcl_CreateCommand(interp, buf, proc, (ClientData) gctx, (Tcl_CmdDeleteProc *) NULL);
+#else
+ Tcl_CreateObjCommand(interp, buf, proc, (ClientData) gctx, (Tcl_CmdDeleteProc *) NULL);
+#endif
+}
+Agiddisc_t myiddisc = {
+ myiddisc_open,
+ myiddisc_map,
+ myiddisc_alloc,
+ myiddisc_free,
+ myiddisc_print,
+ myiddisc_close,
+ myiddisc_register
+};
+#endif
#endif
}
#endif /* WITH_CGRAPH */
+
+#ifdef WITH_CGRAPH
+
+Agraph_t *agread_usergets (ictx_t *ictx, FILE * fp, int (*usergets)(void *chan, char *buf, int bufsize))
+{
+ Agraph_t* g;
+ Agiodisc_t ioDisc;
+
+ ioDisc.afread = usergets;
+ ioDisc.putstr = AgIoDisc.putstr;
+ ioDisc.flush = AgIoDisc.flush;
+
+ ictx->mydisc.io = &ioDisc;
+ g = agread (fp, (Agdisc_t *)ictx);
+ ictx->mydisc.io = &AgIoDisc; /* restore io */
+ return g;
+}
+
+#endif
--- /dev/null
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/*************************************************************************
+ * Copyright (c) 2011 AT&T Intellectual Property
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: See CVS logs. Details at http://www.graphviz.org/
+ *************************************************************************/
+
+
+#include "tcldot.h"
+
+#ifdef WITH_CGRAPH
+#endif
#endif /* TCLOBJ */
)
{
- unsigned long id;
- char c, buf[16], **argv2;
+ char c, buf[32], **argv2;
int i, j, length, argc2;
Agraph_t *g;
- Agnode_t **np, *n, *head;
- Agedge_t **ep, *e;
+ Agnode_t *n, *head;
+ Agedge_t *e;
Agsym_t *a;
+#ifndef WITH_CGRAPH
+ unsigned long id;
+ Agnode_t **np;
+ Agedge_t **ep;
ictx_t *ictx = (ictx_t *)clientData;
+#else
+ gctx_t *gctx = (gctx_t *)clientData;
+ ictx_t *ictx = gctx->ictx;
+#endif
GVC_t *gvc = ictx->gvc;
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"",
- NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " option ?arg arg ...?\"", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[0]))) {
- Tcl_AppendResult(interp, " \"", argv[0], "\"", NULL);
+ Tcl_AppendResult(interp, "Node \"", argv[0], "\" not found", NULL);
return TCL_ERROR;
}
n = *np;
+#else
+ n = cmd2n(gctx,argv[0]);
+ if (!n) {
+ Tcl_AppendResult(interp, "Node \"", argv[0], "\" not found", NULL);
+ return TCL_ERROR;
+ }
+#endif
g = agraphof(n);
c = argv[1][0];
if ((c == 'a') && (strncmp(argv[1], "addedge", length) == 0)) {
if ((argc < 3) || (!(argc % 2))) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0],
- " addedge head ?attributename attributevalue? ?...?\"",
- NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " addedge head ?attributename attributevalue? ?...?\"", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
if (!(np = (Agnode_t **) tclhandleXlate(ictx->nodeTblPtr, argv[2]))) {
if (!(head = agfindnode(g, argv[2]))) {
- Tcl_AppendResult(interp, "Head node \"", argv[2],
- "\" not found.", NULL);
+ Tcl_AppendResult(interp, "Head node \"", argv[2], "\" not found.", NULL);
return TCL_ERROR;
}
} else {
head = *np;
- if (agroot(g) != agroot(agraphof(head))) {
- Tcl_AppendResult(interp, "Nodes ", argv[0], " and ",
- argv[2], " are not in the same graph.",
- NULL);
+ }
+#else
+ head = cmd2n(gctx,argv[2]);
+ if (!head) {
+ if (!(head = agfindnode(g, argv[2]))) {
+ Tcl_AppendResult(interp, "Head node \"", argv[2], "\" not found.", NULL);
return TCL_ERROR;
}
}
+#endif
+ if (agroot(g) != agroot(agraphof(head))) {
+ Tcl_AppendResult(interp, "Nodes ", argv[0], " and ", argv[2], " are not in the same graph.", NULL);
+ return TCL_ERROR;
+ }
#ifdef WITH_CGRAPH
e = agedge(g, n, head, NULL, 1);
+ sprintf(buf,"edge%p",e);
+ Tcl_AppendResult(interp, buf, NULL);
#else
e = agedge(g, n, head);
-#endif
- if (!
- (ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e)))
- || *ep != e) {
- ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp),
- &id);
+ if (!(ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e))) || *ep != e) {
+ ep = (Agedge_t **) tclhandleAlloc(ictx->edgeTblPtr, Tcl_GetStringResult(interp), &id);
*ep = e;
AGID(e) = id;
#ifndef TCLOBJ
} else {
tclhandleString(ictx->edgeTblPtr, Tcl_GetStringResult(interp), AGID(e));
}
+#endif
setedgeattributes(agroot(g), e, &argv[3], argc - 3);
reset_layout(gvc, g);
return TCL_OK;
} else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
#ifndef WITH_CGRAPH
- deleteEdges(ictx, g, n);
- tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n));
- Tcl_DeleteCommand(interp, argv[0]);
+ deleteNode(ictx, g, n);
#else
- deleteEdges(g, n);
+ deleteNode(gctx, g, n);
#endif
- agdelete(g, n);
reset_layout(gvc, g);
return TCL_OK;
} else if ((c == 'f') && (strncmp(argv[1], "findedge", length) == 0)) {
if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " findedge headnodename\"",
- NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " findedge headnodename\"", NULL);
return TCL_ERROR;
}
if (!(head = agfindnode(g, argv[2]))) {
- Tcl_AppendResult(interp, "Head node \"", argv[2],
- "\" not found.", NULL);
+ Tcl_AppendResult(interp, "Head node \"", argv[2], "\" not found.", NULL);
return TCL_ERROR;
}
if (!(e = agfindedge(g, n, head))) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->nodeTblPtr, buf, AGID(head));
- Tcl_AppendResult(interp, "Edge \"", argv[0],
- " - ", buf, "\" not found.", NULL);
+#else
+ sprintf(buf,"node%p",head);
+#endif
+ Tcl_AppendResult(interp, "Edge \"", argv[0], " - ", buf, "\" not found.", NULL);
return TCL_ERROR;
}
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",head);
+#endif
Tcl_AppendElement(interp, buf);
return TCL_OK;
} else if ((c == 'l') && (strncmp(argv[1], "listedges", length) == 0)) {
for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",e);
+#endif
Tcl_AppendElement(interp, buf);
}
return TCL_OK;
} else if ((c == 'l')
&& (strncmp(argv[1], "listinedges", length) == 0)) {
for (e = agfstin(g, n); e; e = agnxtin(g, e)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",e);
+#endif
Tcl_AppendElement(interp, buf);
}
return TCL_OK;
} else if ((c == 'l')
&& (strncmp(argv[1], "listoutedges", length) == 0)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
+#ifndef WITH_CGRAPH
tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+#else
+ sprintf(buf,"edge%p",e);
+#endif
Tcl_AppendElement(interp, buf);
}
return TCL_OK;
Tcl_AppendElement(interp, agxget(n, a));
#endif
} else {
- Tcl_AppendResult(interp, " No attribute named \"",
- argv2[j], "\"", NULL);
+ Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL);
return TCL_ERROR;
}
}
Tcl_AppendElement(interp, agxget(n, a));
#endif
} else {
- Tcl_AppendResult(interp, " No attribute named \"",
- argv2[j], "\"", NULL);
+ Tcl_AppendResult(interp, "No attribute named \"", argv2[j], "\"", NULL);
return TCL_ERROR;
}
}
(CONST84 char ***) &argv2) != TCL_OK)
return TCL_ERROR;
if ((argc2 == 0) || (argc2 % 2)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0],
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0],
"\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
NULL);
Tcl_Free((char *) argv2);
Tcl_Free((char *) argv2);
} else {
if ((argc < 4) || (argc % 2)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0],
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0],
"\" setattributes attributename attributevalue ?attributename attributevalue? ?...?",
NULL);
return TCL_ERROR;
return TCL_OK;
} else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
+ Tcl_AppendResult(interp, "Bad option \"", argv[1],
"\": must be one of:",
"\n\taddedge, listattributes, listedges, listinedges,",
"\n\tlistoutedges, queryattributes, queryattributevalues,",
}
#ifdef WITH_CGRAPH
-void deleteEdges(Agraph_t * g, Agnode_t * n)
+/* handles (tcl commands) to obj* */
+
+Agraph_t *cmd2g(gctx_t *gctx, char *cmd) {
+ Agraph_t *g = NULL;
+
+ if (sscanf(cmd, "graph%p", &g) != 1 || !g)
+ return NULL;
+ return g;
+}
+Agnode_t *cmd2n(gctx_t *gctx, char *cmd) {
+ Agnode_t *n = NULL;
+
+ if (sscanf(cmd, "node%p", &n) != 1 || !n)
+ return NULL;
+ return n;
+}
+Agedge_t *cmd2e(gctx_t *gctx, char *cmd) {
+ Agedge_t *e = NULL;
+
+ if (sscanf(cmd, "edge%p", &e) != 1 || !e)
+ return NULL;
+ return e;
+}
+#endif // WITH_CGRAPH
+
+#ifdef WITH_CGRAPH
+void deleteEdge(gctx_t *gctx, Agraph_t * g, Agedge_t *e)
+{
+ agdelete(gctx->g, e); /* delete edge from root graph */
+}
+static void deleteNodeEdges(gctx_t *gctx, Agraph_t *g, Agnode_t *n)
{
Agedge_t *e, *e1;
e = agfstedge(g, n);
while (e) {
e1 = agnxtedge(g, e, n);
- agdelete(agroot(g), e);
+ deleteEdge(gctx, g, e);
e = e1;
}
}
-
-void deleteNodes(Agraph_t * g)
+void deleteNode(gctx_t * gctx, Agraph_t *g, Agnode_t *n)
+{
+ deleteNodeEdges(gctx, gctx->g, n); /* delete all edges to/from node in root graph */
+ agdelete(gctx->g, n); /* delete node from root graph */
+}
+static void deleteGraphNodes(gctx_t * gctx, Agraph_t *g)
{
Agnode_t *n, *n1;
n = agfstnode(g);
while (n) {
- deleteEdges(agroot(g), n);
n1 = agnxtnode(g, n);
- agdelete(agroot(g), n);
+ deleteNode(gctx, g, n);
n = n1;
}
}
-void deleteGraph(Agraph_t * g)
+void deleteGraph(gctx_t * gctx, Agraph_t *g)
{
Agraph_t *sg;
for (sg = agfstsubg (g); sg; sg = agnxtsubg (sg)) {
- deleteGraph(sg);
+ deleteGraph(gctx, sg);
}
+ deleteGraphNodes(gctx, g);
if (g == agroot(g)) {
agclose(g);
} else {
}
}
#else
-void deleteEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n)
+void deleteEdge(ictx_t * ictx, Agraph_t * g, Agedge_t *e)
+{
+ Agedge_t **ep;
+ char buf[32];
+
+ tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
+ Tcl_DeleteCommand(ictx->interp, buf);
+ ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e));
+ if (!ep)
+ fprintf(stderr, "Bad entry in edgeTbl\n");
+ tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e));
+ agdelete(agroot(g), e);
+}
+static void deleteNodeEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n)
{
- Agedge_t **ep, *e, *e1;
- char buf[16];
+ Agedge_t *e, *e1;
e = agfstedge(g, n);
while (e) {
- tclhandleString(ictx->edgeTblPtr, buf, AGID(e));
- Tcl_DeleteCommand(ictx->interp, buf);
- ep = (Agedge_t **) tclhandleXlateIndex(ictx->edgeTblPtr, AGID(e));
- if (!ep)
- fprintf(stderr, "Bad entry in edgeTbl\n");
- tclhandleFreeIndex(ictx->edgeTblPtr, AGID(e));
e1 = agnxtedge(g, e, n);
- agdelete(agroot(g), e);
+ deleteEdge(ictx, g, e);
e = e1;
}
}
-void deleteNodes(ictx_t * ictx, Agraph_t * g)
+void deleteNode(ictx_t * ictx, Agraph_t * g, Agnode_t *n)
+{
+ Agnode_t **np;
+ char buf[32];
+
+ deleteNodeEdges(ictx, agroot(g), n);
+ tclhandleString(ictx->nodeTblPtr, buf, AGID(n));
+ Tcl_DeleteCommand(ictx->interp, buf);
+ np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n));
+ if (!np)
+ fprintf(stderr, "Bad entry in nodeTbl\n");
+ tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n));
+ agdelete(agroot(g), n);
+}
+static void deleteGraphNodes(ictx_t * ictx, Agraph_t * g)
{
- Agnode_t **np, *n, *n1;
- char buf[16];
+ Agnode_t *n, *n1;
n = agfstnode(g);
while (n) {
- tclhandleString(ictx->nodeTblPtr, buf, AGID(n));
- Tcl_DeleteCommand(ictx->interp, buf);
- np = (Agnode_t **) tclhandleXlateIndex(ictx->nodeTblPtr, AGID(n));
- if (!np)
- fprintf(stderr, "Bad entry in nodeTbl\n");
- tclhandleFreeIndex(ictx->nodeTblPtr, AGID(n));
- deleteEdges(ictx, agroot(g), n);
n1 = agnxtnode(g, n);
- agdelete(agroot(g), n);
+ deleteNode(ictx, g, n);
n = n1;
}
}
{
Agraph_t **sgp;
Agedge_t *e;
- char buf[16];
+ char buf[32];
if (g->meta_node) {
for (e = agfstout(g->meta_node->graph, g->meta_node); e;
if (!sgp)
fprintf(stderr, "Bad entry in graphTbl\n");
tclhandleFreeIndex(ictx->graphTblPtr, AGID(g));
+ deleteGraphNodes(ictx, g);
if (g == agroot(g)) {
agclose(g);
} else {
#include "tcldot.h"
-#ifdef WITH_CGRAPH
-
-// Agiddisc functions
-static void *myiddisc_open(Agraph_t *g, Agdisc_t *disc) {
- ictx_t *ictx = (ictx_t *)disc;
- gctx_t *gctx;
-
- gctx = (gctx_t *)malloc(sizeof(gctx_t));
- gctx->g = g;
- gctx->ictx = ictx;
- return (void *)gctx;
-}
-static long myiddisc_map(void *state, int objtype, char *str, unsigned long *id, int createflag) {
- gctx_t *gctx = (gctx_t *)state;
- ictx_t *ictx = gctx->ictx;
- char *s;
-
- if (str) {
- if (createflag)
- s = agstrdup(gctx->g, str);
- else
- s = agstrbind(gctx->g, str);
- *id = (unsigned long) s;
- } else {
- *id = ictx->ctr; /* counter maintained in per-interp space, so that
- ids are unique across all graphs in the interp */
- ictx->ctr += 2;
- }
- return TRUE;
-}
-/* we don't allow users to explicitly set IDs, either */
-static long myiddisc_alloc(void *state, int objtype, unsigned long request_id) {
- NOTUSED(state);
- NOTUSED(objtype);
- NOTUSED(request_id);
- return FALSE;
-}
-static void myiddisc_free(void *state, int objtype, unsigned long id) {
- gctx_t *gctx = (gctx_t *)state;
-
-/* FIXME no obj* available
- ictx_t *ictx = gctx->ictx;
- char buf[30] = "";
-
- switch (objtype) {
- case AGRAPH: sprintf(buf,"graph%lu",id); break;
- case AGNODE: sprintf(buf,"node%lu",id); break;
- case AGINEDGE:
- case AGOUTEDGE: sprintf(buf,"edge%lu",id); break;
- }
- Tcl_DeleteCommand(ictx->interp, buf);
-*/
- if (id % 2 == 0)
- agstrfree(gctx->g, (char *) id);
-}
-static char *myiddisc_print(void *state, int objtype, unsigned long id) {
- NOTUSED(state);
- NOTUSED(objtype);
- if (id % 2 == 0)
- return (char *) id;
- else
- return "";
-}
-static void myiddisc_close(void *state) {
- free(state);
-}
-static void myiddisc_register(void *state, int objtype, void *obj) {
- gctx_t *gctx = (gctx_t *)state;
- ictx_t *ictx = gctx->ictx;
- Tcl_Interp *interp = ictx->interp;
- Tcl_CmdProc *proc = NULL;
- char buf[30] = "";
-
- switch (objtype) {
- case AGRAPH: sprintf(buf,"graph%p",obj); proc=graphcmd; break;
- case AGNODE: sprintf(buf,"node%p",obj); proc=nodecmd; break;
- case AGINEDGE:
- case AGOUTEDGE: sprintf(buf,"edge%p",obj); proc=edgecmd; break;
- }
- Tcl_AppendResult(interp, buf, NULL);
-#ifndef TCLOBJ
- Tcl_CreateCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) gctx, (Tcl_CmdDeleteProc *) NULL);
-#else
- Tcl_CreateObjCommand(interp, Tcl_GetStringResult(interp), proc, (ClientData) gctx, (Tcl_CmdDeleteProc *) NULL);
-#endif
-}
-static Agiddisc_t myiddisc = {
- myiddisc_open,
- myiddisc_map,
- myiddisc_alloc,
- myiddisc_free,
- myiddisc_print,
- myiddisc_close,
- myiddisc_register
-};
-
-#endif // WITH_CGRAPH
-
static int dotnew(ClientData clientData, Tcl_Interp * interp,
#ifndef TCLOBJ
int argc, char *argv[]
int kind;
unsigned long id;
#else
+ char buf[32];
Agdesc_t kind;
#endif
* so we make sure that it is initialized to "not done" */
GD_drawing(g) = NULL;
- return TCL_OK;
-}
-
#ifdef WITH_CGRAPH
-static void
-init_graphs (ictx_t *ictx, graph_t* g)
-{
- Agraph_t *sg, **sgp;
- unsigned long id;
- char buf[16];
- Tcl_Interp *interp = ictx->interp;
-
- for (sg = agfstsubg (g); sg; sg = agnxtsubg (sg))
- init_graphs (ictx, sg);
+ sprintf(buf, "graph%p", g);
+ Tcl_AppendResult(interp, buf, NULL);
+#endif
- sgp = (Agraph_t **) tclhandleAlloc(ictx->graphTblPtr, buf, &id);
- *sgp = g;
- AGID(g) = id;
-#ifndef TCLOBJ
- Tcl_CreateCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL);
-#else /* TCLOBJ */
- Tcl_CreateObjCommand(interp, buf, graphcmd, (ClientData) ictx, (Tcl_CmdDeleteProc *) NULL);
-#endif /* TCLOBJ */
- if (agroot(g) == g)
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ return TCL_OK;
}
-#endif
+#ifndef WITH_CGRAPH
/*
* when a graph is read in from a file or string we need to walk
* it to create the handles and tcl commands for each
*/
static int tcldot_fixup(ictx_t *ictx, graph_t * g)
{
-#ifndef WITH_CGRAPH
Agraph_t **gp, *sg, **sgp;
-#endif
Agnode_t *n, **np;
Agedge_t *e, **ep;
- char buf[16];
+ char buf[32];
unsigned long id;
Tcl_Interp *interp = ictx->interp;
-#ifdef WITH_CGRAPH
- init_graphs (ictx, g);
-#else
if (g->meta_node) {
for (n = agfstnode(g->meta_node->graph); n;
n = agnxtnode(g->meta_node->graph, n)) {
(ClientData) ictx, (Tcl_CmdDeleteProc *) NULL);
#endif /* TCLOBJ */
}
-#endif /* WITH_CGRAPH */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
np = (Agnode_t **) tclhandleAlloc(ictx->nodeTblPtr, buf, &id);
*np = n;
return TCL_OK;
}
-#ifdef WITH_CGRAPH
-Agraph_t *agread_usergets (FILE * fp, int (*usergets)(void *chan, char *buf, int bufsize))
-{
- Agraph_t* g;
- Agdisc_t disc;
- Agiodisc_t ioDisc;
-
- ioDisc.afread = usergets;
- ioDisc.putstr = AgIoDisc.putstr;
- ioDisc.flush = AgIoDisc.flush;
-
- disc.mem = &AgMemDisc;
- disc.id = &AgIdDisc;
- disc.io = &ioDisc;
- g = agread (fp, &disc);
- return g;
-}
-#endif
+#endif /* WITH_CGRAPH */
static int dotread(ClientData clientData, Tcl_Interp * interp,
#ifndef TCLOBJ
Agraph_t *g;
Tcl_Channel channel;
int mode;
- ictx_t *ictx = (ictx_t *)clientData;
+#ifdef WITH_CGRAPH
+ char buf[32];
+#endif
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " fileHandle\"", NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " fileHandle\"", NULL);
return TCL_ERROR;
}
channel = Tcl_GetChannel(interp, argv[1], &mode);
* a properly parsed graph. If the graph doesn't parse
* during reading then the channel will be left at EOF
*/
- g = agread_usergets((FILE *) channel, (mygets));
+ g = agread_usergets((ictx_t *)clientData, (FILE *) channel, (mygets));
if (!g) {
Tcl_AppendResult(interp, "\nFailure to read graph \"", argv[1], "\"", NULL);
if (agerrors()) {
* so we make sure that it is initialized to "not done" */
GD_drawing(g) = NULL;
- return (tcldot_fixup(ictx, g));
+#ifndef WITH_CGRAPH
+ return (tcldot_fixup((ictx_t *)clientData, g));
+#else
+ sprintf(buf, "graph%p", g);
+ Tcl_AppendResult(interp, buf, NULL);
+ return TCL_OK;
+#endif
}
static int dotstring(ClientData clientData, Tcl_Interp * interp,
)
{
Agraph_t *g;
- ictx_t *ictx = (ictx_t *)clientData;
+#ifdef WITH_CGRAPH
+ char buf[32];
+#endif
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " string\"", NULL);
+ Tcl_AppendResult(interp, "Wrong # args: should be \"", argv[0], " string\"", NULL);
return TCL_ERROR;
}
if (!(g = agmemread(argv[1]))) {
* so we make sure that it is initialized to "not done" */
GD_drawing(g) = NULL;
- return (tcldot_fixup(ictx, g));
+#ifndef WITH_CGRAPH
+ return (tcldot_fixup((ictx_t *)clientData, g));
+#else
+ sprintf(buf, "graph%p", g);
+ Tcl_AppendResult(interp, buf, NULL);
+ return TCL_OK;
+#endif
}
#if defined(_BLD_tcldot) && defined(_DLL)
ictx->interp = interp;
#ifdef WITH_CGRAPH
+ ictx->mydisc.mem = &AgMemDisc;
ictx->mydisc.id = &myiddisc;
+ ictx->mydisc.io = &AgIoDisc;
ictx->ctr = 1; /* init to first odd number, increment by 2 */
#endif
(ClientData) ictx, (Tcl_CmdDeleteProc *) NULL);
#endif /* TCLOBJ */
-#ifdef WITH_CGRAPH
- ictx->graphTblPtr = (void *) tclhandleInit("tcldot", sizeof(gctx_t *), 10);
-#else
+#ifndef WITH_CGRAPH
ictx->graphTblPtr = (void *) tclhandleInit("graph", sizeof(Agraph_t *), 10);
ictx->nodeTblPtr = (void *) tclhandleInit("node", sizeof(Agnode_t *), 100);
ictx->edgeTblPtr = (void *) tclhandleInit("edge", sizeof(Agedge_t *), 100);
typedef struct {
#ifdef WITH_CGRAPH
Agdisc_t mydisc; /* must be first to allow casting mydisc to ictx */
- unsigned long int ctr; /* odd number counter for anon objects over all g's in interp */
-#endif
-/* **FIXME** #ifndef WITH_CGRAPH */
+ unsigned long ctr; /* odd number counter for anon objects over all g's in interp */
+#else
void *graphTblPtr, *nodeTblPtr, *edgeTblPtr;
-/* #endif */
+#endif
Tcl_Interp *interp;
GVC_t *gvc;
} ictx_t;
typedef struct {
Agraph_t *g; /* the graph */
ictx_t *ictx;
- unsigned long int idx;
+ unsigned long idx;
} gctx_t;
#endif
);
#ifdef WITH_CGRAPH
-extern void deleteEdges(Agraph_t * g, Agnode_t * n);
-extern void deleteNodes(Agraph_t * g);
-extern void deleteGraph(Agraph_t * g);
+extern Agiddisc_t myiddisc;
+extern Agiodisc_t myiodisc;
+extern Agmemdisc_t mymemdisc;
+extern Agraph_t *agread_usergets (ictx_t *ictx, FILE * fp, int (*usergets)(void *chan, char *buf, int bufsize));
+extern Agraph_t *cmd2g(gctx_t *gctx, char *cmd);
+extern Agnode_t *cmd2n(gctx_t *gctx, char *cmd);
+extern Agedge_t *cmd2e(gctx_t *gctx, char *cmd);
+extern void deleteEdge(gctx_t *gctx, Agraph_t * g, Agedge_t * e);
+extern void deleteNode(gctx_t *gctx, Agraph_t * g, Agnode_t * n);
+extern void deleteGraph(gctx_t *gctx, Agraph_t * g);
extern void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g);
extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g);
extern void listEdgeAttrs (Tcl_Interp * interp, Agraph_t* g);
extern int mygets(void* channel, char *ubuf, int n);
#else
-extern void deleteEdges(ictx_t * ictx, Agraph_t * g, Agnode_t * n);
-extern void deleteNodes(ictx_t * ictx, Agraph_t * g);
+extern void deleteEdge(ictx_t * ictx, Agraph_t * g, Agedge_t * e);
+extern void deleteNode(ictx_t * ictx, Agraph_t * g, Agnode_t * n);
extern void deleteGraph(ictx_t * ictx, Agraph_t * g);
extern void listGraphAttrs (Tcl_Interp * interp, Agraph_t* g);
extern void listNodeAttrs (Tcl_Interp * interp, Agraph_t* g);