Add gvc.c

This commit is contained in:
c9s 2014-05-18 07:34:51 +08:00
parent b7d3e86181
commit 1439401036
4 changed files with 57 additions and 12 deletions

18
configure vendored
View file

@ -13131,12 +13131,12 @@ if test -n "$DEPS_CFLAGS"; then
pkg_cv_DEPS_CFLAGS="$DEPS_CFLAGS" pkg_cv_DEPS_CFLAGS="$DEPS_CFLAGS"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check gvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check") 2>&5 ($PKG_CONFIG --exists --print-errors "libpcre check gvc") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libpcre check" 2>/dev/null` pkg_cv_DEPS_CFLAGS=`$PKG_CONFIG --cflags "libpcre check gvc" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -13148,12 +13148,12 @@ if test -n "$DEPS_LIBS"; then
pkg_cv_DEPS_LIBS="$DEPS_LIBS" pkg_cv_DEPS_LIBS="$DEPS_LIBS"
elif test -n "$PKG_CONFIG"; then elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \ if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check\""; } >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpcre check gvc\""; } >&5
($PKG_CONFIG --exists --print-errors "libpcre check") 2>&5 ($PKG_CONFIG --exists --print-errors "libpcre check gvc") 2>&5
ac_status=$? ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
pkg_cv_DEPS_LIBS=`$PKG_CONFIG --libs "libpcre check" 2>/dev/null` pkg_cv_DEPS_LIBS=`$PKG_CONFIG --libs "libpcre check gvc" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes test "x$?" != "x0" && pkg_failed=yes
else else
pkg_failed=yes pkg_failed=yes
@ -13174,14 +13174,14 @@ else
_pkg_short_errors_supported=no _pkg_short_errors_supported=no
fi fi
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre check" 2>&1` DEPS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpcre check gvc" 2>&1`
else else
DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre check" 2>&1` DEPS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpcre check gvc" 2>&1`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$DEPS_PKG_ERRORS" >&5 echo "$DEPS_PKG_ERRORS" >&5
as_fn_error $? "Package requirements (libpcre check) were not met: as_fn_error $? "Package requirements (libpcre check gvc) were not met:
$DEPS_PKG_ERRORS $DEPS_PKG_ERRORS

View file

@ -1,5 +1,5 @@
lib_LTLIBRARIES=libr3.la lib_LTLIBRARIES=libr3.la
libr3_la_SOURCES=node.c edge.c list.c str.c token.c libr3_la_SOURCES=node.c edge.c list.c str.c token.c gvc.c
libr3_la_LIBADD=$(DEPS_LIBS) libr3_la_LIBADD=$(DEPS_LIBS)
AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include
# AM_CFLAGS=$(DEPS_CFLAGS) # AM_CFLAGS=$(DEPS_CFLAGS)

View file

@ -123,7 +123,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 = am__DEPENDENCIES_1 =
libr3_la_DEPENDENCIES = $(am__DEPENDENCIES_1) libr3_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_libr3_la_OBJECTS = node.lo edge.lo list.lo str.lo token.lo am_libr3_la_OBJECTS = node.lo edge.lo list.lo str.lo token.lo gvz.lo
libr3_la_OBJECTS = $(am_libr3_la_OBJECTS) libr3_la_OBJECTS = $(am_libr3_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -312,7 +312,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
lib_LTLIBRARIES = libr3.la lib_LTLIBRARIES = libr3.la
libr3_la_SOURCES = node.c edge.c list.c str.c token.c libr3_la_SOURCES = node.c edge.c list.c str.c token.c gvz.c
libr3_la_LIBADD = $(DEPS_LIBS) libr3_la_LIBADD = $(DEPS_LIBS)
AM_CFLAGS = $(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include AM_CFLAGS = $(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include
all: all-am all: all-am
@ -395,6 +395,7 @@ distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edge.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gvz.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Plo@am__quote@

44
src/gvc.c Normal file
View file

@ -0,0 +1,44 @@
/*
* gvz.c
* Copyright (C) 2014 c9s <c9s@c9smba.local>
*
* Distributed under terms of the MIT license.
*/
#include <gvc.h>
#include <stdio.h>
#include <stdlib.h>
#include "r3.h"
// int main(int argc, char **argv)
int r3_tree_render_file(node * tree, char * format, char * filename)
{
Agraph_t *g;
Agnode_t *n, *m;
Agedge_t *e;
/* set up a graphviz context - but only once even for multiple graphs */
static GVC_t *gvc;
if (!gvc) {
gvc = gvContext();
}
/* Create a simple digraph */
g = agopen("g", Agdirected, 0);
n = agnode(g, "n", 1);
m = agnode(g, "m", 1);
e = agedge(g, n, m, 0, 1);
/* Set an attribute - in this case one that affects the visible rendering */
agsafeset(n, "color", "red", "");
/* Use the directed graph layout engine */
gvLayout(gvc, g, "dot");
gvRenderFilename(gvc, g, format, filename);
gvFreeLayout(gvc, g);
agclose(g);
return 0;
}