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