Number: 1206
Title: Please wrap agwrite for SWIG
Submitter: Tobias Gruetzmacher
Date: Sun Oct 7 18:43:57 2007
Subsys: Lib(a)graph
Version: 2.12 (Mon Sep 10 11:29:37 UTC 2007)
System: x86-Linux-
Severity: minor
Problem:
It would be nice if if would be possible to save .dot files without rendering from Perl, Ruby, Python, etc. As I see it this just needs a SWIG wrapping for agwrite...
Comments:
[tobias] Since I had the time:

Attached is a patch against CVS HEAD to add this functionality.


Index: tclpkg/gv/gv.cpp
===================================================================
RCS file: /home/cvsroot/graphviz2/tclpkg/gv/gv.cpp,v
retrieving revision 1.42
diff -u -r1.42 gv.cpp
--- tclpkg/gv/gv.cpp	15 Jun 2006 15:52:56 -0000	1.42
+++ tclpkg/gv/gv.cpp	9 Oct 2007 23:17:05 -0000
@@ -871,3 +871,22 @@
 //
 //    err = gvRenderData(gvc, g, format, data);
 }
+
+void write(Agraph_t *g, FILE *f)
+{
+    int err;
+
+    err = agwrite(g, f);
+}
+
+void write(Agraph_t *g, char *filename)
+{
+    FILE *f;
+    int err;
+
+    f = fopen(filename, "w");
+    if (!f)
+	return;
+    err = agwrite(g, f);
+    fclose(f);
+}
Index: tclpkg/gv/gv.i
===================================================================
RCS file: /home/cvsroot/graphviz2/tclpkg/gv/gv.i,v
retrieving revision 1.29
diff -u -r1.29 gv.i
--- tclpkg/gv/gv.i	17 Sep 2007 16:18:31 -0000	1.29
+++ tclpkg/gv/gv.i	9 Oct 2007 23:17:05 -0000
@@ -191,4 +191,9 @@
 extern void render(Agraph_t *g, char *format, char *filename);
 extern void render(Agraph_t *g, char *format, FILE *f);
 extern void render(Agraph_t *g, char *format, void **data);
+
+/*** Writing graph back to file */
+void write(Agraph_t *g, FILE *f);
+void write(Agraph_t *g, char *filename);
+
 %}


Owner: ellson
Status: Fixed (11 Oct 2007)