]> granicus.if.org Git - graphviz/commitdiff
- provide control of whether demand loading is allowed independent of builtins
authorellson <devnull@localhost>
Sun, 28 May 2006 18:02:04 +0000 (18:02 +0000)
committerellson <devnull@localhost>
Sun, 28 May 2006 18:02:04 +0000 (18:02 +0000)
- provide demo of python wrapper using builtins and no demand laoding

lib/gvc/Makefile.am
lib/gvc/demand_loading.c [new file with mode: 0644]
lib/gvc/gvconfig.c
lib/gvc/gvplugin.c
lib/gvc/gvplugin.h
lib/gvc/libgvc_builtins.pc.in [new file with mode: 0644]
lib/gvc/no_builtins.c
lib/gvc/no_demand_loading.c [new file with mode: 0644]
tclpkg/tcldot/Makefile.am

index e7931a7d341c3a3ff2cd821a78e1c2888e6a8725..26dafffbc9bfececff91eb709cb759ade5e7f770 100644 (file)
@@ -18,33 +18,35 @@ pkginclude_HEADERS = gvc.h gvcext.h gvplugin.h gvcjob.h gvcint.h \
        gvplugin_render.h \
        gvplugin_layout.h \
        gvplugin_textlayout.h \
-       gvplugin_device.h
+       gvplugin_device.h \
+       dot_builtins.c \
+       demand_loading.c no_demand_loading.c
 noinst_HEADERS = gvcproc.h
 noinst_LTLIBRARIES = libgvc_C.la
 pkglib_LTLIBRARIES = libgvc.la libgvc_builtins.la
-pkgconfig_DATA = libgvc.pc
+pkgconfig_DATA = libgvc.pc libgvc_builtins.pc
 
-libgvc_C_la_SOURCES = gvrender.c gvlayout.c gvdevice.c \
-       gvcontext.c gvjobs.c gvevent.c gvplugin.c gvconfig.c \
-       gvtextlayout.c gvusershape.c gvc.c
-libgvc_C_la_LIBADD = \
-       $(top_builddir)/lib/common/libcommon_C.la
+libgvc_C_la_SOURCES = gvrender.c gvlayout.c gvdevice.c gvcontext.c gvjobs.c \
+       gvevent.c gvplugin.c gvconfig.c gvtextlayout.c gvusershape.c gvc.c
+libgvc_C_la_LIBADD = $(top_builddir)/lib/common/libcommon_C.la
 
-#libgvc is intended for use with plugins
+#For use with plugins.
 #   so it is linked with an empty table of builtins.
 libgvc_la_LDFLAGS = -version-info @VERSION_INFO@ -no-undefined
-libgvc_la_SOURCES = $(libgvc_C_la_SOURCES) no_builtins.c
+libgvc_la_SOURCES = $(libgvc_C_la_SOURCES) no_builtins.c demand_loading.c
 libgvc_la_LIBADD = $(libgvc_C_la_LIBADD) \
        $(top_builddir)/lib/cdt/libcdt.la \
        $(top_builddir)/lib/graph/libgraph.la \
        $(top_builddir)/lib/pathplan/libpathplan.la \
        @GD_LIBS@ @EXPAT_LIBS@ @Z_LIBS@ @LIBGEN_LIBS@
 
-#libgvc_builtins is intended for use with builtins (still allowing plugins).
-#   The application needs to provide a table of builtins, dot_builtins.c
-#   provides and example.
+#For use without plugins.
+#  so it needs to be linked with a preset table of builtins, e.g. dot_builtins.c,
+#              with either demand_loading.c or no_demand_loading.c,
+#              and with the plugins themselves, e.g.
+#  -lgvplugin_dot_layout -lgvplugin_neato_layout -lgvplugin_gd -lgvplugin_pangocairo
 libgvc_builtins_la_LDFLAGS = -version-info @VERSION_INFO@
 libgvc_builtins_la_SOURCES = $(libgvc_C_la_SOURCES)
 libgvc_builtins_la_LIBADD = $(libgvc_la_LIBADD)
 
-EXTRA_DIST = Makefile.old dot_builtins.c
+EXTRA_DIST = Makefile.old
diff --git a/lib/gvc/demand_loading.c b/lib/gvc/demand_loading.c
new file mode 100644 (file)
index 0000000..714d48c
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "arith.h"
+
+const bool Demand_Loading = true;
index 129935d167e1dfe7f3cd0ab802fde1780bc2108b..0efcaea19ad81c7e8dcae161367665b44671c773 100644 (file)
@@ -38,6 +38,8 @@
 #include       "gvcint.h"
 #include        "gvcproc.h"
 
