33 "Usage: %s [-Vv?] [-(GNE)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 -Tv - Set output format to 'v'\n\
42 -Kv - Set layout engine to 'v' (overrides default based on command name)\n\
43 -lv - Use external library 'v'\n\
44 -ofile - Write output to 'file'\n\
45 -O - Automatically generate an output filename based on the input filename with a .'format' appended. (Causes all -ofile options to be ignored.) \n\
46 -P - Internally generate a graph of the current plugins. \n\
47 -q[l] - Set level of message suppression (=1)\n\
48 -s[v] - Scale input by 'v' (=72)\n\
49 -y - Invert y coordinate in output\n";
52 "(additional options for neato) [-x] [-n<v>]\n";
54 -n[v] - No layout mode 'v' (=1)\n\
58 "(additional options for fdp) [-L(gO)] [-L(nUCT)<val>]\n";
60 -Lg - Don't use grid\n\
61 -LO - Use old attractive force\n\
62 -Ln<i> - Set number of iterations to i\n\
63 -LU<i> - Set unscaled factor to i\n\
64 -LC<v> - Set overlap expansion factor to v\n\
65 -LT[*]<v> - Set temperature (temperature factor) to v\n";
67static char *
configFlags =
"(additional options for config) [-cv]\n";
69 -c - Configure plugins (Writes $prefix/lib/graphviz/config \n\
70 with available plugin information. Needs write privilege.)\n\
71 -? - Print usage and exit\n";
116 if (*arg && *arg !=
'-') {
132 if (*
s ==
'\0')
return pathname;
139 char* dotp = strrchr (
s,
'.');
140 if (dotp && !strcasecmp(dotp+1,
"exe")) *dotp =
'\0';
146 while (
s > pathname && (*
s ==
'/' || *
s ==
'\\'))
148 if (
s == pathname) ret = pathname;
150 while (
s > pathname && *
s !=
'/' && *
s !=
'\\')
s--;
151 if (*
s ==
'/' || *
s ==
'\\') ret =
s+1;
164 static size_t cnt = 0;
166 const size_t old_nmemb =
cnt == 0 ?
cnt :
cnt + 1;
180 if ((p = strchr(dcl,
'='))) {
229 if (getenv(
"GV_FILE_PATH") !=
NULL) {
230 fprintf(stderr,
"$GV_FILE_PATH environment variable set; exiting\n"
232 "This sandboxing mechanism is no longer supported\n");
238 fprintf(stderr,
"%s - %s version %s (%s)\n",
257 for (i = 1; i < argc; i++)
258 if (argv[i] && argv[i][0] !=
'-')
262 for (i = 1; i < argc; i++) {
264 (
startswith(argv[i],
"-V") || strcmp(argv[i],
"--version") == 0)) {
265 fprintf(stderr,
"%s - %s version %s (%s)\n",
270 }
else if (argv[i] &&
271 (
startswith(argv[i],
"-?") || strcmp(argv[i],
"--help") == 0)) {
273 }
else if (argv[i] &&
startswith(argv[i],
"--filepath=")) {
276 }
else if (argv[i] && argv[i][0] ==
'-') {
278 switch (c = argv[i][1]) {
283 fprintf(stderr,
"Missing argument for -G flag\n");
291 fprintf(stderr,
"Missing argument for -N flag\n");
299 fprintf(stderr,
"Missing argument for -E flag\n");
306 fprintf(stderr,
"Missing argument for -T flag\n");
311 fprintf(stderr,
"Format: \"%s\" not recognized.", val);
312 if (strlen(fmts) > 1) {
313 fprintf(stderr,
" Use one of:%s\n", fmts);
316 fprintf(stderr,
" No formats found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
325 fprintf(stderr,
"Missing argument for -K flag\n");
330 fprintf(stderr,
"There is no layout engine support for \"%s\"\n", val);
331 if (
streq(val,
"dot")) {
332 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
336 if (strlen(lyts) > 1) {
337 fprintf(stderr,
" Use one of:%s\n", lyts);
340 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
354 fprintf(stderr,
"Missing argument for -l flag\n");
362 fprintf(stderr,
"Missing argument for -o flag\n");
373 "Invalid parameter \"%s\" for -q flag - ignored\n",
387 "Invalid parameter \"%s\" for -s flag\n",
423 fprintf(stderr,
"There is no layout engine support for \"%s\"\n",
layout);
425 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
431 if (strlen(lyts) > 1) {
432 fprintf(stderr,
" Use one of:%s\n", lyts);
435 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
448 "Unable to find even the default \"-Tdot\" renderer. Has the config\nfile been generated by running \"dot -c\" with installer's privileges?\n");
470 if ((p =
agget(g, name))) {
471 i = sscanf(p,
"%lf,%lf%c", &xf, &yf, &c);
472 if (i > 1 && xf > 0 && yf > 0) {
480 i = sscanf(p,
"%lf%c", &xf, &c);
481 if (i > 0 && xf > 0) {
483 if (c ==
'!') rv =
true;
495 if ((p =
agget(g, name))) {
496 if (sscanf(p,
"%lf", &f) >= 1)
549 if (!strcasecmp(p,
"latin-1")
550 || !strcasecmp(p,
"latin1")
551 || !strcasecmp(p,
"l1")
552 || !strcasecmp(p,
"ISO-8859-1")
553 || !strcasecmp(p,
"ISO_8859-1")
554 || !strcasecmp(p,
"ISO8859-1")
555 || !strcasecmp(p,
"ISO-IR-100"))
557 if (!strcasecmp(p,
"big-5")
558 || !strcasecmp(p,
"big5"))
560 if (!strcasecmp(p,
"utf-8")
561 || !strcasecmp(p,
"utf8"))
563 agwarningf(
"Unsupported charset \"%s\" - assuming utf-8\n", p);
573 if ((p =
agget(g,
"ratio"))) {
574 if (
streq(p,
"auto")) {
576 }
else if (
streq(p,
"compress")) {
578 }
else if (
streq(p,
"expand")) {
580 }
else if (
streq(p,
"fill")) {
596 static char *rankname[] = {
"local",
"global",
"none",
NULL };
598 static char *fontnamenames[] = {
"gd",
"ps",
"svg",
NULL};
604 if ((p =
agget(g,
"postaction"))) {
612 if ((p =
agget(g,
"fontpath")) || (p = getenv(
"DOTFONTPATH"))) {
616 setenv(
"GDFONTPATH", p, 1);
644 if ((p =
agget(g,
"rankdir"))) {
647 else if (
streq(p,
"BT"))
649 else if (
streq(p,
"RL"))
663 if (sscanf(p,
"%lf", &xf) == 0)
669 if (strstr(p,
"equally"))
677 if (showboxes > UCHAR_MAX) {
678 showboxes = UCHAR_MAX;
691 if ((p =
agget(g,
"rotate")))
693 else if ((p =
agget(g,
"orientation")))
694 GD_drawing(g)->landscape = p[0] ==
'l' || p[0] ==
'L';
695 else if ((p =
agget(g,
"landscape")))
698 p =
agget(g,
"clusterrank");
700 p =
agget(g,
"concentrate");
706 if (((p =
agget(g,
"dpi")) && p[0])
707 || ((p =
agget(g,
"resolution")) && p[0]))
786 if ((p =
agget(g,
"id")) && *p)
821 agerrorf(
"Unsupported charset value %d\n", c);
831 char *
str, *pos, *just;
850 pos =
agget(sg,
"labelloc");
852 if (pos && pos[0] ==
'b')
857 if (pos && pos[0] ==
't')
862 just =
agget(sg,
"labeljust");
866 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(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up 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 * agmemconcat(Agraph_t *g, const char *cp)
void agsetfile(const char *)
sets the current file name for subsequent error reporting
Agraph_t * agread(void *chan, Agdisc_t *disc)
constructs a new graph
#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