#!/usr/bin/perl use strict; use warnings; use lib '../../lib/perl'; use UCW::CGI; use File::Temp; use POSIX; my $src; my $example; my $trace; POSIX::nice(10); UCW::CGI::parse_args({ 'src' => { 'var' => \$src, 'multiline' => 1 }, 'example' => { 'var' => \$example, 'check' => '\w+' }, 'trace' => { 'var' => \$trace, 'check' => '[0-2]', 'default' => 0 }, }); if ($example ne '' && open EX, "ex-$example") { local $/; undef $/; $src = ; close EX; } my $src_html = html_escape($src); my @trsel = map { $trace == $_ ? "selected" : "" } 0..2; print < Minsk-2 Emulator

Minsk-2 Emulator

(see instructions) EOF if ($src ne '') { print "

Output

\n\n
";
	my $tmpf = new File::Temp();
	print $tmpf $src, "\n";
	$tmpf->flush();
	my $in = $tmpf->filename;
	open SIM, "./minsk --set-password --trace=$trace --cpu-quota=1000 --print-quota=100 <$in |" or die;
	while () {
		print html_escape($_);
	}
	close SIM;
	print "
\n\n"; } print <Input

EOF print <

Written by Martin Mareš and Rutger van Bergen. Version 1.1 (2022-04-24). EOF