#! /opt/bin/dash # # os/prog/ssd/post.sh # requires setting ftl_columns = 1000 in ssd.py so FTL list will always print on one line export PATH="/opt/bin:/bin:/usr/bin" echo "Content-type: text/html\n\n
$in\n" n="6"; l="30"; B="3"; p="10"; P="0/70/30" case "$h" in "log") T="log"; s="123456789";; *) T="direct"; s="123456789";; esac if [ -n "$useed" ]; then seed="$useed" msg="- seed = $seed" else x=$(perl -e "print unpack(\"C*\",$user);"); seed="${s}${x}" #echo "
s = $s, x = $x, seed = $seed" msg="" fi echo "$user - ssd results $msg
green = correct |
red = wrong |
" echo "
SSD Type $T\n\nInitial State:" out=$( (echo "$in"; python3 ./ssd.py -s "$seed" -T "$T" -l "$l" -B "$B" -p "$p" -n "$n" -P "$P" -C -F) | awk -v "B=$B" -v "p=$p" '# disp replaces blanks with "-" function disp(z,sep,r,s,b,i,k) { k=6; r=""; for(b=0;b ", " -\\> ", $0); if( v < 0) { if( $1 == "FTL") { print "FTL "; next; } if( $1 == "Data") { print "Data "disp($0," "); next; } if( $1 == "Live") { print "Live "disp($0," "); next; } print; } if( $1 == "cmd") { ++v; if( v > 0) print; } if( v >= 0) { if( $1 == "FTL") { F=""; if( $2 != "(empty)") { gsub( ": *", ":", $0); F=$2; for(i=3;i<=NF;++i) F=F","$i; } } else if( $1 == "State") { S=""; for(i=2;i<=NF;++i) S=S""$i; } else if( $1 == "Data") D=disp($0,""); else if( $1 == "Live") { L=disp($0,""); print "\n""; x=u["v"v"F"]; if( x == F) color="#90EE90"; else color="#FF6347"; if( x == "") x = " " print "
"; } } }' ) if [ -z "$useed" ]; then bad=$(echo "$out" | grep "#FF6347" | wc -l) good=$(echo "$out" | grep "#90EE90" | wc -l) log=$(echo "$in" | tr -dc '\-+,:[:alnum:]') echo "$(date) $user ${T}: good $good bad $bad in: $log" >> log fi echo "\n$out"; x=u["v"v"S"]; if( x == S) color="#90EE90"; else color="#FF6347"; if( x == "") x = " " print " FTL "x" "; x=u["v"v"D"]; if( x == D) color="#90EE90"; else color="#FF6347"; if( x == "") x = " " print " State "x" "; x=u["v"v"L"]; if( x == L) color="#90EE90"; else color="#FF6347"; if( x == "") x = " " print " Data "x" "; print " Live "x"