#!/usr/bin/perl # # fatfixml.pl FATFIfi to eXtended Markup Language converter # Author/Copyright: (C) 2012 O. Kellogg # Version: 2017-03-12 # # This file is part of GNACK, the GNU Ada CORBA Kit. # # GNACK is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # GNACK is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # use strict; sub str2xml; my $envelope = ""; my $mainname = ""; my $infile = ""; while (@ARGV) { my $arg = shift @ARGV; if ($arg eq "-e") { $envelope = shift @ARGV; } elsif ($arg eq "-t") { $mainname = shift @ARGV; } elsif ($arg =~ /^-/) { $arg =~ /^-h/ or warn "Unknown option $arg\n"; warn "Options:\n"; warn " -t MAINNAME Use MAINNAME when the outer type is unknown\n"; warn " -e '' Use as the outer XML tag (default: )\n"; exit($arg !~ /^-h/); } else { $infile = $arg; last; } } $infile or die "fatfixml.pl : supply input file name\n"; open(IN, "< $infile") or die "fatfixml.pl : cannot open input file\n"; unless ($mainname) { $mainname = $infile; $mainname =~ s@^.*/@@; $mainname =~ s/\..*$//; } print "\n"; unless ($envelope) { $envelope = ""; } print "$envelope\n"; my $indent = " "; my @stack = (); while () { my $line = $_; chop $line; if ($line =~ /^ *(--|#)/) { $line =~ s/^ *(--|#)//; print "$indent