return (Agsym_t *)dtprev(dict->dict, a);
}
-static size_t agfwrite(FILE *fp, const char *s, size_t len)
-{
- return fwrite(s, sizeof(char), len, fp);
-}
-
-static int agferror(FILE *fp)
-{
- return ferror(fp);
-}
-
-
/* this is normally called by the aginit() macro */
void aginitlib(int gs, int ns, int es)
{
AG.node_nbytes = ns;
AG.edge_nbytes = es;
AG.init_called = TRUE;
- AG.fwrite = agfwrite;
- AG.ferror = agferror;
+ AG.fwrite = fwrite; /* init to system version of fwrite() */
+ AG.ferror = ferror; /* init to system version of ferror() */
initproto();
} else
if ((AG.graph_nbytes != gs) || (AG.node_nbytes != ns)
extern void agreadline(int);
extern void agsetfile(char *);
extern Agraph_t *agmemread(char *);
- extern void agsetodisc(size_t (*fwrite) (FILE *fp, const char *s, size_t len), int (*ferror) (FILE *fp));
+ extern void agsetodisc(
+ 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, ...);
extern int agputs(const char *s, FILE *fp);
extern int agputc(int c, FILE *fp);
return (_agstrcanon(arg, buf));
}
-void agsetodisc(size_t (*fwrite) (FILE *fp, const char *s, size_t len), int (*ferror) (FILE *fp))
+void agsetodisc(
+ size_t (*myfwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream),
+ int (*myferror) (FILE *stream)
+)
{
- AG.fwrite = fwrite;
- AG.ferror = ferror;
+ AG.fwrite = myfwrite;
+ AG.ferror = myferror;
}
/* agfprintf:
#endif
va_end(argp);
- AG.fwrite(fp, buf, len);
+ AG.fwrite(buf, sizeof(char), len, fp);
}
int agputs(const char *s, FILE *fp)
{
size_t len = strlen(s);
- if (AG.fwrite(fp, s, len) != len) {
+ if (AG.fwrite(s, sizeof(char), len, fp) != len) {
return EOF;
}
return +1;
{
const char cc = c;
- if (AG.fwrite (fp, &cc, 1) != 1) {
+ if (AG.fwrite (&cc, sizeof(char), 1, fp) != 1) {
return EOF;
}
return c;
char *linebuf;
short syntax_errors;
unsigned char accepting_state, init_called;
- size_t (*fwrite) (FILE *fp, const char *s, size_t len);
- int (*ferror) (FILE *fp);
+ size_t (*fwrite) (const void *ptr, size_t size, size_t nmemb, FILE *stream);
+ int (*ferror) (FILE *stream);
} AG;
/* follow structs used in graph parser */
return len;
}
-int gvferror (FILE* fp)
+int gvferror (FILE* stream)
{
+ GVJ_t *job = (GVJ_t*)stream;
+
+ if (!job->gvc->write_fn && !job->output_data)
+ return ferror(job->output_file);
+
return 0;
}
-size_t gvfwrite (FILE* fp, const char *s, size_t len)
+size_t gvfwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
{
- return gvwrite((GVJ_t*)fp, s, len);
+ assert(size = sizeof(char));
+ return gvwrite((GVJ_t*)stream, ptr, nmemb);
}
int gvputs(GVJ_t * job, const char *s)