33 "Usage: %s [-Vv?] [-(GNEA)name=val] [-(KTlso)<val>] <dot files>\n";
36 -V - Print version and exit\n\
37 -v - Enable verbose mode \n\
38 -Gname=val - Set graph attribute 'name' to 'val'\n\
39 -Nname=val - Set node attribute 'name' to 'val'\n\
40 -Ename=val - Set edge attribute 'name' to 'val'\n\
41 -Aname=val - Set attribute 'name' to 'val' for graph, node, and edge\n\
42 -Tv - Set output format to 'v'\n\
43 -Kv - Set layout engine to 'v' (overrides default based on command name)\n\
44 -lv - Use external library 'v'\n\
45 -ofile - Write output to 'file'\n\
46 -O - Automatically generate an output filename based on the input filename with a .'format' appended. (Causes all -ofile options to be ignored.) \n\
47 -P - Internally generate a graph of the current plugins. \n\
48 -q[l] - Set level of message suppression (=1)\n\
49 -s[v] - Scale input by 'v' (=72)\n\
50 -y - Invert y coordinate in output\n";
53 "(additional options for neato) [-x] [-n<v>]\n";
55 -n[v] - No layout mode 'v' (=1)\n\
59 "(additional options for fdp) [-L(gO)] [-L(nUCT)<val>]\n";
61 -Lg - Don't use grid\n\
62 -LO - Use old attractive force\n\
63 -Ln<i> - Set number of iterations to i\n\
64 -LU<i> - Set unscaled factor to i\n\
65 -LC<v> - Set overlap expansion factor to v\n\
66 -LT[*]<v> - Set temperature (temperature factor) to v\n";
68static char *
configFlags =
"(additional options for config) [-cv]\n";
70 -c - Configure plugins (Writes $prefix/lib/graphviz/config \n\
71 with available plugin information. Needs write privilege.)\n\
72 -? - Print usage and exit\n";
117 if (*arg && *arg !=
'-') {
133 if (*
s ==
'\0')
return pathname;
140 char* dotp = strrchr (
s,
'.');
141 if (dotp && !strcasecmp(dotp+1,
"exe")) *dotp =
'\0';
147 while (
s > pathname && (*
s ==
'/' || *
s ==
'\\'))
149 if (
s == pathname) ret = pathname;
151 while (
s > pathname && *
s !=
'/' && *
s !=
'\\')
s--;
152 if (*
s ==
'/' || *
s ==
'\\') ret =
s+1;
165 static size_t cnt = 0;
167 const size_t old_nmemb =
cnt == 0 ?
cnt :
cnt + 1;
181 if ((p = strchr(dcl,
'='))) {
228 if (getenv(
"GV_FILE_PATH") !=
NULL) {
229 fprintf(stderr,
"$GV_FILE_PATH environment variable set; exiting\n"
231 "This sandboxing mechanism is no longer supported\n");
237 fprintf(stderr,
"%s - %s version %s (%s)\n",
256 for (
int i = 1; i < argc; i++)
257 if (argv[i] && argv[i][0] !=
'-')
261 for (
int i = 1; i < argc; i++) {
263 (
startswith(argv[i],
"-V") || strcmp(argv[i],
"--version") == 0)) {
264 fprintf(stderr,
"%s - %s version %s (%s)\n",
269 }
else if (argv[i] &&
270 (
startswith(argv[i],
"-?") || strcmp(argv[i],
"--help") == 0)) {
272 }
else if (argv[i] &&
startswith(argv[i],
"--filepath=")) {
275 }
else if (argv[i] && argv[i][0] ==
'-') {
276 char *
const rest = &argv[i][2];
277 switch (c = argv[i][1]) {
282 fprintf(stderr,
"Missing argument for -G flag\n");
290 fprintf(stderr,
"Missing argument for -N flag\n");
298 fprintf(stderr,
"Missing argument for -E flag\n");
308 fprintf(stderr,
"Missing argument for -A flag\n");
313 const char *
const val =
getFlagOpt(argc, argv, &i);
315 fprintf(stderr,
"Missing argument for -T flag\n");
320 fprintf(stderr,
"Format: \"%s\" not recognized.", val);
321 if (strlen(fmts) > 1) {
322 fprintf(stderr,
" Use one of:%s\n", fmts);
325 fprintf(stderr,
" No formats found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
333 const char *
const val =
getFlagOpt(argc, argv, &i);
335 fprintf(stderr,
"Missing argument for -K flag\n");
340 fprintf(stderr,
"There is no layout engine support for \"%s\"\n", val);
341 if (
streq(val,
"dot")) {
342 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
346 if (strlen(lyts) > 1) {
347 fprintf(stderr,
" Use one of:%s\n", lyts);
350 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
363 const char *
const val =
getFlagOpt(argc, argv, &i);
365 fprintf(stderr,
"Missing argument for -l flag\n");
372 const char *
const val =
getFlagOpt(argc, argv, &i);
374 fprintf(stderr,
"Missing argument for -o flag\n");
383 const int v = atoi(rest);
386 "Invalid parameter \"%s\" for -q flag - ignored\n",
400 "Invalid parameter \"%s\" for -s flag\n",
436 fprintf(stderr,
"There is no layout engine support for \"%s\"\n",
layout);
438 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
441 if (strlen(lyts) > 1) {
442 fprintf(stderr,
" Use one of:%s\n", lyts);
445 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
458 "Unable to find even the default \"-Tdot\" renderer. Has the config\nfile been generated by running \"dot -c\" with installer's privileges?\n");
480 if ((p =
agget(g, name))) {
481 i = sscanf(p,
"%lf,%lf%c", &xf, &yf, &c);
482 if (i > 1 && xf > 0 && yf > 0) {
490 i = sscanf(p,
"%lf%c", &xf, &c);
491 if (i > 0 && xf > 0) {
493 if (c ==
'!') rv =
true;
505 if ((p =
agget(g, name))) {
506 if (sscanf(p,
"%lf", &f) >= 1)
554 if (!strcasecmp(p,
"latin-1")
555 || !strcasecmp(p,
"latin1")
556 || !strcasecmp(p,
"l1")
557 || !strcasecmp(p,
"ISO-8859-1")
558 || !strcasecmp(p,
"ISO_8859-1")
559 || !strcasecmp(p,
"ISO8859-1")
560 || !strcasecmp(p,
"ISO-IR-100"))
562 if (!strcasecmp(p,
"big-5")
563 || !strcasecmp(p,
"big5"))
565 if (!strcasecmp(p,
"utf-8")
566 || !strcasecmp(p,
"utf8"))
568 agwarningf(
"Unsupported charset \"%s\" - assuming utf-8\n", p);
578 if ((p =
agget(g,
"ratio"))) {
579 if (
streq(p,
"auto")) {
581 }
else if (
streq(p,
"compress")) {
583 }
else if (
streq(p,
"expand")) {
585 }
else if (
streq(p,
"fill")) {
601 static char *rankname[] = {
"local",
"global",
"none",
NULL };
603 static char *fontnamenames[] = {
"gd",
"ps",
"svg",
NULL};
609 if ((p =
agget(g,
"postaction"))) {
617 if ((p =
agget(g,
"fontpath")) || (p = getenv(
"DOTFONTPATH"))) {
621 setenv(
"GDFONTPATH", p, 1);
649 if ((p =
agget(g,
"rankdir"))) {
652 else if (
streq(p,
"BT"))
654 else if (
streq(p,
"RL"))
668 if (sscanf(p,
"%lf", &xf) == 0)
674 if (strstr(p,
"equally"))
682 if (showboxes > UCHAR_MAX) {
683 showboxes = UCHAR_MAX;
696 if ((p =
agget(g,
"rotate")))
698 else if ((p =
agget(g,
"orientation")))
699 GD_drawing(g)->landscape = p[0] ==
'l' || p[0] ==
'L';
700 else if ((p =
agget(g,
"landscape")))
703 p =
agget(g,
"clusterrank");
705 p =
agget(g,
"concentrate");
711 if (((p =
agget(g,
"dpi")) && p[0])
712 || ((p =
agget(g,
"resolution")) && p[0]))
791 if ((p =
agget(g,
"id")) && *p)
826 agerrorf(
"Unsupported charset value %d\n", c);
836 char *
str, *pos, *just;
855 pos =
agget(sg,
"labelloc");
857 if (pos && pos[0] ==
'b')
862 if (pos && pos[0] ==
't')
867 just =
agget(sg,
"labeljust");
871 else if (just[0] ==
'r')
static void agxbfree(agxbuf *xb)
free any malloced resources
static size_t agxbput_n(agxbuf *xb, const char *s, size_t ssz)
append string s of length ssz into xb
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
static char * gv_strdup(const char *original)
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
char * late_nnstring(void *obj, attrsym_t *attr, char *defaultValue)
bool mapbool(const char *p)
char * late_string(void *obj, attrsym_t *attr, char *defaultValue)
int late_int(void *obj, attrsym_t *attr, int defaultValue, int minimum)
int maptoken(char *p, char **name, int *val)
double late_double(void *obj, attrsym_t *attr, double defaultValue, double minimum)
void * init_xdot(Agraph_t *g)
static NORETURN void graphviz_exit(int status)
Agsym_t * E_labelfontsize
Agsym_t * N_gradientangle
Agsym_t * G_gradientangle
Agsym_t * E_labelfontname
bool Y_invert
invert y in dot & plain output
Agsym_t * E_labelfontcolor
Agsym_t * E_labeldistance
static int cnt(Dict_t *d, Dtlink_t **set)
Agsym_t * agattr_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text attributes of a graph
char * agget(void *obj, char *name)
#define agfindedgeattr(g, a)
void agwarningf(const char *fmt,...)
void agerrorf(const char *fmt,...)
agerrlevel_t agseterr(agerrlevel_t lvl)
#define agfindgraphattr(g, a)
int agisdirected(Agraph_t *g)
Agraph_t * agconcat(Agraph_t *g, const char *filename, void *chan, Agdisc_t *disc)
merges the file contents with a pre-existing graph
Agraph_t * agmemconcat(Agraph_t *g, const char *cp)
#define GD_exact_ranksep(g)
#define agfindnodeattr(g, a)
Agraph_t * agroot(void *obj)
void agclean(Agraph_t *g, int kind, char *rec_name)
calls agdelrec for all objects of the same class in an entire graph
int aghtmlstr(const char *)
graph_t * gvNextInputGraph(GVC_t *gvc)
graph_t * gvPluginsGraph(GVC_t *gvc)
replacements for ctype.h functions
static void gv_tolower_str(char *s)
FILE * gv_fopen(const char *filename, const char *mode)
wrapper around fopen for internal library usage
Arithmetic helper functions.
static bool is_exactly_zero(double v)
is a value precisely 0.0?
Graphviz context library.
void gvconfig(GVC_t *gvc, bool rescan)
void gvjobs_output_filename(GVC_t *gvc, const char *name)
bool gvjobs_output_langname(GVC_t *gvc, const char *name)
int gvlayout_select(GVC_t *gvc, const char *str)
Agraph_t * gvplugin_graph(GVC_t *gvc)
char * gvplugin_list(GVC_t *gvc, api_t api, const char *str)
textitem scanner parser str
char * strdup_and_subst_obj(char *str, void *obj)
textlabel_t * make_label(void *obj, char *str, int kind, double fontsize, char *fontname, char *fontcolor)
void free_label(textlabel_t *p)
static int layout(graph_t *g, layout_info *infop)
static bool startswith(const char *s, const char *prefix)
does the string s begin with the string prefix?
platform abstraction for case-insensitive string functions
static bool streq(const char *a, const char *b)
are a and b equal?
Agraph_t * root
subgraphs - ancestors
const char * output_langname
#define SET_RANKDIR(g, rd)
parsing and deparsing of xdot operations