#!/import/perl/bin/perl -n
# Edit the above for your site or invoke as "perl -n decode_wizard_outline"
# $Id: decode_wizard_outline,v 1.2 1992/11/05 18:13:22 putz Exp $
# Created by Steve Putz <putz@parc.xerox.com>
#
# This converts a Sharp Wizard outline file as produced by the wizcom
# program (version 1.16) into indented plain text.  Examples:
#
#   wizcom -outline | decode_wizard_outline > outlines.text
#
# To fold long line correctly, use the following filter:
#
#   decode_wizard_outline | fmt -s | expand | sed 's/^\( *[^-* ]\)/  \1/'
#

$indent = 2 unless defined($indent);	# indent two spaces each level

next if /^\[/;		# ignore [label] and [^] lines
next if /^\s*$/;	# ignore lines with all whitespace

if (/^([0-9A-F]{12})/) {
    ($attr, @bytes) = unpack("A2 A2 A2 A2 A2 A2", $_);
    substr($_,0,12) = "";	# remove header bytes
    $len = hex($bytes[2].$bytes[1].$bytes[0]);
    $ntopics = hex($bytes[4].$bytes[3]);
}

($depth, $bits2) = unpack("C b8", $_);
substr($_,0,2) = "";		# remove control bytes
$depth &= 0xF;
$full = substr($bits2,0,1);
$hide = substr($bits2,1,1);
$showchild = substr($bits2,2,1);
$haschild = substr($bits2,3,1);

chop;					# remove newline
chop;					# remove \
$indentstr = " " x ($depth * $indent);	# $indent spaces for each level
$bullet = "-";
$bullet = "*" if $haschild;
print "$indentstr$bullet $_\n";
