]> git.saurik.com Git - bison.git/blame - src/vcg.c
Change @dircategory from "GNU programming tools" to "Software development".
[bison.git] / src / vcg.c
CommitLineData
ce4d5ce0 1/* VCG description handler for Bison.
4613f49b 2
a737b216 3 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
ce4d5ce0
AD
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
7 Bison is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 Bison is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Bison; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include "system.h"
17ee7397
PE
23
24#include <quotearg.h>
25
ce4d5ce0
AD
26#include "vcg.h"
27#include "vcg_defaults.h"
08a946e0 28
e5fb6710
AD
29/* Return an unambiguous printable representated, for NAME, suitable
30 for C strings. Use slot 2 since the user may use slots 0 and 1.
31 */
32
08a946e0
AD
33static char const *
34quote (char const *name)
35{
e5fb6710 36 return quotearg_n_style (2, c_quoting_style, name);
08a946e0
AD
37}
38
ce4d5ce0
AD
39
40/* Initialize a graph with the default values. */
41void
17ee7397 42new_graph (graph *g)
ce4d5ce0
AD
43{
44 g->title = G_TITLE;
45 g->label = G_LABEL;
3e3da797 46
ce4d5ce0
AD
47 g->infos[0] = G_INFOS1;
48 g->infos[1] = G_INFOS2;
49 g->infos[2] = G_INFOS3;
3e3da797 50
ce4d5ce0
AD
51 g->color = G_COLOR;
52 g->textcolor = G_TEXTCOLOR;
53 g->bordercolor = G_BORDERCOLOR;
3e3da797 54
ce4d5ce0
AD
55 g->width = G_WIDTH;
56 g->height = G_HEIGHT;
57 g->borderwidth = G_BORDERWIDTH;
58 g->x = G_X;
59 g->y = G_Y;
60 g->folding = G_FOLDING;
61 g->shrink = G_SHRINK;
ea193b9d 62 g->stretch = G_STRETCH;
ce4d5ce0
AD
63
64 g->textmode = G_TEXTMODE;
65 g->shape = G_SHAPE;
3e3da797 66
342b8b6e
AD
67 g->vertical_order = G_VERTICAL_ORDER;
68 g->horizontal_order = G_HORIZONTAL_ORDER;
69
ce4d5ce0
AD
70 g->xmax = G_XMAX; /* Not output. */
71 g->ymax = G_YMAX; /* Not output. */
3e3da797 72
ce4d5ce0
AD
73 g->xbase = G_XBASE;
74 g->ybase = G_YBASE;
75
76 g->xspace = G_XSPACE;
77 g->yspace = G_YSPACE;
78 g->xlspace = G_XLSPACE; /* Not output. */
3e3da797 79
ce4d5ce0
AD
80 g->xraster = G_XRASTER;
81 g->yraster = G_YRASTER;
82 g->xlraster = G_XLRASTER;
83
84 g->hidden = G_HIDDEN; /* No default value. */
85
86 g->classname = G_CLASSNAME; /* No class name association. */
3e3da797 87
ce4d5ce0
AD
88 g->layout_downfactor = G_LAYOUT_DOWNFACTOR;
89 g->layout_upfactor = G_LAYOUT_UPFACTOR;
90 g->layout_nearfactor = G_LAYOUT_NEARFACTOR;
91 g->layout_splinefactor = G_LAYOUT_SPLINEFACTOR;
3e3da797 92
ce4d5ce0
AD
93 g->late_edge_labels = G_LATE_EDGE_LABELS;
94 g->display_edge_labels = G_DISPLAY_EDGE_LABELS;
95 g->dirty_edge_labels = G_DIRTY_EDGE_LABELS;
96 g->finetuning = G_FINETUNING;
97 g->ignore_singles = G_IGNORE_SINGLES;
ce4d5ce0
AD
98 g->priority_phase = G_PRIORITY_PHASE;
99 g->manhattan_edges = G_MANHATTAN_EDGES;
100 g->smanhattan_edges = G_SMANHATTAN_EDGES;
101 g->near_edges = G_NEAR_EDGES;
3e3da797 102
ce4d5ce0 103 g->orientation = G_ORIENTATION;
17ee7397 104 g->node_alignment = G_NODE_ALIGNMENT;
ce4d5ce0
AD
105 g->port_sharing = G_PORT_SHARING;
106 g->arrow_mode = G_ARROW_MODE;
107 g->treefactor = G_TREEFACTOR;
108 g->spreadlevel = G_SPREADLEVEL;
109 g->crossing_weight = G_CROSSING_WEIGHT;
110 g->crossing_phase2 = G_CROSSING_PHASE2;
111 g->crossing_optimization = G_CROSSING_OPTIMIZATION;
112 g->view = G_VIEW;
113
114 g->edges = G_EDGES;
115 g->nodes = G_NODES;
116 g->splines = G_SPLINES;
117
118 g->bmax = G_BMAX;
119 g->cmin = G_CMIN;
120 g->cmax = G_CMAX;
121 g->pmin = G_PMIN;
122 g->pmax = G_PMAX;
123 g->rmin = G_RMIN;
124 g->rmax = G_RMAX;
125 g->smax = G_SMAX;
3e3da797 126
ce4d5ce0
AD
127 g->node_list = G_NODE_LIST;
128 g->edge_list = G_EDGE_LIST;
3e3da797 129
17ee7397
PE
130 new_edge (&g->edge);
131 new_node (&g->node);
ce4d5ce0
AD
132}
133
17ee7397 134/* Initialize a node with the default values. */
ce4d5ce0 135void
17ee7397 136new_node (node *n)
ce4d5ce0 137{
17ee7397
PE
138 n->title = N_TITLE;
139 n->label = N_LABEL;
3e3da797 140
17ee7397
PE
141 n->locx = N_LOCX; /* Default unspcified. */
142 n->locy = N_LOCY; /* Default unspcified. */
3e3da797 143
17ee7397
PE
144 n->vertical_order = N_VERTICAL_ORDER; /* Default unspcified. */
145 n->horizontal_order = N_HORIZONTAL_ORDER; /* Default unspcified. */
3e3da797 146
17ee7397
PE
147 n->width = N_WIDTH; /* We assume that we can't define it now. */
148 n->height = N_HEIGHT; /* Also. */
3e3da797 149
17ee7397 150 n->shrink = N_SHRINK;
ea193b9d 151 n->stretch = N_STRETCH;
3e3da797 152
17ee7397 153 n->folding = N_FOLDING; /* No explicit default value. */
3e3da797 154
17ee7397
PE
155 n->shape = N_SHAPE;
156 n->textmode = N_TEXTMODE;
157 n->borderwidth = N_BORDERWIDTH;
3e3da797 158
17ee7397
PE
159 n->color = N_COLOR;
160 n->textcolor = N_TEXTCOLOR;
161 n->bordercolor = N_BORDERCOLOR;
3e3da797 162
17ee7397
PE
163 n->infos[0] = N_INFOS1;
164 n->infos[1] = N_INFOS2;
165 n->infos[2] = N_INFOS3;
3e3da797 166
17ee7397 167 n->next = N_NEXT;
ce4d5ce0
AD
168}
169
17ee7397 170/* Initialize an edge with the default values. */
ce4d5ce0 171void
17ee7397 172new_edge (edge *e)
ce4d5ce0 173{
17ee7397 174 e->type = E_EDGE_TYPE;
ce4d5ce0 175
17ee7397
PE
176 e->sourcename = E_SOURCENAME;
177 e->targetname = E_TARGETNAME;
178 e->label = E_LABEL;
ce4d5ce0 179
17ee7397
PE
180 e->linestyle = E_LINESTYLE;
181 e->thickness = E_THICKNESS;
ce4d5ce0 182
17ee7397 183 e->class = E_CLASS;
ce4d5ce0 184
17ee7397
PE
185 e->color = E_COLOR;
186 e->textcolor = E_TEXTCOLOR;
187 e->arrowcolor = E_ARROWCOLOR;
188 e->backarrowcolor = E_BACKARROWCOLOR;
ce4d5ce0 189
17ee7397
PE
190 e->arrowsize = E_ARROWSIZE;
191 e->backarrowsize = E_BACKARROWSIZE;
192 e->arrowstyle = E_ARROWSTYLE;
ce4d5ce0 193
17ee7397 194 e->backarrowstyle = E_BACKARROWSTYLE;
ce4d5ce0 195
17ee7397 196 e->priority = E_PRIORITY;
ce4d5ce0 197
17ee7397 198 e->anchor = E_ANCHOR;
ce4d5ce0 199
17ee7397 200 e->horizontal_order = E_HORIZONTAL_ORDER;
ce4d5ce0 201
17ee7397 202 e->next = E_NEXT;
ce4d5ce0
AD
203}
204
205/*----------------------------------------------.
206| Get functions. |
207| Return string corresponding to an enum value. |
208`----------------------------------------------*/
209
210static const char *
a737b216 211get_color_str (enum color color)
ce4d5ce0 212{
a737b216 213 switch (color)
ce4d5ce0 214 {
3e3da797
AD
215 case white: return "white";
216 case blue: return "blue";
217 case red: return "red";
218 case green: return "green";
219 case yellow: return "yellow";
220 case magenta: return "magenta";
221 case cyan: return "cyan";
222 case darkgrey: return "darkgrey";
223 case darkblue: return "darkblue";
224 case darkred: return "darkred";
225 case darkgreen: return "darkgreen";
226 case darkyellow: return "darkyellow";
227 case darkmagenta: return "darkmagenta";
228 case darkcyan: return "darkcyan";
229 case gold: return "gold";
230 case lightgrey: return "lightgrey";
231 case lightblue: return "lightblue";
232 case lightred: return "lightred";
233 case lightgreen: return "lightgreen";
234 case lightyellow: return "lightyellow";
235 case lightmagenta: return "lightmagenta";
236 case lightcyan: return "lightcyan";
237 case lilac: return "lilac";
238 case turquoise: return "turquoise";
239 case aquamarine: return "aquamarine";
240 case khaki: return "khaki";
241 case purple: return "purple";
242 case yellowgreen: return "yellowgreen";
243 case pink: return "pink";
244 case orange: return "orange";
245 case orchid: return "orchid";
246 case black: return "black";
4344c500 247 default: abort (); return NULL;
ce4d5ce0 248 }
ce4d5ce0
AD
249}
250
251static const char *
a737b216 252get_textmode_str (enum textmode textmode)
ce4d5ce0 253{
a737b216 254 switch (textmode)
ce4d5ce0 255 {
3e3da797
AD
256 case centered: return "center";
257 case left_justify: return "left_justify";
258 case right_justify: return "right_justify";
4344c500 259 default: abort (); return NULL;
ce4d5ce0 260 }
ce4d5ce0
AD
261}
262
263static const char *
a737b216 264get_shape_str (enum shape shape)
ce4d5ce0 265{
a737b216 266 switch (shape)
ce4d5ce0 267 {
3e3da797
AD
268 case box: return "box";
269 case rhomb: return "rhomb";
270 case ellipse: return "ellipse";
271 case triangle: return "triangle";
4344c500 272 default: abort (); return NULL;
ce4d5ce0 273 }
ce4d5ce0
AD
274}
275
ce4d5ce0 276static const char *
a737b216 277get_decision_str (enum decision decision)
ce4d5ce0 278{
a737b216 279 switch (decision)
ce4d5ce0 280 {
3e3da797
AD
281 case no: return "no";
282 case yes: return "yes";
4344c500 283 default: abort (); return NULL;
ce4d5ce0 284 }
ce4d5ce0
AD
285}
286
287static const char *
a737b216 288get_orientation_str (enum orientation orientation)
ce4d5ce0 289{
a737b216 290 switch (orientation)
ce4d5ce0 291 {
3e3da797
AD
292 case top_to_bottom: return "top_to_bottom";
293 case bottom_to_top: return "bottom_to_top";
294 case left_to_right: return "left_to_right";
295 case right_to_left: return "right_to_left";
4344c500 296 default: abort (); return NULL;
ce4d5ce0 297 }
ce4d5ce0
AD
298}
299
300static const char *
a737b216 301get_node_alignment_str (enum alignment alignment)
ce4d5ce0 302{
a737b216 303 switch (alignment)
ce4d5ce0 304 {
3e3da797
AD
305 case center: return "center";
306 case top: return "top";
307 case bottom: return "bottom";
4344c500 308 default: abort (); return NULL;
ce4d5ce0 309 }
ce4d5ce0
AD
310}
311
312static const char *
a737b216 313get_arrow_mode_str (enum arrow_mode arrow_mode)
ce4d5ce0 314{
a737b216 315 switch (arrow_mode)
ce4d5ce0 316 {
3e3da797
AD
317 case fixed: return "fixed";
318 case free_a: return "free";
4344c500 319 default: abort (); return NULL;
ce4d5ce0 320 }
ce4d5ce0
AD
321}
322
323static const char *
a737b216 324get_crossing_type_str (enum crossing_type crossing_type)
ce4d5ce0 325{
a737b216 326 switch (crossing_type)
ce4d5ce0 327 {
3e3da797
AD
328 case bary: return "bary";
329 case median: return "median";
330 case barymedian: return "barymedian";
331 case medianbary: return "medianbary";
4344c500 332 default: abort (); return NULL;
3e3da797 333 }
ce4d5ce0
AD
334}
335
336static const char *
a737b216 337get_view_str (enum view view)
ce4d5ce0 338{
a737b216 339 switch (view)
ce4d5ce0 340 {
3e3da797
AD
341 case normal_view: return "normal_view";
342 case cfish: return "cfish";
343 case pfish: return "pfish";
344 case fcfish: return "fcfish";
345 case fpfish: return "fpfish";
4344c500 346 default: abort (); return NULL;
ce4d5ce0 347 }
ce4d5ce0
AD
348}
349
350static const char *
a737b216 351get_linestyle_str (enum linestyle linestyle)
ce4d5ce0 352{
a737b216 353 switch (linestyle)
ce4d5ce0 354 {
3e3da797
AD
355 case continuous: return "continuous";
356 case dashed: return "dashed";
357 case dotted: return "dotted";
358 case invisible: return "invisible";
4344c500 359 default: abort (); return NULL;
3e3da797 360 }
ce4d5ce0
AD
361}
362
363static const char *
a737b216 364get_arrowstyle_str (enum arrowstyle arrowstyle)
ce4d5ce0 365{
a737b216 366 switch (arrowstyle)
ce4d5ce0 367 {
3e3da797
AD
368 case solid: return "solid";
369 case line: return "line";
370 case none: return "none";
4344c500 371 default: abort (); return NULL;
ce4d5ce0 372 }
ce4d5ce0
AD
373}
374
17ee7397
PE
375/*------------------------------.
376| Add functions. |
377| Edge and nodes into a graph. |
378`------------------------------*/
ce4d5ce0
AD
379
380void
17ee7397 381add_node (graph *g, node *n)
ce4d5ce0 382{
17ee7397
PE
383 n->next = g->node_list;
384 g->node_list = n;
ce4d5ce0
AD
385}
386
387void
17ee7397 388add_edge (graph *g, edge *e)
ce4d5ce0 389{
17ee7397
PE
390 e->next = g->edge_list;
391 g->edge_list = e;
ce4d5ce0
AD
392}
393
342b8b6e 394void
17ee7397 395add_classname (graph *g, int val, const char *name)
342b8b6e 396{
da2a7671 397 struct classname *classname = xmalloc (sizeof *classname);
342b8b6e
AD
398 classname->no = val;
399 classname->name = name;
400 classname->next = g->classname;
401 g->classname = classname;
402}
403
404void
17ee7397 405add_infoname (graph *g, int integer, const char *str)
342b8b6e 406{
da2a7671 407 struct infoname *infoname = xmalloc (sizeof *infoname);
342b8b6e 408 infoname->integer = integer;
17ee7397 409 infoname->chars = str;
342b8b6e
AD
410 infoname->next = g->infoname;
411 g->infoname = infoname;
412}
413
414/* Build a colorentry struct and add it to the list. */
415void
17ee7397 416add_colorentry (graph *g, int color_idx, int red_cp,
342b8b6e
AD
417 int green_cp, int blue_cp)
418{
da2a7671 419 struct colorentry *ce = xmalloc (sizeof *ce);
342b8b6e
AD
420 ce->color_index = color_idx;
421 ce->red_cp = red_cp;
422 ce->green_cp = green_cp;
423 ce->blue_cp = blue_cp;
424 ce->next = g->colorentry;
425 g->colorentry = ce;
426}
427
ce4d5ce0
AD
428/*-------------------------------------.
429| Open and close functions (formatted) |
430`-------------------------------------*/
431
432void
17ee7397 433open_edge (edge *e, FILE *fout)
ce4d5ce0 434{
17ee7397 435 switch (e->type)
ce4d5ce0
AD
436 {
437 case normal_edge:
342b8b6e 438 fputs ("\tedge: {\n", fout);
ce4d5ce0
AD
439 break;
440 case back_edge:
342b8b6e 441 fputs ("\tbackedge: {\n", fout);
ce4d5ce0
AD
442 break;
443 case near_edge:
342b8b6e 444 fputs ("\tnearedge: {\n", fout);
ce4d5ce0
AD
445 break;
446 case bent_near_edge:
342b8b6e 447 fputs ("\tbentnearedge: {\n", fout);
3e3da797 448 break;
ce4d5ce0 449 default:
342b8b6e 450 fputs ("\tedge: {\n", fout);
3e3da797 451 }
ce4d5ce0
AD
452}
453
454void
17ee7397 455close_edge (FILE *fout)
ce4d5ce0 456{
342b8b6e 457 fputs ("\t}\n", fout);
ce4d5ce0
AD
458}
459
460void
17ee7397 461open_node (FILE *fout)
ce4d5ce0 462{
342b8b6e 463 fputs ("\tnode: {\n", fout);
ce4d5ce0
AD
464}
465
466void
17ee7397 467close_node (FILE *fout)
3e3da797 468{
342b8b6e 469 fputs ("\t}\n", fout);
ce4d5ce0
AD
470}
471
472void
17ee7397 473open_graph (FILE *fout)
ce4d5ce0 474{
342b8b6e 475 fputs ("graph: {\n", fout);
ce4d5ce0
AD
476}
477
478void
17ee7397 479close_graph (graph *g, FILE *fout)
ce4d5ce0 480{
342b8b6e 481 fputc ('\n', fout);
ce4d5ce0 482
342b8b6e 483 /* FIXME: Unallocate nodes and edges if required. */
ce4d5ce0 484 {
17ee7397 485 node *n;
3e3da797 486
17ee7397 487 for (n = g->node_list; n; n = n->next)
ce4d5ce0 488 {
342b8b6e 489 open_node (fout);
17ee7397 490 output_node (n, fout);
342b8b6e 491 close_node (fout);
ce4d5ce0
AD
492 }
493 }
3e3da797 494
342b8b6e 495 fputc ('\n', fout);
3e3da797 496
ce4d5ce0 497 {
17ee7397 498 edge *e;
3e3da797 499
17ee7397 500 for (e = g->edge_list; e; e = e->next)
3e3da797 501 {
17ee7397
PE
502 open_edge (e, fout);
503 output_edge (e, fout);
342b8b6e 504 close_edge (fout);
ce4d5ce0
AD
505 }
506 }
3e3da797 507
342b8b6e 508 fputs ("}\n", fout);
3e3da797
AD
509}
510
ce4d5ce0 511/*-------------------------------------------.
342b8b6e 512| Output functions (formatted) in file FOUT |
ce4d5ce0
AD
513`-------------------------------------------*/
514
515void
17ee7397 516output_node (node *n, FILE *fout)
ce4d5ce0 517{
17ee7397
PE
518 if (n->title != N_TITLE)
519 fprintf (fout, "\t\ttitle:\t%s\n", quote (n->title));
520 if (n->label != N_LABEL)
521 fprintf (fout, "\t\tlabel:\t%s\n", quote (n->label));
ce4d5ce0 522
17ee7397
PE
523 if ((n->locx != N_LOCX) && (n->locy != N_LOCY))
524 fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", n->locx, n->locy);
3e3da797 525
17ee7397
PE
526 if (n->vertical_order != N_VERTICAL_ORDER)
527 fprintf (fout, "\t\tvertical_order:\t%d\n", n->vertical_order);
528 if (n->horizontal_order != N_HORIZONTAL_ORDER)
529 fprintf (fout, "\t\thorizontal_order:\t%d\n", n->horizontal_order);
3e3da797 530
17ee7397
PE
531 if (n->width != N_WIDTH)
532 fprintf (fout, "\t\twidth:\t%d\n", n->width);
533 if (n->height != N_HEIGHT)
534 fprintf (fout, "\t\theight:\t%d\n", n->height);
3e3da797 535
17ee7397
PE
536 if (n->shrink != N_SHRINK)
537 fprintf (fout, "\t\tshrink:\t%d\n", n->shrink);
ea193b9d
PE
538 if (n->stretch != N_STRETCH)
539 fprintf (fout, "\t\tstretch:\t%d\n", n->stretch);
3e3da797 540
17ee7397
PE
541 if (n->folding != N_FOLDING)
542 fprintf (fout, "\t\tfolding:\t%d\n", n->folding);
3e3da797 543
17ee7397 544 if (n->textmode != N_TEXTMODE)
342b8b6e 545 fprintf (fout, "\t\ttextmode:\t%s\n",
17ee7397 546 get_textmode_str (n->textmode));
3e3da797 547
17ee7397
PE
548 if (n->shape != N_SHAPE)
549 fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (n->shape));
3e3da797 550
17ee7397
PE
551 if (n->borderwidth != N_BORDERWIDTH)
552 fprintf (fout, "\t\tborderwidth:\t%d\n", n->borderwidth);
3e3da797 553
17ee7397
PE
554 if (n->color != N_COLOR)
555 fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (n->color));
556 if (n->textcolor != N_TEXTCOLOR)
342b8b6e 557 fprintf (fout, "\t\ttextcolor:\t%s\n",
17ee7397
PE
558 get_color_str (n->textcolor));
559 if (n->bordercolor != N_BORDERCOLOR)
342b8b6e 560 fprintf (fout, "\t\tbordercolor:\t%s\n",
17ee7397 561 get_color_str (n->bordercolor));
3e3da797 562
08a946e0
AD
563 {
564 int i;
565 for (i = 0; i < 3; ++i)
17ee7397 566 if (n->infos[i])
08a946e0 567 fprintf (fout, "\t\tinfo%d:\t%s\n",
17ee7397 568 i, quote (n->infos[i]));
08a946e0 569 }
ce4d5ce0
AD
570}
571
572void
17ee7397 573output_edge (edge *e, FILE *fout)
ce4d5ce0 574{
600cad3b
MA
575 /* FIXME: SOURCENAME and TARGETNAME are mandatory
576 so it has to be fatal not to give these informations. */
17ee7397
PE
577 if (e->sourcename != E_SOURCENAME)
578 fprintf (fout, "\t\tsourcename:\t%s\n", quote (e->sourcename));
579 if (e->targetname != E_TARGETNAME)
580 fprintf (fout, "\t\ttargetname:\t%s\n", quote (e->targetname));
3e3da797 581
17ee7397
PE
582 if (e->label != E_LABEL)
583 fprintf (fout, "\t\tlabel:\t%s\n", quote (e->label));
ce4d5ce0 584
17ee7397 585 if (e->linestyle != E_LINESTYLE)
08a946e0 586 fprintf (fout, "\t\tlinestyle:\t%s\n",
17ee7397 587 quote (get_linestyle_str (e->linestyle)));
3e3da797 588
17ee7397
PE
589 if (e->thickness != E_THICKNESS)
590 fprintf (fout, "\t\tthickness:\t%d\n", e->thickness);
591 if (e->class != E_CLASS)
592 fprintf (fout, "\t\tclass:\t%d\n", e->class);
ce4d5ce0 593
17ee7397
PE
594 if (e->color != E_COLOR)
595 fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (e->color));
596 if (e->color != E_TEXTCOLOR)
342b8b6e 597 fprintf (fout, "\t\ttextcolor:\t%s\n",
17ee7397
PE
598 get_color_str (e->textcolor));
599 if (e->arrowcolor != E_ARROWCOLOR)
342b8b6e 600 fprintf (fout, "\t\tarrowcolor:\t%s\n",
17ee7397
PE
601 get_color_str (e->arrowcolor));
602 if (e->backarrowcolor != E_BACKARROWCOLOR)
342b8b6e 603 fprintf (fout, "\t\tbackarrowcolor:\t%s\n",
17ee7397 604 get_color_str (e->backarrowcolor));
ce4d5ce0 605
17ee7397
PE
606 if (e->arrowsize != E_ARROWSIZE)
607 fprintf (fout, "\t\tarrowsize:\t%d\n", e->arrowsize);
608 if (e->backarrowsize != E_BACKARROWSIZE)
609 fprintf (fout, "\t\tbackarrowsize:\t%d\n", e->backarrowsize);
3e3da797 610
17ee7397 611 if (e->arrowstyle != E_ARROWSTYLE)
342b8b6e 612 fprintf (fout, "\t\tarrowstyle:\t%s\n",
17ee7397
PE
613 get_arrowstyle_str (e->arrowstyle));
614 if (e->backarrowstyle != E_BACKARROWSTYLE)
342b8b6e 615 fprintf (fout, "\t\tbackarrowstyle:\t%s\n",
17ee7397
PE
616 get_arrowstyle_str (e->backarrowstyle));
617
618 if (e->priority != E_PRIORITY)
619 fprintf (fout, "\t\tpriority:\t%d\n", e->priority);
620 if (e->anchor != E_ANCHOR)
621 fprintf (fout, "\t\tanchor:\t%d\n", e->anchor);
622 if (e->horizontal_order != E_HORIZONTAL_ORDER)
623 fprintf (fout, "\t\thorizontal_order:\t%d\n", e->horizontal_order);
ce4d5ce0
AD
624}
625
626void
17ee7397 627output_graph (graph *g, FILE *fout)
ce4d5ce0 628{
17ee7397
PE
629 if (g->title)
630 fprintf (fout, "\ttitle:\t%s\n", quote (g->title));
631 if (g->label)
632 fprintf (fout, "\tlabel:\t%s\n", quote (g->label));
3e3da797 633
08a946e0
AD
634 {
635 int i;
636 for (i = 0; i < 3; ++i)
17ee7397
PE
637 if (g->infos[i])
638 fprintf (fout, "\tinfo%d:\t%s\n", i, quote (g->infos[i]));
08a946e0 639 }
3e3da797 640
17ee7397
PE
641 if (g->color != G_COLOR)
642 fprintf (fout, "\tcolor:\t%s\n", get_color_str (g->color));
643 if (g->textcolor != G_TEXTCOLOR)
644 fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (g->textcolor));
645 if (g->bordercolor != G_BORDERCOLOR)
342b8b6e 646 fprintf (fout, "\tbordercolor:\t%s\n",
17ee7397 647 get_color_str (g->bordercolor));
3e3da797 648
17ee7397
PE
649 if (g->width != G_WIDTH)
650 fprintf (fout, "\twidth:\t%d\n", g->width);
651 if (g->height != G_HEIGHT)
652 fprintf (fout, "\theight:\t%d\n", g->height);
653 if (g->borderwidth != G_BORDERWIDTH)
654 fprintf (fout, "\tborderwidth:\t%d\n", g->borderwidth);
3e3da797 655
17ee7397
PE
656 if (g->x != G_X)
657 fprintf (fout, "\tx:\t%d\n", g->x);
658 if (g->y != G_Y)
659 fprintf (fout, "\ty:\t%d\n", g->y);
ce4d5ce0 660
17ee7397
PE
661 if (g->folding != G_FOLDING)
662 fprintf (fout, "\tfolding:\t%d\n", g->folding);
ce4d5ce0 663
17ee7397
PE
664 if (g->shrink != G_SHRINK)
665 fprintf (fout, "\tshrink:\t%d\n", g->shrink);
ea193b9d
PE
666 if (g->stretch != G_STRETCH)
667 fprintf (fout, "\tstretch:\t%d\n", g->stretch);
3e3da797 668
17ee7397 669 if (g->textmode != G_TEXTMODE)
342b8b6e 670 fprintf (fout, "\ttextmode:\t%s\n",
17ee7397
PE
671 get_textmode_str (g->textmode));
672
673 if (g->shape != G_SHAPE)
674 fprintf (fout, "\tshape:\t%s\n", get_shape_str (g->shape));
675
676 if (g->vertical_order != G_VERTICAL_ORDER)
677 fprintf (fout, "\tvertical_order:\t%d\n", g->vertical_order);
678 if (g->horizontal_order != G_HORIZONTAL_ORDER)
679 fprintf (fout, "\thorizontal_order:\t%d\n", g->horizontal_order);
680
681 if (g->xmax != G_XMAX)
682 fprintf (fout, "\txmax:\t%d\n", g->xmax);
683 if (g->ymax != G_YMAX)
684 fprintf (fout, "\tymax:\t%d\n", g->ymax);
685
686 if (g->xbase != G_XBASE)
687 fprintf (fout, "\txbase:\t%d\n", g->xbase);
688 if (g->ybase != G_YBASE)
689 fprintf (fout, "\tybase:\t%d\n", g->ybase);
690
691 if (g->xspace != G_XSPACE)
692 fprintf (fout, "\txspace:\t%d\n", g->xspace);
693 if (g->yspace != G_YSPACE)
694 fprintf (fout, "\tyspace:\t%d\n", g->yspace);
695 if (g->xlspace != G_XLSPACE)
696 fprintf (fout, "\txlspace:\t%d\n", g->xlspace);
697
698 if (g->xraster != G_XRASTER)
699 fprintf (fout, "\txraster:\t%d\n", g->xraster);
700 if (g->yraster != G_YRASTER)
701 fprintf (fout, "\tyraster:\t%d\n", g->yraster);
702 if (g->xlraster != G_XLRASTER)
703 fprintf (fout, "\txlraster:\t%d\n", g->xlraster);
704
705 if (g->hidden != G_HIDDEN)
706 fprintf (fout, "\thidden:\t%d\n", g->hidden);
08a946e0
AD
707
708 /* FIXME: Unallocate struct list if required.
342b8b6e 709 Maybe with a little function. */
17ee7397 710 if (g->classname != G_CLASSNAME)
ce4d5ce0 711 {
17ee7397 712 struct classname *ite;
3e3da797 713
17ee7397 714 for (ite = g->classname; ite; ite = ite->next)
342b8b6e
AD
715 fprintf (fout, "\tclassname %d :\t%s\n", ite->no, ite->name);
716 }
717
17ee7397 718 if (g->infoname != G_INFONAME)
342b8b6e 719 {
17ee7397 720 struct infoname *ite;
342b8b6e 721
17ee7397
PE
722 for (ite = g->infoname; ite; ite = ite->next)
723 fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->chars);
342b8b6e
AD
724 }
725
17ee7397 726 if (g->colorentry != G_COLORENTRY)
342b8b6e 727 {
17ee7397 728 struct colorentry *ite;
08a946e0 729
17ee7397 730 for (ite = g->colorentry; ite; ite = ite->next)
08a946e0
AD
731 {
732 fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",
733 ite->color_index,
342b8b6e
AD
734 ite->red_cp,
735 ite->green_cp,
736 ite->blue_cp);
08a946e0 737 }
ce4d5ce0 738 }
3e3da797 739
17ee7397
PE
740 if (g->layout_downfactor != G_LAYOUT_DOWNFACTOR)
741 fprintf (fout, "\tlayout_downfactor:\t%d\n", g->layout_downfactor);
742 if (g->layout_upfactor != G_LAYOUT_UPFACTOR)
743 fprintf (fout, "\tlayout_upfactor:\t%d\n", g->layout_upfactor);
744 if (g->layout_nearfactor != G_LAYOUT_NEARFACTOR)
745 fprintf (fout, "\tlayout_nearfactor:\t%d\n", g->layout_nearfactor);
746 if (g->layout_splinefactor != G_LAYOUT_SPLINEFACTOR)
342b8b6e 747 fprintf (fout, "\tlayout_splinefactor:\t%d\n",
17ee7397 748 g->layout_splinefactor);
3e3da797 749
17ee7397 750 if (g->late_edge_labels != G_LATE_EDGE_LABELS)
342b8b6e 751 fprintf (fout, "\tlate_edge_labels:\t%s\n",
17ee7397
PE
752 get_decision_str (g->late_edge_labels));
753 if (g->display_edge_labels != G_DISPLAY_EDGE_LABELS)
342b8b6e 754 fprintf (fout, "\tdisplay_edge_labels:\t%s\n",
17ee7397
PE
755 get_decision_str (g->display_edge_labels));
756 if (g->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
342b8b6e 757 fprintf (fout, "\tdirty_edge_labels:\t%s\n",
17ee7397
PE
758 get_decision_str (g->dirty_edge_labels));
759 if (g->finetuning != G_FINETUNING)
342b8b6e 760 fprintf (fout, "\tfinetuning:\t%s\n",
17ee7397
PE
761 get_decision_str (g->finetuning));
762 if (g->ignore_singles != G_IGNORE_SINGLES)
342b8b6e 763 fprintf (fout, "\tignore_singles:\t%s\n",
17ee7397 764 get_decision_str (g->ignore_singles));
17ee7397 765 if (g->priority_phase != G_PRIORITY_PHASE)
342b8b6e 766 fprintf (fout, "\tpriority_phase:\t%s\n",
17ee7397
PE
767 get_decision_str (g->priority_phase));
768 if (g->manhattan_edges != G_MANHATTAN_EDGES)
342b8b6e
AD
769 fprintf (fout,
770 "\tmanhattan_edges:\t%s\n",
17ee7397
PE
771 get_decision_str (g->manhattan_edges));
772 if (g->smanhattan_edges != G_SMANHATTAN_EDGES)
342b8b6e
AD
773 fprintf (fout,
774 "\tsmanhattan_edges:\t%s\n",
17ee7397
PE
775 get_decision_str (g->smanhattan_edges));
776 if (g->near_edges != G_NEAR_EDGES)
342b8b6e 777 fprintf (fout, "\tnear_edges:\t%s\n",
17ee7397 778 get_decision_str (g->near_edges));
3e3da797 779
17ee7397 780 if (g->orientation != G_ORIENTATION)
342b8b6e 781 fprintf (fout, "\torientation:\t%s\n",
17ee7397 782 get_orientation_str (g->orientation));
3e3da797 783
17ee7397
PE
784 if (g->node_alignment != G_NODE_ALIGNMENT)
785 fprintf (fout, "\tnode_alignment:\t%s\n",
786 get_node_alignment_str (g->node_alignment));
3e3da797 787
17ee7397 788 if (g->port_sharing != G_PORT_SHARING)
342b8b6e 789 fprintf (fout, "\tport_sharing:\t%s\n",
17ee7397 790 get_decision_str (g->port_sharing));
3e3da797 791
17ee7397 792 if (g->arrow_mode != G_ARROW_MODE)
342b8b6e 793 fprintf (fout, "\tarrow_mode:\t%s\n",
17ee7397 794 get_arrow_mode_str (g->arrow_mode));
3e3da797 795
17ee7397
PE
796 if (g->treefactor != G_TREEFACTOR)
797 fprintf (fout, "\ttreefactor:\t%f\n", g->treefactor);
798 if (g->spreadlevel != G_SPREADLEVEL)
799 fprintf (fout, "\tspreadlevel:\t%d\n", g->spreadlevel);
3e3da797 800
17ee7397 801 if (g->crossing_weight != G_CROSSING_WEIGHT)
342b8b6e 802 fprintf (fout, "\tcrossing_weight:\t%s\n",
17ee7397
PE
803 get_crossing_type_str (g->crossing_weight));
804 if (g->crossing_phase2 != G_CROSSING_PHASE2)
342b8b6e 805 fprintf (fout, "\tcrossing_phase2:\t%s\n",
17ee7397
PE
806 get_decision_str (g->crossing_phase2));
807 if (g->crossing_optimization != G_CROSSING_OPTIMIZATION)
342b8b6e 808 fprintf (fout, "\tcrossing_optimization:\t%s\n",
17ee7397
PE
809 get_decision_str (g->crossing_optimization));
810
811 if (g->view != G_VIEW)
812 fprintf (fout, "\tview:\t%s\n", get_view_str (g->view));
813
814 if (g->edges != G_EDGES)
815 fprintf (fout, "\tedges:\t%s\n", get_decision_str (g->edges));
816
817 if (g->nodes != G_NODES)
818 fprintf (fout,"\tnodes:\t%s\n", get_decision_str (g->nodes));
819
820 if (g->splines != G_SPLINES)
821 fprintf (fout, "\tsplines:\t%s\n", get_decision_str (g->splines));
822
823 if (g->bmax != G_BMAX)
824 fprintf (fout, "\tbmax:\t%d\n", g->bmax);
825 if (g->cmin != G_CMIN)
826 fprintf (fout, "\tcmin:\t%d\n", g->cmin);
827 if (g->cmax != G_CMAX)
828 fprintf (fout, "\tcmax:\t%d\n", g->cmax);
829 if (g->pmin != G_PMIN)
830 fprintf (fout, "\tpmin:\t%d\n", g->pmin);
831 if (g->pmax != G_PMAX)
832 fprintf (fout, "\tpmax:\t%d\n", g->pmax);
833 if (g->rmin != G_RMIN)
834 fprintf (fout, "\trmin:\t%d\n", g->rmin);
835 if (g->rmax != G_RMAX)
836 fprintf (fout, "\trmax:\t%d\n", g->rmax);
837 if (g->smax != G_SMAX)
838 fprintf (fout, "\tsmax:\t%d\n", g->smax);
ce4d5ce0 839}