#ifndef WITH_CGRAPH
agedge(g, tp, hp);
#else /* WITH_CGRAPH */
- agbindrec(agedge(g, tp, hp, NULL, 1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+ agbindrec(agedge(g, tp, hp, NULL, 1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); // edge custom data
#endif /* WITH_CGRAPH */
DEGREE(tp)++;
agedge(g, tp, hp);
#else /* WITH_CGRAPH */
- agbindrec(agedge(g, tp, hp, NULL, 1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+ agbindrec(agedge(g, tp, hp, NULL, 1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); // edge custom data
#endif /* WITH_CGRAPH */
DEGREE(tp)++;
tl.str = ti->str;
tl.fontname = fname_;
tl.fontsize = fsize_;
+ tl.font = ti->font;
tl.yoffset_layout = ti->yoffset_layout;
/* tl.yoffset_centerline = ti->yoffset_centerline; */
tl.yoffset_centerline = 1;
if (!agfindedge(g, t, h)) {
#ifdef WITH_CGRAPH
e = agedge(g, t, h, NULL, 1);
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE);
#else
e = agedge(g, t, h);
#endif
for (i = 0; i <= tbl->cc; i++) {
#ifdef WITH_CGRAPH
t = agnode(colg, nToName(i),1);
+ agbindrec(t, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE);
#else
t = agnode(colg, nToName(i));
#endif
for (i = 0; i <= tbl->rc; i++) {
#ifdef WITH_CGRAPH
t = agnode(rowg, nToName(i),1);
+ agbindrec(t, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE);
#else
t = agnode(rowg, nToName(i));
#endif
h = agfindnode(colg, nToName(cp->col + cp->cspan));
#ifdef WITH_CGRAPH
e = agedge(colg, t, h, NULL, 1);
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE);
#else
e = agedge(colg, t, h);
#endif
h = agfindnode(rowg, nToName(cp->row + cp->rspan));
#ifdef WITH_CGRAPH
e = agedge(rowg, t, h, NULL, 1);
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE);
#else
e = agedge(rowg, t, h);
#endif
#else
rowg = agopen("rowg", AGDIGRAPH);
colg = agopen("colg", AGDIGRAPH);
+ /* Only need GD_nlist */
+ agbindrec(rowg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); // graph custom data
+ agbindrec(colg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); // graph custom data
#endif
makeGraphs(tbl, rowg, colg);
rank(rowg, 2, INT_MAX);
/* safefile:
* Check to make sure it is okay to read in files.
- * For normal uses, it is a no-op, and returns the input.
* It returns NULL if the filename is trivial.
*
* If the application has set the SERVER_NAME environment variable,
* If filename contains multiple components, the user is
* warned, once, that everything to the left is ignored.
*
+ * For non-server applications, we use the path list in Gvimagepath to
+ * resolve relative pathnames.
+ *
* N.B. safefile uses a fixed buffer, so functions using it should use the
* value immediately or make a copy.
*/
#ifdef WIN32
-#define DIRSEP "\\"
#define PATHSEP ";"
#else
-#define DIRSEP "/"
#define PATHSEP ":"
#endif
+static char** mkDirlist (const char* list, int* maxdirlen)
+{
+ int cnt = 0;
+ char* s = strdup (list);
+ char* dir;
+ char** dirs = NULL;
+ int maxlen = 0;
+
+ for (dir = strtok (s, PATHSEP); dir; dir = strtok (NULL, PATHSEP)) {
+ dirs = ALLOC (cnt+2,dirs,char*);
+ dirs[cnt++] = dir;
+ maxlen = MAX(maxlen, strlen (dir));
+ }
+ dirs[cnt] = NULL;
+ *maxdirlen = maxlen;
+ return dirs;
+}
+
+static char* findPath (char** dirs, int maxdirlen, const char* str)
+{
+ static char *safefilename = NULL;
+ char** dp;
+
+ /* allocate a buffer that we are sure is big enough
+ * +1 for null character.
+ * +1 for directory separator character.
+ */
+ safefilename = realloc(safefilename, (maxdirlen + strlen(str) + 2));
+
+ for (dp = dirs; *dp; dp++) {
+ sprintf (safefilename, "%s%s%s", *dp, DIRSEP, str);
+ if (access (safefilename, R_OK) == 0)
+ return safefilename;
+ }
+ return NULL;
+}
+
const char *safefile(const char *filename)
{
static boolean onetime = TRUE;
- static boolean firsttime = TRUE;
- static char *safefilename = NULL;
+ static char *pathlist = NULL;
static int maxdirlen;
static char** dirs;
- char** dp;
const char *str, *p;
if (!filename || !filename[0])
return NULL;
- if (HTTPServerEnVar) {
+
+ if (HTTPServerEnVar) { /* If used as a server */
/*
* If we are running in an http server we allow
* files only from the directory specified in
}
return NULL;
}
- if (firsttime) {
- int cnt = 0;
- char* s = strdup (Gvfilepath);
- char* dir;
- for (dir = strtok (s, PATHSEP); dir; dir = strtok (NULL, PATHSEP)) {
- dirs = ALLOC (cnt+2,dirs,char*);
- dirs[cnt++] = dir;
- maxdirlen = MAX(maxdirlen, strlen (dir));
- }
- dirs[cnt] = NULL;
- firsttime = FALSE;
+ if (!pathlist) {
+ dirs = mkDirlist (Gvfilepath, &maxdirlen);
+ pathlist = Gvfilepath;
}
str = filename;
onetime = FALSE;
}
- /* allocate a buffer that we are sure is big enough
- * +1 for null character.
- * +1 for directory separator character.
- */
- safefilename = realloc(safefilename,
- (maxdirlen + strlen(str) + 2));
+ return findPath (dirs, maxdirlen, str);
+ }
- for (dp = dirs; *dp; dp++) {
- sprintf (safefilename, "%s%s%s", *dp, DIRSEP, str);
- if (access (safefilename, R_OK) == 0)
- return safefilename;
+ if (pathlist != Gvimagepath) {
+ if (dirs) {
+ free (dirs[0]);
+ free (dirs);
+ dirs = NULL;
}
- return NULL;
+ pathlist = Gvimagepath;
+ if (pathlist && *pathlist)
+ dirs = mkDirlist (pathlist, &maxdirlen);
}
- /* else, not in server, use original filename without modification. */
- else
+
+ if ((*filename == DIRSEP[0]) || !dirs)
return filename;
+
+ return findPath (dirs, maxdirlen, filename);
}
int maptoken(char *p, char **name, int *val)
edge_t *ce = agedge(g, ct, ch);
#else /* WITH_CGRAPH */
edge_t *ce = agedge(g, ct, ch,NULL,1);
+ agbindrec(ce, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE);
#endif /* WITH_CGRAPH */
agcopyattr(e, ce);
ce = agedge(cg, t, h);
#else
ce = agedge(cg, t, h, NULL, 1);
+ agbindrec(ce, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE);
#endif
ED_weight(ce) = 1;
if (ED_minlen(ce) < delta) {
graph_t *cg = agopen("cg", AGDIGRAPHSTRICT);
#else
graph_t *cg = agopen("cg", Agstrictdirected, NIL(Agdisc_t *));
+ agbindrec(cg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); // graph custom data
#endif
node_t *n;
edge_t *e;
e = agedge(cg, p->cnode, nxp->cnode);
#else
e = agedge(cg, p->cnode, nxp->cnode, NULL, 1);
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); // edge custom data
#endif
assert (delta <= 0xFFFF);
ED_minlen(e) = delta;
graph_t *cg = agopen("cg", AGDIGRAPHSTRICT);
#else
graph_t *cg = agopen("cg", Agstrictdirected, NIL(Agdisc_t *));
+ agbindrec(cg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); // graph custom data
#endif
graph_t *vg;
node_t *prev = NULL;
e = agedge(cg, prev, n);
#else
e = agedge(cg, prev, n, NULL, 1);
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); // edge custom data
#endif
ED_minlen(e) = SCALE;
ED_weight(e) = 1;
#ifndef WITH_CGRAPH
n = agnode(vg, agnameof(p->np)); /* FIX */
#else
- n = agnode(cg, agnameof(p->np), 1); /* FIX */
- agbindrec(cg, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
-
+ n = agnode(vg, agnameof(p->np), 1); /* FIX */
+ agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
#endif
p->vnode = n;
ND_alg(n) = p;
elist_append(e, ND_out(n));
elist_append(e, ND_in(vn));
}
-#endif
+#endif /* OLD */
return cg;
}
}
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
+#ifdef WITH_CGRAPH
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //edge custom data
+#endif /* WITH_CGRAPH */
common_init_edge(e);
}
}
#ifdef WITH_CGRAPH
for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
if (!strncmp(agnameof(subg), "cluster", 7)) {
+ agbindrec(g, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE);
do_graph_label (subg);
addCluster(clist, subg);
mkClusters(subg, NULL, subg);
for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
#endif /* WITH_CGRAPH */
if (!strncmp(agnameof(subg), "cluster", 7)) {
+ agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE);
#ifdef FDP_GEN
GD_alg(subg) = (void *) NEW(gdata); /* freed in cleanup_subgs */
GD_ndim(subg) = GD_ndim(parent);
GD_neato_nlist(g) = N_NEW(agnnodes(g) + 1, node_t *);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+#ifdef WITH_CGRAPH
+ agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); // node custom data
+#endif /* WITH_CGRAPH */
ND_alg(n) = alg + i;
GD_neato_nlist(g)[i++] = n;
patchwork_init_node(n);
static void sfdp_init_edge(edge_t * e)
{
+#ifdef WITH_CGRAPH
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
common_init_edge(e);
}
static void twopi_init_edge(edge_t * e)
{
#ifdef WITH_CGRAPH
- agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //edge custom data
#endif /* WITH_CGRAPH */
common_init_edge(e);
ED_factor(e) = late_double(e, E_weight, 1.0, 0.0);