/usr/lib/radare/bin/gdl2gml is in radare-common 1:1.5.2-6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | #!/usr/bin/env perl -w
=head1 NAME
gdl2gml - gdl to gml format converter
=head1 SYNOPSIS
gdl2gml - gdl to gml format converter
=head1 ABSTRACT
gdl2gml provides a stdin/stdout interface to convert GDL (wingraph) files
to the GML format (importable via yEd for.example).
It can be easily modified to support more output formats.
Usage:
$ cat input.gdl | perl gdl2gml > output.gml
=head1 AUTHOR
pancake <pancake@youterm.com>
=cut
my $node_title;
my $node_label;
sub null_handler {}
my $handler = \&null_handler;
die qx(pod2text gdl2gml) if ($ARGV[0] eq "-h");
sub node_label_handler {
my ( $str ) = @_;
if ( $str=~/}/ ) {
$str =~ s/}//g;
$id = $node_title;
$text = $node_label;
$text =~ s/:/:\n/;
$width = 7 * qx(echo "$text"|wc -L);
$height = 20 * qx(echo "$text"|wc -l);
print <<EOF
node
[
id $id
label "$id"
graphics
[
w $width
h $height
type "rectangle"
fill "#FFCC00"
outline "#000000"
]
LabelGraphics
[
text "$text"
fontSize 13
fontName "Dialog"
alignment "left"
anchor "c"
]
]
EOF
;
$handler = \&null_handler;
}
$node_label .= $str;
}
sub node_handler {
my ( $str ) = @_;
$str=~/title: "(.*)" label: "(.*)$/;
if (defined($1)) {
( $node_title, $node_label ) = ( $1, $2 );
$handler = \&node_label_handler;
}
}
sub edge_handler {
my ( $str ) = @_;
$str =~ / sourcename: "(.*)" targetname: "(.*)" label: "(.*)"/;
$str =~ / sourcename: "(.*)" targetname: "(.*)"/ unless (defined($1));
# NOTE: looks like true is false and false is true!
$color = ($3 eq "true")? "#ff0000":"#00ff00" if (defined($3));
print <<EOF
edge
[
source $1
target $2
graphics
[
fill "$color"
targetArrow "standard"
]
]
EOF
if (defined($1));
}
# main #
print <<EOF
Creator "gdl2gml"
Version "0.2"
graph
[
hierarchic 1
label ""
directed 1
EOF
;
while ( <STDIN> ) {
s/\r//g;
s/\14..//g;
s/\\"/"/g;
s/\/\/.*//g;
SWITCH: {
$handler = \&node_handler
and last SWITCH if ( /node: {/ );
$handler = \&edge_handler
and last SWITCH if ( /edge: {/ );
}
&$handler($_);
}
print "]\n";
|