-/*
-
-but here i am, on the road again
-here i am, up on the stage
-here i go, playing the star again
-there i go, turn the page
-
-*/
-
/*default line width */
view->LineWidth =
(float) atof(get_attribute_value("defaultlinewidth", view, g));
}
/* create_xdot_for_graph:
- * Returns (malloced) temp filename for output data
+ * Returns temp filename for output data
* or NULL on error.
- * Calling program needs to remove file and free storage:
+ * Calling program needs to remove file :
* fname = create_xdot_for_graph (...)
* ... use fname ...
* unlink (fname);
- * free (fname);
+ * Uses the mkTemp function to get temp names.
+ * N.B. The returned file name is a static buffer.
+ *
*/
#define FMT "%s%s -Txdot%s %s -o%s"
+#ifdef WIN32
+#define DOTTEMP "c:\\tmp\\_dotXXXXXX"
+#define XDOTTEMP "c:\\tmp\\_xdotXXXXXX"
+
+#define mkTemp(b,s) (_mktemp_s(b,s))
+
+#else
+#define DOTTEMP "/tmp/_dotXXXXXX"
+#define XDOTTEMP "/tmp/_xdotXXXXXX"
+
+/* mkTemp:
+ * Given a template string buf of the form abcdXXXXX,
+ * and its size bufsz, replace the X's by characters creating
+ * a unique file name.
+ * Return 0 on success, non-zero on failure.
+ */
+static int
+mkTemp (char* buf, size_t bufsz)
+{
+ int rv = mkstemp (buf);
+ if (rv < 0) return -1;
+ else {
+ close (rv);
+ return 0;
+ }
+}
+
+#endif
+
static char* create_xdot_for_graph(Agraph_t * graph, int keeppos)
{
static char buf[BUFSIZ];
int len;
int r = 0;
FILE *output_file;
- char* dotfile;
- char* xdotfile;
char* fix;
char* alg;
char* path;
+ static char xdotfile[sizeof(XDOTTEMP)];
+ char dotfile[sizeof(DOTTEMP)];
+
/* The accesses below and in update_graph_params are only valid if
* custom_graph_data has been attached to the graph.
*/
if (haveData)
update_graph_params(graph);
- if (!(dotfile = tempnam(0,"_dot"))) return 0;
- if (!(xdotfile = tempnam(0,"_xdot"))) {
- free (dotfile);
- return 0;
- }
+ strcpy (dotfile, DOTTEMP);
+ if (mkTemp(dotfile, sizeof(dotfile))) return 0;
+ strcpy (xdotfile, XDOTTEMP);
+ if (mkTemp(xdotfile, sizeof(xdotfile))) return 0;
if (!(output_file = fopen(dotfile, "w"))) {
- free (xdotfile);
- free (dotfile);
return 0;
}
alg = " -Kcirco";
break;
case GVK_FDP :
- alg = " -Kfdp";
+ alg = " -Ksfdp";
break;
case GVK_SFDP :
alg = " -Ksfdp";
else cmd = RALLOC (buflen, cmd, char);
}
sprintf (cmd, FMT, path, fix, alg, dotfile, xdotfile);
- r = system (cmd);
+ r = system (cmd);
unlink (dotfile);
- free (dotfile);
if (r) { // something went wrong
unlink (xdotfile);
- free (xdotfile);
return 0;
}
else
- {
- return xdotfile;
-
- }
+ return xdotfile;
}
/*
g_print ("xdot is being loaded\n");
fclose (input_file);
unlink (infile); // Remove temp file
- free (infile); // Free storage for temp file name
return newg;
}
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "diffimg", "contrib\diffimg\diffimg.vcproj", "{89ED80CE-5DEF-46B1-9A12-1D991236EE3E}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fc-fix", "windows\cmd\fc-fix\fc-fix.vcproj", "{0DEA6915-263C-4570-B25C-E0A449894D45}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glcomp", "lib\glcomp\glcomp.vcproj", "{CCEF85C9-BC40-4C26-8755-581276C8B7DA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xdot", "lib\xdot\xdot.vcproj", "{C99C1195-2032-408B-9822-F09F49006A3C}"
{89ED80CE-5DEF-46B1-9A12-1D991236EE3E}.Debug|Win32.Build.0 = Debug|Win32
{89ED80CE-5DEF-46B1-9A12-1D991236EE3E}.Release|Win32.ActiveCfg = Release|Win32
{89ED80CE-5DEF-46B1-9A12-1D991236EE3E}.Release|Win32.Build.0 = Release|Win32
- {0DEA6915-263C-4570-B25C-E0A449894D45}.Debug|Win32.ActiveCfg = Debug|Win32
- {0DEA6915-263C-4570-B25C-E0A449894D45}.Debug|Win32.Build.0 = Debug|Win32
- {0DEA6915-263C-4570-B25C-E0A449894D45}.Release|Win32.ActiveCfg = Release|Win32
- {0DEA6915-263C-4570-B25C-E0A449894D45}.Release|Win32.Build.0 = Release|Win32
{CCEF85C9-BC40-4C26-8755-581276C8B7DA}.Debug|Win32.ActiveCfg = Debug|Win32
{CCEF85C9-BC40-4C26-8755-581276C8B7DA}.Debug|Win32.Build.0 = Debug|Win32
{CCEF85C9-BC40-4C26-8755-581276C8B7DA}.Release|Win32.ActiveCfg = Release|Win32