#include "convert.h"
#include <cgraph/exit.h>
#include <ingraphs/ingraphs.h>
+#include "openFile.h"
typedef enum { Unset, ToGV, ToGXL } mode;
}
#endif
-static FILE *openFile(const char *name)
-{
- FILE *fp;
-
- fp = fopen(name, "w");
- if (!fp) {
- fprintf(stderr, "%s: could not open file %s for writing\n", CmdName, name);
- perror(name);
- graphviz_exit(1);
- }
- return fp;
-}
-
static const char *use = "Usage: %s [-gd?] [-o<file>] [<graphs>]\n\
-g : convert to GXL\n\
-d : convert to GV\n\
case 'o':
if (outFile != NULL)
fclose(outFile);
- outFile = openFile(optarg);
+ outFile = openFile(CmdName, optarg, "w");
break;
case ':':
fprintf(stderr, "%s: option -%c missing argument\n", CmdName, optopt);