35 "Usage: %s [-Vv?] [-(GNEA)name=val] [-(KTlso)<val>] <dot files>\n";
38 -V - Print version and exit\n\
39 -v - Enable verbose mode \n\
40 -Gname=val - Set graph attribute 'name' to 'val'\n\
41 -Nname=val - Set node attribute 'name' to 'val'\n\
42 -Ename=val - Set edge attribute 'name' to 'val'\n\
43 -Aname=val - Set attribute 'name' to 'val' for graph, node, and edge\n\
44 -Tv - Set output format to 'v'\n\
45 -Kv - Set layout engine to 'v' (overrides default based on command name)\n\
46 -lv - Use external library 'v'\n\
47 -ofile - Write output to 'file'\n\
48 -O - Automatically generate an output filename based on the input filename with a .'format' appended. (Causes all -ofile options to be ignored.) \n\
49 -P - Internally generate a graph of the current plugins. \n\
50 -q[l] - Set level of message suppression (=1)\n\
51 -s[v] - Scale input by 'v' (=72)\n\
52 -y - Invert y coordinate in output\n";
55 "(additional options for neato) [-x] [-n<v>]\n";
57 -n[v] - No layout mode 'v' (=1)\n\
61 "(additional options for fdp) [-L(gO)] [-L(nUCT)<val>]\n";
63 -Lg - Don't use grid\n\
64 -LO - Use old attractive force\n\
65 -Ln<i> - Set number of iterations to i\n\
66 -LU<i> - Set unscaled factor to i\n\
67 -LC<v> - Set overlap expansion factor to v\n\
68 -LT[*]<v> - Set temperature (temperature factor) to v\n";
70static char *
configFlags =
"(additional options for config) [-cv]\n";
72 -c - Configure plugins (Writes $prefix/lib/graphviz/config \n\
73 with available plugin information. Needs write privilege.)\n\
74 -? - Print usage and exit\n";
119 if (*arg && *arg !=
'-') {
135 if (*
s ==
'\0')
return pathname;
142 char* dotp = strrchr (
s,
'.');
143 if (dotp && !strcasecmp(dotp+1,
"exe")) *dotp =
'\0';
149 while (
s > pathname && (*
s ==
'/' || *
s ==
'\\'))
151 if (
s == pathname) ret = pathname;
153 while (
s > pathname && *
s !=
'/' && *
s !=
'\\')
s--;
154 if (*
s ==
'/' || *
s ==
'\\') ret =
s+1;
167 static size_t cnt = 0;
169 const size_t old_nmemb =
cnt == 0 ?
cnt :
cnt + 1;
183 if ((p = strchr(dcl,
'='))) {
230 if (getenv(
"GV_FILE_PATH") !=
NULL) {
231 fprintf(stderr,
"$GV_FILE_PATH environment variable set; exiting\n"
233 "This sandboxing mechanism is no longer supported\n");
239 fprintf(stderr,
"%s - %s version %s (%s)\n",
258 for (
int i = 1; i < argc; i++)
259 if (argv[i] && argv[i][0] !=
'-')
263 for (
int i = 1; i < argc; i++) {
265 (
startswith(argv[i],
"-V") || strcmp(argv[i],
"--version") == 0)) {
266 fprintf(stderr,
"%s - %s version %s (%s)\n",
271 }
else if (argv[i] &&
272 (
startswith(argv[i],
"-?") || strcmp(argv[i],
"--help") == 0)) {
274 }
else if (argv[i] &&
startswith(argv[i],
"--filepath=")) {
277 }
else if (argv[i] && argv[i][0] ==
'-') {
278 char *
const rest = &argv[i][2];
279 switch (c = argv[i][1]) {
284 fprintf(stderr,
"Missing argument for -G flag\n");
292 fprintf(stderr,
"Missing argument for -N flag\n");
300 fprintf(stderr,
"Missing argument for -E flag\n");
310 fprintf(stderr,
"Missing argument for -A flag\n");
315 const char *
const val =
getFlagOpt(argc, argv, &i);
317 fprintf(stderr,
"Missing argument for -T flag\n");
322 fprintf(stderr,
"Format: \"%s\" not recognized.", val);
323 if (strlen(fmts) > 1) {
324 fprintf(stderr,
" Use one of:%s\n", fmts);
327 fprintf(stderr,
" No formats found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
335 const char *
const val =
getFlagOpt(argc, argv, &i);
337 fprintf(stderr,
"Missing argument for -K flag\n");
342 fprintf(stderr,
"There is no layout engine support for \"%s\"\n", val);
343 if (
streq(val,
"dot")) {
344 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
348 if (strlen(lyts) > 1) {
349 fprintf(stderr,
" Use one of:%s\n", lyts);
352 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
365 const char *
const val =
getFlagOpt(argc, argv, &i);
367 fprintf(stderr,
"Missing argument for -l flag\n");
374 const char *
const val =
getFlagOpt(argc, argv, &i);
376 fprintf(stderr,
"Missing argument for -o flag\n");
385 const int v = atoi(rest);
388 "Invalid parameter \"%s\" for -q flag - ignored\n",
402 "Invalid parameter \"%s\" for -s flag\n",
438 fprintf(stderr,
"There is no layout engine support for \"%s\"\n",
layout);
440 fprintf(stderr,
"Perhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
443 if (strlen(lyts) > 1) {
444 fprintf(stderr,
" Use one of:%s\n", lyts);
447 fprintf(stderr,
" No layouts found.\nPerhaps \"dot -c\" needs to be run (with installer's privileges) to register the plugins?\n");
460 "Unable to find even the default \"-Tdot\" renderer. Has the config\nfile been generated by running \"dot -c\" with installer's privileges?\n");
482 if ((p =
agget(g, name))) {
483 i = sscanf(p,
"%lf,%lf%c", &xf, &yf, &c);
484 if (i > 1 && xf > 0 && yf > 0) {
492 i = sscanf(p,
"%lf%c", &xf, &c);
493 if (i > 0 && xf > 0) {
495 if (c ==
'!') rv =
true;
507 if ((p =
agget(g, name))) {
508 if (sscanf(p,
"%lf", &f) >= 1)
556 if (!strcasecmp(p,
"latin-1")
557 || !strcasecmp(p,
"latin1")
558 || !strcasecmp(p,
"l1")
559 || !strcasecmp(p,
"ISO-8859-1")
560 || !strcasecmp(p,
"ISO_8859-1")
561 || !strcasecmp(p,
"ISO8859-1")
562 || !strcasecmp(p,
"ISO-IR-100"))
564 if (!strcasecmp(p,
"big-5")
565 || !strcasecmp(p,
"big5"))
567 if (!strcasecmp(p,
"utf-8")
568 || !strcasecmp(p,
"utf8"))
570 agwarningf(
"Unsupported charset \"%s\" - assuming utf-8\n", p);
580 if ((p =
agget(g,
"ratio"))) {
581 if (
streq(p,
"auto")) {
583 }
else if (
streq(p,
"compress")) {
585 }
else if (
streq(p,
"expand")) {
587 }
else if (
streq(p,
"fill")) {
603 static char *rankname[] = {
"local",
"global",
"none",
NULL };
605 static char *fontnamenames[] = {
"gd",
"ps",
"svg",
NULL};
611 if ((p =
agget(g,
"postaction"))) {
619 if ((p =
agget(g,
"fontpath")) || (p = getenv(
"DOTFONTPATH"))) {
623 setenv(
"GDFONTPATH", p, 1);
651 if ((p =
agget(g,
"rankdir"))) {
654 else if (
streq(p,
"BT"))
656 else if (
streq(p,
"RL"))
670 if (sscanf(p,
"%lf", &xf) == 0)
676 if (strstr(p,
"equally"))
684 if (showboxes > UCHAR_MAX) {
685 showboxes = UCHAR_MAX;
698 if ((p =
agget(g,
"rotate")))
700 else if ((p =
agget(g,
"orientation")))
701 GD_drawing(g)->landscape = p[0] ==
'l' || p[0] ==
'L';
702 else if ((p =
agget(g,
"landscape")))
705 p =
agget(g,
"clusterrank");
707 p =
agget(g,
"concentrate");
794 if ((p =
agget(g,
"id")) && *p)
829 agerrorf(
"Unsupported charset value %d\n", c);
839 char *
str, *pos, *just;
858 pos =
agget(sg,
"labelloc");
860 if (pos && pos[0] ==
'b')
865 if (pos && pos[0] ==
't')
870 just =
agget(sg,
"labeljust");
874 else if (just[0] ==
'r')
Dynamically expanding string buffers.
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)
Processes graph object escape sequences; also collapses \ to .
textlabel_t * make_label(void *obj, char *str, bool is_html, bool is_record, 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