#!/bin/sh
# Extract parts from .log file.
# Copyright (C) 2003 Jean Goubault-Larrecq and LSV, CNRS UMR 8643 & ENS Cachan.
#
# This file is part of h1.
#
# h1 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, or (at your option)
# any later version.
#
# h1 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 h1; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
case $1 in
  source | definitions | approximation | justifications | proof | noproof | processed)
	SECTION=$1;;
  *) echo "Usage: h1getlog [source|definitions|approximation|justifications|proof|noproof|processed] file."
     exit 2;;
esac
case $SECTION in
  "proof") awk "BEGIN { ok=1; }; /<[a-zA-Z]*/ { ok=0; }; { if (ok) print; }; /<\/[a-zA-Z]*>/ { ok=1; }" $2;;
  "noproof") awk "BEGIN { ok=0; }; /<\/[a-zA-Z]*>/ { ok=0; print; }; { if (ok) print; }; /<[a-zA-Z]*>/ { ok=1; print; }" $2;;
  "processed") awk "BEGIN { ok=0; }; /<\/(definitions|approximation)>/ { ok=0; }; { if (ok) print; }; /<(definitions|approximation)>/ { ok=1; }" $2;;
  *) awk "BEGIN { ok=0; }; /<\/$SECTION>/ { ok=0; }; { if (ok) print; }; /<$SECTION>/ { ok=1; }" $2;;
esac
