1193141Sdougb#!/usr/bin/env perl
2193141Sdougb#
3245163Serwin# Copyright (C) 2006-2008, 2012  Internet Systems Consortium, Inc. ("ISC")
4193141Sdougb#
5193141Sdougb# Permission to use, copy, modify, and/or distribute this software for any
6193141Sdougb# purpose with or without fee is hereby granted, provided that the above
7193141Sdougb# copyright notice and this permission notice appear in all copies.
8193141Sdougb#
9193141Sdougb# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10193141Sdougb# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11193141Sdougb# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12193141Sdougb# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13193141Sdougb# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14193141Sdougb# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15193141Sdougb# PERFORMANCE OF THIS SOFTWARE.
16193141Sdougb
17234010Sdougb# $Id: convertxsl.pl,v 1.14 2008/07/17 23:43:26 jinmei Exp $
18193141Sdougb
19193141Sdougbuse strict;
20193141Sdougbuse warnings;
21193141Sdougb
22234010Sdougbmy $rev = '$Id: convertxsl.pl,v 1.14 2008/07/17 23:43:26 jinmei Exp $';
23193141Sdougb$rev =~ s/\$//g;
24193141Sdougb$rev =~ s/,v//g;
25193141Sdougb$rev =~ s/Id: //;
26193141Sdougb
27193141Sdougbmy $xsl = "unknown";
28193141Sdougbmy $lines = '';
29193141Sdougb
30193141Sdougbwhile (<>) {
31193141Sdougb    chomp;
32193141Sdougb    # pickout the id for comment.
33193141Sdougb    $xsl = $_ if (/<!-- .Id:.* -->/);
34193141Sdougb    # convert Id string to a form not recognisable by cvs.
35193141Sdougb    $_ =~ s/<!-- .Id:(.*). -->/<!-- \\045Id: $1\\045 -->/;
36193141Sdougb    s/[\ \t]+/ /g;
37193141Sdougb    s/\>\ \</\>\</g;
38193141Sdougb    s/\"/\\\"/g;
39193141Sdougb    s/^/\t\"/;
40193141Sdougb    s/$/\\n\"/;
41193141Sdougb    if ($lines eq "") {
42193141Sdougb	    $lines .= $_;
43193141Sdougb    } else {
44193141Sdougb	    $lines .= "\n" . $_;
45193141Sdougb    }
46193141Sdougb}
47193141Sdougb
48193141Sdougb$xsl =~ s/\$//g;
49193141Sdougb$xsl =~ s/<!-- Id: //;
50193141Sdougb$xsl =~ s/ -->.*//;
51193141Sdougb$xsl =~ s/,v//;
52193141Sdougb
53193141Sdougbprint "/*\n * Generated by $rev \n * From $xsl\n */\n";
54193141Sdougbprint 'static char xslmsg[] =',"\n";
55193141Sdougbprint $lines;
56193141Sdougb
57193141Sdougbprint ';', "\n";
58