From af7a711569808403d517e01de7be9752c6973f80 Mon Sep 17 00:00:00 2001 From: ellson Date: Thu, 26 Feb 2009 16:03:13 +0000 Subject: [PATCH] change agsetodisc() to agsetiodisc() and add hook for fread() --- cmd/dot/dot.c | 2 +- cmd/tools/gvpack.c | 2 +- lib/graph/graph.h | 3 ++- lib/graph/graphio.c | 8 +++++--- lib/graph/libgraph.h | 1 + lib/gvc/gvc.c | 4 ++-- lib/gvc/gvplugin.c | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/dot/dot.c b/cmd/dot/dot.c index 7bf38f94e..f207f6f24 100644 --- a/cmd/dot/dot.c +++ b/cmd/dot/dot.c @@ -129,7 +129,7 @@ static graph_t *create_test_graph(void) /* Create a new graph */ #ifndef WITH_CGRAPH aginit(); - agsetodisc(gvfwrite, gvferror); + agsetiodisc(NULL, gvfwrite, gvferror); g = agopen("new_graph", AGDIGRAPH); #else /* WITH_CGRAPH */ g = agopen("new_graph", Agdirected,NIL(Agdisc_t *)); diff --git a/cmd/tools/gvpack.c b/cmd/tools/gvpack.c index 590ec7e8f..5c12a240c 100644 --- a/cmd/tools/gvpack.c +++ b/cmd/tools/gvpack.c @@ -163,7 +163,7 @@ static void init(int argc, char *argv[]) int c; aginit(); - agsetodisc(gvfwrite, gvferror); + agsetiodisc(NULL, gvfwrite, gvferror); while ((c = getopt(argc, argv, ":ngvum:o:G:?")) != -1) { switch (c) { case 'n': diff --git a/lib/graph/graph.h b/lib/graph/graph.h index 52ed60dbe..1a15a87be 100644 --- a/lib/graph/graph.h +++ b/lib/graph/graph.h @@ -163,7 +163,8 @@ extern "C" { extern void agreadline(int); extern void agsetfile(char *); extern Agraph_t *agmemread(char *); - extern void agsetodisc( + extern void agsetiodisc( + size_t (*myfread) (void *ptr, size_t size, size_t nmemb, FILE *stream), size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream), int (*myferror) (FILE *stream) ); extern void agfprintf(FILE *fp, const char *format, ...); diff --git a/lib/graph/graphio.c b/lib/graph/graphio.c index 2186588bc..08b29dc6b 100644 --- a/lib/graph/graphio.c +++ b/lib/graph/graphio.c @@ -177,16 +177,18 @@ char *agstrcanon(char *arg, char *buf) return (_agstrcanon(arg, buf)); } -void agsetodisc( +void agsetiodisc( + size_t (*myfread) (void *ptr, size_t size, size_t nmemb, FILE *stream), size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream), int (*myferror) (FILE *stream) ) { - AG.fwrite = myfwrite; + if (myfread) AG.fread = myfread; + if (myfwrite) AG.fwrite = myfwrite; #if defined(__SUNPRO_C) #undef ferror - AG.ferror = myferror; #endif + if (myferror) AG.ferror = myferror; } /* agfprintf: diff --git a/lib/graph/libgraph.h b/lib/graph/libgraph.h index 83563a070..c54225e33 100644 --- a/lib/graph/libgraph.h +++ b/lib/graph/libgraph.h @@ -129,6 +129,7 @@ extern "C" { char *linebuf; short syntax_errors; unsigned char accepting_state, init_called; + size_t (*fread) (void *ptr, size_t size, size_t nmemb, FILE *stream); size_t (*fwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream); int (*ferror) (FILE *stream); } AG; diff --git a/lib/gvc/gvc.c b/lib/gvc/gvc.c index 45b02bd09..0f0831df3 100644 --- a/lib/gvc/gvc.c +++ b/lib/gvc/gvc.c @@ -32,7 +32,7 @@ GVC_t *gvContext(void) #ifndef WITH_CGRAPH aginit(); - agsetodisc(gvfwrite, gvferror); + agsetiodisc(NULL, gvfwrite, gvferror); agnodeattr(NULL, "label", NODENAME_ESC); #else agattr(NULL, AGNODE, "label", NODENAME_ESC); @@ -49,7 +49,7 @@ GVC_t *gvContextPlugins(const lt_symlist_t *builtins, int demand_loading) #ifndef WITH_CGRAPH aginit(); - agsetodisc(gvfwrite, gvferror); + agsetiodisc(NULL, gvfwrite, gvferror); agnodeattr(NULL, "label", NODENAME_ESC); #else agattr(NULL, AGNODE, "label", NODENAME_ESC); diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index 70b429c95..7271618c6 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -467,7 +467,7 @@ Agraph_t * gvplugin_graph(GVC_t * gvc) #ifndef WITH_CGRAPH aginit(); - agsetodisc(gvfwrite, gvferror); + agsetiodisc(NULL, gvfwrite, gvferror); /* set persistent attributes here */ agraphattr(NULL, "label", ""); agraphattr(NULL, "rankdir", ""); -- 2.40.0