2
This software may only be used by you under license from AT&T Corp.
3
("AT&T"). A copy of AT&T's Source Code Agreement is available at
4
AT&T's Internet website having the URL:
5
<http://www.research.att.com/sw/tools/graphviz/license/source.html>
6
If you received this software without first entering into a license
7
with AT&T, you have an infringing copy of this software and cannot use
8
it without violating AT&T's intellectual property rights.
12
* Written by Emden Gansner
18
typedef struct { char* dummy; } Agraph_t;
23
* Set next available file.
24
* If Files is NULL, we just read from stdin.
27
nextFile(ingraph_state* sp)
31
if (sp->Files == NULL) {
37
while (sp->Files[sp->ctr]) {
38
if ((rv = fopen(sp->Files[sp->ctr++],"r")) != 0) break;
39
else fprintf(stderr,"Can't open %s\n",sp->Files[sp->ctr-1]);
46
* Read and return next graph; return NULL if done.
47
* Read graph from currently open file. If none, open next file.
50
nextGraph (ingraph_state* sp)
54
if (sp->fp == NULL) nextFile(sp);
57
while (sp->fp != NULL) {
59
if ((g = sp->openf(sp->fp)) != 0) break;
62
fprintf (stderr, "ingraphs: NULL graph reader\n");
65
if (sp->Files) /* Only close if not using stdin */
73
* Create new ingraph state. If sp is non-NULL, we
74
* assume user is supplying memory.
75
* At present, we require opf to be non-NULL. In
76
* theory, we could assume a function agread(FILE*,void*)
79
newIngraph (ingraph_state* sp, char** files, opengfn opf)
82
sp = (ingraph_state*)malloc(sizeof(ingraph_state));
84
fprintf (stderr, "ingraphs: out of memory\n");
91
if (opf) sp->openf = opf;
93
fprintf (stderr, "ingraphs: NULL graph reader\n");
100
* Close any open files. Use must handle freeing of memory.
103
closeIngraph (ingraph_state* sp)
105
if (sp->Files && sp->fp) fclose (sp->fp);
109
* Return name of current file being processed.
112
fileName (ingraph_state* sp)
115
if (sp->ctr) return sp->Files[sp->ctr - 1];
118
else return "<stdin>";