#!/usr/bin/perl

@unpackpo=(0,0,3,0,0);
@unpackid=('\140\352','\032(\010|\011)','lh','PK','ZOO');

@unpacker=('unarj e','arc eno','lha eqf','unzip -Lqo','zoo eOq');

$maxunpack=5;

if ($#ARGV > 0) { exit(1); }

open(in,"<$ARGV[0]") || exit(1);
sysread(in,$val,5);
close(in);

for ($i=0; $i<$maxunpack; $i++) {
	if (substr($val,$unpackpo[$i]) =~ /^$unpackid[$i]/) {
		exit(system("$unpacker[$i] $ARGV[0]")/256);
	}
}

exit(100); # this is no packet!
