#!/usr/local/bin/perl

$infile = $ARGV[0];
$outfile = $infile;
$outfile =~ s/.gz//;
$outfile = $outfile . ".out.gz";

print <<EOF;
## Tracename: mozilla-malloc-trace-bsd
## Author: Chris Waterson <waterson\@netscape.com> (translated to MetaTF format by Richard Jones <R.E.Jones\@ukc.ac.uk>)
## Date: Unknown
## DTDURL: http://www.ukc.ac.uk/people/staff/rej/mtf/dtd/mozilla-malloc-trace-bsd.dtd
## Description: All memory events for Mozilla while loading 500 URLs.
## Program: mozilla
## TraceURL: http://www.ukc.ac.uk/people/staff/rej/mtf/trace/mozilla-malloc-trace-bsd.gz

EOF

while(<>) {
  s/\(nil\)/0/go;
  ($tag, $rest) = /(\w) +(.*)/;
  if    ($tag eq 'm') { $tag = 1; }
  elsif ($tag eq 'f') { $tag = 2; }
  elsif ($tag eq 'r') { $tag = 3; }
  elsif ($tag eq 'c') { $tag = 4; }
  else { next; }
  print "$tag $rest\n";
}




