#!/usr/bin/awk -f

BEGIN {
	code_ok="\x60"
	code_exit="\x66"
	code_exit_ipbox="\x9e"
	code_blue="\x91"
	code_red="\x8e"
	code_yellow="\x90"
	code_green="\x8f"
}

{
	l=0
	s=s $0 "0"
	l=length(s)
	if(l==32) {
		s=substr(s,11,1)
		#system(sprintf("echo '%s' | hexdump -n1",s))
		s=substr(s,0,5)
		if(s==code_ok) exit 0
		if(s==code_exit || s==code_exit_ipbox) exit 1
		if(s==code_blue) exit 2
		if(s==code_red) exit 3
		if(s==code_yellow) exit 4
		if(s==code_green) exit 5
		s=""
	}
}