21 |
#include "system.h" |
#include "system.h" |
22 |
#include "vcg.h" |
#include "vcg.h" |
23 |
#include "vcg_defaults.h" |
#include "vcg_defaults.h" |
24 |
|
#include "quotearg.h" |
25 |
|
|
26 |
|
/* Return an unambiguous printable representated, allocated in slot 0, |
27 |
|
for NAME, suitable for C strings. */ |
28 |
|
static char const * |
29 |
|
quote (char const *name) |
30 |
|
{ |
31 |
|
return quotearg_n_style (0, c_quoting_style, name); |
32 |
|
} |
33 |
|
|
34 |
|
|
35 |
/* Initialize a graph with the default values. */ |
/* Initialize a graph with the default values. */ |
36 |
void |
void |
439 |
add_classname (graph_t *g, int val, const char *name) |
add_classname (graph_t *g, int val, const char *name) |
440 |
{ |
{ |
441 |
struct classname_s *classname; |
struct classname_s *classname; |
442 |
|
|
443 |
classname = XMALLOC (struct classname_s, 1); |
classname = XMALLOC (struct classname_s, 1); |
444 |
classname->no = val; |
classname->no = val; |
445 |
classname->name = name; |
classname->name = name; |
451 |
add_infoname (graph_t *g, int integer, const char *string) |
add_infoname (graph_t *g, int integer, const char *string) |
452 |
{ |
{ |
453 |
struct infoname_s *infoname; |
struct infoname_s *infoname; |
454 |
|
|
455 |
infoname = XMALLOC (struct infoname_s, 1); |
infoname = XMALLOC (struct infoname_s, 1); |
456 |
infoname->integer = integer; |
infoname->integer = integer; |
457 |
infoname->string = string; |
infoname->string = string; |
461 |
|
|
462 |
/* Build a colorentry struct and add it to the list. */ |
/* Build a colorentry struct and add it to the list. */ |
463 |
void |
void |
464 |
add_colorentry (graph_t *g, int color_idx, int red_cp, |
add_colorentry (graph_t *g, int color_idx, int red_cp, |
465 |
int green_cp, int blue_cp) |
int green_cp, int blue_cp) |
466 |
{ |
{ |
467 |
struct colorentry_s *ce; |
struct colorentry_s *ce; |
468 |
|
|
469 |
ce = XMALLOC (struct colorentry_s, 1); |
ce = XMALLOC (struct colorentry_s, 1); |
470 |
ce->color_index = color_idx; |
ce->color_index = color_idx; |
471 |
ce->red_cp = red_cp; |
ce->red_cp = red_cp; |
566 |
output_node (node_t *node, FILE *fout) |
output_node (node_t *node, FILE *fout) |
567 |
{ |
{ |
568 |
if (node->title != N_TITLE) |
if (node->title != N_TITLE) |
569 |
fprintf (fout, "\t\ttitle:\t\"%s\"\n", node->title); |
fprintf (fout, "\t\ttitle:\t%s\n", quote (node->title)); |
570 |
if (node->label != N_LABEL) |
if (node->label != N_LABEL) |
571 |
fprintf (fout, "\t\tlabel:\t\"%s\"\n", node->label); |
fprintf (fout, "\t\tlabel:\t%s\n", quote (node->label)); |
572 |
|
|
573 |
if ((node->locx != N_LOCX) && (node->locy != N_LOCY)) |
if ((node->locx != N_LOCX) && (node->locy != N_LOCY)) |
574 |
fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy); |
fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy); |
610 |
fprintf (fout, "\t\tbordercolor:\t%s\n", |
fprintf (fout, "\t\tbordercolor:\t%s\n", |
611 |
get_color_str (node->bordercolor)); |
get_color_str (node->bordercolor)); |
612 |
|
|
613 |
if (node->infos[0]) |
{ |
614 |
fprintf (fout, "\t\tinfo1:\t\"%s\"\n", node->infos[0]); |
int i; |
615 |
if (node->infos[1]) |
for (i = 0; i < 3; ++i) |
616 |
fprintf (fout, "\t\tinfo2:\t\"%s\"\n", node->infos[1]); |
if (node->infos[i]) |
617 |
if (node->infos[2]) |
fprintf (fout, "\t\tinfo%d:\t%s\n", |
618 |
fprintf (fout, "\t\tinfo3:\t\"%s\"\n", node->infos[2]); |
i, quote (node->infos[i])); |
619 |
|
} |
620 |
} |
} |
621 |
|
|
622 |
void |
void |
625 |
/* FIXME: SOURCENAME and TARGETNAME are mandatory |
/* FIXME: SOURCENAME and TARGETNAME are mandatory |
626 |
so it has to be fatal not to give these informations. */ |
so it has to be fatal not to give these informations. */ |
627 |
if (edge->sourcename != E_SOURCENAME) |
if (edge->sourcename != E_SOURCENAME) |
628 |
fprintf (fout, "\t\tsourcename:\t\"%s\"\n", edge->sourcename); |
fprintf (fout, "\t\tsourcename:\t%s\n", quote (edge->sourcename)); |
629 |
if (edge->targetname != E_TARGETNAME) |
if (edge->targetname != E_TARGETNAME) |
630 |
fprintf (fout, "\t\ttargetname:\t\"%s\"\n", edge->targetname); |
fprintf (fout, "\t\ttargetname:\t%s\n", quote (edge->targetname)); |
631 |
|
|
632 |
if (edge->label != E_LABEL) |
if (edge->label != E_LABEL) |
633 |
fprintf (fout, "\t\tlabel:\t\"%s\"\n", edge->label); |
fprintf (fout, "\t\tlabel:\t%s\n", quote (edge->label)); |
634 |
|
|
635 |
if (edge->linestyle != E_LINESTYLE) |
if (edge->linestyle != E_LINESTYLE) |
636 |
fprintf (fout, "\t\tlinestyle:\t\"%s\"\n", |
fprintf (fout, "\t\tlinestyle:\t%s\n", |
637 |
get_linestyle_str(edge->linestyle)); |
quote (get_linestyle_str(edge->linestyle))); |
638 |
|
|
639 |
if (edge->thickness != E_THICKNESS) |
if (edge->thickness != E_THICKNESS) |
640 |
fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness); |
fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness); |
677 |
output_graph (graph_t *graph, FILE *fout) |
output_graph (graph_t *graph, FILE *fout) |
678 |
{ |
{ |
679 |
if (graph->title) |
if (graph->title) |
680 |
fprintf (fout, "\ttitle:\t\"%s\"\n", graph->title); |
fprintf (fout, "\ttitle:\t%s\n", quote (graph->title)); |
681 |
if (graph->label) |
if (graph->label) |
682 |
fprintf (fout, "\tlabel:\t\"%s\"\n", graph->label); |
fprintf (fout, "\tlabel:\t%s\n", quote (graph->label)); |
683 |
|
|
684 |
if (graph->infos[0]) |
{ |
685 |
fprintf (fout, "\tinfo1:\t\"%s\"\n", graph->infos[0]); |
int i; |
686 |
if (graph->infos[1]) |
for (i = 0; i < 3; ++i) |
687 |
fprintf (fout, "\tinfo2:\t\"%s\"\n", graph->infos[1]); |
if (graph->infos[i]) |
688 |
if (graph->infos[2]) |
fprintf (fout, "\tinfo%d:\t%s\n", i, quote (graph->infos[i])); |
689 |
fprintf (fout, "\tinfo3:\t\"%s\"\n", graph->infos[2]); |
} |
690 |
|
|
691 |
if (graph->color != G_COLOR) |
if (graph->color != G_COLOR) |
692 |
fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color)); |
fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color)); |
722 |
|
|
723 |
if (graph->shape != G_SHAPE) |
if (graph->shape != G_SHAPE) |
724 |
fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape)); |
fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape)); |
725 |
|
|
726 |
if (graph->vertical_order != G_VERTICAL_ORDER) |
if (graph->vertical_order != G_VERTICAL_ORDER) |
727 |
fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order); |
fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order); |
728 |
if (graph->horizontal_order != G_HORIZONTAL_ORDER) |
if (graph->horizontal_order != G_HORIZONTAL_ORDER) |
729 |
fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order); |
fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order); |
730 |
|
|
731 |
if (graph->xmax != G_XMAX) |
if (graph->xmax != G_XMAX) |
732 |
fprintf (fout, "\txmax:\t%d\n", graph->xmax); |
fprintf (fout, "\txmax:\t%d\n", graph->xmax); |
754 |
|
|
755 |
if (graph->hidden != G_HIDDEN) |
if (graph->hidden != G_HIDDEN) |
756 |
fprintf (fout, "\thidden:\t%d\n", graph->hidden); |
fprintf (fout, "\thidden:\t%d\n", graph->hidden); |
757 |
|
|
758 |
/* FIXME: Unallocate struct list if required. |
/* FIXME: Unallocate struct list if required. |
759 |
Maybe with a little function. */ |
Maybe with a little function. */ |
760 |
if (graph->classname != G_CLASSNAME) |
if (graph->classname != G_CLASSNAME) |
761 |
{ |
{ |
776 |
if (graph->colorentry != G_COLORENTRY) |
if (graph->colorentry != G_COLORENTRY) |
777 |
{ |
{ |
778 |
struct colorentry_s *ite; |
struct colorentry_s *ite; |
779 |
|
|
780 |
for (ite = graph->colorentry; ite; ite = ite->next) |
for (ite = graph->colorentry; ite; ite = ite->next) |
781 |
{ |
{ |
782 |
fprintf (fout, "\tcolorentry %d :\t%d %d %d\n", |
fprintf (fout, "\tcolorentry %d :\t%d %d %d\n", |
783 |
ite->color_index, |
ite->color_index, |
784 |
ite->red_cp, |
ite->red_cp, |
785 |
ite->green_cp, |
ite->green_cp, |
786 |
ite->blue_cp); |
ite->blue_cp); |
787 |
} |
} |
788 |
} |
} |
789 |
|
|
790 |
if (graph->layoutalgorithm != G_LAYOUTALGORITHM) |
if (graph->layoutalgorithm != G_LAYOUTALGORITHM) |