Avoid adding -pie on older cmake versions
[metze/wireshark/wip.git] / tools / colorfilters2js.pl
1 #!/usr/bin/env perl
2 #
3 # Copyright 2011 Dirk Jagdmann <doj@cubic.org>
4 #
5 # Wireshark - Network traffic analyzer
6 # By Gerald Combs <gerald@wireshark.org>
7 # Copyright 1998 Gerald Combs
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23
24 # perl program to convert a Wireshark color scheme to javascript
25 # code. The javascript function should then be inserted into the
26 # pdml2html.xsl file.
27 #
28 # run this as: perl tools/colorfilters2js.pl colorfilters
29
30 print<<'EOF';
31 function set_node_color(node,colorname)
32 {
33   if(dojo.isString(node))
34     node = dojo.byId(node);
35   if(!node) return;
36   var fg;
37   var bg;
38 EOF
39
40 my $elseflow = "";
41
42 while(<>)
43 {
44     if(/\@(.+?)\@.+\[(\d+),(\d+),(\d+)\]\[(\d+),(\d+),(\d+)\]/)
45     {
46         print "  " . $elseflow . "if (colorname == '$1') {\n";
47         printf("    bg='#%02x%02x%02x';\n", $2/256, $3/256, $4/256);
48         printf("    fg='#%02x%02x%02x';\n", $5/256, $6/256, $7/256);
49         print "  }\n";
50     }
51     $elseflow = "else ";
52 }
53
54 print<<'EOF';
55   if(fg.length > 0)
56     node.style.color = fg;
57   if(bg.length > 0)
58     node.style.background = bg;
59 }
60 EOF
61
62 exit 0;