+extern const bool Demand_Loading;
+
 #ifdef WITH_CODEGENS
 #ifdef QUARTZ_RENDER
 #include <QuickTime/QuickTime.h>
@@ -511,58 +513,60 @@ void gvconfig(GVC_t * gvc, bool rescan)
    
     gvc->config_found = FALSE;
 #ifdef ENABLE_LTDL
-    /* see if there are any new plugins */
-    libdir = gvconfig_libdir();
-    rc = stat(libdir, &libdir_st);
-    if (rc == -1) {
-       /* if we fail to stat it then it probably doesn't exist so just fail silently */
-       return;
-    }
-
-    if (! gvc->config_path) {
-        gvc->config_path = gmalloc(strlen(libdir) + 1 + strlen(config_file_name) + 1);
-        strcpy(gvc->config_path, libdir);
-        strcat(gvc->config_path, "/");
-        strcat(gvc->config_path, config_file_name);
-    }
-       
-    if (rescan) {
-       config_rescan(gvc, gvc->config_path);
-       gvc->config_found = TRUE;
-       return;
-    }
-
-    /* load in the cached plugin library data */
-
-    rc = stat(gvc->config_path, &config_st);
-    if (rc == -1) {
-       /* silently return without setting gvc->config_found = TRUE */
-       return;
-    }
-    else if (config_st.st_size > MAX_SZ_CONFIG) {
-       agerr(AGERR,"%s is bigger than I can handle.\n", gvc->config_path);
-    }
-    else {
-       f = fopen(gvc->config_path,"r");
-       if (!f) {
-           agerr (AGERR,"failed to open %s for read.\n", gvc->config_path);
-       }
-       else {
-           config_text = gmalloc(config_st.st_size + 1);
-           sz = fread(config_text, 1, config_st.st_size, f);
-           if (sz == 0) {
-               agerr(AGERR,"%s is zero sized, or other read error.\n", gvc->config_path);
-               free(config_text);
-           }
-           else {
-               gvc->config_found = TRUE;
-               config_text[sz] = '\0';  /* make input into a null terminated string */
-               rc = gvconfig_plugin_install_from_config(gvc, config_text);
-               /* NB. config_text not freed because we retain char* into it */
-           }
-       }
-       if (f)
-           fclose(f);
+    if (Demand_Loading) {
+        /* see if there are any new plugins */
+        libdir = gvconfig_libdir();
+        rc = stat(libdir, &libdir_st);
+        if (rc == -1) {
+       /* if we fail to stat it then it probably doesn't exist so just fail silently */
+       return;
+        }
+    
+        if (! gvc->config_path) {
+            gvc->config_path = gmalloc(strlen(libdir) + 1 + strlen(config_file_name) + 1);
+            strcpy(gvc->config_path, libdir);
+            strcat(gvc->config_path, "/");
+            strcat(gvc->config_path, config_file_name);
+        }
+       
+        if (rescan) {
+       config_rescan(gvc, gvc->config_path);
+       gvc->config_found = TRUE;
+       return;
+        }
+    
+        /* load in the cached plugin library data */
+    
+        rc = stat(gvc->config_path, &config_st);
+        if (rc == -1) {
+       /* silently return without setting gvc->config_found = TRUE */
+       return;
+        }
+        else if (config_st.st_size > MAX_SZ_CONFIG) {
+       agerr(AGERR,"%s is bigger than I can handle.\n", gvc->config_path);
+        }
+        else {
+       f = fopen(gvc->config_path,"r");
+       if (!f) {
+           agerr (AGERR,"failed to open %s for read.\n", gvc->config_path);
+       }
+       else {
+           config_text = gmalloc(config_st.st_size + 1);
+           sz = fread(config_text, 1, config_st.st_size, f);
+           if (sz == 0) {
+               agerr(AGERR,"%s is zero sized, or other read error.\n", gvc->config_path);
+               free(config_text);
+           }
+           else {
+               gvc->config_found = TRUE;
+               config_text[sz] = '\0';  /* make input into a null terminated string */
+               rc = gvconfig_plugin_install_from_config(gvc, config_text);
+               /* NB. config_text not freed because we retain char* into it */
+           }
+       }
+       if (f)
+           fclose(f);
+        }
     }
 #endif
     gvtextlayout_select(gvc);   /* choose best available textlayout plugin immediately */
index fc377945c9c0c0bec58206184c3933eca89543d9..b784532bc5e2d32b55abfa92ac81ebb33704ebdd 100644 (file)
@@ -30,6 +30,8 @@
 #include        "gvcint.h"
 #include        "gvcproc.h"
 
+extern const bool Demand_Loading;
+
 /*
  * Define an apis array of name strings using an enumerated api_t as index.
  * The enumerated type is defined gvplugin.h.  The apis array is
@@ -107,6 +109,9 @@ gvplugin_library_t *gvplugin_library_load(char *path)
     char *libdir;
     char *suffix = "_LTX_library";
 
+    if (!Demand_Loading)
+       return NULL;
+
     libdir = gvconfig_libdir();
     len = strlen(libdir) + 1 + strlen(path) + 1;
     if (len > lenp) {
@@ -337,11 +342,16 @@ void gvplugin_write_status(GVC_t * gvc)
     int api;
 
 #ifdef ENABLE_LTDL
-    fprintf(stderr,"The plugin configuration file:\n\t%s\n", gvc->config_path);
-    if (gvc->config_found)
-       fprintf(stderr,"\t\twas successfully loaded.\n");
-    else
-       fprintf(stderr,"\t\twas not found or not usable. No on-demand plugins.\n");
+    if (Demand_Loading) {
+        fprintf(stderr,"The plugin configuration file:\n\t%s\n", gvc->config_path);
+        if (gvc->config_found)
+           fprintf(stderr,"\t\twas successfully loaded.\n");
+        else
+           fprintf(stderr,"\t\twas not found or not usable. No on-demand plugins.\n");
+    }
+    else {
+        fprintf(stderr,"Demand loading of plugins is disabled.\n");
+    }
 #endif
 
     for (api = 0; api < ARRAY_SIZE(api_names); api++) {
index b90f7db1ef7c82b4848accb18790ff6b8008328c..d5eecb58d4cc2217e765c5979417d62b94b12421 100644 (file)
 extern "C" {
 #endif
 
+#include "arith.h"
 #include "gvcext.h"
 
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
 /* 
  * Terminology:
  *
diff --git a/lib/gvc/libgvc_builtins.pc.in b/lib/gvc/libgvc_builtins.pc.in
new file mode 100644 (file)
index 0000000..1a69971
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@/@PACKAGE@
+includedir=@includedir@/@PACKAGE@
+                                                                                       
+Name: libgvc_builtins
+Description: The GraphVizContext library 
+Version: @VERSION@
+Libs: -L${libdir} -lgvc_builtins
+Cflags: -I${includedir}
index 02d7c23795542565dce79da38d5c756b603b0942..886a0736ba7c15b48664b81eb903756f72cdbe86 100644 (file)
@@ -21,4 +21,3 @@
 #include "gvplugin.h"
 
 const lt_symlist_t lt_preloaded_symbols[] = { { 0, 0 } };
-
diff --git a/lib/gvc/no_demand_loading.c b/lib/gvc/no_demand_loading.c
new file mode 100644 (file)
index 0000000..6b12cd5
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/**********************************************************
+*      This software is part of the graphviz package      *
+*                http://www.graphviz.org/                 *
+*                                                         *
+*            Copyright (c) 1994-2004 AT&T Corp.           *
+*                and is licensed under the                *
+*            Common Public License, Version 1.0           *
+*                      by AT&T Corp.                      *
+*                                                         *
+*        Information and Software Systems Research        *
+*              AT&T Research, Florham Park NJ             *
+**********************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "arith.h"
+
+const bool Demand_Loading = false;
index 129fbbe7c44b686a90f4590b9a68665d9900db61..902a0fffbe99f2c32cd8203f0d9993edb48a3116 100644 (file)
@@ -48,7 +48,10 @@ libtcldot_la_LIBADD = \
        $(top_builddir)/tclpkg/tclstubs/libtclstubs_C.la \
        $(top_builddir)/lib/gvc/libgvc.la @LIBGEN_LIBS@ @LIBLTDL@
 
-libtcldot_builtin_la_SOURCES = tcldot.c $(top_srcdir)/lib/gvc/dot_builtins.c $(CODEGENS) $(GDTCLFT)
+libtcldot_builtin_la_SOURCES = \
+       tcldot.c $(CODEGENS) $(GDTCLFT) \
+       $(top_srcdir)/lib/gvc/dot_builtins.c \
+       $(top_srcdir)/lib/gvc/no_demand_loading.c 
 libtcldot_builtin_la_LDFLAGS = -no-undefined
 libtcldot_builtin_la_LIBADD = \
        $(top_builddir)/tclpkg/tclhandle/libtclhandle_C.la \