#!/usr/bin/perl -w
#
# - original c code by davidsof
#   http://www.linksysinfo.org/forums/showpost.php?p=233548&postcount=11
#
# - perl port (took 5 years to write) by gr11x

use strict;

sub decode($) {
	my $c = shift;
	$c = pack "C", sprintf("%d", ~(($c << 2) | (($c & 0xC0) >> 6)) & 255);
	unless ($c eq "\0") {
		if ($c =~ m/^[[:print:]]$/) {
			return $c;
		} else {
			return " ";
		}
	}
	return "\n";
}

my $file = shift;
unless (defined($file) && -f $file) {
	print "Usage: $0 <linksys.cfg>\n";
	exit 0;
}
open FH, "<", $file or die "Couldn't open file $file: $!\n";
while (<FH>) {
	my @line = split //, $_;
	foreach (@line) {
		print decode(ord $_);
	}
}
close FH;

exit 0;

